Merge pull request #1441 from trml/pr_sync_weapon_input

Sync weapon input with other input
This commit is contained in:
Dennis Felsing 2019-02-14 10:27:52 +01:00 committed by GitHub
commit 6f3d261b73
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 27 additions and 7 deletions

View file

@ -219,6 +219,7 @@ public:
virtual void OnClientDrop(int ClientID, const char *pReason) = 0;
virtual void OnClientDirectInput(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 IsClientPlayer(int ClientID) = 0;

View file

@ -1966,6 +1966,12 @@ int CServer::Run()
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++;
NewTicks++;

View file

@ -961,6 +961,12 @@ void CGameContext::OnClientPredictedInput(int ClientID, void *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)
{
CVoteOptionServer *pCurrent;

View file

@ -234,6 +234,7 @@ public:
virtual void OnClientDrop(int ClientID, const char *pReason);
virtual void OnClientDirectInput(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 OnClientEngineDrop(int ClientID, const char *pReason);

View file

@ -446,13 +446,8 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *NewInput)
m_PlayerFlags = NewInput->m_PlayerFlags;
if(m_pCharacter)
{
if(!m_Paused)
m_pCharacter->OnDirectInput(NewInput);
else
if(m_pCharacter && m_Paused)
m_pCharacter->ResetInput();
}
if(!m_pCharacter && m_Team != TEAM_SPECTATORS && (NewInput->m_Fire&1))
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()
{
if(m_pCharacter && m_pCharacter->IsAlive())

View file

@ -37,6 +37,7 @@ public:
void OnDirectInput(CNetObj_PlayerInput *NewInput);
void OnPredictedInput(CNetObj_PlayerInput *NewInput);
void OnPredictedEarlyInput(CNetObj_PlayerInput *NewInput);
void OnDisconnect(const char *pReason);
void ThreadKillCharacter(int Weapon = WEAPON_GAME);