mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-19 14:38:18 +00:00
Merge pull request #1441 from trml/pr_sync_weapon_input
Sync weapon input with other input
This commit is contained in:
commit
6f3d261b73
|
@ -219,6 +219,7 @@ public:
|
||||||
virtual void OnClientDrop(int ClientID, const char *pReason) = 0;
|
virtual void OnClientDrop(int ClientID, const char *pReason) = 0;
|
||||||
virtual void OnClientDirectInput(int ClientID, void *pInput) = 0;
|
virtual void OnClientDirectInput(int ClientID, void *pInput) = 0;
|
||||||
virtual void OnClientPredictedInput(int ClientID, void *pInput) = 0;
|
virtual void OnClientPredictedInput(int ClientID, void *pInput) = 0;
|
||||||
|
virtual void OnClientPredictedEarlyInput(int ClientID, void *pInput) = 0;
|
||||||
|
|
||||||
virtual bool IsClientReady(int ClientID) = 0;
|
virtual bool IsClientReady(int ClientID) = 0;
|
||||||
virtual bool IsClientPlayer(int ClientID) = 0;
|
virtual bool IsClientPlayer(int ClientID) = 0;
|
||||||
|
|
|
@ -1966,6 +1966,12 @@ int CServer::Run()
|
||||||
|
|
||||||
while(t > TickStartTime(m_CurrentGameTick+1))
|
while(t > TickStartTime(m_CurrentGameTick+1))
|
||||||
{
|
{
|
||||||
|
for(int c = 0; c < MAX_CLIENTS; c++)
|
||||||
|
if(m_aClients[c].m_State == CClient::STATE_INGAME)
|
||||||
|
for(int i = 0; i < 200; i++)
|
||||||
|
if(m_aClients[c].m_aInputs[i].m_GameTick == Tick() + 1)
|
||||||
|
GameServer()->OnClientPredictedEarlyInput(c, m_aClients[c].m_aInputs[i].m_aData);
|
||||||
|
|
||||||
m_CurrentGameTick++;
|
m_CurrentGameTick++;
|
||||||
NewTicks++;
|
NewTicks++;
|
||||||
|
|
||||||
|
|
|
@ -961,6 +961,12 @@ void CGameContext::OnClientPredictedInput(int ClientID, void *pInput)
|
||||||
m_apPlayers[ClientID]->OnPredictedInput((CNetObj_PlayerInput *)pInput);
|
m_apPlayers[ClientID]->OnPredictedInput((CNetObj_PlayerInput *)pInput);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CGameContext::OnClientPredictedEarlyInput(int ClientID, void *pInput)
|
||||||
|
{
|
||||||
|
if(!m_World.m_Paused)
|
||||||
|
m_apPlayers[ClientID]->OnPredictedEarlyInput((CNetObj_PlayerInput *)pInput);
|
||||||
|
}
|
||||||
|
|
||||||
struct CVoteOptionServer *CGameContext::GetVoteOption(int Index)
|
struct CVoteOptionServer *CGameContext::GetVoteOption(int Index)
|
||||||
{
|
{
|
||||||
CVoteOptionServer *pCurrent;
|
CVoteOptionServer *pCurrent;
|
||||||
|
|
|
@ -234,6 +234,7 @@ public:
|
||||||
virtual void OnClientDrop(int ClientID, const char *pReason);
|
virtual void OnClientDrop(int ClientID, const char *pReason);
|
||||||
virtual void OnClientDirectInput(int ClientID, void *pInput);
|
virtual void OnClientDirectInput(int ClientID, void *pInput);
|
||||||
virtual void OnClientPredictedInput(int ClientID, void *pInput);
|
virtual void OnClientPredictedInput(int ClientID, void *pInput);
|
||||||
|
virtual void OnClientPredictedEarlyInput(int ClientID, void *pInput);
|
||||||
|
|
||||||
virtual void OnClientEngineJoin(int ClientID);
|
virtual void OnClientEngineJoin(int ClientID);
|
||||||
virtual void OnClientEngineDrop(int ClientID, const char *pReason);
|
virtual void OnClientEngineDrop(int ClientID, const char *pReason);
|
||||||
|
|
|
@ -446,13 +446,8 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
|
||||||
|
|
||||||
m_PlayerFlags = NewInput->m_PlayerFlags;
|
m_PlayerFlags = NewInput->m_PlayerFlags;
|
||||||
|
|
||||||
if(m_pCharacter)
|
if(m_pCharacter && m_Paused)
|
||||||
{
|
m_pCharacter->ResetInput();
|
||||||
if(!m_Paused)
|
|
||||||
m_pCharacter->OnDirectInput(NewInput);
|
|
||||||
else
|
|
||||||
m_pCharacter->ResetInput();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1))
|
if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1))
|
||||||
m_Spawning = true;
|
m_Spawning = true;
|
||||||
|
@ -468,6 +463,16 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CPlayer::OnPredictedEarlyInput(CNetObj_PlayerInput *NewInput)
|
||||||
|
{
|
||||||
|
// skip the input if chat is active
|
||||||
|
if((m_PlayerFlags&PLAYERFLAG_CHATTING) && (NewInput->m_PlayerFlags&PLAYERFLAG_CHATTING))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(m_pCharacter && !m_Paused)
|
||||||
|
m_pCharacter->OnDirectInput(NewInput);
|
||||||
|
}
|
||||||
|
|
||||||
CCharacter *CPlayer::GetCharacter()
|
CCharacter *CPlayer::GetCharacter()
|
||||||
{
|
{
|
||||||
if(m_pCharacter && m_pCharacter->IsAlive())
|
if(m_pCharacter && m_pCharacter->IsAlive())
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
|
|
||||||
void OnDirectInput(CNetObj_PlayerInput *NewInput);
|
void OnDirectInput(CNetObj_PlayerInput *NewInput);
|
||||||
void OnPredictedInput(CNetObj_PlayerInput *NewInput);
|
void OnPredictedInput(CNetObj_PlayerInput *NewInput);
|
||||||
|
void OnPredictedEarlyInput(CNetObj_PlayerInput *NewInput);
|
||||||
void OnDisconnect(const char *pReason);
|
void OnDisconnect(const char *pReason);
|
||||||
|
|
||||||
void ThreadKillCharacter(int Weapon = WEAPON_GAME);
|
void ThreadKillCharacter(int Weapon = WEAPON_GAME);
|
||||||
|
|
Loading…
Reference in a new issue