Remove global CGameClient instance

This commit is contained in:
Jupeyy 2021-07-12 12:04:45 +02:00
parent 26c5332dc6
commit 7e55b64556
3 changed files with 31 additions and 32 deletions

View file

@ -4344,7 +4344,7 @@ int main(int argc, const char **argv) // ignore_convention
RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast<IMap *>(pEngineMap), false);
RegisterFail = RegisterFail || !pKernel->RegisterInterface(CreateEditor(), false);
RegisterFail = RegisterFail || !pKernel->RegisterInterface(CreateGameClient(), false);
RegisterFail = RegisterFail || !pKernel->RegisterInterface(CreateGameClient());
RegisterFail = RegisterFail || !pKernel->RegisterInterface(pStorage);
RegisterFail = RegisterFail || !pKernel->RegisterInterface(pDiscord);
RegisterFail = RegisterFail || !pKernel->RegisterInterface(pSteam);

View file

@ -67,8 +67,6 @@
#include "components/race_demo.h"
#include <base/system.h>
CGameClient g_GameClient;
CGameClient::CStack::CStack() { m_Num = 0; }
void CGameClient::CStack::Add(class CComponent *pComponent) { m_paComponents[m_Num++] = pComponent; }
@ -564,28 +562,6 @@ void CGameClient::UpdatePositions()
UpdateRenderedCharacters();
}
static void Evolve(CNetObj_Character *pCharacter, int Tick)
{
CWorldCore TempWorld;
CCharacterCore TempCore;
CTeamsCore TempTeams;
mem_zero(&TempCore, sizeof(TempCore));
mem_zero(&TempTeams, sizeof(TempTeams));
TempCore.Init(&TempWorld, g_GameClient.Collision(), &TempTeams);
TempCore.Read(pCharacter);
TempCore.m_ActiveWeapon = pCharacter->m_Weapon;
while(pCharacter->m_Tick < Tick)
{
pCharacter->m_Tick++;
TempCore.Tick(false);
TempCore.Move();
TempCore.Quantize();
}
TempCore.Write(pCharacter);
}
void CGameClient::OnRender()
{
// update the local character and spectate position
@ -1100,6 +1076,27 @@ void CGameClient::InvalidateSnapshot()
void CGameClient::OnNewSnapshot()
{
auto &&Evolve = [=](CNetObj_Character *pCharacter, int Tick) {
CWorldCore TempWorld;
CCharacterCore TempCore;
CTeamsCore TempTeams;
mem_zero(&TempCore, sizeof(TempCore));
mem_zero(&TempTeams, sizeof(TempTeams));
TempCore.Init(&TempWorld, Collision(), &TempTeams);
TempCore.Read(pCharacter);
TempCore.m_ActiveWeapon = pCharacter->m_Weapon;
while(pCharacter->m_Tick < Tick)
{
pCharacter->m_Tick++;
TempCore.Tick(false);
TempCore.Move();
TempCore.Quantize();
}
TempCore.Write(pCharacter);
};
InvalidateSnapshot();
m_NewTick = true;
@ -1201,7 +1198,7 @@ void CGameClient::OnNewSnapshot()
pClient->m_SkinInfo.m_ColorFeet = ColorRGBA(1, 1, 1);
}
pClient->UpdateRenderInfo();
pClient->UpdateRenderInfo(IsTeamPlay());
}
}
else if(Item.m_Type == NETOBJTYPE_PLAYERINFO)
@ -1886,12 +1883,12 @@ void CGameClient::CClientStats::Reset()
m_FlagCaptures = 0;
}
void CGameClient::CClientData::UpdateRenderInfo()
void CGameClient::CClientData::UpdateRenderInfo(bool IsTeamPlay)
{
m_RenderInfo = m_SkinInfo;
// force team colors
if(g_GameClient.m_Snap.m_pGameInfoObj && g_GameClient.m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS)
if(IsTeamPlay)
{
m_RenderInfo.m_CustomColoredSkin = true;
const int TeamColors[2] = {65461, 10223541};
@ -1956,7 +1953,7 @@ void CGameClient::CClientData::Reset()
m_SpecChar = vec2(0, 0);
m_SpecCharPresent = false;
UpdateRenderInfo();
UpdateRenderInfo(false);
}
void CGameClient::SendSwitchTeam(int Team)
@ -2094,7 +2091,7 @@ void CGameClient::ConchainClTextEntitiesSize(IConsole::IResult *pResult, void *p
IGameClient *CreateGameClient()
{
return &g_GameClient;
return new CGameClient();
}
int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, int ownID)
@ -2915,7 +2912,7 @@ void CGameClient::RefindSkins()
const CSkin *pSkin = m_Skins.Get(m_Skins.Find(Client.m_aSkinName));
Client.m_SkinInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin;
Client.m_SkinInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin;
Client.UpdateRenderInfo();
Client.UpdateRenderInfo(IsTeamPlay());
}
}
m_Ghost.RefindSkin();

View file

@ -373,7 +373,7 @@ public:
CNetObj_Character m_Snapped;
CNetObj_Character m_Evolved;
void UpdateRenderInfo();
void UpdateRenderInfo(bool IsTeamPlay);
void Reset();
// rendered characters
@ -491,6 +491,8 @@ public:
virtual int GetLastRaceTick();
bool IsTeamPlay() { return m_Snap.m_pGameInfoObj && m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_TEAMS; }
bool AntiPingPlayers() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingPlayers && !m_Snap.m_SpecInfo.m_Active && Client()->State() != IClient::STATE_DEMOPLAYBACK && (m_Tuning[g_Config.m_ClDummy].m_PlayerCollision || m_Tuning[g_Config.m_ClDummy].m_PlayerHooking); }
bool AntiPingGrenade() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingGrenade && !m_Snap.m_SpecInfo.m_Active && Client()->State() != IClient::STATE_DEMOPLAYBACK; }
bool AntiPingWeapons() { return g_Config.m_ClAntiPing && g_Config.m_ClAntiPingWeapons && !m_Snap.m_SpecInfo.m_Active && Client()->State() != IClient::STATE_DEMOPLAYBACK; }