3276: Fix prediction of no hook/collision tile r=def- a=trml

I believe this fixes #3043 and #2510, but I haven't tested it extensively yet (and I couldn't reproduce the bug for no-collision tiles)

Perhaps there should also be some further cleanups of the code, to avoid double bookkeeping of whether a character can collide/hook/hit others, as this easily leads to problems. For example: m_Hook/m_NoHookHit in CCharacterCore, m_Hit in CCharacter vs NoHammerHit (etc), and also fake tunings that in some cases are no longer required for ddnet clients.

## 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
- [x] Considered possible null pointers and out of bounds array indexing
- [x] 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: trml <trml@users.noreply.github.com>
This commit is contained in:
bors[bot] 2020-11-08 13:27:20 +00:00 committed by GitHub
commit 8a818439b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -2217,6 +2217,13 @@ void CGameClient::UpdatePrediction()
else
m_GameWorld.TuningList()[TuneZone] = m_GameWorld.m_Core.m_Tuning[g_Config.m_ClDummy] = m_Tuning[g_Config.m_ClDummy];
// if ddnetcharacter is available, ignore server-wide tunings for hook and collision
if(m_Snap.m_aCharacters[m_Snap.m_LocalClientID].m_HasExtendedData)
{
m_GameWorld.m_Tuning[g_Config.m_ClDummy].m_PlayerCollision = 1;
m_GameWorld.m_Tuning[g_Config.m_ClDummy].m_PlayerHooking = 1;
}
// restore characters from previously saved ones if they temporarily left the snapshot
for(int i = 0; i < MAX_CLIENTS; i++)
if(m_aLastWorldCharacters[i].IsAlive() && m_Snap.m_aCharacters[i].m_Active && !m_GameWorld.GetCharacterByID(i))

View file

@ -559,6 +559,9 @@ void CCharacterCore::ReadDDNet(const CNetObj_DDNetCharacter *pObjDDNet)
m_NoHookHit = pObjDDNet->m_Flags & CHARACTERFLAG_NO_HOOK;
m_Super = pObjDDNet->m_Flags & CHARACTERFLAG_SUPER;
m_Hook = !m_NoHookHit;
m_Collision = !m_NoCollision;
// Endless
m_EndlessHook = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_HOOK;
m_EndlessJump = pObjDDNet->m_Flags & CHARACTERFLAG_ENDLESS_JUMP;