Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: merge g_pClientGame and g_pGame into g_pSharedGame #3107

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/CClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CGame* g_pGame = NULL;
CMultiplayer* g_pMultiplayer = NULL;
CNet* g_pNet = NULL;
CClientGame* g_pClientGame = NULL;
CClientGame* g_pSharedGame = nullptr;

int CClient::ClientInitialize(const char* szArguments, CCoreInterface* pCore)
{
Expand Down Expand Up @@ -138,6 +139,7 @@ int CClient::ClientInitialize(const char* szArguments, CCoreInterface* pCore)
{
// Create new clientgame
g_pClientGame = new CClientGame(true);
g_pSharedGame = g_pClientGame;

// Connect
g_pCore->GetConsole()->Echo("Starting playback...");
Expand Down Expand Up @@ -205,6 +207,7 @@ void CClient::ClientShutdown()
{
delete g_pClientGame;
g_pClientGame = NULL;
g_pSharedGame = nullptr;
}
}

Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/ClientCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ using std::vector;
// Hide the "conversion from 'unsigned long' to 'DWORD*' of greater size" warning
#pragma warning(disable:4312)

extern CClientGame* g_pClientGame;

bool COMMAND_Executed(const char* szCommand, const char* szArguments, bool bHandleRemotely, bool bHandled, bool bIsScriptedBind)
{
// Has the core already handled this command?
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClient3DMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <game/C3DMarkers.h>
#include <game/CVisibilityPlugins.h>

extern CClientGame* g_pClientGame;

CClient3DMarker::CClient3DMarker(CClientMarker* pThis)
{
// Init
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClientEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

using std::list;

extern CClientGame* g_pClientGame;

#pragma warning( disable : 4355 ) // warning C4355: 'this' : used in base member initializer list

CClientEntity::CClientEntity(ElementID ID) : ClassInit(this)
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClientExplosionManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#include <StdInc.h>
#include <game/CExplosionManager.h>

extern CClientGame* g_pClientGame;

CClientExplosionManager* g_pExplosionManager = NULL;

CClientExplosionManager::CClientExplosionManager(CClientManager* pManager)
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClientGUIElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

using std::list;

extern CClientGame* g_pClientGame;

CClientGUIElement::CClientGUIElement(CClientManager* pManager, CLuaMain* pLuaMain, CGUIElement* pCGUIElement, ElementID ID) : ClassInit(this), CClientEntity(ID)
{
m_pManager = pManager;
Expand Down
1 change: 0 additions & 1 deletion Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ using std::vector;
#pragma warning(disable:4312)

// Used within this file by the packet handler to grab the this pointer of CClientGame
extern CClientGame* g_pClientGame;
extern int g_iDamageEventLimit;
float g_fApplyDamageLastAmount;
uchar g_ucApplyDamageLastHitZone;
Expand Down
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/CClientGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,4 @@ class CClientGame
};

extern CClientGame* g_pClientGame;
extern CClientGame* g_pSharedGame;
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClientManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

using SharedUtil::CalcMTASAPath;

extern CClientGame* g_pClientGame;

CClientManager::CClientManager()
{
m_pMarkerStreamer = new CClientStreamer(CClientMarker::IsLimitReached, 600.0f, 300, 300);
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClientMarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

#include "StdInc.h"

extern CClientGame* g_pClientGame;

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
Expand Down
3 changes: 0 additions & 3 deletions Client/mods/deathmatch/logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
using std::list;
using std::vector;

extern CClientGame* g_pClientGame;

#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
Expand Down Expand Up @@ -3333,7 +3331,6 @@ void CClientPed::SetTargetRotation(unsigned long ulDelay, float fRotation, float

// Temporary
#include "../mods/deathmatch/logic/CClientGame.h"
extern CClientGame* g_pClientGame;

void CClientPed::Interpolate()
{
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CClientPickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
#include <game/CPickups.h>
#include <game/CPickup.h>

extern CClientGame* g_pClientGame;

CClientPickup::CClientPickup(CClientManager* pManager, ElementID ID, unsigned short usModel, CVector vecPosition)
: ClassInit(this), CClientStreamElement(pManager->GetPickupStreamer(), ID)
{
Expand Down
1 change: 0 additions & 1 deletion Client/mods/deathmatch/logic/CClientStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ void CClientStreamer::ConnectRow(CClientStreamSectorRow* pRow)
}

#include "..\deathmatch\logic\CClientGame.h"
extern CClientGame* g_pClientGame;
void CClientStreamer::DoPulse(CVector& vecPosition)
{
/* Debug code
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CDeathmatchObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

using std::list;

extern CClientGame* g_pClientGame;

#ifdef WITH_OBJECT_SYNC
CDeathmatchObject::CDeathmatchObject(CClientManager* pManager, CMovingObjectsManager* pMovingObjectsManager, CObjectSync* pObjectSync, ElementID ID,
unsigned short usModel)
Expand Down
4 changes: 1 addition & 3 deletions Client/mods/deathmatch/logic/CElementGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

using std::list;

extern CClientGame* g_pClientGame;

CElementGroup::~CElementGroup()
{
CElementDeleter* deleter = g_pClientGame->GetElementDeleter();
Expand Down Expand Up @@ -49,4 +47,4 @@ void CElementGroup::Remove(class CClientEntity* element)
unsigned int CElementGroup::GetCount()
{
return m_elements.size();
}
}
1 change: 0 additions & 1 deletion Client/mods/deathmatch/logic/CNetAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <game/CWeaponStat.h>
#include <game/CWeaponStatManager.h>

extern CClientGame* g_pClientGame;
CTickRateSettings g_TickRateSettings;

CNetAPI::CNetAPI(CClientManager* pManager)
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CPedSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

using std::list;

extern CClientGame* g_pClientGame;

#define PED_SYNC_RATE ( g_TickRateSettings.iPedSync )

CPedSync::CPedSync(CClientPedManager* pPedManager)
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CResource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

using namespace std;

extern CClientGame* g_pClientGame;

int CResource::m_iShowingCursor = 0;

CResource::CResource(unsigned short usNetID, const char* szResourceName, CClientEntity* pResourceEntity, CClientEntity* pResourceDynamicEntity,
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/CUnoccupiedVehicleSync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

using std::list;

extern CClientGame* g_pClientGame;

#define UNOCCUPIED_VEHICLE_SYNC_RATE ( g_TickRateSettings.iUnoccupiedVehicle )

CUnoccupiedVehicleSync::CUnoccupiedVehicleSync(CClientVehicleManager* pVehicleManager)
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/lua/CLuaArgument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#define VERIFY_RESOURCE(resource) (g_pClientGame->GetResourceManager()->Exists(resource))
#endif

extern CClientGame* g_pClientGame;

using namespace std;

// Prevent the warning issued when doing unsigned short -> void*
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/lua/CLuaArguments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ using namespace std;
#define VERIFY_ENTITY(entity) (CStaticFunctionDefinitions::GetRootElement()->IsMyChild(entity,true)&&!entity->IsBeingDeleted())
#endif

extern CClientGame* g_pClientGame;

CLuaArguments::CLuaArguments(NetBitStreamInterface& bitStream, std::vector<CLuaArguments*>* pKnownTables)
{
ReadFromBitStream(bitStream, pKnownTables);
Expand Down
2 changes: 0 additions & 2 deletions Client/mods/deathmatch/logic/lua/CLuaMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

using std::list;

extern CClientGame* g_pClientGame;

static CLuaManager* m_pLuaManager;
SString CLuaMain::ms_strExpectedUndumpHash;

Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include "CGame.h"
#include "CAccountManager.h"

extern CGame* g_pGame;

CClient::CClient(bool bAddGuestAccount)
{
if (bAddGuestAccount)
Expand Down
3 changes: 0 additions & 3 deletions Server/mods/deathmatch/logic/CConsoleCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "CGame.h"
#include "CMainConfig.h"

extern CGame* g_pGame;

// Helper functions
static std::string GetAdminNameForLog(CClient* pClient)
{
Expand Down Expand Up @@ -825,7 +823,6 @@ bool CConsoleCommands::Nick(CConsole* pConsole, const char* szArguments, CClient

// HACKED IN FOR NOW
#include "CGame.h"
extern CGame* g_pGame;

bool CConsoleCommands::LogIn(CConsole* pConsole, const char* szArguments, CClient* pClient, CClient* pEchoClient)
{
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
#include "Utils.h"
#include "lua/CLuaFunctionParseHelpers.h"

extern CGame* g_pGame;

#if defined(_MSC_VER)
#pragma warning(disable : 4355) // warning C4355: 'this' : used in base member initializer list
#endif
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CElementDeleter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "CElementDeleter.h"
#include "CGame.h"

extern CGame* g_pGame;

void CElementDeleter::Delete(class CElement* pElement, bool bUnlink, bool bUpdatePerPlayerEntities)
{
if (pElement)
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CElementGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include "CMapManager.h"
#include "CPerPlayerEntity.h"

extern CGame* g_pGame;

CElementGroup::~CElementGroup()
{
// Delete all the elements
Expand Down
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#endif

CGame* g_pGame = NULL;
CGame* g_pSharedGame = NULL;

char szProgress[4] = {'-', '\\', '|', '/'};
unsigned char ucProgress = 0;
Expand Down Expand Up @@ -146,6 +147,7 @@ CGame::CGame() : m_FloodProtect(4, 30000, 30000) // Max of 4 connecti
{
// Set our global pointer
g_pGame = this;
g_pSharedGame = g_pGame;

m_bServerFullyUp = false;

Expand Down
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/CGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -656,3 +656,6 @@ class CGame
bool m_DevelopmentModeEnabled;
bool m_showClientTransferBox = true;
};

extern CGame* g_pGame;
extern CGame* g_pSharedGame;
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CHTTPD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <arpa/inet.h>
#endif

extern CGame* g_pGame;

CHTTPD::CHTTPD()
: m_BruteForceProtect(4, 30000, 60000 * 5) // Max of 4 attempts per 30 seconds, then 5 minute ignore
,
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CMainConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

#define MTA_SERVER_CONF_TEMPLATE "mtaserver.conf.template"

extern CGame* g_pGame;

CBandwidthSettings* g_pBandwidthSettings = new CBandwidthSettings();
CTickRateSettings g_TickRateSettings;

Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CMapManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include "packets/CPickupHideShowPacket.h"
#include "packets/CVehicleSpawnPacket.h"

extern CGame* g_pGame;

CMapManager::CMapManager(CBlipManager* pBlipManager, CObjectManager* pObjectManager, CPickupManager* pPickupManager, CPlayerManager* pPlayerManager,
CRadarAreaManager* pRadarAreaManager, CMarkerManager* pMarkerManager, CVehicleManager* pVehicleManager, CTeamManager* pTeamManager,
CPedManager* pPedManager, CColManager* pColManager, CWaterManager* pWaterManager, CClock* pClock, CGroups* pGroups, CEvents* pEvents,
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#include "CLogger.h"
#include "Utils.h"

extern CGame* g_pGame;

CObject::CObject(CElement* pParent, CObjectManager* pObjectManager, bool bIsLowLod) : CElement(pParent), m_bIsLowLod(bIsLowLod), m_pLowLodObject(NULL)
{
// Init
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CPickup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "packets/CPickupHitConfirmPacket.h"
#include "CStaticFunctionDefinitions.h"

extern CGame* g_pGame;

CPickup::CPickup(CElement* pParent, CPickupManager* pPickupManager, CColManager* pColManager) : CElement(pParent)
{
// Init
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
#include "CSpatialDatabase.h"
#include "net/SimHeaders.h"

extern CGame* g_pGame;

CPlayer::CPlayer(CPlayerManager* pPlayerManager, class CScriptDebugging* pScriptDebugging, const NetServerPlayerID& PlayerSocket) : CPed(nullptr, nullptr, 0)
{
CElementRefManager::AddElementRefs(ELEMENT_REF_DEBUG(this, "CPlayer"), &m_pTeam, NULL);
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CResourceClientFileItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
#include "StdInc.h"
#include "CResourceClientFileItem.h"

extern CGame* g_pGame;

CResourceClientFileItem::CResourceClientFileItem(CResource* resource, const char* szShortName, const char* szResourceFileName, CXMLAttributes* xmlAttributes,
bool bClientAutoDownload)
: CResourceFile(resource, szShortName, szResourceFileName, xmlAttributes)
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CResourceClientScriptItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#include "CScriptDebugging.h"
#include <zlib.h>

extern CGame* g_pGame;

CResourceClientScriptItem::CResourceClientScriptItem(CResource* resource, const char* szShortName, const char* szResourceFileName,
CXMLAttributes* xmlAttributes)
: CResourceFile(resource, szShortName, szResourceFileName, xmlAttributes)
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CResourceMapItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "Enums.h"
#include "lua/CLuaFunctionParseHelpers.h"

extern CGame* g_pGame;

CResourceMapItem::CResourceMapItem(CResource* pResource, const char* szShortName, const char* szResourceFileName, CXMLAttributes* pXMLAttributes,
int iDimension)
: CResourceFile(pResource, szShortName, szResourceFileName, pXMLAttributes)
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CScriptDebugging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "CScriptDebugging.h"
#include "packets/CDebugEchoPacket.h"

extern CGame* g_pGame;

CScriptDebugging::CScriptDebugging()
{
m_uiLogFileLevel = 0;
Expand Down
2 changes: 0 additions & 2 deletions Server/mods/deathmatch/logic/CVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
#include "CBandwidthSettings.h"
#include "Utils.h"

extern CGame* g_pGame;

CVehicle::CVehicle(CVehicleManager* pVehicleManager, CElement* pParent, unsigned short usModel, unsigned char ucVariant, unsigned char ucVariant2)
: CElement(pParent)
{
Expand Down
Loading