4288: Fix characters disappearing (fixes #4285) r=def- a=fokkonaut

Doesnt change entity types order or adds new ones, because `@trml` didnt want that to not change physics at all (might have negative side effects which I personally couldnt see in my mod, where I have custom enttypes for doors, draggers, etc...)

## Checklist

- [ ] Tested the change ingame
- [ ] Provided screenshots if it is a visual change
- [ ] Tested in combination with possibly related configuration options
- [ ] Written a unit test if it works standalone, system.c especially
- [ ] Considered possible null pointers and out of bounds array indexing
- [ ] Changed no physics that affect existing maps
- [ ] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional)


Co-authored-by: fokkonaut <35420825+fokkonaut@users.noreply.github.com>
This commit is contained in:
bors[bot] 2021-11-04 13:16:05 +00:00 committed by GitHub
commit 29c376cf55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,13 +106,25 @@ void CGameWorld::RemoveEntity(CEntity *pEnt)
//
void CGameWorld::Snap(int SnappingClient)
{
for(auto *pEnt : m_apFirstEntityTypes)
for(; pEnt;)
for(CEntity *pEnt = m_apFirstEntityTypes[ENTTYPE_CHARACTER]; pEnt;)
{
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->Snap(SnappingClient);
pEnt = m_pNextTraverseEntity;
}
for(int i = 0; i < NUM_ENTTYPES; i++)
{
if(i == ENTTYPE_CHARACTER)
continue;
for(CEntity *pEnt = m_apFirstEntityTypes[i]; pEnt;)
{
m_pNextTraverseEntity = pEnt->m_pNextTypeEntity;
pEnt->Snap(SnappingClient);
pEnt = m_pNextTraverseEntity;
}
}
}
void CGameWorld::Reset()