5153: keep input if chat is closed r=heinrich5991 a=C0D3D3V

fixes #4653

## 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
- [x] Considered possible null pointers and out of bounds array indexing
- [?] Changed no physics that affect existing maps
- [x] 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: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
This commit is contained in:
bors[bot] 2022-05-20 06:32:44 +00:00 committed by GitHub
commit 0fbfcad242
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 8 additions and 14 deletions

View file

@ -255,14 +255,7 @@ int CControls::SnapInput(int *pData)
else if(m_pClient->m_Menus.IsActive())
m_InputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_IN_MENU;
else
{
if(m_InputData[g_Config.m_ClDummy].m_PlayerFlags == PLAYERFLAG_CHATTING)
{
if(GameClient()->m_GameInfo.m_BugDDRaceInput)
ResetInput(g_Config.m_ClDummy);
}
m_InputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_PLAYING;
}
if(m_pClient->m_Scoreboard.Active())
m_InputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_SCOREBOARD;

View file

@ -2253,6 +2253,7 @@ void CGameClient::UpdatePrediction()
m_GameWorld.m_WorldConfig.m_UseTuneZones = m_GameInfo.m_PredictDDRaceTiles;
m_GameWorld.m_WorldConfig.m_PredictFreeze = g_Config.m_ClPredictFreeze;
m_GameWorld.m_WorldConfig.m_PredictWeapons = AntiPingWeapons();
m_GameWorld.m_WorldConfig.m_BugDDRaceInput = m_GameInfo.m_BugDDRaceInput;
// always update default tune zone, even without character
if(!m_GameWorld.m_WorldConfig.m_UseTuneZones)

View file

@ -494,8 +494,12 @@ void CCharacter::GiveNinja()
void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
{
// skip the input if chat is active
if(pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING)
if(GameWorld()->m_WorldConfig.m_BugDDRaceInput && pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING)
{
// save reseted input
mem_copy(&m_SavedInput, &m_Input, sizeof(m_SavedInput));
return;
}
// copy new input
mem_copy(&m_Input, pNewInput, sizeof(m_Input));
@ -511,11 +515,10 @@ void CCharacter::OnPredictedInput(CNetObj_PlayerInput *pNewInput)
void CCharacter::OnDirectInput(CNetObj_PlayerInput *pNewInput)
{
// skip the input if chat is active
if(pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING)
if(GameWorld()->m_WorldConfig.m_BugDDRaceInput && pNewInput->m_PlayerFlags & PLAYERFLAG_CHATTING)
{
// reset input
ResetInput();
return;
}

View file

@ -72,6 +72,7 @@ public:
bool m_PredictDDRace;
bool m_IsSolo;
bool m_UseTuneZones;
bool m_BugDDRaceInput;
} m_WorldConfig;
bool m_IsValidCopy;

View file

@ -538,10 +538,6 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
if(m_PlayerFlags & PLAYERFLAG_CHATTING)
return;
// reset input
if(m_pCharacter)
m_pCharacter->ResetInput();
m_PlayerFlags = NewInput->m_PlayerFlags;
return;
}