From 36164aa507c67db7696cb05acd598684bdc84ce1 Mon Sep 17 00:00:00 2001 From: Sam V Date: Sun, 28 Nov 2021 20:40:56 +0100 Subject: [PATCH] Remove unused globals and duplicate global variable forward declarations (cherry picked from commit 9ca8e6a47a03cfe6880cb9d6502836faeaaa4edf) --- cl_dll/hl/hl_baseentity.cpp | 9 ---- cl_dll/hl/hl_weapons.cpp | 1 - dlls/UserMessages.cpp | 40 -------------- dlls/UserMessages.h | 78 +++++++++++++-------------- dlls/animation.cpp | 2 - dlls/apache.cpp | 2 - dlls/bmodels.cpp | 2 - dlls/cbase.cpp | 7 +-- dlls/cbase.h | 8 +++ dlls/client.cpp | 10 +--- dlls/combat.cpp | 4 -- dlls/enginecallback.h | 3 +- dlls/explode.cpp | 1 + dlls/explode.h | 4 -- dlls/flyingmonster.cpp | 3 -- dlls/func_break.cpp | 3 +- dlls/game.cpp | 6 --- dlls/game.h | 40 +++++++------- dlls/gamerules.cpp | 5 -- dlls/gamerules.h | 7 ++- dlls/globals.cpp | 38 ------------- dlls/h_ai.cpp | 2 - dlls/h_export.cpp | 4 -- dlls/hassassin.cpp | 2 - dlls/hgrunt.cpp | 2 - dlls/islave.cpp | 2 - dlls/items.cpp | 2 - dlls/monsters.cpp | 4 -- dlls/monsters.h | 13 +++-- dlls/multiplay_gamerules.cpp | 19 ++----- dlls/nodes.cpp | 3 -- dlls/player.cpp | 17 +----- dlls/player.h | 12 ++++- dlls/singleplay_gamerules.cpp | 3 -- dlls/skill.cpp | 4 -- dlls/skill.h | 4 +- dlls/soundent.cpp | 2 - dlls/soundent.h | 2 + dlls/subs.cpp | 2 - dlls/teamplay_gamerules.cpp | 5 +- dlls/triggers.cpp | 2 - dlls/util.cpp | 6 --- dlls/util.h | 8 +-- dlls/weapons.cpp | 18 ------- dlls/weapons.h | 26 ++++----- dlls/weapons_shared.cpp | 2 - dlls/world.cpp | 12 +---- projects/vs2017/hldll.vcxproj | 1 - projects/vs2017/hldll.vcxproj.filters | 3 -- projects/vs2019/hldll.vcxproj | 1 - projects/vs2019/hldll.vcxproj.filters | 3 -- 51 files changed, 126 insertions(+), 333 deletions(-) delete mode 100644 dlls/globals.cpp diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 518c58e57..d8cf1f15e 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -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 @@ -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; } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index a311a956f..a65745427 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -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 diff --git a/dlls/UserMessages.cpp b/dlls/UserMessages.cpp index d24c4c159..213ed402d 100644 --- a/dlls/UserMessages.cpp +++ b/dlls/UserMessages.cpp @@ -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? diff --git a/dlls/UserMessages.h b/dlls/UserMessages.h index 7480599fe..608f82ad1 100644 --- a/dlls/UserMessages.h +++ b/dlls/UserMessages.h @@ -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(); diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 78cc1f2b7..84ca338de 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -22,8 +22,6 @@ #include "animation.h" #include "scriptevent.h" -extern globalvars_t* gpGlobals; - #pragma warning(disable : 4244) diff --git a/dlls/apache.cpp b/dlls/apache.cpp index e806f806b..678cd0e56 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -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 diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index f00a49cda..952b76fa8 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -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. diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index fcf1a7eae..c229a1911 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -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" @@ -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 = { @@ -226,10 +225,6 @@ void DispatchKeyValue(edict_t* pentKeyvalue, KeyValueData* pkvd) pkvd->fHandled = static_cast(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) diff --git a/dlls/cbase.h b/dlls/cbase.h index 64943c86c..384add2cc 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -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); @@ -941,3 +947,5 @@ class CWorld : public CBaseEntity }; extern CWorld* g_pWorld; + +inline DLL_GLOBAL edict_t* g_pBodyQueueHead = nullptr; diff --git a/dlls/client.cpp b/dlls/client.cpp index edcf7885d..cd6bad5bd 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -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(); diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 710c07bf0..dfff98d4c 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -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 diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index ad572cbef..452e8968d 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -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) diff --git a/dlls/explode.cpp b/dlls/explode.cpp index 658f23b19..5e8c16eb6 100644 --- a/dlls/explode.cpp +++ b/dlls/explode.cpp @@ -25,6 +25,7 @@ #include "decals.h" #include "explode.h" #include "locus.h" +#include "weapons.h" // Spark Shower class CShower : public CBaseEntity diff --git a/dlls/explode.h b/dlls/explode.h index b60b350f9..59a45709f 100644 --- a/dlls/explode.h +++ b/dlls/explode.h @@ -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); diff --git a/dlls/flyingmonster.cpp b/dlls/flyingmonster.cpp index 6f5c333bf..8df3b9bc7 100644 --- a/dlls/flyingmonster.cpp +++ b/dlls/flyingmonster.cpp @@ -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 diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 907fed072..949ff87e8 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -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 diff --git a/dlls/game.cpp b/dlls/game.cpp index d9f435400..0dc0a2222 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -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"}; diff --git a/dlls/game.h b/dlls/game.h index c59fd099c..f2b8e6ba2 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -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; diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index afbb4b68d..e4d23eea0 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -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) diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 8ee43c7a1..dda85c098 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -358,9 +358,12 @@ class CHalfLifeMultiplay : public CGameRules protected: virtual void ChangeLevel(); virtual void GoToIntermission(); - float m_flIntermissionEndTime; + float m_flIntermissionStartTime = 0; + float m_flIntermissionEndTime = 0; bool m_iEndIntermissionButtonHit; void SendMOTDToClient(edict_t* client); }; -extern DLL_GLOBAL CGameRules* g_pGameRules; +inline DLL_GLOBAL CGameRules* g_pGameRules = nullptr; +inline DLL_GLOBAL bool g_fGameOver; +inline bool g_teamplay = false; diff --git a/dlls/globals.cpp b/dlls/globals.cpp deleted file mode 100644 index 2da302f38..000000000 --- a/dlls/globals.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -/* - -===== globals.cpp ======================================================== - - DLL-wide global variable definitions. - They're all defined here, for convenient centralization. - Source files that need them should "extern ..." declare each - variable, to better document what globals they care about. - -*/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "soundent.h" - -DLL_GLOBAL unsigned int g_ulFrameCount; -DLL_GLOBAL unsigned int g_ulModelIndexEyes; -DLL_GLOBAL unsigned int g_ulModelIndexPlayer; -DLL_GLOBAL Vector g_vecAttackDir; -DLL_GLOBAL int g_iSkillLevel; -DLL_GLOBAL bool gDisplayTitle; -DLL_GLOBAL bool g_fGameOver; -DLL_GLOBAL int g_Language; diff --git a/dlls/h_ai.cpp b/dlls/h_ai.cpp index c7d705978..12c565172 100644 --- a/dlls/h_ai.cpp +++ b/dlls/h_ai.cpp @@ -30,8 +30,6 @@ //float flRandom = RANDOM_FLOAT(0,1); -DLL_GLOBAL bool g_fDrawLines = false; - //========================================================= // // AI UTILITY FUNCTIONS diff --git a/dlls/h_export.cpp b/dlls/h_export.cpp index 29fef03f3..48b5ad17b 100644 --- a/dlls/h_export.cpp +++ b/dlls/h_export.cpp @@ -25,10 +25,6 @@ #include "cbase.h" -// Holds engine functionality callbacks -enginefuncs_t g_engfuncs; -globalvars_t* gpGlobals; - #undef DLLEXPORT #ifdef WIN32 #define DLLEXPORT __stdcall diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index 1eb8778c1..105272254 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -28,8 +28,6 @@ #include "scripted.h" #include "game.h" -extern DLL_GLOBAL int g_iSkillLevel; - //========================================================= // monster-specific schedule types //========================================================= diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index ca1d34537..f41d72408 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -45,8 +45,6 @@ int g_fGruntQuestion; // true if an idle grunt asked a question. Cleared when someone answers. -extern DLL_GLOBAL int g_iSkillLevel; - //========================================================= // monster-specific DEFINE's //========================================================= diff --git a/dlls/islave.cpp b/dlls/islave.cpp index c9c088315..9e6d9c535 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -26,8 +26,6 @@ #include "weapons.h" #include "soundent.h" -extern DLL_GLOBAL int g_iSkillLevel; - //========================================================= // Monster's Anim Events Go Here //========================================================= diff --git a/dlls/items.cpp b/dlls/items.cpp index 1096e9b1e..e4279d285 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -102,8 +102,6 @@ void CItem::Spawn() } } -extern bool gEvilImpulse101; - void CItem::ItemTouch(CBaseEntity* pOther) { // if it's not a player, ignore diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index 75001624f..2f4bf0036 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -39,10 +39,6 @@ Vector VecBModelOrigin(entvars_t* pevBModel); -extern DLL_GLOBAL bool g_fDrawLines; -extern DLL_GLOBAL short g_sModelIndexLaser; // holds the index for the laser beam -extern DLL_GLOBAL short g_sModelIndexLaserDot; // holds the index for the laser beam dot - // Global Savedata for monster // UNDONE: Save schedule data? Can this be done? We may // lose our enemy pointer or other data (goal ent, target, etc) diff --git a/dlls/monsters.h b/dlls/monsters.h index a4484d368..eb9de19a6 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -74,15 +74,20 @@ #define MOVE_NORMAL 0 // normal move in the direction monster is facing #define MOVE_STRAFE 1 // moves in direction specified, no matter which way monster is facing +inline DLL_GLOBAL Vector g_vecAttackDir; + +/** +* @brief Set in combat.cpp. Used to pass the damage inflictor for death messages. +* Better solution: Add as parameter to all Killed() functions. +*/ +inline entvars_t* g_pevLastInflictor = nullptr; +inline DLL_GLOBAL bool g_fDrawLines = false; + // spawn flags 256 and above are already taken by the engine extern void UTIL_MoveToOrigin(edict_t* pent, const Vector& vecGoal, float flDist, int iMoveType); Vector VecCheckToss(entvars_t* pev, const Vector& vecSpot1, Vector vecSpot2, float flGravityAdj = 1.0); Vector VecCheckThrow(entvars_t* pev, const Vector& vecSpot1, Vector vecSpot2, float flSpeed, float flGravityAdj = 1.0); -extern DLL_GLOBAL Vector g_vecAttackDir; -extern DLL_GLOBAL CONSTANT float g_flMeleeRange; -extern DLL_GLOBAL CONSTANT float g_flMediumRange; -extern DLL_GLOBAL CONSTANT float g_flLongRange; extern void EjectBrass(const Vector& vecOrigin, const Vector& vecVelocity, float rotation, int model, int soundtype); extern void ExplodeModel(const Vector& vecOrigin, float speed, int model, int count); diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 1fe06ba91..122ae7561 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -29,17 +29,10 @@ #include "hltv.h" #include "UserMessages.h" -extern DLL_GLOBAL CGameRules* g_pGameRules; -extern DLL_GLOBAL bool g_fGameOver; - -extern bool g_teamplay; - #define ITEM_RESPAWN_TIME 30 #define WEAPON_RESPAWN_TIME 20 #define AMMO_RESPAWN_TIME 20 -float g_flIntermissionStartTime = 0; - CVoiceGameMgr g_VoiceGameMgr; class CMultiplayGameMgrHelper : public IVoiceGameMgrHelper @@ -69,8 +62,6 @@ CHalfLifeMultiplay ::CHalfLifeMultiplay() g_VoiceGameMgr.Init(&g_GameMgrHelper, gpGlobals->maxClients); RefreshSkillData(); - m_flIntermissionEndTime = 0; - g_flIntermissionStartTime = 0; // 11/8/98 // Modified by YWB: Server .cfg file is now a cvar, so that @@ -170,10 +161,6 @@ void CHalfLifeMultiplay::RefreshSkillData() // longest the intermission can last, in seconds #define MAX_INTERMISSION_TIME 120 -extern cvar_t timeleft, fragsleft; - -extern cvar_t mp_chattime; - //========================================================= //========================================================= void CHalfLifeMultiplay ::Think() @@ -196,13 +183,13 @@ void CHalfLifeMultiplay ::Think() else if (time > MAX_INTERMISSION_TIME) CVAR_SET_STRING("mp_chattime", UTIL_dtos1(MAX_INTERMISSION_TIME)); - m_flIntermissionEndTime = g_flIntermissionStartTime + mp_chattime.value; + m_flIntermissionEndTime = m_flIntermissionStartTime + mp_chattime.value; // check to see if we should change levels now if (m_flIntermissionEndTime < gpGlobals->time) { if (m_iEndIntermissionButtonHit // check that someone has pressed a key, or the max intermission time is over - || ((g_flIntermissionStartTime + MAX_INTERMISSION_TIME) < gpGlobals->time)) + || ((m_flIntermissionStartTime + MAX_INTERMISSION_TIME) < gpGlobals->time)) ChangeLevel(); // intermission is over } @@ -1158,7 +1145,7 @@ void CHalfLifeMultiplay ::GoToIntermission() CVAR_SET_STRING("mp_chattime", UTIL_dtos1(MAX_INTERMISSION_TIME)); m_flIntermissionEndTime = gpGlobals->time + ((int)mp_chattime.value); - g_flIntermissionStartTime = gpGlobals->time; + m_flIntermissionStartTime = gpGlobals->time; g_fGameOver = true; m_iEndIntermissionButtonHit = false; diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index 9a5fbad9b..5e18a9cfe 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -37,8 +37,6 @@ #define MAX_NODE_INITIAL_LINKS 128 #define MAX_NODES 1024 -extern DLL_GLOBAL edict_t* g_pBodyQueueHead; - Vector VecBModelOrigin(entvars_t* pevBModel); CGraph WorldGraph; @@ -1615,7 +1613,6 @@ void CTestHull ::ShowBadNode() SetNextThink(0.1); } -extern bool gTouchDisabled; void CTestHull::CallBuildNodeGraph() { // TOUCH HACK -- Don't allow this entity to call anyone's "touch" function diff --git a/dlls/player.cpp b/dlls/player.cpp index 2c55c5a72..dcecc9f0e 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -45,16 +45,7 @@ // #define DUCKFIX -extern DLL_GLOBAL unsigned int g_ulModelIndexPlayer; -extern DLL_GLOBAL bool g_fGameOver; -extern DLL_GLOBAL bool g_fDrawLines; -bool gEvilImpulse101; bool g_markFrameBounds = false; //LRC -extern DLL_GLOBAL int g_iSkillLevel; -extern DLL_GLOBAL bool gDisplayTitle; - - -bool gInitHUD = true; extern void CopyToBodyQue(entvars_t* pev); extern edict_t* EntSelectSpawnPoint(CBaseEntity* pPlayer); @@ -162,9 +153,6 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = }; - -bool giPrecacheGrunt = false; - LINK_ENTITY_TO_CLASS(player, CBasePlayer); @@ -916,8 +904,6 @@ void CBasePlayer::RemoveItems(int iWeaponMask, int i9mm, int i357, int iBuck, in * * ENTITY_METHOD(PlayerDie) */ -entvars_t* g_pevLastInflictor; // Set in combat.cpp. Used to pass the damage inflictor for death messages. - // Better solution: Add as parameter to all Killed() functions. void CBasePlayer::Killed(entvars_t* pevAttacker, int iGib) { @@ -2854,8 +2840,6 @@ bool IsSpawnPointValid(CBaseEntity* pPlayer, CBaseEntity* pSpot) return true; } - -DLL_GLOBAL CBaseEntity* g_pLastSpawn; //LRC- moved to cbase.h //inline int FNullEnt( CBaseEntity *ent ) { return (ent == NULL) || FNullEnt( ent->edict() ); } @@ -4116,6 +4100,7 @@ void CBasePlayer ::UpdateClientData() } // HACKHACK -- send the message to display the game title + //TODO: will not work properly in multiplayer if (gDisplayTitle) { MESSAGE_BEGIN(MSG_ONE, gmsgShowGameTitle, NULL, pev); diff --git a/dlls/player.h b/dlls/player.h index acc05bacf..3ba1d7f7d 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -350,5 +350,13 @@ class CBasePlayer : public CBaseMonster #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 - -extern bool gInitHUD; +inline bool gInitHUD = true; +inline bool gEvilImpulse101 = false; +inline bool giPrecacheGrunt = false; + +/** +* @brief Display the game title if this key is set +*/ +inline DLL_GLOBAL bool gDisplayTitle = false; +inline DLL_GLOBAL unsigned int g_ulModelIndexPlayer = 0; +inline DLL_GLOBAL CBaseEntity* g_pLastSpawn = nullptr; diff --git a/dlls/singleplay_gamerules.cpp b/dlls/singleplay_gamerules.cpp index 9984aef10..8ddb8bdb3 100644 --- a/dlls/singleplay_gamerules.cpp +++ b/dlls/singleplay_gamerules.cpp @@ -25,9 +25,6 @@ #include "items.h" #include "UserMessages.h" -extern DLL_GLOBAL CGameRules* g_pGameRules; -extern DLL_GLOBAL bool g_fGameOver; - //========================================================= //========================================================= CHalfLifeRules::CHalfLifeRules() diff --git a/dlls/skill.cpp b/dlls/skill.cpp index a57b747a7..053a4c619 100644 --- a/dlls/skill.cpp +++ b/dlls/skill.cpp @@ -19,10 +19,6 @@ #include "util.h" #include "skill.h" - -skilldata_t gSkillData; - - //========================================================= // take the name of a cvar, tack a digit for the skill level // on, and return the value.of that Cvar diff --git a/dlls/skill.h b/dlls/skill.h index de35072f1..02814afd9 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -139,10 +139,10 @@ struct skilldata_t float plrArm; }; -extern DLL_GLOBAL skilldata_t gSkillData; +inline DLL_GLOBAL skilldata_t gSkillData; float GetSkillCvar(const char* pName); -extern DLL_GLOBAL int g_iSkillLevel; +inline DLL_GLOBAL int g_iSkillLevel; #define SKILL_EASY 1 #define SKILL_MEDIUM 2 diff --git a/dlls/soundent.cpp b/dlls/soundent.cpp index 365ff7c8c..733233585 100644 --- a/dlls/soundent.cpp +++ b/dlls/soundent.cpp @@ -21,8 +21,6 @@ LINK_ENTITY_TO_CLASS(soundent, CSoundEnt); -CSoundEnt* pSoundEnt; - //========================================================= // CSound - Clear - zeros all fields for a sound //========================================================= diff --git a/dlls/soundent.h b/dlls/soundent.h index 0528d5ea1..9a84c34a7 100644 --- a/dlls/soundent.h +++ b/dlls/soundent.h @@ -94,3 +94,5 @@ class CSoundEnt : public CBaseEntity private: CSound m_SoundPool[MAX_WORLD_SOUNDS]; }; + +inline CSoundEnt* pSoundEnt; diff --git a/dlls/subs.cpp b/dlls/subs.cpp index fb2101c70..1d6e1c665 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -31,8 +31,6 @@ extern bool FEntIsVisible(entvars_t* pev, entvars_t* pevTarget); -extern DLL_GLOBAL int g_iSkillLevel; - // Landmark class void CPointEntity ::Spawn() { diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 582312b1a..d9400703a 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -25,12 +25,11 @@ #include "game.h" #include "UserMessages.h" +//TODO: these should be members of CHalfLifeTeamplay static char team_names[MAX_TEAMS][MAX_TEAMNAME_LENGTH]; static int team_scores[MAX_TEAMS]; static int num_teams = 0; -extern DLL_GLOBAL bool g_fGameOver; - CHalfLifeTeamplay ::CHalfLifeTeamplay() { m_DisableDeathMessages = false; @@ -67,8 +66,6 @@ CHalfLifeTeamplay ::CHalfLifeTeamplay() RecountTeams(); } -extern cvar_t timeleft, fragsleft; - #include "voice_gamemgr.h" extern CVoiceGameMgr g_VoiceGameMgr; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 682c63a36..453d7b226 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -43,8 +43,6 @@ #define SF_TRIGGER_HURT_CLIENTONLYFIRE 16 // trigger hurt will only fire its target if it is hurting a client #define SF_TRIGGER_HURT_CLIENTONLYTOUCH 32 // only clients may touch this trigger. -extern DLL_GLOBAL bool g_fGameOver; - extern void SetMovedir(entvars_t* pev); extern Vector VecBModelOrigin(entvars_t* pevBModel); diff --git a/dlls/util.cpp b/dlls/util.cpp index 18e85ed88..b52733e5e 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -173,9 +173,6 @@ void UTIL_ParametricRocket(entvars_t* pev, Vector vecOrigin, Vector vecAngles, e pev->impacttime = gpGlobals->time + travelTime; } -int g_groupmask = 0; -int g_groupop = 0; - // Normal overrides void UTIL_SetGroupTrace(int groupmask, int op) { @@ -1911,9 +1908,6 @@ float UTIL_WaterLevel(const Vector& position, float minz, float maxz) return midUp.z; } - -extern DLL_GLOBAL short g_sModelIndexBubbles; // holds the index for the bubbles model - void UTIL_Bubbles(Vector mins, Vector maxs, int count) { Vector mid = (mins + maxs) * 0.5; diff --git a/dlls/util.h b/dlls/util.h index 1ff42f217..35766973c 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -25,7 +25,7 @@ inline void MESSAGE_BEGIN(int msg_dest, int msg_type, const float* pOrigin, entvars_t* ent); // implementation later in this file -extern globalvars_t* gpGlobals; +inline globalvars_t* gpGlobals = nullptr; // Use this instead of ALLOC_STRING on constant strings #define STRING(offset) ((const char*)(gpGlobals->pStringBase + (unsigned int)(offset))) @@ -417,7 +417,7 @@ void DBG_AssertFunction(bool fExpr, const char* szExpr, const char* szFile, int #define LANGUAGE_FRENCH 2 #define LANGUAGE_BRITISH 3 -extern DLL_GLOBAL int g_Language; +inline DLL_GLOBAL int g_Language; #define AMBIENT_SOUND_STATIC 0 // medium radius attenuation #define AMBIENT_SOUND_EVERYWHERE 1 @@ -562,8 +562,8 @@ void EMIT_GROUPNAME_SUIT(edict_t* entity, const char* groupname); #define GROUP_OP_AND 0 #define GROUP_OP_NAND 1 -extern int g_groupmask; -extern int g_groupop; +inline int g_groupmask = 0; +inline int g_groupop = 0; class UTIL_GroupTrace { diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 72da87d67..aa4825093 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -31,26 +31,8 @@ #include "gamerules.h" #include "UserMessages.h" -extern bool gEvilImpulse101; - - #define NOT_USED 255 -DLL_GLOBAL short g_sModelIndexLaser; // holds the index for the laser beam -DLL_GLOBAL const char* g_pModelNameLaser = "sprites/laserbeam.spr"; -DLL_GLOBAL short g_sModelIndexLaserDot; // holds the index for the laser beam dot -DLL_GLOBAL short g_sModelIndexFireball; // holds the index for the fireball -DLL_GLOBAL short g_sModelIndexSmoke; // holds the index for the smoke cloud -DLL_GLOBAL short g_sModelIndexWExplosion; // holds the index for the underwater explosion -DLL_GLOBAL short g_sModelIndexBubbles; // holds the index for the bubbles model -DLL_GLOBAL short g_sModelIndexBloodDrop; // holds the sprite index for the initial blood -DLL_GLOBAL short g_sModelIndexBloodSpray; // holds the sprite index for splattered blood - -ItemInfo CBasePlayerItem::ItemInfoArray[MAX_WEAPONS]; -AmmoInfo CBasePlayerItem::AmmoInfoArray[MAX_AMMO_SLOTS]; - -MULTIDAMAGE gMultiDamage; - #define TRACER_FREQ 4 // Tracers fire every fourth bullet diff --git a/dlls/weapons.h b/dlls/weapons.h index 1a6698f74..822b33215 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -218,7 +218,7 @@ typedef struct int iId; } AmmoInfo; -extern int giAmmoIndex; +inline int giAmmoIndex = 0; void AddAmmoNameToAmmoRegistry(const char* szAmmoname); @@ -268,8 +268,8 @@ class CBasePlayerItem : public CBaseAnimating virtual CBasePlayerItem* GetWeaponPtr() { return NULL; } - static ItemInfo ItemInfoArray[MAX_WEAPONS]; - static AmmoInfo AmmoInfoArray[MAX_AMMO_SLOTS]; + static inline ItemInfo ItemInfoArray[MAX_WEAPONS]; + static inline AmmoInfo AmmoInfoArray[MAX_AMMO_SLOTS]; CBasePlayer* m_pPlayer; CBasePlayerItem* m_pNext; @@ -390,16 +390,16 @@ class CBasePlayerAmmo : public CBaseEntity }; -extern DLL_GLOBAL short g_sModelIndexLaser; // holds the index for the laser beam -extern DLL_GLOBAL const char* g_pModelNameLaser; +inline DLL_GLOBAL short g_sModelIndexLaser; // holds the index for the laser beam +constexpr DLL_GLOBAL const char* g_pModelNameLaser = "sprites/laserbeam.spr"; -extern DLL_GLOBAL short g_sModelIndexLaserDot; // holds the index for the laser beam dot -extern DLL_GLOBAL short g_sModelIndexFireball; // holds the index for the fireball -extern DLL_GLOBAL short g_sModelIndexSmoke; // holds the index for the smoke cloud -extern DLL_GLOBAL short g_sModelIndexWExplosion; // holds the index for the underwater explosion -extern DLL_GLOBAL short g_sModelIndexBubbles; // holds the index for the bubbles model -extern DLL_GLOBAL short g_sModelIndexBloodDrop; // holds the sprite index for blood drops -extern DLL_GLOBAL short g_sModelIndexBloodSpray; // holds the sprite index for blood spray (bigger) +inline DLL_GLOBAL short g_sModelIndexLaserDot; // holds the index for the laser beam dot +inline DLL_GLOBAL short g_sModelIndexFireball; // holds the index for the fireball +inline DLL_GLOBAL short g_sModelIndexSmoke; // holds the index for the smoke cloud +inline DLL_GLOBAL short g_sModelIndexWExplosion; // holds the index for the underwater explosion +inline DLL_GLOBAL short g_sModelIndexBubbles; // holds the index for the bubbles model +inline DLL_GLOBAL short g_sModelIndexBloodDrop; // holds the sprite index for blood drops +inline DLL_GLOBAL short g_sModelIndexBloodSpray; // holds the sprite index for blood spray (bigger) extern void ClearMultiDamage(); extern void ApplyMultiDamage(entvars_t* pevInflictor, entvars_t* pevAttacker); @@ -417,7 +417,7 @@ typedef struct int type; } MULTIDAMAGE; -extern MULTIDAMAGE gMultiDamage; +inline MULTIDAMAGE gMultiDamage; #define LOUD_GUN_VOLUME 1000 diff --git a/dlls/weapons_shared.cpp b/dlls/weapons_shared.cpp index f6102a3d4..ae0f137ba 100644 --- a/dlls/weapons_shared.cpp +++ b/dlls/weapons_shared.cpp @@ -19,8 +19,6 @@ #include "weapons.h" #include "gamerules.h" -int giAmmoIndex = 0; - // Precaches the ammo and queues the ammo info for sending to clients void AddAmmoNameToAmmoRegistry(const char* szAmmoname) { diff --git a/dlls/world.cpp b/dlls/world.cpp index 8d5960eaf..203302d8a 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -35,12 +35,7 @@ #include "teamplay_gamerules.h" #include "movewith.h" //LRC -extern CSoundEnt* pSoundEnt; - -extern CBaseEntity* g_pLastSpawn; -DLL_GLOBAL edict_t* g_pBodyQueueHead; CGlobalState gGlobalState; -extern DLL_GLOBAL bool gDisplayTitle; extern void W_Precache(); @@ -469,8 +464,6 @@ LINK_ENTITY_TO_CLASS(worldspawn, CWorld); #define SF_WORLD_FORCETEAM 0x0004 // Force teams //#define SF_WORLD_STARTSUIT 0x0008 // LRC- Start this level with an HEV suit! -extern DLL_GLOBAL bool g_fGameOver; - bool g_startSuit; //LRC void CWorld ::Spawn() @@ -630,10 +623,7 @@ void CWorld ::Precache() else CVAR_SET_FLOAT("v_dark", 0.0); - if ((pev->spawnflags & SF_WORLD_TITLE) != 0) - gDisplayTitle = true; // display the game title if this key is set - else - gDisplayTitle = false; + gDisplayTitle = (pev->spawnflags & SF_WORLD_TITLE) != 0; if ((pev->spawnflags & SF_WORLD_FORCETEAM) != 0) { diff --git a/projects/vs2017/hldll.vcxproj b/projects/vs2017/hldll.vcxproj index 0f3354bc0..6311bc898 100644 --- a/projects/vs2017/hldll.vcxproj +++ b/projects/vs2017/hldll.vcxproj @@ -141,7 +141,6 @@ - diff --git a/projects/vs2017/hldll.vcxproj.filters b/projects/vs2017/hldll.vcxproj.filters index c81c21850..97f98fc05 100644 --- a/projects/vs2017/hldll.vcxproj.filters +++ b/projects/vs2017/hldll.vcxproj.filters @@ -153,9 +153,6 @@ Source Files\dlls - - Source Files\dlls - Source Files\dlls diff --git a/projects/vs2019/hldll.vcxproj b/projects/vs2019/hldll.vcxproj index 5dbeed116..c498516c7 100644 --- a/projects/vs2019/hldll.vcxproj +++ b/projects/vs2019/hldll.vcxproj @@ -146,7 +146,6 @@ EXIT /B 0 - diff --git a/projects/vs2019/hldll.vcxproj.filters b/projects/vs2019/hldll.vcxproj.filters index 41f1cf3b6..56500dc54 100644 --- a/projects/vs2019/hldll.vcxproj.filters +++ b/projects/vs2019/hldll.vcxproj.filters @@ -153,9 +153,6 @@ Source Files\dlls - - Source Files\dlls - Source Files\dlls