mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Restructure input send checks without if
s
This commit is contained in:
parent
178a0dabfa
commit
2904c4a2e8
|
@ -180,8 +180,6 @@ void CControls::OnMessage(int Msg, void *pRawMsg)
|
|||
|
||||
int CControls::SnapInput(int *pData)
|
||||
{
|
||||
bool Send = false;
|
||||
|
||||
// update player state
|
||||
if(m_pClient->m_Chat.IsActive())
|
||||
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_CHATTING;
|
||||
|
@ -196,8 +194,7 @@ int CControls::SnapInput(int *pData)
|
|||
if(m_pClient->m_Controls.m_aShowHookColl[g_Config.m_ClDummy])
|
||||
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_AIM;
|
||||
|
||||
if(m_aLastData[g_Config.m_ClDummy].m_PlayerFlags != m_aInputData[g_Config.m_ClDummy].m_PlayerFlags)
|
||||
Send = true;
|
||||
bool Send = m_aLastData[g_Config.m_ClDummy].m_PlayerFlags != m_aInputData[g_Config.m_ClDummy].m_PlayerFlags;
|
||||
|
||||
m_aLastData[g_Config.m_ClDummy].m_PlayerFlags = m_aInputData[g_Config.m_ClDummy].m_PlayerFlags;
|
||||
|
||||
|
@ -215,8 +212,7 @@ int CControls::SnapInput(int *pData)
|
|||
m_aInputData[g_Config.m_ClDummy].m_TargetY = (int)m_aMousePos[g_Config.m_ClDummy].y;
|
||||
|
||||
// send once a second just to be sure
|
||||
if(time_get() > m_LastSendTime + time_freq())
|
||||
Send = true;
|
||||
Send = Send || time_get() > m_LastSendTime + time_freq();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -303,27 +299,15 @@ int CControls::SnapInput(int *pData)
|
|||
}
|
||||
#endif
|
||||
// check if we need to send input
|
||||
if(m_aInputData[g_Config.m_ClDummy].m_Direction != m_aLastData[g_Config.m_ClDummy].m_Direction)
|
||||
Send = true;
|
||||
else if(m_aInputData[g_Config.m_ClDummy].m_Jump != m_aLastData[g_Config.m_ClDummy].m_Jump)
|
||||
Send = true;
|
||||
else if(m_aInputData[g_Config.m_ClDummy].m_Fire != m_aLastData[g_Config.m_ClDummy].m_Fire)
|
||||
Send = true;
|
||||
else if(m_aInputData[g_Config.m_ClDummy].m_Hook != m_aLastData[g_Config.m_ClDummy].m_Hook)
|
||||
Send = true;
|
||||
else if(m_aInputData[g_Config.m_ClDummy].m_WantedWeapon != m_aLastData[g_Config.m_ClDummy].m_WantedWeapon)
|
||||
Send = true;
|
||||
else if(m_aInputData[g_Config.m_ClDummy].m_NextWeapon != m_aLastData[g_Config.m_ClDummy].m_NextWeapon)
|
||||
Send = true;
|
||||
else if(m_aInputData[g_Config.m_ClDummy].m_PrevWeapon != m_aLastData[g_Config.m_ClDummy].m_PrevWeapon)
|
||||
Send = true;
|
||||
|
||||
// send at at least 10hz
|
||||
if(time_get() > m_LastSendTime + time_freq() / 25)
|
||||
Send = true;
|
||||
|
||||
if(m_pClient->m_Snap.m_pLocalCharacter && m_pClient->m_Snap.m_pLocalCharacter->m_Weapon == WEAPON_NINJA && (m_aInputData[g_Config.m_ClDummy].m_Direction || m_aInputData[g_Config.m_ClDummy].m_Jump || m_aInputData[g_Config.m_ClDummy].m_Hook))
|
||||
Send = true;
|
||||
Send = Send || m_aInputData[g_Config.m_ClDummy].m_Direction != m_aLastData[g_Config.m_ClDummy].m_Direction;
|
||||
Send = Send || m_aInputData[g_Config.m_ClDummy].m_Jump != m_aLastData[g_Config.m_ClDummy].m_Jump;
|
||||
Send = Send || m_aInputData[g_Config.m_ClDummy].m_Fire != m_aLastData[g_Config.m_ClDummy].m_Fire;
|
||||
Send = Send || m_aInputData[g_Config.m_ClDummy].m_Hook != m_aLastData[g_Config.m_ClDummy].m_Hook;
|
||||
Send = Send || m_aInputData[g_Config.m_ClDummy].m_WantedWeapon != m_aLastData[g_Config.m_ClDummy].m_WantedWeapon;
|
||||
Send = Send || m_aInputData[g_Config.m_ClDummy].m_NextWeapon != m_aLastData[g_Config.m_ClDummy].m_NextWeapon;
|
||||
Send = Send || m_aInputData[g_Config.m_ClDummy].m_PrevWeapon != m_aLastData[g_Config.m_ClDummy].m_PrevWeapon;
|
||||
Send = Send || time_get() > m_LastSendTime + time_freq() / 25; // send at least 10hz
|
||||
Send = Send || (m_pClient->m_Snap.m_pLocalCharacter && m_pClient->m_Snap.m_pLocalCharacter->m_Weapon == WEAPON_NINJA && (m_aInputData[g_Config.m_ClDummy].m_Direction || m_aInputData[g_Config.m_ClDummy].m_Jump || m_aInputData[g_Config.m_ClDummy].m_Hook));
|
||||
}
|
||||
|
||||
// copy and return size
|
||||
|
|
Loading…
Reference in a new issue