Rename CWorld::Instance to CWorld::World to avoid conflicting with CBaseEntity::Instance function name

This commit is contained in:
Sam V 2023-02-02 13:17:24 +01:00
parent a370af08e6
commit 9c4af83c7d
7 changed files with 23 additions and 22 deletions

View file

@ -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

View file

@ -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));
}

View file

@ -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);

View file

@ -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;

View file

@ -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;

View file

@ -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;

View file

@ -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;