3787: Fix Airjump for Antiping r=def- a=TsFreddie

closes #3361

also made sure dummy gets the predicted airjump as well to sync up with local character because why not.

## Checklist

- [x] 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: Freddie Wang <tsfreddiewang@gmail.com>
This commit is contained in:
bors[bot] 2021-04-23 06:09:39 +00:00 committed by GitHub
commit f9430f7724
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1659,10 +1659,10 @@ void CGameClient::OnNewSnapshot()
m_pGhost->OnNewSnapshot();
m_pRaceDemo->OnNewSnapshot();
// detect air jump for unpredicted players
// detect air jump for other players
for(int i = 0; i < MAX_CLIENTS; i++)
if(m_Snap.m_aCharacters[i].m_Active && (m_Snap.m_aCharacters[i].m_Cur.m_Jumped & 2) && !(m_Snap.m_aCharacters[i].m_Prev.m_Jumped & 2))
if(!Predict() || (!AntiPingPlayers() && i != m_Snap.m_LocalClientID))
if(!Predict() || (i != m_Snap.m_LocalClientID && (!AntiPingPlayers() || i != m_PredictedDummyID)))
{
vec2 Pos = mix(vec2(m_Snap.m_aCharacters[i].m_Prev.m_X, m_Snap.m_aCharacters[i].m_Prev.m_Y),
vec2(m_Snap.m_aCharacters[i].m_Cur.m_X, m_Snap.m_aCharacters[i].m_Cur.m_Y),
@ -1807,6 +1807,17 @@ void CGameClient::OnPredict()
m_pSounds->PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_NOATTACH, 1.0f, Pos);
}
}
// check if we want to trigger predicted airjump for dummy
if(AntiPingPlayers() && pDummyChar && Tick > m_LastNewPredictedTick[!Dummy])
{
m_LastNewPredictedTick[!Dummy] = Tick;
vec2 Pos = pDummyChar->Core()->m_Pos;
int Events = pDummyChar->Core()->m_TriggeredEvents;
if(g_Config.m_ClPredict)
if(Events & COREEVENT_AIR_JUMP)
m_pEffects->AirJump(Pos);
}
}
// detect mispredictions of other players and make corrections smoother when possible