Skip to content

Commit

Permalink
Remove unused globals and duplicate global variable forward declarations
Browse files Browse the repository at this point in the history
(cherry picked from commit 9ca8e6a)
  • Loading branch information
SamVanheer authored and LogicAndTrick committed Dec 26, 2021
1 parent 349d429 commit 36164aa
Show file tree
Hide file tree
Showing 51 changed files with 126 additions and 333 deletions.
9 changes: 0 additions & 9 deletions cl_dll/hl/hl_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,6 @@ This file contains "stubs" of class member implementations so that we can predic
#include "soundent.h"
#include "skill.h"

// Globals used by game logic
int gmsgWeapPickup = 0;
enginefuncs_t g_engfuncs;
globalvars_t* gpGlobals;

ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS];
AmmoInfo CBasePlayerItem::AmmoInfoArray[MAX_AMMO_SLOTS];

void EMIT_SOUND_DYN(edict_t* entity, int channel, const char* sample, float volume, float attenuation, int flags, int pitch) {}

// CBaseEntity Stubs
Expand Down Expand Up @@ -104,7 +96,6 @@ CGrenade* CGrenade::ShootContact(entvars_t* pevOwner, Vector vecStart, Vector ve
void CGrenade::DetonateUse(CBaseEntity* pActivator, CBaseEntity* pCaller, USE_TYPE useType, float value) {}

void UTIL_Remove(CBaseEntity* pEntity) {}
struct skilldata_t gSkillData;
void UTIL_SetSize(entvars_t* pev, const Vector& vecMin, const Vector& vecMax) {}
CBaseEntity* UTIL_FindEntityInSphere(CBaseEntity* pStartEntity, const Vector& vecCenter, float flRadius) { return 0; }

Expand Down
1 change: 0 additions & 1 deletion cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "../com_weapons.h"
#include "../demo.h"

extern globalvars_t* gpGlobals;
extern int g_iUser1;

// Pool of client side entities/entvars_t
Expand Down
40 changes: 0 additions & 40 deletions dlls/UserMessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,6 @@
#include "shake.h"
#include "UserMessages.h"

int gmsgShake = 0;
int gmsgFade = 0;
int gmsgFlashlight = 0;
int gmsgFlashBattery = 0;
int gmsgResetHUD = 0;
int gmsgInitHUD = 0;
int gmsgSetFog = 0; //LRC
int gmsgShowGameTitle = 0;
int gmsgCurWeapon = 0;
int gmsgHealth = 0;
int gmsgDamage = 0;
int gmsgBattery = 0;
int gmsgTrain = 0;
int gmsgLogo = 0;
int gmsgHUDColor = 0; //LRC
int gmsgWeaponList = 0;
int gmsgAmmoX = 0;
int gmsgHudText = 0;
int gmsgDeathMsg = 0;
int gmsgScoreInfo = 0;
int gmsgTeamInfo = 0;
int gmsgTeamScore = 0;
int gmsgGameMode = 0;
int gmsgMOTD = 0;
int gmsgServerName = 0;
int gmsgAmmoPickup = 0;
int gmsgWeapPickup = 0;
int gmsgItemPickup = 0;
int gmsgHideWeapon = 0;
int gmsgSetCurWeap = 0;
int gmsgSayText = 0;
int gmsgTextMsg = 0;
int gmsgSetFOV = 0;
int gmsgShowMenu = 0;
int gmsgGeigerRange = 0;
int gmsgTeamNames = 0;
int gmsgStatusIcon = 0; //LRC
int gmsgStatusText = 0;
int gmsgStatusValue = 0;

void LinkUserMessages()
{
// Already taken care of?
Expand Down
78 changes: 39 additions & 39 deletions dlls/UserMessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,44 @@

#pragma once

extern int gmsgShake;
extern int gmsgFade;
extern int gmsgFlashlight;
extern int gmsgFlashBattery;
extern int gmsgResetHUD;
extern int gmsgInitHUD;
extern int gmsgSetFog; //LRC
extern int gmsgShowGameTitle;
extern int gmsgCurWeapon;
extern int gmsgHealth;
extern int gmsgDamage;
extern int gmsgBattery;
extern int gmsgTrain;
extern int gmsgLogo;
extern int gmsgHUDColor; //LRC
extern int gmsgWeaponList;
extern int gmsgAmmoX;
extern int gmsgHudText;
extern int gmsgDeathMsg;
extern int gmsgScoreInfo;
extern int gmsgTeamInfo;
extern int gmsgTeamScore;
extern int gmsgGameMode;
extern int gmsgMOTD;
extern int gmsgServerName;
extern int gmsgAmmoPickup;
extern int gmsgWeapPickup;
extern int gmsgItemPickup;
extern int gmsgHideWeapon;
extern int gmsgSetCurWeap;
extern int gmsgSayText;
extern int gmsgTextMsg;
extern int gmsgSetFOV;
extern int gmsgShowMenu;
extern int gmsgGeigerRange;
extern int gmsgTeamNames;
extern int gmsgStatusIcon; //LRC
extern int gmsgStatusText;
extern int gmsgStatusValue;
inline int gmsgShake = 0;
inline int gmsgFade = 0;
inline int gmsgFlashlight = 0;
inline int gmsgFlashBattery = 0;
inline int gmsgResetHUD = 0;
inline int gmsgInitHUD = 0;
inline int gmsgSetFog = 0; //LRC
inline int gmsgShowGameTitle = 0;
inline int gmsgCurWeapon = 0;
inline int gmsgHealth = 0;
inline int gmsgDamage = 0;
inline int gmsgBattery = 0;
inline int gmsgTrain = 0;
inline int gmsgLogo = 0;
inline int gmsgHUDColor = 0; //LRC
inline int gmsgWeaponList = 0;
inline int gmsgAmmoX = 0;
inline int gmsgHudText = 0;
inline int gmsgDeathMsg = 0;
inline int gmsgScoreInfo = 0;
inline int gmsgTeamInfo = 0;
inline int gmsgTeamScore = 0;
inline int gmsgGameMode = 0;
inline int gmsgMOTD = 0;
inline int gmsgServerName = 0;
inline int gmsgAmmoPickup = 0;
inline int gmsgWeapPickup = 0;
inline int gmsgItemPickup = 0;
inline int gmsgHideWeapon = 0;
inline int gmsgSetCurWeap = 0;
inline int gmsgSayText = 0;
inline int gmsgTextMsg = 0;
inline int gmsgSetFOV = 0;
inline int gmsgShowMenu = 0;
inline int gmsgGeigerRange = 0;
inline int gmsgTeamNames = 0;
inline int gmsgStatusIcon = 0; //LRC
inline int gmsgStatusText = 0;
inline int gmsgStatusValue = 0;

void LinkUserMessages();
2 changes: 0 additions & 2 deletions dlls/animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#include "animation.h"
#include "scriptevent.h"

extern globalvars_t* gpGlobals;

#pragma warning(disable : 4244)


Expand Down
2 changes: 0 additions & 2 deletions dlls/apache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
#include "weapons.h"
#include "effects.h"

extern DLL_GLOBAL int g_iSkillLevel;

#define SF_WAITFORTRIGGER (0x04 | 0x40) // UNDONE: Fix!
#define SF_NOWRECKAGE 0x08

Expand Down
2 changes: 0 additions & 2 deletions dlls/bmodels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
#include "doors.h"
#include "movewith.h"

extern DLL_GLOBAL Vector g_vecAttackDir;

#define SF_BRUSH_ACCDCC 16 // brush should accelerate and decelerate when toggled
#define SF_BRUSH_HURT 32 // rotating brush that inflicts pain based on rotation speed
#define SF_ROTATING_NOT_SOLID 64 // some special rotating objects are not solid.
Expand Down
7 changes: 1 addition & 6 deletions dlls/cbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "saverestore.h"
#include "client.h"
#include "decals.h"
Expand All @@ -32,8 +33,6 @@ char PM_FindTextureType(char* name);
void OnFreeEntPrivateData(edict_s* pEdict);

extern Vector VecBModelOrigin(entvars_t* pevBModel);
extern DLL_GLOBAL Vector g_vecAttackDir;
extern DLL_GLOBAL int g_iSkillLevel;

static DLL_FUNCTIONS gFunctionTable =
{
Expand Down Expand Up @@ -226,10 +225,6 @@ void DispatchKeyValue(edict_t* pentKeyvalue, KeyValueData* pkvd)
pkvd->fHandled = static_cast<int32>(pEntity->KeyValue(pkvd));
}


// HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers)
// while it builds the graph
bool gTouchDisabled = false;
void DispatchTouch(edict_t* pentTouched, edict_t* pentOther)
{
if (gTouchDisabled)
Expand Down
8 changes: 8 additions & 0 deletions dlls/cbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ extern "C" DLLEXPORT int GetEntityAPI(DLL_FUNCTIONS* pFunctionTable, int interfa
extern "C" DLLEXPORT int GetEntityAPI2(DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion);
extern "C" DLLEXPORT int GetNewDLLFunctions(NEW_DLL_FUNCTIONS* pFunctionTable, int* interfaceVersion);

/**
* @brief HACKHACK -- this is a hack to keep the node graph entity from "touching" things (like triggers)
* while it builds the graph
*/
inline bool gTouchDisabled = false;

extern int DispatchSpawn(edict_t* pent);
extern void DispatchKeyValue(edict_t* pentKeyvalue, KeyValueData* pkvd);
extern void DispatchTouch(edict_t* pentTouched, edict_t* pentOther);
Expand Down Expand Up @@ -941,3 +947,5 @@ class CWorld : public CBaseEntity
};

extern CWorld* g_pWorld;

inline DLL_GLOBAL edict_t* g_pBodyQueueHead = nullptr;
10 changes: 1 addition & 9 deletions dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,9 @@
#include "UserMessages.h"
#include "movewith.h"

extern DLL_GLOBAL unsigned int g_ulModelIndexPlayer;
extern DLL_GLOBAL bool g_fGameOver;
extern DLL_GLOBAL int g_iSkillLevel;
extern DLL_GLOBAL unsigned int g_ulFrameCount;
DLL_GLOBAL unsigned int g_ulFrameCount;

extern void CopyToBodyQue(entvars_t* pev);
extern bool giPrecacheGrunt;

extern cvar_t allow_spectators;

extern bool g_teamplay;

void LinkUserMessages();

Expand Down
4 changes: 0 additions & 4 deletions dlls/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@
#include "func_break.h"
#include "studio.h"

extern DLL_GLOBAL Vector g_vecAttackDir;
extern DLL_GLOBAL int g_iSkillLevel;

extern Vector VecBModelOrigin(entvars_t* pevBModel);
extern entvars_t* g_pevLastInflictor;

#define GERMAN_GIB_COUNT 4
#define HUMAN_GIB_COUNT 6
Expand Down
3 changes: 2 additions & 1 deletion dlls/enginecallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
#include "event_flags.h"

// Must be provided by user of this code
extern enginefuncs_t g_engfuncs;
// Holds engine functionality callbacks
inline enginefuncs_t g_engfuncs;

// The actual engine callbacks
#define GETPLAYERUSERID (*g_engfuncs.pfnGetPlayerUserId)
Expand Down
1 change: 1 addition & 0 deletions dlls/explode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "decals.h"
#include "explode.h"
#include "locus.h"
#include "weapons.h"

// Spark Shower
class CShower : public CBaseEntity
Expand Down
4 changes: 0 additions & 4 deletions dlls/explode.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@
#define SF_ENVEXPLOSION_NODECAL (1 << 4) // don't make a scorch mark
#define SF_ENVEXPLOSION_NOSPARKS (1 << 5) // don't make a scorch mark

extern DLL_GLOBAL short g_sModelIndexFireball;
extern DLL_GLOBAL short g_sModelIndexSmoke;


extern void ExplosionCreate(const Vector& center, const Vector& angles, edict_t* pOwner, int magnitude, bool doDamage);
3 changes: 0 additions & 3 deletions dlls/flyingmonster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
#define FLYING_AE_FLAP (8)
#define FLYING_AE_FLAPSOUND (9)


extern DLL_GLOBAL edict_t* g_pBodyQueueHead;

int CFlyingMonster ::CheckLocalMove(const Vector& vecStart, const Vector& vecEnd, CBaseEntity* pTarget, float* pflDist)
{
// UNDONE: need to check more than the endpoint
Expand Down
3 changes: 1 addition & 2 deletions dlls/func_break.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "monsters.h"
#include "saverestore.h"
#include "func_break.h"
#include "decals.h"
#include "explode.h"

extern DLL_GLOBAL Vector g_vecAttackDir;

// =================== FUNC_Breakable ==============================================

// Just add more items to the bottom of this array and they will automagically be supported
Expand Down
6 changes: 0 additions & 6 deletions dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ cvar_t mw_debug = {"sohl_mwdebug", "0", FCVAR_SERVER}; //LRC - debug info. f

cvar_t mp_chattime = {"mp_chattime", "10", FCVAR_SERVER};

// Engine Cvars
cvar_t* g_psv_gravity = NULL;
cvar_t* g_psv_aim = NULL;
cvar_t* g_footsteps = NULL;
cvar_t* g_psv_cheats = nullptr;

//CVARS FOR SKILL LEVEL SETTINGS
// Agrunt
cvar_t sk_agrunt_health1 = {"sk_agrunt_health1", "0"};
Expand Down
40 changes: 22 additions & 18 deletions dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,27 @@ void GameDLLShutdown();
extern cvar_t displaysoundlist;

// multiplayer server rules
extern cvar_t teamplay;
extern cvar_t fraglimit;
extern cvar_t timelimit;
extern cvar_t friendlyfire;
extern cvar_t falldamage;
extern cvar_t weaponstay;
extern cvar_t forcerespawn;
extern cvar_t flashlight;
extern cvar_t aimcrosshair;
extern cvar_t decalfrequency;
extern cvar_t teamlist;
extern cvar_t teamoverride;
extern cvar_t defaultteam;
extern cvar_t allowmonsters;
extern cvar_t fragsleft;
extern cvar_t timeleft;
extern cvar_t teamplay;
extern cvar_t fraglimit;
extern cvar_t timelimit;
extern cvar_t friendlyfire;
extern cvar_t falldamage;
extern cvar_t weaponstay;
extern cvar_t forcerespawn;
extern cvar_t flashlight;
extern cvar_t aimcrosshair;
extern cvar_t decalfrequency;
extern cvar_t teamlist;
extern cvar_t teamoverride;
extern cvar_t defaultteam;
extern cvar_t allowmonsters;
extern cvar_t allow_spectators;
extern cvar_t mp_chattime;

// Engine Cvars
extern cvar_t *g_psv_gravity;
extern cvar_t *g_psv_aim;
extern cvar_t *g_footsteps;
extern cvar_t* g_psv_cheats;
inline cvar_t* g_psv_gravity;
inline cvar_t* g_psv_aim;
inline cvar_t* g_footsteps;
inline cvar_t* g_psv_cheats;
5 changes: 0 additions & 5 deletions dlls/gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@

extern edict_t* EntSelectSpawnPoint(CBaseEntity* pPlayer);

DLL_GLOBAL CGameRules* g_pGameRules = NULL;
extern DLL_GLOBAL bool g_fGameOver;

bool g_teamplay = false;

//=========================================================
//=========================================================
bool CGameRules::CanHaveAmmo(CBasePlayer* pPlayer, const char* pszAmmoName, int iMaxCarry)
Expand Down
Loading

0 comments on commit 36164aa

Please sign in to comment.