Clean up a bit and hopefully fix player move on dummy connect

This commit is contained in:
def 2015-04-19 14:03:40 +02:00
parent b0085aef55
commit 9c1e65a1f5
4 changed files with 34 additions and 47 deletions

View file

@ -63,17 +63,8 @@ CControls::CControls()
void CControls::OnReset() void CControls::OnReset()
{ {
m_LastData[g_Config.m_ClDummy].m_Direction = 0; ResetInput(0);
//m_LastData.m_Hook = 0; ResetInput(1);
// 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;
m_JoystickFirePressed = false; m_JoystickFirePressed = false;
m_JoystickRunPressed = false; m_JoystickRunPressed = false;
@ -83,22 +74,19 @@ void CControls::OnReset()
m_OldMouseX = m_OldMouseY = 0.0f; m_OldMouseX = m_OldMouseY = 0.0f;
} }
void CControls::ResetDummyInput() void CControls::ResetInput(int dummy)
{ {
m_LastData[!g_Config.m_ClDummy].m_Direction = 0; m_LastData[dummy].m_Direction = 0;
if(m_LastData[!g_Config.m_ClDummy].m_Fire & 1) //m_LastData.m_Hook = 0;
m_LastData[!g_Config.m_ClDummy].m_Fire++; // simulate releasing the fire button
m_LastData[!g_Config.m_ClDummy].m_Hook = 0; if((m_LastData[dummy].m_Fire&1) != 0)
m_LastData[!g_Config.m_ClDummy].m_Jump = 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; m_InputDirectionLeft[dummy] = 0;
if(m_InputData[!g_Config.m_ClDummy].m_Fire & 1) m_InputDirectionRight[dummy] = 0;
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;
} }
void CControls::OnRelease() void CControls::OnRelease()
@ -108,11 +96,11 @@ void CControls::OnRelease()
void CControls::OnPlayerDeath() void CControls::OnPlayerDeath()
{ {
if (g_Config.m_ClResetWantedWeaponOnDeath) if (g_Config.m_ClResetWantedWeaponOnDeath)
m_LastData[g_Config.m_ClDummy].m_WantedWeapon = m_InputData[g_Config.m_ClDummy].m_WantedWeapon = 0; 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++ ) for( int i = 0; i < NUM_WEAPONS; i++ )
m_AmmoCount[i] = 0; m_AmmoCount[i] = 0;
m_JoystickTapTime = 0; // Do not launch hook on first tap m_JoystickTapTime = 0; // Do not launch hook on first tap
} }
struct CInputState struct CInputState
@ -248,7 +236,7 @@ int CControls::SnapInput(int *pData)
// we freeze the input if chat or menu is activated // we freeze the input if chat or menu is activated
if(!(m_InputData[g_Config.m_ClDummy].m_PlayerFlags&PLAYERFLAG_PLAYING)) 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])); mem_copy(pData, &m_InputData[g_Config.m_ClDummy], sizeof(m_InputData[0]));

View file

@ -44,6 +44,6 @@ public:
int SnapInput(int *pData); int SnapInput(int *pData);
void ClampMousePos(); void ClampMousePos();
void ResetDummyInput(); void ResetInput(int dummy);
}; };
#endif #endif

View file

@ -108,7 +108,7 @@ const char *CGameClient::GetItemName(int Type) { return m_NetObjHandler.GetObjNa
void CGameClient::ResetDummyInput() void CGameClient::ResetDummyInput()
{ {
m_pControls->ResetDummyInput(); m_pControls->ResetInput(!g_Config.m_ClDummy);
} }
void CGameClient::OnConsoleInit() void CGameClient::OnConsoleInit()
@ -581,7 +581,7 @@ void CGameClient::OnRender()
// resend player and dummy info if it was filtered by server // resend player and dummy info if it was filtered by server
if(Client()->State() == IClient::STATE_ONLINE && !m_pMenus->IsActive()) { if(Client()->State() == IClient::STATE_ONLINE && !m_pMenus->IsActive()) {
if(m_CheckInfo == 0) { if(m_CheckInfo[0] == 0) {
if( if(
str_comp(m_aClients[Client()->m_LocalIDs[0]].m_aName, g_Config.m_PlayerName) || 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) || str_comp(m_aClients[Client()->m_LocalIDs[0]].m_aClan, g_Config.m_PlayerClan) ||
@ -593,14 +593,14 @@ void CGameClient::OnRender()
) )
SendInfo(false); SendInfo(false);
else else
m_CheckInfo = -1; m_CheckInfo[0] = -1;
} }
if(m_CheckInfo > 0) if(m_CheckInfo[0] > 0)
m_CheckInfo--; m_CheckInfo[0]--;
if(Client()->DummyConnected()) { if(Client()->DummyConnected()) {
if(m_CheckDummyInfo == 0) { if(m_CheckInfo[1] == 0) {
if( if(
str_comp(m_aClients[Client()->m_LocalIDs[1]].m_aName, g_Config.m_DummyName) || 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) || str_comp(m_aClients[Client()->m_LocalIDs[1]].m_aClan, g_Config.m_DummyClan) ||
@ -612,11 +612,11 @@ void CGameClient::OnRender()
) )
SendDummyInfo(false); SendDummyInfo(false);
else else
m_CheckDummyInfo = -1; m_CheckInfo[1] = -1;
} }
if(m_CheckDummyInfo > 0) if(m_CheckInfo[1] > 0)
m_CheckDummyInfo--; m_CheckInfo[1]--;
} }
} }
} }
@ -1721,7 +1721,7 @@ void CGameClient::SendInfo(bool Start)
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID());
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0); Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0);
m_CheckInfo = -1; m_CheckInfo[0] = -1;
} }
else else
{ {
@ -1736,7 +1736,7 @@ void CGameClient::SendInfo(bool Start)
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID());
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0); 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()); CMsgPacker Packer(Msg.MsgID());
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 1); Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 1);
m_CheckDummyInfo = -1; m_CheckInfo[1] = -1;
} }
else else
{ {
@ -1770,7 +1770,7 @@ void CGameClient::SendDummyInfo(bool Start)
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID());
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 1); Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 1);
m_CheckDummyInfo = Client()->GameTickSpeed(); m_CheckInfo[1] = Client()->GameTickSpeed();
} }
} }

View file

@ -108,8 +108,7 @@ class CGameClient : public IGameClient
int m_PredictedTick; int m_PredictedTick;
int m_LastNewPredictedTick[2]; int m_LastNewPredictedTick[2];
int m_CheckInfo; int m_CheckInfo[2];
int m_CheckDummyInfo;
static void ConTeam(IConsole::IResult *pResult, void *pUserData); static void ConTeam(IConsole::IResult *pResult, void *pUserData);
static void ConKill(IConsole::IResult *pResult, void *pUserData); static void ConKill(IConsole::IResult *pResult, void *pUserData);