mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08:18 +00:00
Clean up a bit and hopefully fix player move on dummy connect
This commit is contained in:
parent
b0085aef55
commit
9c1e65a1f5
|
@ -63,17 +63,8 @@ CControls::CControls()
|
|||
|
||||
void CControls::OnReset()
|
||||
{
|
||||
m_LastData[g_Config.m_ClDummy].m_Direction = 0;
|
||||
//m_LastData.m_Hook = 0;
|
||||
// simulate releasing the fire button
|
||||
if((m_LastData[g_Config.m_ClDummy].m_Fire&1) != 0)
|
||||
m_LastData[g_Config.m_ClDummy].m_Fire++;
|
||||
m_LastData[g_Config.m_ClDummy].m_Fire &= INPUT_STATE_MASK;
|
||||
m_LastData[g_Config.m_ClDummy].m_Jump = 0;
|
||||
m_InputData[g_Config.m_ClDummy] = m_LastData[g_Config.m_ClDummy];
|
||||
|
||||
m_InputDirectionLeft[g_Config.m_ClDummy] = 0;
|
||||
m_InputDirectionRight[g_Config.m_ClDummy] = 0;
|
||||
ResetInput(0);
|
||||
ResetInput(1);
|
||||
|
||||
m_JoystickFirePressed = false;
|
||||
m_JoystickRunPressed = false;
|
||||
|
@ -83,22 +74,19 @@ void CControls::OnReset()
|
|||
m_OldMouseX = m_OldMouseY = 0.0f;
|
||||
}
|
||||
|
||||
void CControls::ResetDummyInput()
|
||||
void CControls::ResetInput(int dummy)
|
||||
{
|
||||
m_LastData[!g_Config.m_ClDummy].m_Direction = 0;
|
||||
if(m_LastData[!g_Config.m_ClDummy].m_Fire & 1)
|
||||
m_LastData[!g_Config.m_ClDummy].m_Fire++;
|
||||
m_LastData[!g_Config.m_ClDummy].m_Hook = 0;
|
||||
m_LastData[!g_Config.m_ClDummy].m_Jump = 0;
|
||||
m_LastData[dummy].m_Direction = 0;
|
||||
//m_LastData.m_Hook = 0;
|
||||
// simulate releasing the fire button
|
||||
if((m_LastData[dummy].m_Fire&1) != 0)
|
||||
m_LastData[dummy].m_Fire++;
|
||||
m_LastData[dummy].m_Fire &= INPUT_STATE_MASK;
|
||||
m_LastData[dummy].m_Jump = 0;
|
||||
m_InputData[dummy] = m_LastData[dummy];
|
||||
|
||||
m_InputData[!g_Config.m_ClDummy].m_Direction = 0;
|
||||
if(m_InputData[!g_Config.m_ClDummy].m_Fire & 1)
|
||||
m_InputData[!g_Config.m_ClDummy].m_Fire++;
|
||||
m_InputData[!g_Config.m_ClDummy].m_Hook = 0;
|
||||
m_InputData[!g_Config.m_ClDummy].m_Jump = 0;
|
||||
|
||||
m_InputDirectionLeft[!g_Config.m_ClDummy] = 0;
|
||||
m_InputDirectionRight[!g_Config.m_ClDummy] = 0;
|
||||
m_InputDirectionLeft[dummy] = 0;
|
||||
m_InputDirectionRight[dummy] = 0;
|
||||
}
|
||||
|
||||
void CControls::OnRelease()
|
||||
|
@ -108,11 +96,11 @@ void CControls::OnRelease()
|
|||
|
||||
void CControls::OnPlayerDeath()
|
||||
{
|
||||
if (g_Config.m_ClResetWantedWeaponOnDeath)
|
||||
m_LastData[g_Config.m_ClDummy].m_WantedWeapon = m_InputData[g_Config.m_ClDummy].m_WantedWeapon = 0;
|
||||
for( int i = 0; i < NUM_WEAPONS; i++ )
|
||||
m_AmmoCount[i] = 0;
|
||||
m_JoystickTapTime = 0; // Do not launch hook on first tap
|
||||
if (g_Config.m_ClResetWantedWeaponOnDeath)
|
||||
m_LastData[g_Config.m_ClDummy].m_WantedWeapon = m_InputData[g_Config.m_ClDummy].m_WantedWeapon = 0;
|
||||
for( int i = 0; i < NUM_WEAPONS; i++ )
|
||||
m_AmmoCount[i] = 0;
|
||||
m_JoystickTapTime = 0; // Do not launch hook on first tap
|
||||
}
|
||||
|
||||
struct CInputState
|
||||
|
@ -248,7 +236,7 @@ int CControls::SnapInput(int *pData)
|
|||
// we freeze the input if chat or menu is activated
|
||||
if(!(m_InputData[g_Config.m_ClDummy].m_PlayerFlags&PLAYERFLAG_PLAYING))
|
||||
{
|
||||
OnReset();
|
||||
ResetInput(g_Config.m_ClDummy);
|
||||
|
||||
mem_copy(pData, &m_InputData[g_Config.m_ClDummy], sizeof(m_InputData[0]));
|
||||
|
||||
|
|
|
@ -44,6 +44,6 @@ public:
|
|||
|
||||
int SnapInput(int *pData);
|
||||
void ClampMousePos();
|
||||
void ResetDummyInput();
|
||||
void ResetInput(int dummy);
|
||||
};
|
||||
#endif
|
||||
|
|
|
@ -108,7 +108,7 @@ const char *CGameClient::GetItemName(int Type) { return m_NetObjHandler.GetObjNa
|
|||
|
||||
void CGameClient::ResetDummyInput()
|
||||
{
|
||||
m_pControls->ResetDummyInput();
|
||||
m_pControls->ResetInput(!g_Config.m_ClDummy);
|
||||
}
|
||||
|
||||
void CGameClient::OnConsoleInit()
|
||||
|
@ -581,7 +581,7 @@ void CGameClient::OnRender()
|
|||
|
||||
// resend player and dummy info if it was filtered by server
|
||||
if(Client()->State() == IClient::STATE_ONLINE && !m_pMenus->IsActive()) {
|
||||
if(m_CheckInfo == 0) {
|
||||
if(m_CheckInfo[0] == 0) {
|
||||
if(
|
||||
str_comp(m_aClients[Client()->m_LocalIDs[0]].m_aName, g_Config.m_PlayerName) ||
|
||||
str_comp(m_aClients[Client()->m_LocalIDs[0]].m_aClan, g_Config.m_PlayerClan) ||
|
||||
|
@ -593,14 +593,14 @@ void CGameClient::OnRender()
|
|||
)
|
||||
SendInfo(false);
|
||||
else
|
||||
m_CheckInfo = -1;
|
||||
m_CheckInfo[0] = -1;
|
||||
}
|
||||
|
||||
if(m_CheckInfo > 0)
|
||||
m_CheckInfo--;
|
||||
if(m_CheckInfo[0] > 0)
|
||||
m_CheckInfo[0]--;
|
||||
|
||||
if(Client()->DummyConnected()) {
|
||||
if(m_CheckDummyInfo == 0) {
|
||||
if(m_CheckInfo[1] == 0) {
|
||||
if(
|
||||
str_comp(m_aClients[Client()->m_LocalIDs[1]].m_aName, g_Config.m_DummyName) ||
|
||||
str_comp(m_aClients[Client()->m_LocalIDs[1]].m_aClan, g_Config.m_DummyClan) ||
|
||||
|
@ -612,11 +612,11 @@ void CGameClient::OnRender()
|
|||
)
|
||||
SendDummyInfo(false);
|
||||
else
|
||||
m_CheckDummyInfo = -1;
|
||||
m_CheckInfo[1] = -1;
|
||||
}
|
||||
|
||||
if(m_CheckDummyInfo > 0)
|
||||
m_CheckDummyInfo--;
|
||||
if(m_CheckInfo[1] > 0)
|
||||
m_CheckInfo[1]--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1721,7 +1721,7 @@ void CGameClient::SendInfo(bool Start)
|
|||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0);
|
||||
m_CheckInfo = -1;
|
||||
m_CheckInfo[0] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1736,7 +1736,7 @@ void CGameClient::SendInfo(bool Start)
|
|||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0);
|
||||
m_CheckInfo = Client()->GameTickSpeed();
|
||||
m_CheckInfo[0] = Client()->GameTickSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1755,7 +1755,7 @@ void CGameClient::SendDummyInfo(bool Start)
|
|||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 1);
|
||||
m_CheckDummyInfo = -1;
|
||||
m_CheckInfo[1] = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1770,7 +1770,7 @@ void CGameClient::SendDummyInfo(bool Start)
|
|||
CMsgPacker Packer(Msg.MsgID());
|
||||
Msg.Pack(&Packer);
|
||||
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 1);
|
||||
m_CheckDummyInfo = Client()->GameTickSpeed();
|
||||
m_CheckInfo[1] = Client()->GameTickSpeed();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -108,8 +108,7 @@ class CGameClient : public IGameClient
|
|||
int m_PredictedTick;
|
||||
int m_LastNewPredictedTick[2];
|
||||
|
||||
int m_CheckInfo;
|
||||
int m_CheckDummyInfo;
|
||||
int m_CheckInfo[2];
|
||||
|
||||
static void ConTeam(IConsole::IResult *pResult, void *pUserData);
|
||||
static void ConKill(IConsole::IResult *pResult, void *pUserData);
|
||||
|
|
Loading…
Reference in a new issue