diff --git a/CMakeLists.txt b/CMakeLists.txt index da26be8bf..afb9b1cbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1750,6 +1750,7 @@ if(CLIENT) set_src(GAME_CLIENT GLOB_RECURSE src/game/client animstate.cpp animstate.h + component.cpp component.h components/background.cpp components/background.h diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 8c24f1ade..0ae099d32 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -4344,7 +4344,7 @@ int main(int argc, const char **argv) // ignore_convention RegisterFail = RegisterFail || !pKernel->RegisterInterface(static_cast(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); diff --git a/src/game/client/component.cpp b/src/game/client/component.cpp new file mode 100644 index 000000000..e5aa80072 --- /dev/null +++ b/src/game/client/component.cpp @@ -0,0 +1,39 @@ +#include "component.h" + +#include "gameclient.h" + +class IKernel *CComponent::Kernel() const { return m_pClient->Kernel(); } +class IGraphics *CComponent::Graphics() const { return m_pClient->Graphics(); } +class ITextRender *CComponent::TextRender() const { return m_pClient->TextRender(); } +class IInput *CComponent::Input() const { return m_pClient->Input(); } +class IStorage *CComponent::Storage() const { return m_pClient->Storage(); } +class CUI *CComponent::UI() const { return m_pClient->UI(); } +class ISound *CComponent::Sound() const { return m_pClient->Sound(); } +class CRenderTools *CComponent::RenderTools() const { return m_pClient->RenderTools(); } +class CConfig *CComponent::Config() const { return m_pClient->Config(); } +class IConsole *CComponent::Console() const { return m_pClient->Console(); } +class IDemoPlayer *CComponent::DemoPlayer() const { return m_pClient->DemoPlayer(); } +class IDemoRecorder *CComponent::DemoRecorder(int Recorder) const { return m_pClient->DemoRecorder(Recorder); } +class IServerBrowser *CComponent::ServerBrowser() const { return m_pClient->ServerBrowser(); } +class CLayers *CComponent::Layers() const { return m_pClient->Layers(); } +class CCollision *CComponent::Collision() const { return m_pClient->Collision(); } +#if defined(CONF_AUTOUPDATE) +class IUpdater *CComponent::Updater() const +{ + return m_pClient->Updater(); +} +#endif + +float CComponent::LocalTime() const +{ +#if defined(CONF_VIDEORECORDER) + return IVideo::Current() ? IVideo::LocalTime() : Client()->LocalTime(); +#else + return Client()->LocalTime(); +#endif +} + +class IClient *CComponent::Client() const +{ + return m_pClient->Client(); +} diff --git a/src/game/client/component.h b/src/game/client/component.h index 30d12ecbf..5dbfe12df 100644 --- a/src/game/client/component.h +++ b/src/game/client/component.h @@ -7,9 +7,17 @@ #include #endif -#include "gameclient.h" +#include #include +#include +#include +#include + +#include + +class CGameClient; + class CComponent { protected: @@ -18,26 +26,23 @@ protected: CGameClient *m_pClient; // perhaps propagte pointers for these as well - class IKernel *Kernel() const { return m_pClient->Kernel(); } - class IGraphics *Graphics() const { return m_pClient->Graphics(); } - class ITextRender *TextRender() const { return m_pClient->TextRender(); } - class IInput *Input() const { return m_pClient->Input(); } - class IStorage *Storage() const { return m_pClient->Storage(); } - class CUI *UI() const { return m_pClient->UI(); } - class ISound *Sound() const { return m_pClient->Sound(); } - class CRenderTools *RenderTools() const { return m_pClient->RenderTools(); } - class CConfig *Config() const { return m_pClient->Config(); } - class IConsole *Console() const { return m_pClient->Console(); } - class IDemoPlayer *DemoPlayer() const { return m_pClient->DemoPlayer(); } - class IDemoRecorder *DemoRecorder(int Recorder) const { return m_pClient->DemoRecorder(Recorder); } - class IServerBrowser *ServerBrowser() const { return m_pClient->ServerBrowser(); } - class CLayers *Layers() const { return m_pClient->Layers(); } - class CCollision *Collision() const { return m_pClient->Collision(); } + class IKernel *Kernel() const; + class IGraphics *Graphics() const; + class ITextRender *TextRender() const; + class IInput *Input() const; + class IStorage *Storage() const; + class CUI *UI() const; + class ISound *Sound() const; + class CRenderTools *RenderTools() const; + class CConfig *Config() const; + class IConsole *Console() const; + class IDemoPlayer *DemoPlayer() const; + class IDemoRecorder *DemoRecorder(int Recorder) const; + class IServerBrowser *ServerBrowser() const; + class CLayers *Layers() const; + class CCollision *Collision() const; #if defined(CONF_AUTOUPDATE) - class IUpdater *Updater() const - { - return m_pClient->Updater(); - } + class IUpdater *Updater() const; #endif #if defined(CONF_VIDEORECORDER) @@ -45,19 +50,18 @@ protected: { return IVideo::Current() ? IVideo::Time() : time_get(); } - float LocalTime() const { return IVideo::Current() ? IVideo::LocalTime() : Client()->LocalTime(); } #else int64_t time() const { return time_get(); } - float LocalTime() const { return Client()->LocalTime(); } #endif + float LocalTime() const; public: virtual ~CComponent() {} class CGameClient *GameClient() const { return m_pClient; } - class IClient *Client() const { return m_pClient->Client(); } + class IClient *Client() const; virtual void OnStateChange(int NewState, int OldState){}; virtual void OnConsoleInit(){}; diff --git a/src/game/client/components/background.cpp b/src/game/client/components/background.cpp index cdac777d6..5e3dfcbf2 100644 --- a/src/game/client/components/background.cpp +++ b/src/game/client/components/background.cpp @@ -8,6 +8,9 @@ #include #include +#include +#include + #include "background.h" CBackground::CBackground(int MapType, bool OnlineOnly) : @@ -68,7 +71,7 @@ void CBackground::LoadBackground() if(m_pMap->IsLoaded()) { m_pLayers = GameClient()->Layers(); - m_pImages = GameClient()->m_pMapimages; + m_pImages = &GameClient()->m_MapImages; m_Loaded = true; } } diff --git a/src/game/client/components/binds.h b/src/game/client/components/binds.h index f09475dcf..9c7b20084 100644 --- a/src/game/client/components/binds.h +++ b/src/game/client/components/binds.h @@ -5,6 +5,10 @@ #include #include +#include "console.h" + +class IConfigManager; + class CBinds : public CComponent { int GetKeyID(const char *pKeyName); diff --git a/src/game/client/components/broadcast.cpp b/src/game/client/components/broadcast.cpp index fa7f4ca09..ddab12172 100644 --- a/src/game/client/components/broadcast.cpp +++ b/src/game/client/components/broadcast.cpp @@ -20,7 +20,7 @@ void CBroadcast::OnReset() void CBroadcast::OnRender() { - if(m_pClient->m_pScoreboard->Active() || m_pClient->m_pMotd->IsActive() || !g_Config.m_ClShowBroadcasts) + if(m_pClient->m_Scoreboard.Active() || m_pClient->m_Motd.IsActive() || !g_Config.m_ClShowBroadcasts) return; Graphics()->MapScreen(0, 0, 300 * Graphics()->ScreenAspect(), 300); diff --git a/src/game/client/components/camera.cpp b/src/game/client/components/camera.cpp index e5f62669b..bb8caa908 100644 --- a/src/game/client/components/camera.cpp +++ b/src/game/client/components/camera.cpp @@ -107,22 +107,22 @@ void CCamera::OnRender() { if(m_CamType != CAMTYPE_SPEC) { - m_LastPos[g_Config.m_ClDummy] = m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy]; - m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy] = m_PrevCenter; - m_pClient->m_pControls->ClampMousePos(); + m_LastPos[g_Config.m_ClDummy] = m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy]; + m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy] = m_PrevCenter; + m_pClient->m_Controls.ClampMousePos(); m_CamType = CAMTYPE_SPEC; } - m_Center = m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy]; + m_Center = m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy]; } else { if(m_CamType != CAMTYPE_PLAYER) { if((m_LastPos[g_Config.m_ClDummy].x < g_Config.m_ClMouseMinDistance) || (m_LastPos[g_Config.m_ClDummy].x < g_Config.m_ClDyncamMinDistance)) - m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy].x = m_LastPos[g_Config.m_ClDummy].x + g_Config.m_ClMouseMinDistance + g_Config.m_ClDyncamMinDistance; + m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy].x = m_LastPos[g_Config.m_ClDummy].x + g_Config.m_ClMouseMinDistance + g_Config.m_ClDyncamMinDistance; else - m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy] = m_LastPos[g_Config.m_ClDummy]; - m_pClient->m_pControls->ClampMousePos(); + m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy] = m_LastPos[g_Config.m_ClDummy]; + m_pClient->m_Controls.ClampMousePos(); m_CamType = CAMTYPE_PLAYER; } @@ -139,7 +139,7 @@ void CCamera::OnRender() s_SpeedBias += CameraSpeed * DeltaTime; if(g_Config.m_ClDyncam) { - s_SpeedBias -= length(m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy] - s_LastMousePos) * log10f(CameraStabilizingFactor) * 0.02f; + s_SpeedBias -= length(m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy] - s_LastMousePos) * log10f(CameraStabilizingFactor) * 0.02f; s_SpeedBias = clamp(s_SpeedBias, 0.5f, CameraSpeed); } else @@ -149,7 +149,7 @@ void CCamera::OnRender() } vec2 TargetCameraOffset(0, 0); - s_LastMousePos = m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy]; + s_LastMousePos = m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy]; float l = length(s_LastMousePos); if(l > 0.0001f) // make sure that this isn't 0 { @@ -157,7 +157,7 @@ void CCamera::OnRender() float FollowFactor = (g_Config.m_ClDyncam ? g_Config.m_ClDyncamFollowFactor : g_Config.m_ClMouseFollowfactor) / 100.0f; float OffsetAmount = maximum(l - DeadZone, 0.0f) * FollowFactor; - TargetCameraOffset = normalize(m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy]) * OffsetAmount; + TargetCameraOffset = normalize(m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy]) * OffsetAmount; } if(g_Config.m_ClDyncamSmoothness > 0) @@ -173,7 +173,7 @@ void CCamera::OnRender() if(m_ForceFreeviewPos != vec2(-1, -1) && m_CamType == CAMTYPE_SPEC) { - m_Center = m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy] = m_ForceFreeviewPos; + m_Center = m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy] = m_ForceFreeviewPos; m_ForceFreeviewPos = vec2(-1, -1); } m_PrevCenter = m_Center; diff --git a/src/game/client/components/chat.cpp b/src/game/client/components/chat.cpp index 1bfe0d50b..c630fafeb 100644 --- a/src/game/client/components/chat.cpp +++ b/src/game/client/components/chat.cpp @@ -853,7 +853,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) { if(g_Config.m_SndServerMessage) { - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0); + m_pClient->m_Sounds.Play(CSounds::CHN_GUI, SOUND_CHAT_SERVER, 0); m_aLastSoundPlayed[CHAT_SERVER] = Now; } } @@ -871,7 +871,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) Client()->Notify("DDNet Chat", aBuf); if(g_Config.m_SndHighlight) { - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); + m_pClient->m_Sounds.Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); m_aLastSoundPlayed[CHAT_HIGHLIGHT] = Now; } @@ -887,7 +887,7 @@ void CChat::AddLine(int ClientID, int Team, const char *pLine) { if((g_Config.m_SndTeamChat || !m_aLines[m_CurrentLine].m_Team) && (g_Config.m_SndChat || m_aLines[m_CurrentLine].m_Team)) { - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); + m_pClient->m_Sounds.Play(CSounds::CHN_GUI, SOUND_CHAT_CLIENT, 0); m_aLastSoundPlayed[CHAT_CLIENT] = Now; } } @@ -900,7 +900,7 @@ void CChat::RefindSkins() { if(Line.m_HasRenderTee) { - const CSkin *pSkin = m_pClient->m_pSkins->Get(m_pClient->m_pSkins->Find(Line.m_aSkinName)); + const CSkin *pSkin = m_pClient->m_Skins.Get(m_pClient->m_Skins.Find(Line.m_aSkinName)); if(Line.m_CustomColoredSkin) Line.m_RenderSkin = pSkin->m_ColorableSkin; else @@ -919,7 +919,7 @@ void CChat::OnPrepareLines() float ScreenRatio = Graphics()->ScreenAspect(); - bool IsScoreBoardOpen = m_pClient->m_pScoreboard->Active() && (ScreenRatio > 1.7f); // only assume scoreboard when screen ratio is widescreen(something around 16:9) + bool IsScoreBoardOpen = m_pClient->m_Scoreboard.Active() && (ScreenRatio > 1.7f); // only assume scoreboard when screen ratio is widescreen(something around 16:9) bool ForceRecreate = IsScoreBoardOpen != m_PrevScoreBoardShowed; bool ShowLargeArea = m_Show || g_Config.m_ClShowChat == 2; @@ -1239,7 +1239,7 @@ void CChat::OnRender() Marker.m_X -= MarkerOffset; TextRender()->TextEx(&Marker, "|", -1); TextRender()->TextEx(&Cursor, m_Input.GetString(Editing) + m_Input.GetCursorOffset(Editing), -1); - if(m_pClient->m_pGameConsole->IsClosed()) + if(m_pClient->m_GameConsole.IsClosed()) Input()->SetEditingPosition(Marker.m_X, Marker.m_Y + Marker.m_FontSize); } @@ -1255,7 +1255,7 @@ void CChat::OnRender() OnPrepareLines(); float ScreenRatio = Graphics()->ScreenAspect(); - bool IsScoreBoardOpen = m_pClient->m_pScoreboard->Active() && (ScreenRatio > 1.7f); // only assume scoreboard when screen ratio is widescreen(something around 16:9) + bool IsScoreBoardOpen = m_pClient->m_Scoreboard.Active() && (ScreenRatio > 1.7f); // only assume scoreboard when screen ratio is widescreen(something around 16:9) int64_t Now = time(); float HeightLimit = IsScoreBoardOpen ? 180.0f : m_PrevShowChat ? 50.0f : 200.0f; diff --git a/src/game/client/components/chat.h b/src/game/client/components/chat.h index aaa0e82b6..97eb5946f 100644 --- a/src/game/client/components/chat.h +++ b/src/game/client/components/chat.h @@ -7,6 +7,8 @@ #include #include +#include + class CChat : public CComponent { CLineInput m_Input; diff --git a/src/game/client/components/console.cpp b/src/game/client/components/console.cpp index 1e66fabf7..8dd98961c 100644 --- a/src/game/client/components/console.cpp +++ b/src/game/client/components/console.cpp @@ -31,6 +31,8 @@ #include #include +#include + #include "console.h" CGameConsole::CInstance::CInstance(int Type) @@ -750,17 +752,17 @@ void CGameConsole::Toggle(int Type) if(m_ConsoleState == CONSOLE_CLOSED || m_ConsoleState == CONSOLE_CLOSING) { /*Input()->MouseModeAbsolute();*/ - m_pClient->m_pMenus->UseMouseButtons(false); + m_pClient->m_Menus.UseMouseButtons(false); m_ConsoleState = CONSOLE_OPENING; /*// reset controls - m_pClient->m_pControls->OnReset();*/ + m_pClient->m_Controls.OnReset();*/ Input()->SetIMEState(true); } else { Input()->MouseModeRelative(); - m_pClient->m_pMenus->UseMouseButtons(true); + m_pClient->m_Menus.UseMouseButtons(true); m_pClient->OnRelease(); m_ConsoleState = CONSOLE_CLOSING; diff --git a/src/game/client/components/console.h b/src/game/client/components/console.h index b02060a79..846232d21 100644 --- a/src/game/client/components/console.h +++ b/src/game/client/components/console.h @@ -6,6 +6,8 @@ #include #include +#include + enum { CONSOLE_CLOSED, diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index 8074b73c0..b1101cf36 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -250,9 +250,9 @@ int CControls::SnapInput(int *pData) bool Send = false; // update player state - if(m_pClient->m_pChat->IsActive()) + if(m_pClient->m_Chat.IsActive()) m_InputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_CHATTING; - else if(m_pClient->m_pMenus->IsActive()) + else if(m_pClient->m_Menus.IsActive()) m_InputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_IN_MENU; else { @@ -264,13 +264,13 @@ int CControls::SnapInput(int *pData) m_InputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_PLAYING; } - if(m_pClient->m_pScoreboard->Active()) + if(m_pClient->m_Scoreboard.Active()) m_InputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_SCOREBOARD; if(m_InputData[g_Config.m_ClDummy].m_PlayerFlags != PLAYERFLAG_PLAYING) m_JoystickTapTime = 0; // Do not launch hook on first tap - if(m_pClient->m_pControls->m_ShowHookColl[g_Config.m_ClDummy]) + if(m_pClient->m_Controls.m_ShowHookColl[g_Config.m_ClDummy]) m_InputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_AIM; if(m_LastData[g_Config.m_ClDummy].m_PlayerFlags != m_InputData[g_Config.m_ClDummy].m_PlayerFlags) @@ -547,8 +547,8 @@ bool CControls::OnMouseMove(float x, float y) if(m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorID < 0) { - x = x * m_pClient->m_pCamera->m_Zoom; - y = y * m_pClient->m_pCamera->m_Zoom; + x = x * m_pClient->m_Camera.m_Zoom; + y = y * m_pClient->m_Camera.m_Zoom; } m_MousePos[g_Config.m_ClDummy] += vec2(x, y); // TODO: ugly diff --git a/src/game/client/components/controls.h b/src/game/client/components/controls.h index f4218ca65..17b2c0290 100644 --- a/src/game/client/components/controls.h +++ b/src/game/client/components/controls.h @@ -7,6 +7,8 @@ #include #include +#include + class CControls : public CComponent { public: diff --git a/src/game/client/components/damageind.cpp b/src/game/client/components/damageind.cpp index ec500cea0..a07b2dff3 100644 --- a/src/game/client/components/damageind.cpp +++ b/src/game/client/components/damageind.cpp @@ -9,6 +9,8 @@ #include #include +#include + CDamageInd::CDamageInd() { m_Lastupdate = 0; diff --git a/src/game/client/components/effects.cpp b/src/game/client/components/effects.cpp index 84e23dd1f..928471999 100644 --- a/src/game/client/components/effects.cpp +++ b/src/game/client/components/effects.cpp @@ -42,23 +42,23 @@ void CEffects::AirJump(vec2 Pos) p.m_Gravity = 500; p.m_Friction = 0.7f; p.m_FlowAffected = 0.0f; - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_GENERAL, &p); p.m_Pos = Pos + vec2(6.0f, 16.0f); - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_GENERAL, &p); if(g_Config.m_SndGame) - m_pClient->m_pSounds->PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, Pos); + m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_AIRJUMP, 1.0f, Pos); } void CEffects::DamageIndicator(vec2 Pos, vec2 Dir) { - m_pClient->m_pDamageind->Create(Pos, Dir); + m_pClient->m_DamageInd.Create(Pos, Dir); } void CEffects::ResetDamageIndicator() { - m_pClient->m_pDamageind->Reset(); + m_pClient->m_DamageInd.Reset(); } void CEffects::PowerupShine(vec2 Pos, vec2 size) @@ -79,7 +79,7 @@ void CEffects::PowerupShine(vec2 Pos, vec2 size) p.m_Gravity = 500; p.m_Friction = 0.9f; p.m_FlowAffected = 0.0f; - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_GENERAL, &p); } void CEffects::SmokeTrail(vec2 Pos, vec2 Vel, float Alpha, float TimePassed) @@ -98,7 +98,7 @@ void CEffects::SmokeTrail(vec2 Pos, vec2 Vel, float Alpha, float TimePassed) p.m_Friction = 0.7f; p.m_Gravity = frandom() * -500.0f; p.m_Color.a *= Alpha; - m_pClient->m_pParticles->Add(CParticles::GROUP_PROJECTILE_TRAIL, &p, TimePassed); + m_pClient->m_Particles.Add(CParticles::GROUP_PROJECTILE_TRAIL, &p, TimePassed); } void CEffects::SkidTrail(vec2 Pos, vec2 Vel) @@ -117,7 +117,7 @@ void CEffects::SkidTrail(vec2 Pos, vec2 Vel) p.m_Friction = 0.7f; p.m_Gravity = frandom() * -500.0f; p.m_Color = ColorRGBA(0.75f, 0.75f, 0.75f, 1.0f); - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_GENERAL, &p); } void CEffects::BulletTrail(vec2 Pos, float Alpha, float TimePassed) @@ -134,7 +134,7 @@ void CEffects::BulletTrail(vec2 Pos, float Alpha, float TimePassed) p.m_EndSize = 0; p.m_Friction = 0.7f; p.m_Color.a *= Alpha; - m_pClient->m_pParticles->Add(CParticles::GROUP_PROJECTILE_TRAIL, &p, TimePassed); + m_pClient->m_Particles.Add(CParticles::GROUP_PROJECTILE_TRAIL, &p, TimePassed); } void CEffects::PlayerSpawn(vec2 Pos) @@ -154,10 +154,10 @@ void CEffects::PlayerSpawn(vec2 Pos) p.m_Gravity = frandom() * -400.0f; p.m_Friction = 0.7f; p.m_Color = ColorRGBA(0xb5 / 255.0f, 0x50 / 255.0f, 0xcb / 255.0f, 1.0f); - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_GENERAL, &p); } if(g_Config.m_SndGame) - m_pClient->m_pSounds->PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SPAWN, 1.0f, Pos); + m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SPAWN, 1.0f, Pos); } void CEffects::PlayerDeath(vec2 Pos, int ClientID) @@ -190,7 +190,7 @@ void CEffects::PlayerDeath(vec2 Pos, int ClientID) p.m_Friction = 0.8f; ColorRGBA c = BloodColor.v4() * (0.75f + frandom() * 0.25f); p.m_Color = ColorRGBA(c.r, c.g, c.b, 0.75f); - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_GENERAL, &p); } } @@ -204,7 +204,7 @@ void CEffects::Explosion(vec2 Pos) continue; float a = 1 - (length(vec2(x, y)) / length(vec2(8, 8))); - m_pClient->m_pFlow->Add(Pos + vec2(x, y) * 16, normalize(vec2(x, y)) * 5000.0f * a, 10.0f); + m_pClient->m_Flow.Add(Pos + vec2(x, y) * 16, normalize(vec2(x, y)) * 5000.0f * a, 10.0f); } // add the explosion @@ -216,7 +216,7 @@ void CEffects::Explosion(vec2 Pos) p.m_StartSize = 150.0f; p.m_EndSize = 0; p.m_Rot = frandom() * pi * 2; - m_pClient->m_pParticles->Add(CParticles::GROUP_EXPLOSIONS, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_EXPLOSIONS, &p); // add the smoke for(int i = 0; i < 24; i++) @@ -232,7 +232,7 @@ void CEffects::Explosion(vec2 Pos) p.m_Gravity = frandom() * -800.0f; p.m_Friction = 0.4f; p.m_Color = mix(vec4(0.75f, 0.75f, 0.75f, 1.0f), vec4(0.5f, 0.5f, 0.5f, 1.0f), frandom()); - m_pClient->m_pParticles->Add(CParticles::GROUP_GENERAL, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_GENERAL, &p); } } @@ -247,9 +247,9 @@ void CEffects::HammerHit(vec2 Pos) p.m_StartSize = 120.0f; p.m_EndSize = 0; p.m_Rot = frandom() * pi * 2; - m_pClient->m_pParticles->Add(CParticles::GROUP_EXPLOSIONS, &p); + m_pClient->m_Particles.Add(CParticles::GROUP_EXPLOSIONS, &p); if(g_Config.m_SndGame) - m_pClient->m_pSounds->PlayAt(CSounds::CHN_WORLD, SOUND_HAMMER_HIT, 1.0f, Pos); + m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_HAMMER_HIT, 1.0f, Pos); } void CEffects::OnRender() @@ -278,7 +278,7 @@ void CEffects::OnRender() m_Add50hz = false; if(m_Add50hz) - m_pClient->m_pFlow->Update(); + m_pClient->m_Flow.Update(); return; } @@ -300,5 +300,5 @@ void CEffects::OnRender() m_Add50hz = false; if(m_Add50hz) - m_pClient->m_pFlow->Update(); + m_pClient->m_Flow.Update(); } diff --git a/src/game/client/components/emoticon.cpp b/src/game/client/components/emoticon.cpp index d42194cda..bfe773474 100644 --- a/src/game/client/components/emoticon.cpp +++ b/src/game/client/components/emoticon.cpp @@ -13,6 +13,8 @@ #include #include // get_angle +#include + CEmoticon::CEmoticon() { OnReset(); @@ -217,5 +219,5 @@ void CEmoticon::EyeEmote(int Emote) str_format(aBuf, sizeof(aBuf), "/emote blink %d", g_Config.m_ClEyeDuration); break; } - GameClient()->m_pChat->Say(0, aBuf); + GameClient()->m_Chat.Say(0, aBuf); } diff --git a/src/game/client/components/ghost.cpp b/src/game/client/components/ghost.cpp index 5b64317f6..484826563 100644 --- a/src/game/client/components/ghost.cpp +++ b/src/game/client/components/ghost.cpp @@ -12,6 +12,8 @@ #include "players.h" #include "skins.h" +#include + const char *CGhost::ms_pGhostDir = "ghosts"; CGhost::CGhost() : @@ -341,8 +343,8 @@ void CGhost::OnRender() Player.m_AttackTick += Client()->GameTick(g_Config.m_ClDummy) - GhostTick; - m_pClient->m_pPlayers->RenderHook(&Prev, &Player, &Ghost.m_RenderInfo, -2, IntraTick); - m_pClient->m_pPlayers->RenderPlayer(&Prev, &Player, &Ghost.m_RenderInfo, -2, IntraTick); + m_pClient->m_Players.RenderHook(&Prev, &Player, &Ghost.m_RenderInfo, -2, IntraTick); + m_pClient->m_Players.RenderPlayer(&Prev, &Player, &Ghost.m_RenderInfo, -2, IntraTick); } } @@ -352,8 +354,8 @@ void CGhost::InitRenderInfos(CGhostItem *pGhost) IntsToStr(&pGhost->m_Skin.m_Skin0, 6, aSkinName); CTeeRenderInfo *pRenderInfo = &pGhost->m_RenderInfo; - int SkinId = m_pClient->m_pSkins->Find(aSkinName); - const CSkin *pSkin = m_pClient->m_pSkins->Get(SkinId); + int SkinId = m_pClient->m_Skins.Find(aSkinName); + const CSkin *pSkin = m_pClient->m_Skins.Get(SkinId); pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin; pRenderInfo->m_ColorableRenderSkin = pSkin->m_ColorableSkin; pRenderInfo->m_BloodColor = pSkin->m_BloodColor; @@ -393,7 +395,7 @@ void CGhost::StopRecord(int Time) if(RecordingToFile) GhostRecorder()->Stop(m_CurGhost.m_Path.Size(), Time); - CMenus::CGhostItem *pOwnGhost = m_pClient->m_pMenus->GetOwnGhost(); + CMenus::CGhostItem *pOwnGhost = m_pClient->m_Menus.GetOwnGhost(); if(Time > 0 && (!pOwnGhost || Time < pOwnGhost->m_Time)) { if(pOwnGhost && pOwnGhost->Active()) @@ -417,7 +419,7 @@ void CGhost::StopRecord(int Time) Storage()->RenameFile(m_aTmpFilename, Item.m_aFilename, IStorage::TYPE_SAVE); // add item to menu list - m_pClient->m_pMenus->UpdateOwnGhost(Item); + m_pClient->m_Menus.UpdateOwnGhost(Item); } else if(RecordingToFile) // no new record Storage()->RemoveFile(m_aTmpFilename, IStorage::TYPE_SAVE); @@ -620,7 +622,7 @@ void CGhost::OnMapLoad() { OnReset(); UnloadAll(); - m_pClient->m_pMenus->GhostlistPopulate(); + m_pClient->m_Menus.GhostlistPopulate(); m_AllowRestart = false; } @@ -639,8 +641,8 @@ void CGhost::RefindSkin() { CTeeRenderInfo *pRenderInfo = &Ghost.m_RenderInfo; - int SkinId = m_pClient->m_pSkins->Find(aSkinName); - const CSkin *pSkin = m_pClient->m_pSkins->Get(SkinId); + int SkinId = m_pClient->m_Skins.Find(aSkinName); + const CSkin *pSkin = m_pClient->m_Skins.Get(SkinId); pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin; pRenderInfo->m_ColorableRenderSkin = pSkin->m_ColorableSkin; pRenderInfo->m_SkinMetrics = pSkin->m_Metrics; @@ -651,8 +653,8 @@ void CGhost::RefindSkin() { CTeeRenderInfo *pRenderInfo = &m_CurGhost.m_RenderInfo; - int SkinId = m_pClient->m_pSkins->Find(aSkinName); - const CSkin *pSkin = m_pClient->m_pSkins->Get(SkinId); + int SkinId = m_pClient->m_Skins.Find(aSkinName); + const CSkin *pSkin = m_pClient->m_Skins.Get(SkinId); pRenderInfo->m_OriginalRenderSkin = pSkin->m_OriginalSkin; pRenderInfo->m_ColorableRenderSkin = pSkin->m_ColorableSkin; pRenderInfo->m_SkinMetrics = pSkin->m_Metrics; diff --git a/src/game/client/components/ghost.h b/src/game/client/components/ghost.h index 771483d11..186dea73f 100644 --- a/src/game/client/components/ghost.h +++ b/src/game/client/components/ghost.h @@ -6,6 +6,10 @@ #include #include +#include + +struct CNetObj_Character; + enum { GHOSTDATA_TYPE_SKIN = 0, diff --git a/src/game/client/components/hud.cpp b/src/game/client/components/hud.cpp index 2dd582f17..71323579a 100644 --- a/src/game/client/components/hud.cpp +++ b/src/game/client/components/hud.cpp @@ -605,7 +605,7 @@ void CHud::RenderTeambalanceWarning() void CHud::RenderVoting() { - if((!g_Config.m_ClShowVotesAfterVoting && !m_pClient->m_pScoreboard->Active() && m_pClient->m_pVoting->TakenChoice()) || !m_pClient->m_pVoting->IsVoting() || Client()->State() == IClient::STATE_DEMOPLAYBACK) + if((!g_Config.m_ClShowVotesAfterVoting && !m_pClient->m_Scoreboard.Active() && m_pClient->m_Voting.TakenChoice()) || !m_pClient->m_Voting.IsVoting() || Client()->State() == IClient::STATE_DEMOPLAYBACK) return; Graphics()->TextureClear(); @@ -619,7 +619,7 @@ void CHud::RenderVoting() CTextCursor Cursor; char aBuf[512]; - str_format(aBuf, sizeof(aBuf), Localize("%ds left"), m_pClient->m_pVoting->SecondsLeft()); + str_format(aBuf, sizeof(aBuf), Localize("%ds left"), m_pClient->m_Voting.SecondsLeft()); float tw = TextRender()->TextWidth(0x0, 6, aBuf, -1, -1.0f); TextRender()->SetCursor(&Cursor, 5.0f + 100.0f - tw, 60.0f, 6.0f, TEXTFLAG_RENDER); TextRender()->TextEx(&Cursor, aBuf, -1); @@ -627,26 +627,26 @@ void CHud::RenderVoting() TextRender()->SetCursor(&Cursor, 5.0f, 60.0f, 6.0f, TEXTFLAG_RENDER); Cursor.m_LineWidth = 100.0f - tw; Cursor.m_MaxLines = 3; - TextRender()->TextEx(&Cursor, m_pClient->m_pVoting->VoteDescription(), -1); + TextRender()->TextEx(&Cursor, m_pClient->m_Voting.VoteDescription(), -1); // reason - str_format(aBuf, sizeof(aBuf), "%s %s", Localize("Reason:"), m_pClient->m_pVoting->VoteReason()); + str_format(aBuf, sizeof(aBuf), "%s %s", Localize("Reason:"), m_pClient->m_Voting.VoteReason()); TextRender()->SetCursor(&Cursor, 5.0f, 79.0f, 6.0f, TEXTFLAG_RENDER | TEXTFLAG_STOP_AT_END); Cursor.m_LineWidth = 100.0f; TextRender()->TextEx(&Cursor, aBuf, -1); CUIRect Base = {5, 88, 100, 4}; - m_pClient->m_pVoting->RenderBars(Base, false); + m_pClient->m_Voting.RenderBars(Base, false); char aKey[64]; - m_pClient->m_pBinds->GetKey("vote yes", aKey, sizeof(aKey)); + m_pClient->m_Binds.GetKey("vote yes", aKey, sizeof(aKey)); str_format(aBuf, sizeof(aBuf), "%s - %s", aKey, Localize("Vote yes")); Base.y += Base.h; Base.h = 11.f; UI()->DoLabel(&Base, aBuf, 6.0f, -1); - m_pClient->m_pBinds->GetKey("vote no", aKey, sizeof(aKey)); + m_pClient->m_Binds.GetKey("vote no", aKey, sizeof(aKey)); str_format(aBuf, sizeof(aBuf), "%s - %s", Localize("Vote no"), aKey); UI()->DoLabel(&Base, aBuf, 6.0f, 1); } @@ -656,7 +656,7 @@ void CHud::RenderCursor() if(!m_pClient->m_Snap.m_pLocalCharacter || Client()->State() == IClient::STATE_DEMOPLAYBACK) return; - MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup()); + MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup()); int CurWeapon = m_pClient->m_Snap.m_pLocalCharacter->m_Weapon % NUM_WEAPONS; @@ -665,7 +665,7 @@ void CHud::RenderCursor() // render cursor int QuadOffset = NUM_WEAPONS * 10 * 2 + 40 * 2 + (CurWeapon); Graphics()->SetColor(1.f, 1.f, 1.f, 1.f); - Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, QuadOffset, m_pClient->m_pControls->m_TargetPos[g_Config.m_ClDummy].x, m_pClient->m_pControls->m_TargetPos[g_Config.m_ClDummy].y); + Graphics()->RenderQuadContainerAsSprite(m_HudQuadContainerIndex, QuadOffset, m_pClient->m_Controls.m_TargetPos[g_Config.m_ClDummy].x, m_pClient->m_Controls.m_TargetPos[g_Config.m_ClDummy].y); } void CHud::PrepareHealthAmoQuads() @@ -805,7 +805,7 @@ void CHud::RenderSpectatorHud() void CHud::RenderLocalTime(float x) { - if(!g_Config.m_ClShowLocalTimeAlways && !m_pClient->m_pScoreboard->Active()) + if(!g_Config.m_ClShowLocalTimeAlways && !m_pClient->m_Scoreboard.Active()) return; //draw the box diff --git a/src/game/client/components/items.cpp b/src/game/client/components/items.cpp index 096578c06..95296dcde 100644 --- a/src/game/client/components/items.cpp +++ b/src/game/client/components/items.cpp @@ -80,7 +80,7 @@ void CItems::RenderProjectile(const CProjectileData *pCurrent, int ItemID) // don't check for validity of the projectile for the current weapon here, so particle effects are rendered for mod compability if(CurWeapon == WEAPON_GRENADE) { - m_pClient->m_pEffects->SmokeTrail(Pos, Vel * -1, Alpha); + m_pClient->m_Effects.SmokeTrail(Pos, Vel * -1, Alpha); static float s_Time = 0.0f; static float s_LastLocalTime = LocalTime(); @@ -101,7 +101,7 @@ void CItems::RenderProjectile(const CProjectileData *pCurrent, int ItemID) } else { - m_pClient->m_pEffects->BulletTrail(Pos, Alpha); + m_pClient->m_Effects.BulletTrail(Pos, Alpha); if(length(Vel) > 0.00001f) Graphics()->QuadsSetRotation(angle(Vel)); @@ -160,7 +160,7 @@ void CItems::RenderPickup(const CNetObj_Pickup *pPrev, const CNetObj_Pickup *pCu if(c[pCurrent->m_Type] == SPRITE_PICKUP_NINJA) { QuadOffset = 2 + 8 - 1; // ninja is the last weapon - m_pClient->m_pEffects->PowerupShine(Pos, vec2(96, 18)); + m_pClient->m_Effects.PowerupShine(Pos, vec2(96, 18)); Pos.x -= 10.0f; } } @@ -559,8 +559,8 @@ void CItems::ReconstructSmokeTrail(const CProjectileData *pCurrent, int DestroyT TimePassed = minimum(TimePassed, (TimePassed - MinTrailSpan) / (Pt - MinTrailSpan) * (MinTrailSpan * 0.5f) + MinTrailSpan); // add particle for this projectile if(pCurrent->m_Type == WEAPON_GRENADE) - m_pClient->m_pEffects->SmokeTrail(Pos, Vel * -1, Alpha, TimePassed); + m_pClient->m_Effects.SmokeTrail(Pos, Vel * -1, Alpha, TimePassed); else - m_pClient->m_pEffects->BulletTrail(Pos, Alpha, TimePassed); + m_pClient->m_Effects.BulletTrail(Pos, Alpha, TimePassed); } } diff --git a/src/game/client/components/killmessages.h b/src/game/client/components/killmessages.h index 74c51c6c3..1fb553275 100644 --- a/src/game/client/components/killmessages.h +++ b/src/game/client/components/killmessages.h @@ -4,6 +4,8 @@ #define GAME_CLIENT_COMPONENTS_KILLMESSAGES_H #include +#include + class CKillMessages : public CComponent { int m_SpriteQuadContainerIndex; diff --git a/src/game/client/components/mapimages.cpp b/src/game/client/components/mapimages.cpp index f80c6b902..6b5069611 100644 --- a/src/game/client/components/mapimages.cpp +++ b/src/game/client/components/mapimages.cpp @@ -8,8 +8,12 @@ #include #include +#include + #include "mapimages.h" +#include + CMapImages::CMapImages() : CMapImages(100) { diff --git a/src/game/client/components/maplayers.cpp b/src/game/client/components/maplayers.cpp index 48045dcaa..dbf5a80ac 100644 --- a/src/game/client/components/maplayers.cpp +++ b/src/game/client/components/maplayers.cpp @@ -32,12 +32,12 @@ CMapLayers::CMapLayers(int t, bool OnlineOnly) void CMapLayers::OnInit() { m_pLayers = Layers(); - m_pImages = m_pClient->m_pMapimages; + m_pImages = &m_pClient->m_MapImages; } CCamera *CMapLayers::GetCurCamera() { - return m_pClient->m_pCamera; + return &m_pClient->m_Camera; } void CMapLayers::EnvelopeUpdate() diff --git a/src/game/client/components/maplayers.h b/src/game/client/components/maplayers.h index 4a3d4bcdf..2676e467a 100644 --- a/src/game/client/components/maplayers.h +++ b/src/game/client/components/maplayers.h @@ -4,6 +4,8 @@ #define GAME_CLIENT_COMPONENTS_MAPLAYERS_H #include +#include + #include #include @@ -15,6 +17,10 @@ typedef char *offset_ptr_size; typedef uintptr_t offset_ptr; typedef unsigned int offset_ptr32; +struct CMapItemGroup; +struct CMapItemLayerTilemap; +struct CMapItemLayerQuads; + class CMapLayers : public CComponent { friend class CBackground; diff --git a/src/game/client/components/mapsounds.cpp b/src/game/client/components/mapsounds.cpp index ef36b31f0..ca8922ae2 100644 --- a/src/game/client/components/mapsounds.cpp +++ b/src/game/client/components/mapsounds.cpp @@ -6,6 +6,10 @@ #include // envelope #include +#include + +#include + #include "mapsounds.h" CMapSounds::CMapSounds() @@ -128,7 +132,7 @@ void CMapSounds::OnRender() if(!pSource->m_pSource->m_Pan) Flags |= ISound::FLAG_NO_PANNING; - pSource->m_Voice = m_pClient->m_pSounds->PlaySampleAt(CSounds::CHN_MAPSOUND, m_aSounds[pSource->m_Sound], 1.0f, vec2(fx2f(pSource->m_pSource->m_Position.x), fx2f(pSource->m_pSource->m_Position.y)), Flags); + pSource->m_Voice = m_pClient->m_Sounds.PlaySampleAt(CSounds::CHN_MAPSOUND, m_aSounds[pSource->m_Sound], 1.0f, vec2(fx2f(pSource->m_pSource->m_Position.x), fx2f(pSource->m_pSource->m_Position.y)), Flags); Sound()->SetVoiceTimeOffset(pSource->m_Voice, Offset); Sound()->SetVoiceFalloff(pSource->m_Voice, pSource->m_pSource->m_Falloff / 255.0f); switch(pSource->m_pSource->m_Shape.m_Type) @@ -155,7 +159,7 @@ void CMapSounds::OnRender() } } - vec2 Center = m_pClient->m_pCamera->m_Center; + vec2 Center = m_pClient->m_Camera.m_Center; for(int g = 0; g < Layers()->NumGroups(); g++) { CMapItemGroup *pGroup = Layers()->GetGroup(g); @@ -199,7 +203,7 @@ void CMapSounds::OnRender() if(pVoice->m_pSource->m_PosEnv >= 0) { float aChannels[4]; - CMapLayers::EnvelopeEval(pVoice->m_pSource->m_PosEnvOffset, pVoice->m_pSource->m_PosEnv, aChannels, m_pClient->m_pMapLayersBackGround); + CMapLayers::EnvelopeEval(pVoice->m_pSource->m_PosEnvOffset, pVoice->m_pSource->m_PosEnv, aChannels, &m_pClient->m_MapLayersBackGround); OffsetX = aChannels[0]; OffsetY = aChannels[1]; } @@ -218,7 +222,7 @@ void CMapSounds::OnRender() if(pVoice->m_pSource->m_SoundEnv >= 0) { float aChannels[4]; - CMapLayers::EnvelopeEval(pVoice->m_pSource->m_SoundEnvOffset, pVoice->m_pSource->m_SoundEnv, aChannels, m_pClient->m_pMapLayersBackGround); + CMapLayers::EnvelopeEval(pVoice->m_pSource->m_SoundEnvOffset, pVoice->m_pSource->m_SoundEnv, aChannels, &m_pClient->m_MapLayersBackGround); float Volume = clamp(aChannels[0], 0.0f, 1.0f); Sound()->SetVoiceVolume(pVoice->m_Voice, Volume); diff --git a/src/game/client/components/mapsounds.h b/src/game/client/components/mapsounds.h index f3ecc0f3d..182832a20 100644 --- a/src/game/client/components/mapsounds.h +++ b/src/game/client/components/mapsounds.h @@ -7,6 +7,8 @@ #include +struct CSoundSource; + class CMapSounds : public CComponent { int m_aSounds[64]; diff --git a/src/game/client/components/menu_background.cpp b/src/game/client/components/menu_background.cpp index 9bab7d446..af05095d5 100644 --- a/src/game/client/components/menu_background.cpp +++ b/src/game/client/components/menu_background.cpp @@ -10,6 +10,10 @@ #include #include +#include + +#include + #include "menu_background.h" CMenuBackground::CMenuBackground() : diff --git a/src/game/client/components/menus.cpp b/src/game/client/components/menus.cpp index 7d3e1752a..45fddbd88 100644 --- a/src/game/client/components/menus.cpp +++ b/src/game/client/components/menus.cpp @@ -86,8 +86,6 @@ CMenus::CMenus() m_DeletePressed = false; m_NumInputEvents = 0; - m_LastInput = time_get(); - str_copy(m_aCurrentDemoFolder, "demos", sizeof(m_aCurrentDemoFolder)); m_aCallvoteReason[0] = 0; @@ -1465,7 +1463,7 @@ int CMenus::Render() } else if(s_Frame == 1) { - m_pClient->m_pSounds->Enqueue(CSounds::CHN_MUSIC, SOUND_MENU); + m_pClient->m_Sounds.Enqueue(CSounds::CHN_MUSIC, SOUND_MENU); s_Frame++; m_DoubleClickIndex = -1; @@ -2003,11 +2001,11 @@ int CMenus::Render() ActSelection = g_Config.m_BrFilterCountryIndex; static float s_ScrollValue = 0.0f; int OldSelected = -1; - UiDoListboxStart(&s_ScrollValue, &Box, 50.0f, Localize("Country / Region"), "", m_pClient->m_pCountryFlags->Num(), 6, OldSelected, s_ScrollValue); + UiDoListboxStart(&s_ScrollValue, &Box, 50.0f, Localize("Country / Region"), "", m_pClient->m_CountryFlags.Num(), 6, OldSelected, s_ScrollValue); - for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i) + for(int i = 0; i < m_pClient->m_CountryFlags.Num(); ++i) { - const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i); + const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_CountryFlags.GetByIndex(i); if(pEntry->m_CountryCode == ActSelection) OldSelected = i; @@ -2021,14 +2019,14 @@ int CMenus::Render() Item.m_Rect.w = Item.m_Rect.h * 2; Item.m_Rect.x += (OldWidth - Item.m_Rect.w) / 2.0f; ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f); - m_pClient->m_pCountryFlags->Render(pEntry->m_CountryCode, &Color, Item.m_Rect.x, Item.m_Rect.y, Item.m_Rect.w, Item.m_Rect.h); + m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, &Color, Item.m_Rect.x, Item.m_Rect.y, Item.m_Rect.w, Item.m_Rect.h); UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, 0); } } const int NewSelected = UiDoListboxEnd(&s_ScrollValue, 0); if(OldSelected != NewSelected) - ActSelection = m_pClient->m_pCountryFlags->GetByIndex(NewSelected)->m_CountryCode; + ActSelection = m_pClient->m_CountryFlags.GetByIndex(NewSelected)->m_CountryCode; Part.VMargin(120.0f, &Part); @@ -2554,8 +2552,6 @@ void CMenus::OnReset() bool CMenus::OnMouseMove(float x, float y) { - m_LastInput = time_get(); - if(!m_MenuActive) return false; @@ -2578,8 +2574,6 @@ bool CMenus::OnMouseMove(float x, float y) bool CMenus::OnInput(IInput::CEvent e) { - m_LastInput = time_get(); - // special handle esc and enter for popup purposes if(e.m_Flags & IInput::FLAG_PRESS) { @@ -2618,7 +2612,7 @@ void CMenus::OnStateChange(int NewState, int OldState) if(NewState == IClient::STATE_OFFLINE) { if(OldState >= IClient::STATE_ONLINE && NewState < IClient::STATE_QUITTING) - m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); + m_pClient->m_Sounds.Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); m_Popup = POPUP_NONE; if(Client()->ErrorString() && Client()->ErrorString()[0] != 0) { @@ -2809,7 +2803,7 @@ bool CMenus::CheckHotKey(int Key) const { return m_Popup == POPUP_NONE && !Input()->KeyIsPressed(KEY_LSHIFT) && !Input()->KeyIsPressed(KEY_RSHIFT) && !Input()->KeyIsPressed(KEY_LCTRL) && !Input()->KeyIsPressed(KEY_RCTRL) && !Input()->KeyIsPressed(KEY_LALT) && // no modifier - Input()->KeyIsPressed(Key) && m_pClient->m_pGameConsole->IsClosed(); + Input()->KeyIsPressed(Key) && m_pClient->m_GameConsole.IsClosed(); } int CMenus::DoButton_CheckBox_DontCare(const void *pID, const char *pText, int Checked, const CUIRect *pRect) diff --git a/src/game/client/components/menus.h b/src/game/client/components/menus.h index 274e32cd2..3155685a9 100644 --- a/src/game/client/components/menus.h +++ b/src/game/client/components/menus.h @@ -18,6 +18,8 @@ #include #include +#include + struct CServerProcess { PROCESS Process; @@ -292,8 +294,6 @@ protected: char m_aNextServer[256]; - int64_t m_LastInput; - // images struct CMenuImage { diff --git a/src/game/client/components/menus_browser.cpp b/src/game/client/components/menus_browser.cpp index d77a7832e..65f97411a 100644 --- a/src/game/client/components/menus_browser.cpp +++ b/src/game/client/components/menus_browser.cpp @@ -19,6 +19,8 @@ #include #include +#include + #include "menus.h" static const int g_OffsetColFlagLock = 2; @@ -191,7 +193,7 @@ void CMenus::RenderServerbrowserServerList(CUIRect View) s_ScrollValue = DoScrollbarV(&s_ScrollBar, &Scroll, s_ScrollValue); - if(Input()->KeyPress(KEY_TAB) && m_pClient->m_pGameConsole->IsClosed()) + if(Input()->KeyPress(KEY_TAB) && m_pClient->m_GameConsole.IsClosed()) { if(Input()->KeyIsPressed(KEY_LSHIFT) || Input()->KeyIsPressed(KEY_RSHIFT)) g_Config.m_UiToolboxPage = (g_Config.m_UiToolboxPage + 3 - 1) % 3; @@ -758,7 +760,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) Rect.w = Rect.h * 2; Rect.x += (OldWidth - Rect.w) / 2.0f; ColorRGBA Color(1.0f, 1.0f, 1.0f, g_Config.m_BrFilterCountry ? 1.0f : 0.5f); - m_pClient->m_pCountryFlags->Render(g_Config.m_BrFilterCountryIndex, &Color, Rect.x, Rect.y, Rect.w, Rect.h); + m_pClient->m_CountryFlags.Render(g_Config.m_BrFilterCountryIndex, &Color, Rect.x, Rect.y, Rect.w, Rect.h); if(g_Config.m_BrFilterCountry && UI()->DoButtonLogic(&g_Config.m_BrFilterCountryIndex, "", 0, &Rect)) m_Popup = POPUP_COUNTRY; @@ -973,7 +975,7 @@ void CMenus::RenderServerbrowserFilters(CUIRect View) } ColorRGBA Color(1.0f, 1.0f, 1.0f, Active ? 1.0f : 0.2f); - m_pClient->m_pCountryFlags->Render(FlagID, &Color, Pos.x, Pos.y, FlagWidth, FlagHeight); + m_pClient->m_CountryFlags.Render(FlagID, &Color, Pos.x, Pos.y, FlagWidth, FlagHeight); } } } @@ -1209,7 +1211,7 @@ void CMenus::RenderServerbrowserServerDetail(CUIRect View) // flag ColorRGBA FColor(1.0f, 1.0f, 1.0f, 0.5f); - m_pClient->m_pCountryFlags->Render(pSelectedServer->m_aClients[i].m_Country, &FColor, Flag.x, Flag.y, Flag.w, Flag.h); + m_pClient->m_CountryFlags.Render(pSelectedServer->m_aClients[i].m_Country, &FColor, Flag.x, Flag.y, Flag.w, Flag.h); } UiDoListboxEnd(&s_ScrollValue, 0); diff --git a/src/game/client/components/menus_demo.cpp b/src/game/client/components/menus_demo.cpp index 362272de9..dfef7e37d 100644 --- a/src/game/client/components/menus_demo.cpp +++ b/src/game/client/components/menus_demo.cpp @@ -166,7 +166,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) } // handle keyboard shortcuts independent of active menu - if(m_pClient->m_pGameConsole->IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE && g_Config.m_ClDemoKeyboardShortcuts) + if(m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE && g_Config.m_ClDemoKeyboardShortcuts) { // increase/decrease speed if(!Input()->KeyIsPressed(KEY_LSHIFT) && !Input()->KeyIsPressed(KEY_RSHIFT)) @@ -351,8 +351,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) m_pClient->m_SuppressEvents = true; DemoPlayer()->SeekPercent(Amount); m_pClient->m_SuppressEvents = false; - m_pClient->m_pMapLayersBackGround->EnvelopeUpdate(); - m_pClient->m_pMapLayersForeGround->EnvelopeUpdate(); + m_pClient->m_MapLayersBackGround.EnvelopeUpdate(); + m_pClient->m_MapLayersForeGround.EnvelopeUpdate(); } } else @@ -363,8 +363,8 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) m_pClient->m_SuppressEvents = true; DemoPlayer()->SeekPercent(Amount); m_pClient->m_SuppressEvents = false; - m_pClient->m_pMapLayersBackGround->EnvelopeUpdate(); - m_pClient->m_pMapLayersForeGround->EnvelopeUpdate(); + m_pClient->m_MapLayersBackGround.EnvelopeUpdate(); + m_pClient->m_MapLayersForeGround.EnvelopeUpdate(); } } } @@ -464,7 +464,7 @@ void CMenus::RenderDemoPlayer(CUIRect MainView) // close button ButtonBar.VSplitRight(ButtonbarHeight * 3, &ButtonBar, &Button); static int s_ExitButton = 0; - if(DoButton_DemoPlayer(&s_ExitButton, Localize("Close"), 0, &Button) || (Input()->KeyPress(KEY_C) && m_pClient->m_pGameConsole->IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) + if(DoButton_DemoPlayer(&s_ExitButton, Localize("Close"), 0, &Button) || (Input()->KeyPress(KEY_C) && m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) { Client()->Disconnect(); DemolistOnUpdate(false); @@ -1220,7 +1220,7 @@ void CMenus::RenderDemoList(CUIRect MainView) } static int s_PlayButton = 0; - if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir ? Localize("Open") : Localize("Play", "Demo browser"), 0, &PlayRect) || Activated || (Input()->KeyPress(KEY_P) && m_pClient->m_pGameConsole->IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) + if(DoButton_Menu(&s_PlayButton, m_DemolistSelectedIsDir ? Localize("Open") : Localize("Play", "Demo browser"), 0, &PlayRect) || Activated || (Input()->KeyPress(KEY_P) && m_pClient->m_GameConsole.IsClosed() && m_DemoPlayerState == DEMOPLAYER_NONE)) { if(m_DemolistSelectedIndex >= 0) { @@ -1271,7 +1271,7 @@ void CMenus::RenderDemoList(CUIRect MainView) if(!m_DemolistSelectedIsDir) { static int s_DeleteButton = 0; - if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed || (Input()->KeyPress(KEY_D) && m_pClient->m_pGameConsole->IsClosed())) + if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &DeleteRect) || m_DeletePressed || (Input()->KeyPress(KEY_D) && m_pClient->m_GameConsole.IsClosed())) { if(m_DemolistSelectedIndex >= 0) { @@ -1295,7 +1295,7 @@ void CMenus::RenderDemoList(CUIRect MainView) #if defined(CONF_VIDEORECORDER) static int s_RenderButton = 0; - if(DoButton_Menu(&s_RenderButton, Localize("Render"), 0, &RenderRect) || (Input()->KeyPress(KEY_R) && m_pClient->m_pGameConsole->IsClosed())) + if(DoButton_Menu(&s_RenderButton, Localize("Render"), 0, &RenderRect) || (Input()->KeyPress(KEY_R) && m_pClient->m_GameConsole.IsClosed())) { if(m_DemolistSelectedIndex >= 0) { diff --git a/src/game/client/components/menus_ingame.cpp b/src/game/client/components/menus_ingame.cpp index 5c7088a7c..77064e55c 100644 --- a/src/game/client/components/menus_ingame.cpp +++ b/src/game/client/components/menus_ingame.cpp @@ -319,7 +319,7 @@ void CMenus::RenderPlayers(CUIRect MainView) //TextRender()->SetCursor(&Cursor, Button2.x,Button2.y, 14.0f, TEXTFLAG_RENDER|TEXTFLAG_STOP_AT_END); //Cursor.m_LineWidth = Button.w; ColorRGBA Color(1.0f, 1.0f, 1.0f, 0.5f); - m_pClient->m_pCountryFlags->Render(m_pClient->m_aClients[Index].m_Country, &Color, + m_pClient->m_CountryFlags.Render(m_pClient->m_aClients[Index].m_Country, &Color, Button2.x, Button2.y + Button2.h / 2.0f - 0.75 * Button2.h / 2.0f, 1.5f * Button2.h, 0.75f * Button2.h); // ignore chat button @@ -516,7 +516,7 @@ void CMenus::RenderServerInfo(CUIRect MainView) x = 5.0f; TextRender()->Text(0, Motd.x + x, Motd.y + y, 32, Localize("MOTD"), -1.0f); y += 32.0f + 5.0f; - TextRender()->Text(0, Motd.x + x, Motd.y + y, 16, m_pClient->m_pMotd->m_aServerMotd, Motd.w); + TextRender()->Text(0, Motd.x + x, Motd.y + y, 16, m_pClient->m_Motd.m_aServerMotd, Motd.w); } bool CMenus::RenderServerControlServer(CUIRect MainView) @@ -524,13 +524,13 @@ bool CMenus::RenderServerControlServer(CUIRect MainView) static int s_VoteList = 0; static float s_ScrollValue = 0; CUIRect List = MainView; - int Total = m_pClient->m_pVoting->m_NumVoteOptions; + int Total = m_pClient->m_Voting.m_NumVoteOptions; int NumVoteOptions = 0; int aIndices[MAX_VOTE_OPTIONS]; static int s_CurVoteOption = 0; int TotalShown = 0; - for(CVoteOptionClient *pOption = m_pClient->m_pVoting->m_pFirst; pOption; pOption = pOption->m_pNext) + for(CVoteOptionClient *pOption = m_pClient->m_Voting.m_pFirst; pOption; pOption = pOption->m_pNext) { if(m_aFilterString[0] != '\0' && !str_utf8_find_nocase(pOption->m_aDescription, m_aFilterString)) continue; @@ -540,7 +540,7 @@ bool CMenus::RenderServerControlServer(CUIRect MainView) UiDoListboxStart(&s_VoteList, &List, 19.0f, "", "", TotalShown, 1, s_CurVoteOption, s_ScrollValue); int i = -1; - for(CVoteOptionClient *pOption = m_pClient->m_pVoting->m_pFirst; pOption; pOption = pOption->m_pNext) + for(CVoteOptionClient *pOption = m_pClient->m_Voting.m_pFirst; pOption; pOption = pOption->m_pNext) { i++; if(m_aFilterString[0] != '\0' && !str_utf8_find_nocase(pOption->m_aDescription, m_aFilterString)) @@ -699,7 +699,7 @@ void CMenus::RenderServerControl(CUIRect MainView) { if(s_ControlPage == 0) { - m_pClient->m_pVoting->CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason); + m_pClient->m_Voting.CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason); if(g_Config.m_UiCloseWindowAfterChangingSetting) SetActive(false); } @@ -708,7 +708,7 @@ void CMenus::RenderServerControl(CUIRect MainView) if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { - m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason); + m_pClient->m_Voting.CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason); SetActive(false); } } @@ -717,7 +717,7 @@ void CMenus::RenderServerControl(CUIRect MainView) if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { - m_pClient->m_pVoting->CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason); + m_pClient->m_Voting.CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason); SetActive(false); } } @@ -754,13 +754,13 @@ void CMenus::RenderServerControl(CUIRect MainView) if(DoButton_Menu(&s_ForceVoteButton, Localize("Force vote"), 0, &Button)) { if(s_ControlPage == 0) - m_pClient->m_pVoting->CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason, true); + m_pClient->m_Voting.CallvoteOption(m_CallvoteSelectedOption, m_aCallvoteReason, true); else if(s_ControlPage == 1) { if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { - m_pClient->m_pVoting->CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason, true); + m_pClient->m_Voting.CallvoteKick(m_CallvoteSelectedPlayer, m_aCallvoteReason, true); SetActive(false); } } @@ -769,7 +769,7 @@ void CMenus::RenderServerControl(CUIRect MainView) if(m_CallvoteSelectedPlayer >= 0 && m_CallvoteSelectedPlayer < MAX_CLIENTS && m_pClient->m_Snap.m_paPlayerInfos[m_CallvoteSelectedPlayer]) { - m_pClient->m_pVoting->CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason, true); + m_pClient->m_Voting.CallvoteSpectate(m_CallvoteSelectedPlayer, m_aCallvoteReason, true); SetActive(false); } } @@ -783,7 +783,7 @@ void CMenus::RenderServerControl(CUIRect MainView) Bottom.VSplitRight(120.0f, 0, &Button); static int s_RemoveVoteButton = 0; if(DoButton_Menu(&s_RemoveVoteButton, Localize("Remove"), 0, &Button)) - m_pClient->m_pVoting->RemovevoteOption(m_CallvoteSelectedOption); + m_pClient->m_Voting.RemovevoteOption(m_CallvoteSelectedOption); // add vote RconExtension.HSplitTop(20.0f, &Bottom, &RconExtension); @@ -802,7 +802,7 @@ void CMenus::RenderServerControl(CUIRect MainView) static int s_AddVoteButton = 0; if(DoButton_Menu(&s_AddVoteButton, Localize("Add"), 0, &Button)) if(s_aVoteDescription[0] != 0 && s_aVoteCommand[0] != 0) - m_pClient->m_pVoting->AddvoteOption(s_aVoteDescription, s_aVoteCommand); + m_pClient->m_Voting.AddvoteOption(s_aVoteDescription, s_aVoteCommand); Bottom.VSplitLeft(5.0f, 0, &Bottom); Bottom.VSplitLeft(250.0f, &Button, &Bottom); @@ -900,10 +900,10 @@ int CMenus::GhostlistFetchCallback(const char *pName, int IsDir, int StorageType return 0; char aFilename[256]; - str_format(aFilename, sizeof(aFilename), "%s/%s", pSelf->m_pClient->m_pGhost->GetGhostDir(), pName); + str_format(aFilename, sizeof(aFilename), "%s/%s", pSelf->m_pClient->m_Ghost.GetGhostDir(), pName); CGhostInfo Info; - if(!pSelf->m_pClient->m_pGhost->GhostLoader()->GetGhostInfo(aFilename, &Info, pMap, pSelf->Client()->GetCurrentMapSha256(), pSelf->Client()->GetCurrentMapCrc())) + if(!pSelf->m_pClient->m_Ghost.GhostLoader()->GetGhostInfo(aFilename, &Info, pMap, pSelf->Client()->GetCurrentMapSha256(), pSelf->Client()->GetCurrentMapCrc())) return 0; CGhostItem Item; @@ -919,7 +919,7 @@ void CMenus::GhostlistPopulate() { CGhostItem *pOwnGhost = 0; m_lGhosts.clear(); - Storage()->ListDirectory(IStorage::TYPE_ALL, m_pClient->m_pGhost->GetGhostDir(), GhostlistFetchCallback, this); + Storage()->ListDirectory(IStorage::TYPE_ALL, m_pClient->m_Ghost.GetGhostDir(), GhostlistFetchCallback, this); for(int i = 0; i < m_lGhosts.size(); i++) { @@ -930,7 +930,7 @@ void CMenus::GhostlistPopulate() if(pOwnGhost) { pOwnGhost->m_Own = true; - pOwnGhost->m_Slot = m_pClient->m_pGhost->Load(pOwnGhost->m_aFilename); + pOwnGhost->m_Slot = m_pClient->m_Ghost.Load(pOwnGhost->m_aFilename); } } @@ -1151,7 +1151,7 @@ void CMenus::RenderGhost(CUIRect MainView) static int s_ReloadButton = 0; if(DoButton_Menu(&s_ReloadButton, Localize("Reload"), 0, &Button) || Input()->KeyPress(KEY_F5)) { - m_pClient->m_pGhost->UnloadAll(); + m_pClient->m_Ghost.UnloadAll(); GhostlistPopulate(); } @@ -1162,7 +1162,7 @@ void CMenus::RenderGhost(CUIRect MainView) CGhostItem *pOwnGhost = GetOwnGhost(); int ReservedSlots = !pGhost->m_Own && !(pOwnGhost && pOwnGhost->Active()); - if(pGhost->HasFile() && (pGhost->Active() || m_pClient->m_pGhost->FreeSlots() > ReservedSlots)) + if(pGhost->HasFile() && (pGhost->Active() || m_pClient->m_Ghost.FreeSlots() > ReservedSlots)) { Status.VSplitRight(120.0f, &Status, &Button); @@ -1172,11 +1172,11 @@ void CMenus::RenderGhost(CUIRect MainView) { if(pGhost->Active()) { - m_pClient->m_pGhost->Unload(pGhost->m_Slot); + m_pClient->m_Ghost.Unload(pGhost->m_Slot); pGhost->m_Slot = -1; } else - pGhost->m_Slot = m_pClient->m_pGhost->Load(pGhost->m_aFilename); + pGhost->m_Slot = m_pClient->m_Ghost.Load(pGhost->m_aFilename); } Status.VSplitRight(5.0f, &Status, 0); @@ -1188,18 +1188,18 @@ void CMenus::RenderGhost(CUIRect MainView) if(DoButton_Menu(&s_DeleteButton, Localize("Delete"), 0, &Button)) { if(pGhost->Active()) - m_pClient->m_pGhost->Unload(pGhost->m_Slot); + m_pClient->m_Ghost.Unload(pGhost->m_Slot); DeleteGhostItem(s_SelectedIndex); } Status.VSplitRight(5.0f, &Status, 0); - bool Recording = m_pClient->m_pGhost->GhostRecorder()->IsRecording(); + bool Recording = m_pClient->m_Ghost.GhostRecorder()->IsRecording(); if(!pGhost->HasFile() && !Recording && pGhost->Active()) { static int s_SaveButton = 0; Status.VSplitRight(120.0f, &Status, &Button); if(DoButton_Menu(&s_SaveButton, Localize("Save"), 0, &Button)) - m_pClient->m_pGhost->SaveGhost(pGhost); + m_pClient->m_Ghost.SaveGhost(pGhost); } } diff --git a/src/game/client/components/menus_settings.cpp b/src/game/client/components/menus_settings.cpp index a370325f5..030c2d6c8 100644 --- a/src/game/client/components/menus_settings.cpp +++ b/src/game/client/components/menus_settings.cpp @@ -407,11 +407,11 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) MainView.HSplitTop(20.0f, 0, &MainView); static float s_ScrollValue = 0.0f; int OldSelected = -1; - UiDoListboxStart(&s_ScrollValue, &MainView, 50.0f, Localize("Country / Region"), "", m_pClient->m_pCountryFlags->Num(), 6, OldSelected, s_ScrollValue); + UiDoListboxStart(&s_ScrollValue, &MainView, 50.0f, Localize("Country / Region"), "", m_pClient->m_CountryFlags.Num(), 6, OldSelected, s_ScrollValue); - for(int i = 0; i < m_pClient->m_pCountryFlags->Num(); ++i) + for(int i = 0; i < m_pClient->m_CountryFlags.Num(); ++i) { - const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_pCountryFlags->GetByIndex(i); + const CCountryFlags::CCountryFlag *pEntry = m_pClient->m_CountryFlags.GetByIndex(i); if(pEntry->m_CountryCode == *pCountry) OldSelected = i; @@ -425,7 +425,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) Item.m_Rect.w = Item.m_Rect.h * 2; Item.m_Rect.x += (OldWidth - Item.m_Rect.w) / 2.0f; ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f); - m_pClient->m_pCountryFlags->Render(pEntry->m_CountryCode, &Color, Item.m_Rect.x, Item.m_Rect.y, Item.m_Rect.w, Item.m_Rect.h); + m_pClient->m_CountryFlags.Render(pEntry->m_CountryCode, &Color, Item.m_Rect.x, Item.m_Rect.y, Item.m_Rect.w, Item.m_Rect.h); if(pEntry->m_Texture != -1) UI()->DoLabel(&Label, pEntry->m_aCountryCodeString, 10.0f, 0); } @@ -438,7 +438,7 @@ void CMenus::RenderSettingsPlayer(CUIRect MainView) if(OldSelected != NewSelected) { - *pCountry = m_pClient->m_pCountryFlags->GetByIndex(NewSelected)->m_CountryCode; + *pCountry = m_pClient->m_CountryFlags.GetByIndex(NewSelected)->m_CountryCode; SetNeedSendInfo(); } } @@ -482,7 +482,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) // skin info CTeeRenderInfo OwnSkinInfo; - const CSkin *pSkin = m_pClient->m_pSkins->Get(m_pClient->m_pSkins->Find(Skin)); + const CSkin *pSkin = m_pClient->m_Skins.Get(m_pClient->m_Skins.Find(Skin)); OwnSkinInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; OwnSkinInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; OwnSkinInfo.m_SkinMetrics = pSkin->m_Metrics; @@ -626,12 +626,12 @@ void CMenus::RenderSettingsTee(CUIRect MainView) static sorted_array s_paSkinList; static int s_SkinCount = 0; static float s_ScrollValue = 0.0f; - if(s_InitSkinlist || m_pClient->m_pSkins->Num() != s_SkinCount) + if(s_InitSkinlist || m_pClient->m_Skins.Num() != s_SkinCount) { s_paSkinList.clear(); - for(int i = 0; i < m_pClient->m_pSkins->Num(); ++i) + for(int i = 0; i < m_pClient->m_Skins.Num(); ++i) { - const CSkin *s = m_pClient->m_pSkins->Get(i); + const CSkin *s = m_pClient->m_Skins.Get(i); // filter quick search if(g_Config.m_ClSkinFilterString[0] != '\0' && !str_utf8_find_nocase(s->m_aName, g_Config.m_ClSkinFilterString)) @@ -651,7 +651,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) s_paSkinList.add(CUISkin(s)); } s_InitSkinlist = false; - s_SkinCount = m_pClient->m_pSkins->Num(); + s_SkinCount = m_pClient->m_Skins.Num(); } int OldSelected = -1; @@ -758,7 +758,7 @@ void CMenus::RenderSettingsTee(CUIRect MainView) static int s_SkinRefreshButtonID = 0; if(DoButton_Menu(&s_SkinRefreshButtonID, "\xEE\x97\x95", 0, &RefreshButton, NULL, 15, 5, 0, vec4(1.0f, 1.0f, 1.0f, 0.75f), vec4(1, 1, 1, 0.5f), 0)) { - m_pClient->m_pSkins->Refresh(); + m_pClient->m_Skins.Refresh(); s_InitSkinlist = true; if(Client()->State() >= IClient::STATE_ONLINE) { @@ -863,9 +863,9 @@ void CMenus::UiDoGetButtons(int Start, int Stop, CUIRect View, CUIRect ScopeView if(NewId != OldId || NewModifier != OldModifier) { if(OldId != 0 || NewId == 0) - m_pClient->m_pBinds->Bind(OldId, "", false, OldModifier); + m_pClient->m_Binds.Bind(OldId, "", false, OldModifier); if(NewId != 0) - m_pClient->m_pBinds->Bind(NewId, gs_aKeys[i].m_pCommand, false, NewModifier); + m_pClient->m_Binds.Bind(NewId, gs_aKeys[i].m_pCommand, false, NewModifier); } } @@ -885,7 +885,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) { for(int KeyId = 0; KeyId < KEY_LAST; KeyId++) { - const char *pBind = m_pClient->m_pBinds->Get(KeyId, Mod); + const char *pBind = m_pClient->m_Binds.Get(KeyId, Mod); if(!pBind[0]) continue; @@ -976,7 +976,7 @@ void CMenus::RenderSettingsControls(CUIRect MainView) ResetButton.HSplitTop(20.0f, &ResetButton, 0); static int s_DefaultButton = 0; if(DoButton_Menu((void *)&s_DefaultButton, Localize("Reset to defaults"), 0, &ResetButton)) - m_pClient->m_pBinds->SetDefaults(); + m_pClient->m_Binds.SetDefaults(); } // voting settings @@ -1290,10 +1290,10 @@ void CMenus::RenderSettingsSound(CUIRect MainView) if(g_Config.m_SndEnable) { if(g_Config.m_SndMusic && Client()->State() == IClient::STATE_OFFLINE) - m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); + m_pClient->m_Sounds.Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); } else - m_pClient->m_pSounds->Stop(SOUND_MENU); + m_pClient->m_Sounds.Stop(SOUND_MENU); m_NeedRestartSound = g_Config.m_SndEnable && (!s_SndEnable || s_SndRate != g_Config.m_SndRate); } @@ -1307,9 +1307,9 @@ void CMenus::RenderSettingsSound(CUIRect MainView) if(Client()->State() == IClient::STATE_OFFLINE) { if(g_Config.m_SndMusic) - m_pClient->m_pSounds->Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); + m_pClient->m_Sounds.Play(CSounds::CHN_MUSIC, SOUND_MENU, 1.0f); else - m_pClient->m_pSounds->Stop(SOUND_MENU); + m_pClient->m_Sounds.Stop(SOUND_MENU); } } @@ -1526,7 +1526,7 @@ void CMenus::RenderLanguageSelection(CUIRect MainView) Rect.VMargin(6.0f, &Rect); Rect.HMargin(3.0f, &Rect); ColorRGBA Color(1.0f, 1.0f, 1.0f, 1.0f); - m_pClient->m_pCountryFlags->Render(r.front().m_CountryCode, &Color, Rect.x, Rect.y, Rect.w, Rect.h); + m_pClient->m_CountryFlags.Render(r.front().m_CountryCode, &Color, Rect.x, Rect.y, Rect.w, Rect.h); Item.m_Rect.HSplitTop(2.0f, 0, &Item.m_Rect); UI()->DoLabelScaled(&Item.m_Rect, r.front().m_Name, 16.0f, -1); } @@ -2102,7 +2102,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) // ***** Chat ***** // if(DoButton_CheckBoxAutoVMarginAndSet(&g_Config.m_ClChatOld, Localize("Use old chat style"), &g_Config.m_ClChatOld, &Chat, LineMargin)) - GameClient()->m_pChat->RebuildChat(); + GameClient()->m_Chat.RebuildChat(); Chat.HSplitTop(30.0f, 0x0, &Chat); @@ -2222,7 +2222,7 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) // Load skins - int DefaultInd = GameClient()->m_pSkins->Find("default"); + int DefaultInd = GameClient()->m_Skins.Find("default"); for(auto &i : RenderInfo) { @@ -2233,10 +2233,10 @@ void CMenus::RenderSettingsHUD(CUIRect MainView) int ind = -1; int i = 0; - RenderInfo[i++].m_OriginalRenderSkin = GameClient()->m_pSkins->Get(DefaultInd)->m_OriginalSkin; - RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("pinky")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; - RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("cammostripes")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; - RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_pSkins->Find("beast")) != -1 ? GameClient()->m_pSkins->Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; + RenderInfo[i++].m_OriginalRenderSkin = GameClient()->m_Skins.Get(DefaultInd)->m_OriginalSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_Skins.Find("pinky")) != -1 ? GameClient()->m_Skins.Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_Skins.Find("cammostripes")) != -1 ? GameClient()->m_Skins.Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; + RenderInfo[i++].m_OriginalRenderSkin = (ind = GameClient()->m_Skins.Find("beast")) != -1 ? GameClient()->m_Skins.Get(ind)->m_OriginalSkin : RenderInfo[0].m_OriginalRenderSkin; } // System diff --git a/src/game/client/components/menus_settings_assets.cpp b/src/game/client/components/menus_settings_assets.cpp index 8a49f64c3..e67218e50 100644 --- a/src/game/client/components/menus_settings_assets.cpp +++ b/src/game/client/components/menus_settings_assets.cpp @@ -251,7 +251,7 @@ void CMenus::ClearCustomItems(int CurTab) m_EntitiesList.clear(); // reload current entities - m_pClient->m_pMapimages->ChangeEntitiesPath(g_Config.m_ClAssetsEntites); + m_pClient->m_MapImages.ChangeEntitiesPath(g_Config.m_ClAssetsEntites); } else if(CurTab == 1) { @@ -484,7 +484,7 @@ void CMenus::RenderSettingsCustom(CUIRect MainView) if(s_CurCustomTab == 0) { str_copy(g_Config.m_ClAssetsEntites, GetCustomItem(s_CurCustomTab, NewSelected)->m_aName, sizeof(g_Config.m_ClAssetsEntites)); - m_pClient->m_pMapimages->ChangeEntitiesPath(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName); + m_pClient->m_MapImages.ChangeEntitiesPath(GetCustomItem(s_CurCustomTab, NewSelected)->m_aName); } else if(s_CurCustomTab == 1) { @@ -573,7 +573,7 @@ void CMenus::ConchainAssetsEntities(IConsole::IResult *pResult, void *pUserData, const char *pArg = pResult->GetString(0); if(str_comp(pArg, g_Config.m_ClAssetsEntites) != 0) { - pThis->m_pClient->m_pMapimages->ChangeEntitiesPath(pArg); + pThis->m_pClient->m_MapImages.ChangeEntitiesPath(pArg); } } diff --git a/src/game/client/components/menus_start.cpp b/src/game/client/components/menus_start.cpp index 2f768e1e1..ccbf5078b 100644 --- a/src/game/client/components/menus_start.cpp +++ b/src/game/client/components/menus_start.cpp @@ -13,6 +13,10 @@ #include #include +#include + +#include + #include "menus.h" void CMenus::RenderStartMenu(CUIRect MainView) diff --git a/src/game/client/components/nameplates.cpp b/src/game/client/components/nameplates.cpp index 11c9f8a1b..a3d7e39a5 100644 --- a/src/game/client/components/nameplates.cpp +++ b/src/game/client/components/nameplates.cpp @@ -55,7 +55,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP { float a = 1; if(g_Config.m_ClNameplatesAlways == 0) - a = clamp(1 - powf(distance(m_pClient->m_pControls->m_TargetPos[g_Config.m_ClDummy], Position) / 200.0f, 16.0f), 0.0f, 1.0f); + a = clamp(1 - powf(distance(m_pClient->m_Controls.m_TargetPos[g_Config.m_ClDummy], Position) / 200.0f, 16.0f), 0.0f, 1.0f); const char *pName = m_pClient->m_aClients[pPlayerInfo->m_ClientID].m_aName; if(str_comp(pName, m_aNamePlates[ClientID].m_aName) != 0 || FontSize != m_aNamePlates[ClientID].m_NameTextFontSize) @@ -73,7 +73,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP // create nameplates at standard zoom float ScreenX0, ScreenY0, ScreenX1, ScreenY1; Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); - MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup()); + MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup()); m_aNamePlates[ClientID].m_NameTextWidth = TextRender()->TextWidth(0, FontSize, pName, -1, -1.0f); @@ -99,7 +99,7 @@ void CNamePlates::RenderNameplatePos(vec2 Position, const CNetObj_PlayerInfo *pP // create nameplates at standard zoom float ScreenX0, ScreenY0, ScreenX1, ScreenY1; Graphics()->GetScreen(&ScreenX0, &ScreenY0, &ScreenX1, &ScreenY1); - MapscreenToGroup(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y, Layers()->GameGroup()); + MapscreenToGroup(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y, Layers()->GameGroup()); m_aNamePlates[ClientID].m_ClanNameTextWidth = TextRender()->TextWidth(0, FontSizeClan, pClan, -1, -1.0f); diff --git a/src/game/client/components/nameplates.h b/src/game/client/components/nameplates.h index 35529922e..891c3918f 100644 --- a/src/game/client/components/nameplates.h +++ b/src/game/client/components/nameplates.h @@ -3,6 +3,11 @@ #ifndef GAME_CLIENT_COMPONENTS_NAMEPLATES_H #define GAME_CLIENT_COMPONENTS_NAMEPLATES_H #include + +struct CNetObj_Character; +struct CNetObj_PlayerInfo; +struct CMapItemGroup; + struct SPlayerNamePlate { SPlayerNamePlate() diff --git a/src/game/client/components/particles.cpp b/src/game/client/components/particles.cpp index 0fdf71def..11e0576da 100644 --- a/src/game/client/components/particles.cpp +++ b/src/game/client/components/particles.cpp @@ -9,6 +9,8 @@ #include #include +#include + CParticles::CParticles() { OnReset(); diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index 2db48d785..eaaf9d16b 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -206,7 +206,7 @@ void CPlayers::RenderPlayer( if(Local && Client()->State() != IClient::STATE_DEMOPLAYBACK) { // just use the direct input if it's the local player we are rendering - Angle = angle(m_pClient->m_pControls->m_MousePos[g_Config.m_ClDummy]); + Angle = angle(m_pClient->m_Controls.m_MousePos[g_Config.m_ClDummy]); } else { @@ -234,7 +234,7 @@ void CPlayers::RenderPlayer( vec2 Vel = mix(vec2(Prev.m_VelX / 256.0f, Prev.m_VelY / 256.0f), vec2(Player.m_VelX / 256.0f, Player.m_VelY / 256.0f), IntraTick); - m_pClient->m_pFlow->Add(Position, Vel * 100.0f, 10.0f); + m_pClient->m_Flow.Add(Position, Vel * 100.0f, 10.0f); RenderInfo.m_GotAirJump = Player.m_Jumped & 2 ? 0 : 1; @@ -266,11 +266,11 @@ void CPlayers::RenderPlayer( if(time() - SkidSoundTime > time_freq() / 10) { if(g_Config.m_SndGame) - m_pClient->m_pSounds->PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, Position); + m_pClient->m_Sounds.PlayAt(CSounds::CHN_WORLD, SOUND_PLAYER_SKID, 0.25f, Position); SkidSoundTime = time(); } - m_pClient->m_pEffects->SkidTrail( + m_pClient->m_Effects.SkidTrail( Position + vec2(-Player.m_Direction * 6, 12), vec2(-Player.m_Direction * 100 * length(Vel), -50)); } @@ -288,7 +288,7 @@ void CPlayers::RenderPlayer( vec2 ExDirection = Direction; if(Local && Client()->State() != IClient::STATE_DEMOPLAYBACK) - ExDirection = normalize(vec2(m_pClient->m_pControls->m_InputData[g_Config.m_ClDummy].m_TargetX, m_pClient->m_pControls->m_InputData[g_Config.m_ClDummy].m_TargetY)); + ExDirection = normalize(vec2(m_pClient->m_Controls.m_InputData[g_Config.m_ClDummy].m_TargetX, m_pClient->m_Controls.m_InputData[g_Config.m_ClDummy].m_TargetY)); Graphics()->TextureClear(); vec2 InitPos = Position; @@ -399,12 +399,12 @@ void CPlayers::RenderPlayer( { Graphics()->QuadsSetRotation(-pi / 2 - State.GetAttach()->m_Angle * pi * 2); p.x -= g_pData->m_Weapons.m_aId[iw].m_Offsetx; - m_pClient->m_pEffects->PowerupShine(p + vec2(32, 0), vec2(32, 12)); + m_pClient->m_Effects.PowerupShine(p + vec2(32, 0), vec2(32, 12)); } else { Graphics()->QuadsSetRotation(-pi / 2 + State.GetAttach()->m_Angle * pi * 2); - m_pClient->m_pEffects->PowerupShine(p - vec2(32, 0), vec2(32, 12)); + m_pClient->m_Effects.PowerupShine(p - vec2(32, 0), vec2(32, 12)); } Graphics()->RenderQuadContainerAsSprite(m_WeaponEmoteQuadContainerIndex, QuadOffset, p.x, p.y); @@ -647,10 +647,10 @@ void CPlayers::OnRender() if(m_pClient->m_Snap.m_aCharacters[i].m_Cur.m_Weapon == WEAPON_NINJA && g_Config.m_ClShowNinja) { // change the skin for the player to the ninja - int Skin = m_pClient->m_pSkins->Find("x_ninja"); + int Skin = m_pClient->m_Skins.Find("x_ninja"); if(Skin != -1) { - const CSkin *pSkin = m_pClient->m_pSkins->Get(Skin); + const CSkin *pSkin = m_pClient->m_Skins.Get(Skin); m_aRenderInfo[i].m_OriginalRenderSkin = pSkin->m_OriginalSkin; m_aRenderInfo[i].m_ColorableRenderSkin = pSkin->m_ColorableSkin; m_aRenderInfo[i].m_BloodColor = pSkin->m_BloodColor; @@ -664,8 +664,8 @@ void CPlayers::OnRender() } } } - int Skin = m_pClient->m_pSkins->Find("x_spec"); - const CSkin *pSkin = m_pClient->m_pSkins->Get(Skin); + int Skin = m_pClient->m_Skins.Find("x_spec"); + const CSkin *pSkin = m_pClient->m_Skins.Get(Skin); m_RenderInfoSpec.m_OriginalRenderSkin = pSkin->m_OriginalSkin; m_RenderInfoSpec.m_ColorableRenderSkin = pSkin->m_ColorableSkin; m_RenderInfoSpec.m_BloodColor = pSkin->m_BloodColor; diff --git a/src/game/client/components/players.h b/src/game/client/components/players.h index cd0e928e9..25067acb7 100644 --- a/src/game/client/components/players.h +++ b/src/game/client/components/players.h @@ -4,6 +4,9 @@ #define GAME_CLIENT_COMPONENTS_PLAYERS_H #include +#include +#include + class CPlayers : public CComponent { friend class CGhost; diff --git a/src/game/client/components/race_demo.cpp b/src/game/client/components/race_demo.cpp index 468e20823..cee9a70a7 100644 --- a/src/game/client/components/race_demo.cpp +++ b/src/game/client/components/race_demo.cpp @@ -11,6 +11,8 @@ #include "race_demo.h" +#include + const char *CRaceDemo::ms_pRaceDemoDir = "demos/auto/race"; struct CDemoItem diff --git a/src/game/client/components/scoreboard.cpp b/src/game/client/components/scoreboard.cpp index 4e3637a39..39e2182c9 100644 --- a/src/game/client/components/scoreboard.cpp +++ b/src/game/client/components/scoreboard.cpp @@ -512,7 +512,7 @@ void CScoreboard::RenderScoreboard(float x, float y, float w, int Team, const ch // country flag ColorRGBA Color(1.0f, 1.0f, 1.0f, 0.5f); - m_pClient->m_pCountryFlags->Render(m_pClient->m_aClients[pInfo->m_ClientID].m_Country, &Color, + m_pClient->m_CountryFlags.Render(m_pClient->m_aClients[pInfo->m_ClientID].m_Country, &Color, CountryOffset, y + (Spacing + TeeSizeMod * 5.0f) / 2.0f, CountryLength, LineHeight - Spacing - TeeSizeMod * 5.0f); // ping @@ -613,8 +613,8 @@ void CScoreboard::OnRender() return; // if the score board is active, then we should clear the motd message as well - if(m_pClient->m_pMotd->IsActive()) - m_pClient->m_pMotd->Clear(); + if(m_pClient->m_Motd.IsActive()) + m_pClient->m_Motd.Clear(); float Width = 400 * 3.0f * Graphics()->ScreenAspect(); float Height = 400 * 3.0f; @@ -695,7 +695,7 @@ void CScoreboard::OnRender() bool CScoreboard::Active() { // if statboard is active don't show scoreboard - if(m_pClient->m_pStatboard->IsActive()) + if(m_pClient->m_Statboard.IsActive()) return false; if(m_Active) diff --git a/src/game/client/components/skins.cpp b/src/game/client/components/skins.cpp index 865a6bef2..b0a432b91 100644 --- a/src/game/client/components/skins.cpp +++ b/src/game/client/components/skins.cpp @@ -11,6 +11,10 @@ #include #include +#include + +#include + #include "skins.h" static const char *VANILLA_SKINS[] = {"bluekitty", "bluestripe", "brownbear", diff --git a/src/game/client/components/sounds.cpp b/src/game/client/components/sounds.cpp index 27d4258d7..4ef4fa362 100644 --- a/src/game/client/components/sounds.cpp +++ b/src/game/client/components/sounds.cpp @@ -29,7 +29,7 @@ void CSoundLoading::Run() } if(m_Render) - m_pGameClient->m_pMenus->RenderLoading(); + m_pGameClient->m_Menus.RenderLoading(); } } @@ -114,7 +114,7 @@ void CSounds::OnRender() } // set listener pos - Sound()->SetListenerPos(m_pClient->m_pCamera->m_Center.x, m_pClient->m_pCamera->m_Center.y); + Sound()->SetListenerPos(m_pClient->m_Camera.m_Center.x, m_pClient->m_Camera.m_Center.y); // update volume float NewGuiSoundVol = g_Config.m_SndChatSoundVolume / 100.0f; diff --git a/src/game/client/components/spectator.cpp b/src/game/client/components/spectator.cpp index ddff965e0..534b7433a 100644 --- a/src/game/client/components/spectator.cpp +++ b/src/game/client/components/spectator.cpp @@ -17,6 +17,8 @@ #include "camera.h" #include "spectator.h" +#include + bool CSpectator::CanChangeSpectator() { // Don't change SpectatorID when not spectating @@ -123,7 +125,7 @@ void CSpectator::ConSpectateClosest(IConsole::IResult *pResult, void *pUserData) int NewSpectatorID = -1; - vec2 CurPosition(pSelf->m_pClient->m_pCamera->m_Center); + vec2 CurPosition(pSelf->m_pClient->m_Camera.m_Center); if(SpectatorID != SPEC_FREEVIEW) { const CNetObj_Character &CurCharacter = Snap.m_aCharacters[SpectatorID].m_Cur; diff --git a/src/game/client/components/statboard.cpp b/src/game/client/components/statboard.cpp index 5564093ad..48cc504b0 100644 --- a/src/game/client/components/statboard.cpp +++ b/src/game/client/components/statboard.cpp @@ -162,8 +162,8 @@ void CStatboard::RenderGlobalStats() return; //clear motd if it is active - if(m_pClient->m_pMotd->IsActive()) - m_pClient->m_pMotd->Clear(); + if(m_pClient->m_Motd.IsActive()) + m_pClient->m_Motd.Clear(); bool GameWithFlags = m_pClient->m_Snap.m_pGameInfoObj && m_pClient->m_Snap.m_pGameInfoObj->m_GameFlags & GAMEFLAG_FLAGS; diff --git a/src/game/client/components/voting.cpp b/src/game/client/components/voting.cpp index e276a23d8..469b2d3b2 100644 --- a/src/game/client/components/voting.cpp +++ b/src/game/client/components/voting.cpp @@ -8,6 +8,8 @@ #include #include +#include + void CVoting::ConCallvote(IConsole::IResult *pResult, void *pUserData) { CVoting *pSelf = (CVoting *)pUserData; @@ -201,7 +203,7 @@ void CVoting::OnMessage(int MsgType, void *pRawMsg) char aBuf[512]; str_format(aBuf, sizeof(aBuf), "%s (%s)", m_aDescription, m_aReason); Client()->Notify("DDNet Vote", aBuf); - m_pClient->m_pSounds->Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); + m_pClient->m_Sounds.Play(CSounds::CHN_GUI, SOUND_CHAT_HIGHLIGHT, 0); } } } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index d848845dd..acb0f71c0 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -67,48 +67,6 @@ #include "components/race_demo.h" #include -CGameClient g_GameClient; - -// instantiate all systems -static CKillMessages gs_KillMessages; -static CCamera gs_Camera; -static CChat gs_Chat; -static CMotd gs_Motd; -static CBroadcast gs_Broadcast; -static CGameConsole gs_GameConsole; -static CBinds gs_Binds; -static CParticles gs_Particles; -static CMenus gs_Menus; -static CSkins gs_Skins; -static CCountryFlags gs_CountryFlags; -static CFlow gs_Flow; -static CHud gs_Hud; -static CDebugHud gs_DebugHud; -static CControls gs_Controls; -static CEffects gs_Effects; -static CScoreboard gs_Scoreboard; -static CStatboard gs_Statboard; -static CSounds gs_Sounds; -static CEmoticon gs_Emoticon; -static CDamageInd gsDamageInd; -static CVoting gs_Voting; -static CSpectator gs_Spectator; - -static CPlayers gs_Players; -static CNamePlates gs_NamePlates; -static CItems gs_Items; -static CMapImages gs_MapImages; - -static CMapLayers gs_MapLayersBackGround(CMapLayers::TYPE_BACKGROUND); -static CMapLayers gs_MapLayersForeGround(CMapLayers::TYPE_FOREGROUND); -static CBackground gs_BackGround; -static CMenuBackground gs_MenuBackground; - -static CMapSounds gs_MapSounds; - -static CRaceDemo gs_RaceDemo; -static CGhost gs_Ghost; - CGameClient::CStack::CStack() { m_Num = 0; } void CGameClient::CStack::Add(class CComponent *pComponent) { m_paComponents[m_Num++] = pComponent; } @@ -136,94 +94,63 @@ void CGameClient::OnConsoleInit() m_pUpdater = Kernel()->RequestInterface(); #endif - // setup pointers - m_pMenuBackground = &::gs_MenuBackground; - m_pBinds = &::gs_Binds; - m_pGameConsole = &::gs_GameConsole; - m_pParticles = &::gs_Particles; - m_pMenus = &::gs_Menus; - m_pSkins = &::gs_Skins; - m_pCountryFlags = &::gs_CountryFlags; - m_pChat = &::gs_Chat; - m_pFlow = &::gs_Flow; - m_pCamera = &::gs_Camera; - m_pControls = &::gs_Controls; - m_pEffects = &::gs_Effects; - m_pSounds = &::gs_Sounds; - m_pMotd = &::gs_Motd; - m_pDamageind = &::gsDamageInd; - m_pMapimages = &::gs_MapImages; - m_pVoting = &::gs_Voting; - m_pScoreboard = &::gs_Scoreboard; - m_pStatboard = &::gs_Statboard; - m_pItems = &::gs_Items; - m_pMapLayersBackGround = &::gs_MapLayersBackGround; - m_pMapLayersForeGround = &::gs_MapLayersForeGround; - m_pBackGround = &::gs_BackGround; + m_Menus.SetMenuBackground(&m_MenuBackground); - m_pMapSounds = &::gs_MapSounds; - m_pPlayers = &::gs_Players; - - m_pRaceDemo = &::gs_RaceDemo; - m_pGhost = &::gs_Ghost; - - m_pMenus->SetMenuBackground(m_pMenuBackground); - - gs_NamePlates.SetPlayers(m_pPlayers); + m_NamePlates.SetPlayers(&m_Players); // make a list of all the systems, make sure to add them in the correct render order - m_All.Add(m_pSkins); - m_All.Add(m_pCountryFlags); - m_All.Add(m_pMapimages); - m_All.Add(m_pEffects); // doesn't render anything, just updates effects - m_All.Add(m_pBinds); - m_All.Add(&m_pBinds->m_SpecialBinds); - m_All.Add(m_pControls); - m_All.Add(m_pCamera); - m_All.Add(m_pSounds); - m_All.Add(m_pVoting); - m_All.Add(m_pParticles); // doesn't render anything, just updates all the particles - m_All.Add(m_pRaceDemo); - m_All.Add(m_pMapSounds); + m_All.Add(&m_Skins); + m_All.Add(&m_CountryFlags); + m_All.Add(&m_MapImages); + m_All.Add(&m_Effects); // doesn't render anything, just updates effects + m_All.Add(&m_Binds); + m_All.Add(&m_Binds.m_SpecialBinds); + m_All.Add(&m_Controls); + m_All.Add(&m_Camera); + m_All.Add(&m_Sounds); + m_All.Add(&m_Voting); + m_All.Add(&m_Particles); // doesn't render anything, just updates all the particles + m_All.Add(&m_RaceDemo); + m_All.Add(&m_MapSounds); - m_All.Add(&gs_BackGround); //render instead of gs_MapLayersBackGround when g_Config.m_ClOverlayEntities == 100 - m_All.Add(&gs_MapLayersBackGround); // first to render - m_All.Add(&m_pParticles->m_RenderTrail); - m_All.Add(m_pItems); - m_All.Add(m_pPlayers); - m_All.Add(m_pGhost); - m_All.Add(&gs_MapLayersForeGround); - m_All.Add(&m_pParticles->m_RenderExplosions); - m_All.Add(&gs_NamePlates); - m_All.Add(&m_pParticles->m_RenderGeneral); - m_All.Add(m_pDamageind); - m_All.Add(&gs_Hud); - m_All.Add(&gs_Spectator); - m_All.Add(&gs_Emoticon); - m_All.Add(&gs_KillMessages); - m_All.Add(m_pChat); - m_All.Add(&gs_Broadcast); - m_All.Add(&gs_DebugHud); - m_All.Add(&gs_Scoreboard); - m_All.Add(&gs_Statboard); - m_All.Add(m_pMotd); - m_All.Add(m_pMenus); - m_All.Add(&m_pMenus->m_Binder); - m_All.Add(m_pGameConsole); + m_All.Add(&m_BackGround); //render instead of m_MapLayersBackGround when g_Config.m_ClOverlayEntities == 100 + m_All.Add(&m_MapLayersBackGround); // first to render + m_All.Add(&m_Particles.m_RenderTrail); + m_All.Add(&m_Items); + m_All.Add(&m_Players); + m_All.Add(&m_Ghost); + m_All.Add(&m_MapLayersForeGround); + m_All.Add(&m_Particles.m_RenderExplosions); + m_All.Add(&m_NamePlates); + m_All.Add(&m_Particles.m_RenderGeneral); + m_All.Add(&m_DamageInd); + m_All.Add(&m_Hud); + m_All.Add(&m_Spectator); + m_All.Add(&m_Emoticon); + m_All.Add(&m_KillMessages); + m_All.Add(&m_Chat); + m_All.Add(&m_Broadcast); + m_All.Add(&m_DebugHud); + m_All.Add(&m_Scoreboard); + m_All.Add(&m_Statboard); + m_All.Add(&m_Motd); + m_All.Add(&m_Menus); + m_All.Add(&m_Menus.m_Binder); + m_All.Add(&m_GameConsole); - m_All.Add(m_pMenuBackground); + m_All.Add(&m_MenuBackground); // build the input stack - m_Input.Add(&m_pMenus->m_Binder); // this will take over all input when we want to bind a key - m_Input.Add(&m_pBinds->m_SpecialBinds); - m_Input.Add(m_pGameConsole); - m_Input.Add(m_pChat); // chat has higher prio due to tha you can quit it by pressing esc - m_Input.Add(m_pMotd); // for pressing esc to remove it - m_Input.Add(m_pMenus); - m_Input.Add(&gs_Spectator); - m_Input.Add(&gs_Emoticon); - m_Input.Add(m_pControls); - m_Input.Add(m_pBinds); + m_Input.Add(&m_Menus.m_Binder); // this will take over all input when we want to bind a key + m_Input.Add(&m_Binds.m_SpecialBinds); + m_Input.Add(&m_GameConsole); + m_Input.Add(&m_Chat); // chat has higher prio due to tha you can quit it by pressing esc + m_Input.Add(&m_Motd); // for pressing esc to remove it + m_Input.Add(&m_Menus); + m_Input.Add(&m_Spectator); + m_Input.Add(&m_Emoticon); + m_Input.Add(&m_Controls); + m_Input.Add(&m_Binds); // add the some console commands Console()->Register("team", "i[team-id]", CFGFLAG_CLIENT, ConTeam, this, "Switch team"); @@ -337,7 +264,7 @@ void CGameClient::OnInit() LoadParticlesSkin(g_Config.m_ClAssetParticles); else g_pData->m_aImages[i].m_Id = Graphics()->LoadTexture(g_pData->m_aImages[i].m_pFilename, IStorage::TYPE_ALL, CImageInfo::FORMAT_AUTO, 0); - g_GameClient.m_pMenus->RenderLoading(); + m_Menus.RenderLoading(); } for(int i = 0; i < m_All.m_Num; i++) @@ -355,7 +282,7 @@ void CGameClient::OnInit() m_LastDummyConnected = false; // Set free binds to DDRace binds if it's active - gs_Binds.SetDDRaceBinds(true); + m_Binds.SetDDRaceBinds(true); if(g_Config.m_ClTimeoutCode[0] == '\0' || str_comp(g_Config.m_ClTimeoutCode, "hGuEYnfxicsXGwFq") == 0) { @@ -387,7 +314,7 @@ void CGameClient::OnInit() m_GameWorld.m_pCollision = Collision(); m_GameWorld.m_pTuningList = m_aTuningList; - m_pMapimages->SetTextureScale(g_Config.m_ClTextEntitiesSize); + m_MapImages.SetTextureScale(g_Config.m_ClTextEntitiesSize); // Agressively try to grab window again since some Windows users report // window not being focussed after starting client. @@ -428,12 +355,12 @@ void CGameClient::OnDummySwap() if(g_Config.m_ClDummyResetOnSwitch) { int PlayerOrDummy = (g_Config.m_ClDummyResetOnSwitch == 2) ? g_Config.m_ClDummy : (!g_Config.m_ClDummy); - m_pControls->ResetInput(PlayerOrDummy); - m_pControls->m_InputData[PlayerOrDummy].m_Hook = 0; + m_Controls.ResetInput(PlayerOrDummy); + m_Controls.m_InputData[PlayerOrDummy].m_Hook = 0; } int tmp = m_DummyInput.m_Fire; - m_DummyInput = m_pControls->m_InputData[!g_Config.m_ClDummy]; - m_pControls->m_InputData[g_Config.m_ClDummy].m_Fire = tmp; + m_DummyInput = m_Controls.m_InputData[!g_Config.m_ClDummy]; + m_Controls.m_InputData[g_Config.m_ClDummy].m_Fire = tmp; m_IsDummySwapping = 1; } @@ -441,7 +368,7 @@ int CGameClient::OnSnapInput(int *pData, bool Dummy, bool Force) { if(!Dummy) { - return m_pControls->SnapInput(pData); + return m_Controls.SnapInput(pData); } if(!g_Config.m_ClDummyHammer) @@ -635,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 @@ -665,9 +570,9 @@ void CGameClient::OnRender() // display gfx & client warnings for(SWarning *pWarning : {Graphics()->GetCurWarning(), Client()->GetCurWarning()}) { - if(pWarning != NULL && m_pMenus->CanDisplayWarning()) + if(pWarning != NULL && m_Menus.CanDisplayWarning()) { - m_pMenus->PopupWarning(Localize("Warning"), pWarning->m_aWarningMsg, "Ok", 10000000); + m_Menus.PopupWarning(Localize("Warning"), pWarning->m_aWarningMsg, "Ok", 10000000); pWarning->m_WasShown = true; } } @@ -687,7 +592,7 @@ void CGameClient::OnRender() g_Config.m_ClDummy = 0; // 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_Menus.IsActive()) { if(m_CheckInfo[0] == 0) { @@ -740,7 +645,7 @@ void CGameClient::OnDummyDisconnect() int CGameClient::GetLastRaceTick() { - return m_pGhost->GetLastRaceTick(); + return m_Ghost.GetLastRaceTick(); } void CGameClient::OnRelease() @@ -766,7 +671,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) if(pUnpacker->Error()) return; - g_GameClient.m_pItems->AddExtraProjectile(&Proj); + m_Items.AddExtraProjectile(&Proj); } return; @@ -814,7 +719,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) if((pMsg->m_Team == 1 && (m_aClients[m_LocalIDs[0]].m_Team != m_aClients[m_LocalIDs[1]].m_Team || m_Teams.Team(m_LocalIDs[0]) != m_Teams.Team(m_LocalIDs[1]))) || pMsg->m_Team > 1) { - m_pChat->OnMessage(MsgId, pRawMsg); + m_Chat.OnMessage(MsgId, pRawMsg); } } return; // no need of all that stuff for the dummy @@ -848,12 +753,12 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) pMsg->m_SoundID == SOUND_CTF_GRAB_PL) { if(g_Config.m_SndGame) - g_GameClient.m_pSounds->Enqueue(CSounds::CHN_GLOBAL, pMsg->m_SoundID); + m_Sounds.Enqueue(CSounds::CHN_GLOBAL, pMsg->m_SoundID); } else { if(g_Config.m_SndGame) - g_GameClient.m_pSounds->Play(CSounds::CHN_GLOBAL, pMsg->m_SoundID, 1.0f); + m_Sounds.Play(CSounds::CHN_GLOBAL, pMsg->m_SoundID, 1.0f); } } else if(MsgId == NETMSGTYPE_SV_TEAMSSTATE || MsgId == NETMSGTYPE_SV_TEAMSSTATELEGACY) @@ -883,8 +788,8 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) if(i <= 16) m_Teams.m_IsDDRace16 = true; - m_pGhost->m_AllowRestart = true; - m_pRaceDemo->m_AllowRestart = true; + m_Ghost.m_AllowRestart = true; + m_RaceDemo.m_AllowRestart = true; } else if(MsgId == NETMSGTYPE_SV_KILLMSG) { @@ -914,14 +819,14 @@ void CGameClient::OnStateChange(int NewState, int OldState) void CGameClient::OnShutdown() { - m_pMenus->KillServer(); - m_pRaceDemo->OnReset(); - m_pGhost->OnReset(); + m_Menus.KillServer(); + m_RaceDemo.OnReset(); + m_Ghost.OnReset(); } void CGameClient::OnEnterGame() { - g_GameClient.m_pEffects->ResetDamageIndicator(); + m_Effects.ResetDamageIndicator(); } void CGameClient::OnGameOver() @@ -934,7 +839,7 @@ void CGameClient::OnStartGame() { if(Client()->State() != IClient::STATE_DEMOPLAYBACK && !g_Config.m_ClAutoDemoOnConnect) Client()->DemoRecorder_HandleAutoStart(); - m_pStatboard->OnReset(); + m_Statboard.OnReset(); } void CGameClient::OnFlagGrab(int TeamID) @@ -967,12 +872,12 @@ void CGameClient::OnLanguageChange() void CGameClient::OnRconType(bool UsernameReq) { - m_pGameConsole->RequireUsername(UsernameReq); + m_GameConsole.RequireUsername(UsernameReq); } void CGameClient::OnRconLine(const char *pLine) { - m_pGameConsole->PrintLine(CGameConsole::CONSOLETYPE_REMOTE, pLine); + m_GameConsole.PrintLine(CGameConsole::CONSOLETYPE_REMOTE, pLine); } void CGameClient::ProcessEvents() @@ -990,33 +895,33 @@ void CGameClient::ProcessEvents() if(Item.m_Type == NETEVENTTYPE_DAMAGEIND) { CNetEvent_DamageInd *ev = (CNetEvent_DamageInd *)pData; - g_GameClient.m_pEffects->DamageIndicator(vec2(ev->m_X, ev->m_Y), direction(ev->m_Angle / 256.0f)); + m_Effects.DamageIndicator(vec2(ev->m_X, ev->m_Y), direction(ev->m_Angle / 256.0f)); } else if(Item.m_Type == NETEVENTTYPE_EXPLOSION) { CNetEvent_Explosion *ev = (CNetEvent_Explosion *)pData; - g_GameClient.m_pEffects->Explosion(vec2(ev->m_X, ev->m_Y)); + m_Effects.Explosion(vec2(ev->m_X, ev->m_Y)); } else if(Item.m_Type == NETEVENTTYPE_HAMMERHIT) { CNetEvent_HammerHit *ev = (CNetEvent_HammerHit *)pData; - g_GameClient.m_pEffects->HammerHit(vec2(ev->m_X, ev->m_Y)); + m_Effects.HammerHit(vec2(ev->m_X, ev->m_Y)); } else if(Item.m_Type == NETEVENTTYPE_SPAWN) { CNetEvent_Spawn *ev = (CNetEvent_Spawn *)pData; - g_GameClient.m_pEffects->PlayerSpawn(vec2(ev->m_X, ev->m_Y)); + m_Effects.PlayerSpawn(vec2(ev->m_X, ev->m_Y)); } else if(Item.m_Type == NETEVENTTYPE_DEATH) { CNetEvent_Death *ev = (CNetEvent_Death *)pData; - g_GameClient.m_pEffects->PlayerDeath(vec2(ev->m_X, ev->m_Y), ev->m_ClientID); + m_Effects.PlayerDeath(vec2(ev->m_X, ev->m_Y), ev->m_ClientID); } else if(Item.m_Type == NETEVENTTYPE_SOUNDWORLD) { CNetEvent_SoundWorld *ev = (CNetEvent_SoundWorld *)pData; if(g_Config.m_SndGame && (ev->m_SoundID != SOUND_GUN_FIRE || g_Config.m_SndGun) && (ev->m_SoundID != SOUND_PLAYER_PAIN_LONG || g_Config.m_SndLongPain)) - g_GameClient.m_pSounds->PlayAt(CSounds::CHN_WORLD, ev->m_SoundID, 1.0f, vec2(ev->m_X, ev->m_Y)); + m_Sounds.PlayAt(CSounds::CHN_WORLD, ev->m_SoundID, 1.0f, vec2(ev->m_X, ev->m_Y)); } } } @@ -1165,12 +1070,33 @@ static CGameInfo GetGameInfo(const CNetObj_GameInfoEx *pInfoEx, int InfoExSize, void CGameClient::InvalidateSnapshot() { // clear all pointers - mem_zero(&g_GameClient.m_Snap, sizeof(g_GameClient.m_Snap)); + mem_zero(&m_Snap, sizeof(m_Snap)); m_Snap.m_LocalClientID = -1; } 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; @@ -1259,7 +1185,7 @@ void CGameClient::OnNewSnapshot() pClient->m_SkinInfo.m_Size = 64; // find new skin - const CSkin *pSkin = m_pSkins->Get(m_pSkins->Find(pClient->m_aSkinName)); + const CSkin *pSkin = m_Skins.Get(m_Skins.Find(pClient->m_aSkinName)); pClient->m_SkinInfo.m_OriginalRenderSkin = pSkin->m_OriginalSkin; pClient->m_SkinInfo.m_ColorableRenderSkin = pSkin->m_ColorableSkin; pClient->m_SkinInfo.m_SkinMetrics = pSkin->m_Metrics; @@ -1272,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) @@ -1427,7 +1353,7 @@ void CGameClient::OnNewSnapshot() // hence no need to reset stats until player leaves GameOver // and it would be a mistake to reset stats after or during the pause && !(CurrentTickGameOver || m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED || s_GamePaused)) - m_pStatboard->OnReset(); + m_Statboard.OnReset(); m_LastRoundStartTick = m_Snap.m_pGameInfoObj->m_RoundStartTick; s_GameOver = CurrentTickGameOver; s_GamePaused = (bool)(m_Snap.m_pGameInfoObj->m_GameStateFlags & GAMESTATEFLAG_PAUSED); @@ -1499,7 +1425,7 @@ void CGameClient::OnNewSnapshot() else if(Client()->SnapFindItem(IClient::SNAP_PREV, NETOBJTYPE_CHARACTER, m_Snap.m_LocalClientID)) { // player died - m_pControls->OnPlayerDeath(); + m_Controls.OnPlayerDeath(); } } if(Client()->State() == IClient::STATE_DEMOPLAYBACK) @@ -1639,12 +1565,12 @@ void CGameClient::OnNewSnapshot() m_ShowOthers[g_Config.m_ClDummy] = g_Config.m_ClShowOthers; } - float ZoomToSend = m_pCamera->m_Zoom; - if(m_pCamera->m_ZoomSmoothingTarget != .0) + float ZoomToSend = m_Camera.m_Zoom; + if(m_Camera.m_ZoomSmoothingTarget != .0) { - if(m_pCamera->m_ZoomSmoothingTarget > m_pCamera->m_Zoom) // Zooming out - ZoomToSend = m_pCamera->m_ZoomSmoothingTarget; - else if(m_pCamera->m_ZoomSmoothingTarget < m_pCamera->m_Zoom && m_LastZoom > 0) // Zooming in + if(m_Camera.m_ZoomSmoothingTarget > m_Camera.m_Zoom) // Zooming out + ZoomToSend = m_Camera.m_ZoomSmoothingTarget; + else if(m_Camera.m_ZoomSmoothingTarget < m_Camera.m_Zoom && m_LastZoom > 0) // Zooming in ZoomToSend = m_LastZoom; } @@ -1666,8 +1592,8 @@ void CGameClient::OnNewSnapshot() } m_LastDummyConnected = Client()->DummyConnected(); - m_pGhost->OnNewSnapshot(); - m_pRaceDemo->OnNewSnapshot(); + m_Ghost.OnNewSnapshot(); + m_RaceDemo.OnNewSnapshot(); // detect air jump for other players for(int i = 0; i < MAX_CLIENTS; i++) @@ -1677,7 +1603,7 @@ void CGameClient::OnNewSnapshot() vec2 Pos = mix(vec2(m_Snap.m_aCharacters[i].m_Prev.m_X, m_Snap.m_aCharacters[i].m_Prev.m_Y), vec2(m_Snap.m_aCharacters[i].m_Cur.m_X, m_Snap.m_aCharacters[i].m_Cur.m_Y), Client()->IntraGameTick(g_Config.m_ClDummy)); - m_pEffects->AirJump(Pos); + m_Effects.AirJump(Pos); } static int PrevLocalID = -1; @@ -1806,15 +1732,15 @@ void CGameClient::OnPredict() int Events = pLocalChar->Core()->m_TriggeredEvents; if(g_Config.m_ClPredict) if(Events & COREEVENT_AIR_JUMP) - m_pEffects->AirJump(Pos); + m_Effects.AirJump(Pos); if(g_Config.m_SndGame) { if(Events & COREEVENT_GROUND_JUMP) - m_pSounds->PlayAndRecord(CSounds::CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, Pos); + m_Sounds.PlayAndRecord(CSounds::CHN_WORLD, SOUND_PLAYER_JUMP, 1.0f, Pos); if(Events & COREEVENT_HOOK_ATTACH_GROUND) - m_pSounds->PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_ATTACH_GROUND, 1.0f, Pos); + m_Sounds.PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_ATTACH_GROUND, 1.0f, Pos); if(Events & COREEVENT_HOOK_HIT_NOHOOK) - m_pSounds->PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_NOATTACH, 1.0f, Pos); + m_Sounds.PlayAndRecord(CSounds::CHN_WORLD, SOUND_HOOK_NOATTACH, 1.0f, Pos); } } @@ -1826,7 +1752,7 @@ void CGameClient::OnPredict() int Events = pDummyChar->Core()->m_TriggeredEvents; if(g_Config.m_ClPredict) if(Events & COREEVENT_AIR_JUMP) - m_pEffects->AirJump(Pos); + m_Effects.AirJump(Pos); } } @@ -1925,7 +1851,7 @@ void CGameClient::OnPredict() m_PredictedTick = Client()->PredGameTick(g_Config.m_ClDummy); if(m_NewPredictedTick) - m_pGhost->OnNewPredictedSnapshot(); + m_Ghost.OnNewPredictedSnapshot(); } void CGameClient::OnActivateEditor() @@ -1957,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}; @@ -2027,7 +1953,7 @@ void CGameClient::CClientData::Reset() m_SpecChar = vec2(0, 0); m_SpecCharPresent = false; - UpdateRenderInfo(); + UpdateRenderInfo(false); } void CGameClient::SendSwitchTeam(int Team) @@ -2037,7 +1963,7 @@ void CGameClient::SendSwitchTeam(int Team) Client()->SendPackMsg(&Msg, MSGFLAG_VITAL); if(Team != TEAM_SPECTATORS) - m_pCamera->OnReset(); + m_Camera.OnReset(); } void CGameClient::SendInfo(bool Start) @@ -2159,13 +2085,13 @@ void CGameClient::ConchainClTextEntitiesSize(IConsole::IResult *pResult, void *p if(pResult->NumArguments()) { CGameClient *pGameClient = (CGameClient *)pUserData; - pGameClient->m_pMapimages->SetTextureScale(g_Config.m_ClTextEntitiesSize); + pGameClient->m_MapImages.SetTextureScale(g_Config.m_ClTextEntitiesSize); } } IGameClient *CreateGameClient() { - return &g_GameClient; + return new CGameClient(); } int CGameClient::IntersectCharacter(vec2 HookPos, vec2 NewPos, vec2 &NewPos2, int ownID) @@ -2601,7 +2527,7 @@ vec2 CGameClient::GetSmoothPos(int ClientID) void CGameClient::Echo(const char *pString) { - m_pChat->Echo(pString); + m_Chat.Echo(pString); } bool CGameClient::IsOtherTeam(int ClientID) @@ -2983,15 +2909,15 @@ void CGameClient::RefindSkins() Client.m_SkinInfo.m_ColorableRenderSkin.Reset(); if(Client.m_aSkinName[0] != '\0') { - const CSkin *pSkin = m_pSkins->Get(m_pSkins->Find(Client.m_aSkinName)); + 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_pGhost->RefindSkin(); - m_pChat->RefindSkins(); - gs_KillMessages.RefindSkins(); + m_Ghost.RefindSkin(); + m_Chat.RefindSkins(); + m_KillMessages.RefindSkins(); } void CGameClient::LoadMapSettings() @@ -3059,7 +2985,7 @@ void CGameClient::ConchainMenuMap(IConsole::IResult *pResult, void *pUserData, I if(str_comp(g_Config.m_ClMenuMap, pResult->GetString(0)) != 0) { str_format(g_Config.m_ClMenuMap, sizeof(g_Config.m_ClMenuMap), "%s", pResult->GetString(0)); - pSelf->m_pMenuBackground->LoadMenuBackground(); + pSelf->m_MenuBackground.LoadMenuBackground(); } } else @@ -3074,19 +3000,19 @@ void CGameClient::DummyResetInput() if((m_DummyInput.m_Fire & 1) != 0) m_DummyInput.m_Fire++; - m_pControls->ResetInput(!g_Config.m_ClDummy); - m_pControls->m_InputData[!g_Config.m_ClDummy].m_Hook = 0; - m_pControls->m_InputData[!g_Config.m_ClDummy].m_Fire = m_DummyInput.m_Fire; + m_Controls.ResetInput(!g_Config.m_ClDummy); + m_Controls.m_InputData[!g_Config.m_ClDummy].m_Hook = 0; + m_Controls.m_InputData[!g_Config.m_ClDummy].m_Fire = m_DummyInput.m_Fire; - m_DummyInput = m_pControls->m_InputData[!g_Config.m_ClDummy]; + m_DummyInput = m_Controls.m_InputData[!g_Config.m_ClDummy]; } bool CGameClient::CanDisplayWarning() { - return m_pMenus->CanDisplayWarning(); + return m_Menus.CanDisplayWarning(); } bool CGameClient::IsDisplayingWarning() { - return m_pMenus->GetCurPopup() == CMenus::POPUP_WARNING; + return m_Menus.GetCurPopup() == CMenus::POPUP_WARNING; } diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 56f00309f..c2156724d 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -20,6 +20,41 @@ #include #include +// components +#include "components/background.h" +#include "components/binds.h" +#include "components/broadcast.h" +#include "components/camera.h" +#include "components/chat.h" +#include "components/console.h" +#include "components/controls.h" +#include "components/countryflags.h" +#include "components/damageind.h" +#include "components/debughud.h" +#include "components/effects.h" +#include "components/emoticon.h" +#include "components/flow.h" +#include "components/ghost.h" +#include "components/hud.h" +#include "components/items.h" +#include "components/killmessages.h" +#include "components/mapimages.h" +#include "components/maplayers.h" +#include "components/mapsounds.h" +#include "components/menu_background.h" +#include "components/menus.h" +#include "components/motd.h" +#include "components/nameplates.h" +#include "components/particles.h" +#include "components/players.h" +#include "components/race_demo.h" +#include "components/scoreboard.h" +#include "components/skins.h" +#include "components/sounds.h" +#include "components/spectator.h" +#include "components/statboard.h" +#include "components/voting.h" + class CGameInfo { public: @@ -59,6 +94,48 @@ public: class CGameClient : public IGameClient { +public: + // all components + CKillMessages m_KillMessages; + CCamera m_Camera; + CChat m_Chat; + CMotd m_Motd; + CBroadcast m_Broadcast; + CGameConsole m_GameConsole; + CBinds m_Binds; + CParticles m_Particles; + CMenus m_Menus; + CSkins m_Skins; + CCountryFlags m_CountryFlags; + CFlow m_Flow; + CHud m_Hud; + CDebugHud m_DebugHud; + CControls m_Controls; + CEffects m_Effects; + CScoreboard m_Scoreboard; + CStatboard m_Statboard; + CSounds m_Sounds; + CEmoticon m_Emoticon; + CDamageInd m_DamageInd; + CVoting m_Voting; + CSpectator m_Spectator; + + CPlayers m_Players; + CNamePlates m_NamePlates; + CItems m_Items; + CMapImages m_MapImages; + + CMapLayers m_MapLayersBackGround = CMapLayers{CMapLayers::TYPE_BACKGROUND}; + CMapLayers m_MapLayersForeGround = CMapLayers{CMapLayers::TYPE_FOREGROUND}; + CBackground m_BackGround; + CMenuBackground m_MenuBackground; + + CMapSounds m_MapSounds; + + CRaceDemo m_RaceDemo; + CGhost m_Ghost; + +private: class CStack { public: @@ -296,7 +373,7 @@ public: CNetObj_Character m_Snapped; CNetObj_Character m_Evolved; - void UpdateRenderInfo(); + void UpdateRenderInfo(bool IsTeamPlay); void Reset(); // rendered characters @@ -400,34 +477,6 @@ public: virtual void SendDummyInfo(bool Start); void SendKill(int ClientID); - // pointers to all systems - class CMenuBackground *m_pMenuBackground; - class CGameConsole *m_pGameConsole; - class CBinds *m_pBinds; - class CParticles *m_pParticles; - class CMenus *m_pMenus; - class CSkins *m_pSkins; - class CCountryFlags *m_pCountryFlags; - class CFlow *m_pFlow; - class CChat *m_pChat; - class CDamageInd *m_pDamageind; - class CCamera *m_pCamera; - class CControls *m_pControls; - class CEffects *m_pEffects; - class CSounds *m_pSounds; - class CMotd *m_pMotd; - class CMapImages *m_pMapimages; - class CVoting *m_pVoting; - class CScoreboard *m_pScoreboard; - class CStatboard *m_pStatboard; - class CItems *m_pItems; - class CMapLayers *m_pMapLayersBackGround; - class CMapLayers *m_pMapLayersForeGround; - class CBackground *m_pBackGround; - - class CMapSounds *m_pMapSounds; - class CPlayers *m_pPlayers; - // DDRace int m_LocalIDs[NUM_DUMMIES]; @@ -436,14 +485,14 @@ public: int m_DummyFire; bool m_ReceivedDDNetPlayer; - class CRaceDemo *m_pRaceDemo; - class CGhost *m_pGhost; class CTeamsCore m_Teams; int IntersectCharacter(vec2 Pos0, vec2 Pos1, vec2 &NewPos, int ownID); 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; } diff --git a/src/game/editor/editor.cpp b/src/game/editor/editor.cpp index 1e4b8e550..30c63129a 100644 --- a/src/game/editor/editor.cpp +++ b/src/game/editor/editor.cpp @@ -3956,7 +3956,7 @@ void CEditor::RenderImages(CUIRect ToolBox, CUIRect View) // render image int i = m_SelectedImage; - if(i < m_Map.m_lImages.size()) + if(i != -1 && i < m_Map.m_lImages.size()) { CUIRect r; View.Margin(10.0f, &r); @@ -6387,7 +6387,7 @@ void CEditor::LoadCurrentMap() m_ValidSaveFilename = true; CGameClient *pGameClient = (CGameClient *)Kernel()->RequestInterface(); - vec2 Center = pGameClient->m_pCamera->m_Center; + vec2 Center = pGameClient->m_Camera.m_Center; m_WorldOffsetX = Center.x; m_WorldOffsetY = Center.y; diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp index 4ccf53d2e..75cb296b5 100644 --- a/src/game/server/gamecontext.cpp +++ b/src/game/server/gamecontext.cpp @@ -36,12 +36,14 @@ enum void CGameContext::Construct(int Resetting) { + m_Resetting = false; m_pServer = 0; for(auto &pPlayer : m_apPlayers) pPlayer = 0; m_pController = 0; + m_aVoteCommand[0] = 0; m_VoteType = VOTE_TYPE_UNKNOWN; m_VoteCloseTime = 0; m_pVoteOptionFirst = 0; @@ -83,9 +85,14 @@ CGameContext::CGameContext() Construct(NO_RESET); } +CGameContext::CGameContext(int Reset) +{ + Construct(Reset); +} + CGameContext::~CGameContext() { - Destruct(NO_RESET); + Destruct(m_Resetting ? RESET : NO_RESET); } void CGameContext::Clear() @@ -96,8 +103,9 @@ void CGameContext::Clear() int NumVoteOptions = m_NumVoteOptions; CTuningParams Tuning = m_Tuning; - Destruct(RESET); - Construct(RESET); + m_Resetting = true; + this->~CGameContext(); + new(this) CGameContext(RESET); m_pVoteOptionHeap = pVoteOptionHeap; m_pVoteOptionFirst = pVoteOptionFirst; diff --git a/src/game/server/gamecontext.h b/src/game/server/gamecontext.h index 1e1ed8c66..e36d53b61 100644 --- a/src/game/server/gamecontext.h +++ b/src/game/server/gamecontext.h @@ -82,6 +82,8 @@ class CGameContext : public IGameServer CMapBugs m_MapBugs; CPrng m_Prng; + bool m_Resetting; + static void CommandCallback(int ClientID, int FlagMask, const char *pCmd, IConsole::IResult *pResult, void *pUser); static void TeeHistorianWrite(const void *pData, int DataSize, void *pUser); @@ -140,6 +142,7 @@ public: bool TeeHistorianActive() const { return m_TeeHistorianActive; } CGameContext(); + CGameContext(int Reset); ~CGameContext(); void Clear(); diff --git a/src/game/server/gamemodes/DDRace.cpp b/src/game/server/gamemodes/DDRace.cpp index 54eaeb28a..916e2f819 100644 --- a/src/game/server/gamemodes/DDRace.cpp +++ b/src/game/server/gamemodes/DDRace.cpp @@ -62,8 +62,9 @@ void CGameControllerDDRace::HandleCharacterTiles(CCharacter *pChr, int MapIndex) int FTile4 = GameServer()->Collision()->GetFTileIndex(S4); const int PlayerDDRaceState = pChr->m_DDRaceState; + bool IsOnStartTile = (m_TileIndex == TILE_START) || (m_TileFIndex == TILE_START) || FTile1 == TILE_START || FTile2 == TILE_START || FTile3 == TILE_START || FTile4 == TILE_START || Tile1 == TILE_START || Tile2 == TILE_START || Tile3 == TILE_START || Tile4 == TILE_START; // start - if(((m_TileIndex == TILE_START) || (m_TileFIndex == TILE_START) || FTile1 == TILE_START || FTile2 == TILE_START || FTile3 == TILE_START || FTile4 == TILE_START || Tile1 == TILE_START || Tile2 == TILE_START || Tile3 == TILE_START || Tile4 == TILE_START) && (PlayerDDRaceState == DDRACE_NONE || PlayerDDRaceState == DDRACE_FINISHED || (PlayerDDRaceState == DDRACE_STARTED && !GetPlayerTeam(ClientID) && g_Config.m_SvTeam != 3))) + if(IsOnStartTile && PlayerDDRaceState != DDRACE_CHEAT) { if(m_Teams.GetSaving(GetPlayerTeam(ClientID))) { @@ -163,6 +164,7 @@ void CGameControllerDDRace::Tick() { IGameController::Tick(); m_Teams.ProcessSaveTeam(); + m_Teams.Tick(); if(m_pInitResult != nullptr && m_pInitResult->m_Completed) { diff --git a/src/game/server/save.cpp b/src/game/server/save.cpp index d549ce92d..7c7d2140e 100644 --- a/src/game/server/save.cpp +++ b/src/game/server/save.cpp @@ -26,6 +26,7 @@ void CSaveTee::Save(CCharacter *pChr) m_Paused = abs(pChr->m_pPlayer->IsPaused()); m_NeededFaketuning = pChr->m_NeededFaketuning; + m_TeeStarted = pChr->Teams()->TeeStarted(m_ClientID); m_TeeFinished = pChr->Teams()->TeeFinished(m_ClientID); m_IsSolo = pChr->m_Solo; @@ -116,6 +117,7 @@ void CSaveTee::Load(CCharacter *pChr, int Team) pChr->m_NeededFaketuning = m_NeededFaketuning; pChr->Teams()->SetForceCharacterTeam(pChr->m_pPlayer->GetCID(), Team); + pChr->Teams()->SetStarted(pChr->m_pPlayer->GetCID(), m_TeeStarted); pChr->Teams()->SetFinished(pChr->m_pPlayer->GetCID(), m_TeeFinished); for(int i = 0; i < NUM_WEAPONS; i++) @@ -248,12 +250,13 @@ char *CSaveTee::GetString(const CSaveTeam *pTeam) "%f\t%f\t%f\t%f\t%f\t" "%f\t%f\t%f\t%f\t%f\t" "%f\t%f\t%f\t%f\t%f\t" - "%d\t" - "%d\t%d\t%d\t" - "%s\t" - "%d\t%d\t" - "%d\t%d\t%d\t%d\t" - "%d", + "%d\t" // m_NotEligibleForFinish + "%d\t%d\t%d\t" // tele weapons + "%s\t" // m_aGameUuid + "%d\t%d\t" // m_HookedPlayer, m_NewHook + "%d\t%d\t%d\t%d\t" // input stuff + "%d\t" // m_ReloadTimer + "%d", // m_TeeStarted m_aName, m_Alive, m_Paused, m_NeededFaketuning, m_TeeFinished, m_IsSolo, // weapons m_aWeapons[0].m_AmmoRegenStart, m_aWeapons[0].m_Ammo, m_aWeapons[0].m_Ammocost, m_aWeapons[0].m_Got, @@ -284,7 +287,8 @@ char *CSaveTee::GetString(const CSaveTeam *pTeam) m_aGameUuid, HookedPlayer, m_NewHook, m_InputDirection, m_InputJump, m_InputFire, m_InputHook, - m_ReloadTimer); + m_ReloadTimer, + m_TeeStarted); return m_aString; } @@ -317,12 +321,13 @@ int CSaveTee::FromString(const char *String) "%f\t%f\t%f\t%f\t%f\t" "%f\t%f\t%f\t%f\t%f\t" "%f\t%f\t%f\t%f\t%f\t" - "%d\t" - "%d\t%d\t%d\t" - "%36s\t" - "%d\t%d" - "%d\t%d\t%d\t%d\t" - "%d", + "%d\t" // m_NotEligibleForFinish + "%d\t%d\t%d\t" // tele weapons + "%36s\t" // m_aGameUuid + "%d\t%d\t" // m_HookedPlayer, m_NewHook + "%d\t%d\t%d\t%d\t" // input stuff + "%d\t" // m_ReloadTimer + "%d", // m_TeeStarted m_aName, &m_Alive, &m_Paused, &m_NeededFaketuning, &m_TeeFinished, &m_IsSolo, // weapons &m_aWeapons[0].m_AmmoRegenStart, &m_aWeapons[0].m_Ammo, &m_aWeapons[0].m_Ammocost, &m_aWeapons[0].m_Got, @@ -353,7 +358,8 @@ int CSaveTee::FromString(const char *String) m_aGameUuid, &m_HookedPlayer, &m_NewHook, &m_InputDirection, &m_InputJump, &m_InputFire, &m_InputHook, - &m_ReloadTimer); + &m_ReloadTimer, + &m_TeeStarted); switch(Num) // Don't forget to update this when you save / load more / less. { case 96: @@ -377,6 +383,9 @@ int CSaveTee::FromString(const char *String) m_ReloadTimer = 0; // fall through case 108: + m_TeeStarted = true; + // fall through + case 109: return 0; default: dbg_msg("load", "failed to load tee-string"); diff --git a/src/game/server/save.h b/src/game/server/save.h index c44265f9c..1615abb5f 100644 --- a/src/game/server/save.h +++ b/src/game/server/save.h @@ -37,6 +37,7 @@ private: int m_NeededFaketuning; // Teamstuff + int m_TeeStarted; int m_TeeFinished; int m_IsSolo; diff --git a/src/game/server/teams.cpp b/src/game/server/teams.cpp index 4fb3f14fd..84d8f4232 100644 --- a/src/game/server/teams.cpp +++ b/src/game/server/teams.cpp @@ -20,6 +20,7 @@ void CGameTeams::Reset() { m_TeamState[i] = TEAMSTATE_EMPTY; m_TeamLocked[i] = false; + m_TeeStarted[i] = false; m_TeeFinished[i] = false; m_LastChat[i] = 0; m_pSaveTeamResult[i] = nullptr; @@ -27,6 +28,7 @@ void CGameTeams::Reset() m_Invited[i] = 0; m_Practice[i] = false; m_LastSwap[i] = 0; + m_TeamSentStartWarning[i] = false; } } @@ -66,11 +68,14 @@ void CGameTeams::OnCharacterStart(int ClientID) CCharacter *pStartingChar = Character(ClientID); if(!pStartingChar) return; + if(g_Config.m_SvTeam == 3 && pStartingChar->m_DDRaceState == DDRACE_STARTED) + return; if((g_Config.m_SvTeam == 3 || m_Core.Team(ClientID) != TEAM_FLOCK) && pStartingChar->m_DDRaceState == DDRACE_FINISHED) return; if(g_Config.m_SvTeam != 3 && (m_Core.Team(ClientID) == TEAM_FLOCK || m_Core.Team(ClientID) == TEAM_SUPER)) { + m_TeeStarted[ClientID] = true; pStartingChar->m_DDRaceState = DDRACE_STARTED; pStartingChar->m_StartTime = Tick; return; @@ -113,9 +118,15 @@ void CGameTeams::OnCharacterStart(int ClientID) } } + if(!Waiting) + { + m_TeeStarted[ClientID] = true; + } + if(m_TeamState[m_Core.Team(ClientID)] < TEAMSTATE_STARTED && !Waiting) { ChangeTeamState(m_Core.Team(ClientID), TEAMSTATE_STARTED); + m_TeamSentStartWarning[m_Core.Team(ClientID)] = false; int NumPlayers = Count(m_Core.Team(ClientID)); @@ -183,12 +194,86 @@ void CGameTeams::OnCharacterFinish(int ClientID) } else { - m_TeeFinished[ClientID] = true; - + if(m_TeeStarted[ClientID]) + { + m_TeeFinished[ClientID] = true; + } CheckTeamFinished(m_Core.Team(ClientID)); } } +void CGameTeams::Tick() +{ + int Now = Server()->Tick(); + int Frequency = Server()->TickSpeed() * 60; + int Remainder = Server()->TickSpeed() * 30; + uint64_t TeamHasWantedStartTime = 0; + for(int i = 0; i < MAX_CLIENTS; i++) + { + CCharacter *pChar = GameServer()->m_apPlayers[i] ? GameServer()->m_apPlayers[i]->GetCharacter() : nullptr; + int Team = m_Core.Team(i); + if(!pChar || m_TeamState[Team] != TEAMSTATE_STARTED || m_TeeStarted[i]) + { + continue; + } + if((Now - pChar->m_StartTime) % Frequency == Remainder) + { + TeamHasWantedStartTime |= ((uint64_t)1) << m_Core.Team(i); + } + } + TeamHasWantedStartTime &= ~(uint64_t)1; + if(!TeamHasWantedStartTime) + { + return; + } + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(((TeamHasWantedStartTime >> i) & 1) == 0) + { + continue; + } + if(Count(i) <= 1) + { + continue; + } + int NumPlayersNotStarted = 0; + char aPlayerNames[256]; + aPlayerNames[0] = 0; + for(int j = 0; j < MAX_CLIENTS; j++) + { + if(m_Core.Team(j) == i && !m_TeeStarted[j]) + { + if(aPlayerNames[0]) + { + str_append(aPlayerNames, ", ", sizeof(aPlayerNames)); + } + str_append(aPlayerNames, Server()->ClientName(j), sizeof(aPlayerNames)); + NumPlayersNotStarted += 1; + break; + } + } + if(!aPlayerNames[0]) + { + continue; + } + char aBuf[512]; + str_format(aBuf, sizeof(aBuf), + "Your team has %d %s not started yet, they need " + "to touch the start before this team can finish: %s", + NumPlayersNotStarted, + NumPlayersNotStarted == 1 ? "player that has" : "players that have", + aPlayerNames); + + for(int j = 0; j < MAX_CLIENTS; j++) + { + if(m_Core.Team(j) == i) + { + GameServer()->SendChatTarget(j, aBuf); + } + } + } +} + void CGameTeams::CheckTeamFinished(int Team) { if(TeamFinished(Team)) @@ -203,6 +288,7 @@ void CGameTeams::CheckTeamFinished(int Team) CPlayer *pPlayer = GetPlayer(i); if(pPlayer && pPlayer->IsPlaying()) { + m_TeeStarted[i] = false; m_TeeFinished[i] = false; TeamPlayers[PlayersCount++] = pPlayer; @@ -287,6 +373,7 @@ const char *CGameTeams::SetCharacterTeam(int ClientID, int Team) void CGameTeams::SetForceCharacterTeam(int ClientID, int Team) { + m_TeeStarted[ClientID] = false; m_TeeFinished[ClientID] = false; int OldTeam = m_Core.Team(ClientID); @@ -349,6 +436,10 @@ void CGameTeams::ChangeTeamState(int Team, int State) bool CGameTeams::TeamFinished(int Team) { + if(m_TeamState[Team] != TEAMSTATE_STARTED) + { + return false; + } for(int i = 0; i < MAX_CLIENTS; ++i) if(m_Core.Team(i) == Team && !m_TeeFinished[i]) return false; @@ -909,6 +1000,21 @@ void CGameTeams::OnCharacterDeath(int ClientID, int Weapon) } else { + if(m_TeamState[m_Core.Team(ClientID)] == CGameTeams::TEAMSTATE_STARTED && !m_TeeStarted[ClientID]) + { + char aBuf[128]; + str_format(aBuf, sizeof(aBuf), "This team cannot finish anymore because '%s' left the team before hitting the start", Server()->ClientName(ClientID)); + for(int i = 0; i < MAX_CLIENTS; i++) + { + if(m_Core.Team(i) != Team || i == ClientID) + { + continue; + } + GameServer()->SendChatTarget(i, aBuf); + } + + ChangeTeamState(Team, CGameTeams::TEAMSTATE_STARTED_UNFINISHABLE); + } SetForceCharacterTeam(ClientID, TEAM_FLOCK); CheckTeamFinished(Team); } diff --git a/src/game/server/teams.h b/src/game/server/teams.h index e6dd8b484..4f1eab4db 100644 --- a/src/game/server/teams.h +++ b/src/game/server/teams.h @@ -12,12 +12,21 @@ class CGameTeams { int m_TeamState[MAX_CLIENTS]; + // `m_TeeStarted` is used to keep track whether a given tee has hit the + // start of the map yet. If a tee that leaves hasn't hit the start line + // yet, the team will be marked as "not allowed to finish" + // (`TEAMSTATE_STARTED_UNFINISHABLE`). If this were not the case, tees + // could go around the startline on a map, leave one tee behind at + // start, go to the finish line, let the tee start and kill, allowing + // the team to finish instantly. + bool m_TeeStarted[MAX_CLIENTS]; bool m_TeeFinished[MAX_CLIENTS]; bool m_TeamLocked[MAX_CLIENTS]; uint64_t m_Invited[MAX_CLIENTS]; bool m_Practice[MAX_CLIENTS]; std::shared_ptr m_pSaveTeamResult[MAX_CLIENTS]; uint64_t m_LastSwap[MAX_CLIENTS]; + bool m_TeamSentStartWarning[MAX_CLIENTS]; class CGameContext *m_pGameContext; @@ -31,6 +40,9 @@ public: TEAMSTATE_EMPTY, TEAMSTATE_OPEN, TEAMSTATE_STARTED, + // Happens when a tee that hasn't hit the start tiles leaves + // the team. + TEAMSTATE_STARTED_UNFINISHABLE, TEAMSTATE_FINISHED }; @@ -61,6 +73,7 @@ public: void OnCharacterFinish(int ClientID); void OnCharacterSpawn(int ClientID); void OnCharacterDeath(int ClientID, int Weapon); + void Tick(); // returns nullptr if successful, error string if failed const char *SetCharacterTeam(int ClientID, int Team); @@ -98,6 +111,11 @@ public: void SwapTeamCharacters(CPlayer *pPlayer, CPlayer *pTargetPlayer, int Team); void ProcessSaveTeam(); + bool TeeStarted(int ClientID) + { + return m_TeeStarted[ClientID]; + } + bool TeeFinished(int ClientID) { return m_TeeFinished[ClientID]; @@ -126,9 +144,14 @@ public: return m_TeamState[Team] == CGameTeams::TEAMSTATE_STARTED; } - void SetFinished(int ClientID, bool finished) + void SetStarted(int ClientID, bool Started) { - m_TeeFinished[ClientID] = finished; + m_TeeStarted[ClientID] = Started; + } + + void SetFinished(int ClientID, bool Finished) + { + m_TeeFinished[ClientID] = Finished; } void SetSaving(int TeamID, std::shared_ptr &SaveResult)