From 9c4af83c7decbe8687d47fc59a03752ad93bbfe0 Mon Sep 17 00:00:00 2001 From: Sam V Date: Thu, 2 Feb 2023 13:17:24 +0100 Subject: [PATCH] Rename CWorld::Instance to CWorld::World to avoid conflicting with CBaseEntity::Instance function name --- CHANGELOG.md | 1 + dlls/cbase.h | 6 +++--- dlls/gauss.cpp | 2 +- dlls/player.cpp | 14 +++++++------- dlls/sound.cpp | 8 ++++---- dlls/teamplay_gamerules.cpp | 4 ++-- dlls/world.cpp | 10 +++++----- 7 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0970b9..7e1770a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * Fixed NPCs not being able to speak scripted sentences while in scripted death [#180](https://github.com/SamVanheer/halflife-updated/issues/180) (Thanks λλλλλλ) * Removed unnecessary semicolons (Thanks Shepard) * Updated source file encoding to UTF-8 [#183](https://github.com/SamVanheer/halflife-updated/issues/183) (Thanks anchurcn) +* Renamed `CWorld::Instance` to `CWorld::World` to avoid conflicting with `CBaseEntity::Instance` function name ## Changes in V1.0.0 Beta 013 diff --git a/dlls/cbase.h b/dlls/cbase.h index 37c3cb6..0c2c241 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -748,7 +748,7 @@ public: void Precache() override; bool KeyValue(KeyValueData* pkvd) override; - static inline CWorld* Instance = nullptr; + static inline CWorld* World = nullptr; }; inline DLL_GLOBAL edict_t* g_pBodyQueueHead = nullptr; @@ -756,14 +756,14 @@ inline DLL_GLOBAL edict_t* g_pBodyQueueHead = nullptr; inline CBaseEntity* CBaseEntity::Instance(edict_t* pent) { if (!pent) - return CWorld::Instance; + return CWorld::World; return (CBaseEntity*)GET_PRIVATE(pent); } inline CBaseEntity* CBaseEntity::Instance(entvars_t* pev) { if (!pev) - return CWorld::Instance; + return CWorld::World; return Instance(ENT(pev)); } diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 441d7ae..18da1e8 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -263,7 +263,7 @@ void CGauss::SecondaryAttack() SendStopEvent(false); #ifndef CLIENT_DLL - m_pPlayer->TakeDamage(CWorld::Instance->pev, CWorld::Instance->pev, 50, DMG_SHOCK); + m_pPlayer->TakeDamage(CWorld::World->pev, CWorld::World->pev, 50, DMG_SHOCK); UTIL_ScreenFade(m_pPlayer, Vector(255, 128, 0), 2, 0.5, 128, FFADE_IN); #endif SendWeaponAnim(GAUSS_IDLE); diff --git a/dlls/player.cpp b/dlls/player.cpp index 0755d3f..2897d2a 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1096,7 +1096,7 @@ void CBasePlayer::WaterMove() pev->dmg += 1; if (pev->dmg > 5) pev->dmg = 5; - TakeDamage(CWorld::Instance->pev, CWorld::Instance->pev, pev->dmg, DMG_DROWN); + TakeDamage(CWorld::World->pev, CWorld::World->pev, pev->dmg, DMG_DROWN); pev->pain_finished = gpGlobals->time + 1; // track drowning damage, give it back when @@ -1148,12 +1148,12 @@ void CBasePlayer::WaterMove() if (pev->watertype == CONTENT_LAVA) // do damage { if (pev->dmgtime < gpGlobals->time) - TakeDamage(CWorld::Instance->pev, CWorld::Instance->pev, 10 * pev->waterlevel, DMG_BURN); + TakeDamage(CWorld::World->pev, CWorld::World->pev, 10 * pev->waterlevel, DMG_BURN); } else if (pev->watertype == CONTENT_SLIME) // do damage { pev->dmgtime = gpGlobals->time + 1; - TakeDamage(CWorld::Instance->pev, CWorld::Instance->pev, 4 * pev->waterlevel, DMG_ACID); + TakeDamage(CWorld::World->pev, CWorld::World->pev, 4 * pev->waterlevel, DMG_ACID); } if (!FBitSet(pev->flags, FL_INWATER)) @@ -2548,7 +2548,7 @@ void CBasePlayer::PostThink() if (flFallDamage > 0) { - TakeDamage(CWorld::Instance->pev, CWorld::Instance->pev, flFallDamage, DMG_FALL); + TakeDamage(CWorld::World->pev, CWorld::World->pev, flFallDamage, DMG_FALL); pev->punchangle.x = 0; } } @@ -2740,7 +2740,7 @@ edict_t* EntSelectSpawnPoint(CBaseEntity* pPlayer) { // if ent is a client, kill em (unless they are ourselves) if (ent->IsPlayer() && !(ent->edict() == player)) - ent->TakeDamage(CWorld::Instance->pev, CWorld::Instance->pev, 300, DMG_GENERIC); + ent->TakeDamage(CWorld::World->pev, CWorld::World->pev, 300, DMG_GENERIC); } goto ReturnSpot; } @@ -2764,7 +2764,7 @@ ReturnSpot: if (FNullEnt(pSpot)) { ALERT(at_error, "PutClientInServer: no info_player_start on level"); - return CWorld::Instance->edict(); + return CWorld::World->edict(); } g_pLastSpawn = pSpot; @@ -3554,7 +3554,7 @@ void CBasePlayer::CheatImpulseCommands(int iImpulse) { TraceResult tr; - edict_t* pWorld = CWorld::Instance->edict(); + edict_t* pWorld = CWorld::World->edict(); Vector start = pev->origin + pev->view_ofs; Vector end = start + gpGlobals->v_forward * 1024; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 3bfc680..134f750 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1677,7 +1677,7 @@ float TEXTURETYPE_PlaySound(TraceResult* ptr, Vector vecSrc, Vector vecEnd, int if (pEntity) pTextureName = TRACE_TEXTURE(ENT(pEntity->pev), rgfl1, rgfl2); else - pTextureName = TRACE_TEXTURE(CWorld::Instance->edict(), rgfl1, rgfl2); + pTextureName = TRACE_TEXTURE(CWorld::World->edict(), rgfl1, rgfl2); if (pTextureName) { @@ -1804,10 +1804,10 @@ float TEXTURETYPE_PlaySound(TraceResult* ptr, Vector vecSrc, Vector vecEnd, int switch (RANDOM_LONG(0, 1)) { case 0: - UTIL_EmitAmbientSound(CWorld::Instance->edict(), ptr->vecEndPos, "buttons/spark5.wav", flVolume, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound(CWorld::World->edict(), ptr->vecEndPos, "buttons/spark5.wav", flVolume, ATTN_NORM, 0, 100); break; case 1: - UTIL_EmitAmbientSound(CWorld::Instance->edict(), ptr->vecEndPos, "buttons/spark6.wav", flVolume, ATTN_NORM, 0, 100); + UTIL_EmitAmbientSound(CWorld::World->edict(), ptr->vecEndPos, "buttons/spark6.wav", flVolume, ATTN_NORM, 0, 100); break; // case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark5.wav", flVolume, ATTN_NORM); break; // case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "buttons/spark6.wav", flVolume, ATTN_NORM); break; @@ -1816,7 +1816,7 @@ float TEXTURETYPE_PlaySound(TraceResult* ptr, Vector vecSrc, Vector vecEnd, int } // play material hit sound - UTIL_EmitAmbientSound(CWorld::Instance->edict(), ptr->vecEndPos, rgsz[RANDOM_LONG(0, cnt - 1)], fvol, fattn, 0, 96 + RANDOM_LONG(0, 0xf)); + UTIL_EmitAmbientSound(CWorld::World->edict(), ptr->vecEndPos, rgsz[RANDOM_LONG(0, cnt - 1)], fvol, fattn, 0, 96 + RANDOM_LONG(0, 0xf)); //EMIT_SOUND_DYN( ENT(m_pPlayer->pev), CHAN_WEAPON, rgsz[RANDOM_LONG(0,cnt-1)], fvol, ATTN_NORM, 0, 96 + RANDOM_LONG(0,0xf)); return fvolbar; diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 484c85b..19d99af 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -45,7 +45,7 @@ CHalfLifeTeamplay::CHalfLifeTeamplay() // Cache this because the team code doesn't want to deal with changing this in the middle of a game strncpy(m_szTeamList, teamlist.string, TEAMPLAY_TEAMLISTLENGTH); - edict_t* pWorld = CWorld::Instance->edict(); + edict_t* pWorld = CWorld::World->edict(); if (pWorld && !FStringNull(pWorld->v.team)) { if (0 != teamoverride.value) @@ -270,7 +270,7 @@ void CHalfLifeTeamplay::ChangePlayerTeam(CBasePlayer* pPlayer, const char* pTeam m_DisableDeathMessages = true; m_DisableDeathPenalty = true; - pPlayer->TakeDamage(CWorld::Instance->pev, CWorld::Instance->pev, 900, damageFlags); + pPlayer->TakeDamage(CWorld::World->pev, CWorld::World->pev, 900, damageFlags); m_DisableDeathMessages = false; m_DisableDeathPenalty = false; diff --git a/dlls/world.cpp b/dlls/world.cpp index 92cf721..3a5dfd4 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -474,23 +474,23 @@ LINK_ENTITY_TO_CLASS(worldspawn, CWorld); CWorld::CWorld() { - if (Instance) + if (World) { ALERT(at_error, "Do not create multiple instances of worldspawn\n"); return; } - Instance = this; + World = this; } CWorld::~CWorld() { - if (Instance != this) + if (World != this) { return; } - Instance = nullptr; + World = nullptr; } void CWorld::Spawn() @@ -502,7 +502,7 @@ void CWorld::Spawn() void CWorld::Precache() { // Flag this entity for removal if it's not the actual world entity. - if (Instance != this) + if (World != this) { UTIL_Remove(this); return;