Replace virtual UpdateOnRemove to OnDestroy

This commit is contained in:
s1lent 2017-11-02 01:23:23 +07:00
parent 8b31478b83
commit 1411eca4a0
No known key found for this signature in database
GPG Key ID: 0FE401DC73916B5C
9 changed files with 44 additions and 36 deletions

View File

@ -1447,6 +1447,7 @@ void OnFreeEntPrivateData(edict_t *pEnt)
pEntity->OnDestroy(); pEntity->OnDestroy();
#endif #endif
pEntity->UpdateOnRemove();
RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME); RemoveEntityHashValue(pEntity->pev, STRING(pEntity->pev->classname), CLASSNAME);
#ifdef REGAMEDLL_API #ifdef REGAMEDLL_API
@ -1466,10 +1467,11 @@ void OnFreeEntPrivateData(edict_t *pEnt)
#ifdef REGAMEDLL_API #ifdef REGAMEDLL_API
void CBaseEntity::OnCreate() void CBaseEntity::OnCreate()
{ {
;
} }
void CBaseEntity::OnDestroy() void CBaseEntity::OnDestroy()
{ {
UpdateOnRemove(); ;
} }
#endif #endif

View File

@ -2,7 +2,7 @@
CMapInfo *g_pMapInfo = nullptr; CMapInfo *g_pMapInfo = nullptr;
CMapInfo::CMapInfo() void CMapInfo::OnCreate()
{ {
m_flBombRadius = 500.0f; m_flBombRadius = 500.0f;
m_iBuyingStatus = BUYING_EVERYONE; m_iBuyingStatus = BUYING_EVERYONE;
@ -20,6 +20,11 @@ CMapInfo::CMapInfo()
} }
} }
void CMapInfo::OnDestroy()
{
g_pMapInfo = nullptr;
}
void CMapInfo::CheckMapInfo() void CMapInfo::CheckMapInfo()
{ {
bool bCTCantBuy, bTCantBuy; bool bCTCantBuy, bTCantBuy;
@ -85,9 +90,4 @@ void CMapInfo::Spawn()
pev->effects |= EF_NODRAW; pev->effects |= EF_NODRAW;
} }
void CMapInfo::UpdateOnRemove()
{
g_pMapInfo = nullptr;
}
LINK_ENTITY_TO_CLASS(info_map_parameters, CMapInfo, CCSMapInfo) LINK_ENTITY_TO_CLASS(info_map_parameters, CMapInfo, CCSMapInfo)

View File

@ -33,10 +33,11 @@ const float MAX_BOMB_RADIUS = 2048.0f;
class CMapInfo: public CPointEntity class CMapInfo: public CPointEntity
{ {
public: public:
CMapInfo();
virtual void Spawn(); virtual void Spawn();
virtual void OnCreate();
virtual void OnDestroy();
virtual void KeyValue(KeyValueData *pkvd); virtual void KeyValue(KeyValueData *pkvd);
virtual void UpdateOnRemove();
void CheckMapInfo(); void CheckMapInfo();
public: public:

View File

@ -3454,7 +3454,7 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient)
if (pPlayer->m_iMapVote) if (pPlayer->m_iMapVote)
{ {
--m_iMapVotes[pPlayer->m_iMapVote]; m_iMapVotes[pPlayer->m_iMapVote]--;
if (m_iMapVotes[pPlayer->m_iMapVote] < 0) if (m_iMapVotes[pPlayer->m_iMapVote] < 0)
{ {
@ -3493,22 +3493,22 @@ void CHalfLifeMultiplay::ClientDisconnected(edict_t *pClient)
pPlayer->m_pObserver->SUB_Remove(); pPlayer->m_pObserver->SUB_Remove();
} }
CBasePlayer *client = nullptr; CBasePlayer *pClient = nullptr;
while ((client = (CBasePlayer *)UTIL_FindEntityByClassname(client, "player"))) while ((pClient = UTIL_FindEntityByClassname(pClient, "player")))
{ {
if (FNullEnt(client->edict())) if (FNullEnt(pClient->edict()))
break; break;
if (!client->pev || client == pPlayer) if (!pClient->pev || pClient == pPlayer)
continue; continue;
// If a spectator was chasing this player, move him/her onto the next player // If a spectator was chasing this player, move him/her onto the next player
if (client->m_hObserverTarget == pPlayer) if (pClient->m_hObserverTarget == pPlayer)
{ {
int iMode = client->pev->iuser1; int iMode = pClient->pev->iuser1;
client->pev->iuser1 = OBS_NONE; pClient->pev->iuser1 = OBS_NONE;
client->Observer_SetMode(iMode); pClient->Observer_SetMode(iMode);
} }
} }
} }

View File

@ -87,6 +87,22 @@ entvars_t *g_pevLastInflictor;
LINK_ENTITY_TO_CLASS(player, CBasePlayer, CCSPlayer) LINK_ENTITY_TO_CLASS(player, CBasePlayer, CCSPlayer)
#ifdef REGAMEDLL_API
void CBasePlayer::OnCreate()
{
;
}
void CBasePlayer::OnDestroy()
{
if (m_rebuyString)
{
delete[] m_rebuyString;
m_rebuyString = nullptr;
}
}
#endif
void CBasePlayer::SendItemStatus() void CBasePlayer::SendItemStatus()
{ {
int itemStatus = 0; int itemStatus = 0;
@ -9296,17 +9312,6 @@ void CBasePlayer::Disconnect()
SetThink(nullptr); SetThink(nullptr);
} }
#ifdef REGAMEDLL_FIXES
void CBasePlayer::UpdateOnRemove()
{
if (m_rebuyString)
{
delete[] m_rebuyString;
m_rebuyString = nullptr;
}
}
#endif
LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, OnSpawnEquip, (bool addDefault, bool equipGame), addDefault, equipGame) LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, OnSpawnEquip, (bool addDefault, bool equipGame), addDefault, equipGame)
void EXT_FUNC CBasePlayer::__API_HOOK(OnSpawnEquip)(bool addDefault, bool equipGame) void EXT_FUNC CBasePlayer::__API_HOOK(OnSpawnEquip)(bool addDefault, bool equipGame)

View File

@ -343,12 +343,14 @@ public:
virtual BOOL AddPlayerItem(CBasePlayerItem *pItem); virtual BOOL AddPlayerItem(CBasePlayerItem *pItem);
virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem); virtual BOOL RemovePlayerItem(CBasePlayerItem *pItem);
virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1); virtual int GiveAmmo(int iAmount, const char *szName, int iMax = -1);
virtual void StartSneaking() { m_tSneaking = gpGlobals->time - 1; }
#ifndef REGAMEDLL_FIXES #ifndef REGAMEDLL_API
virtual void StartSneaking() { m_tSneaking = gpGlobals->time - 1; }
virtual void StopSneaking() { m_tSneaking = gpGlobals->time + 30; } virtual void StopSneaking() { m_tSneaking = gpGlobals->time + 30; }
#else #else
virtual void UpdateOnRemove(); virtual void OnCreate();
virtual void OnDestroy();
void StartSneaking() { m_tSneaking = gpGlobals->time - 1; };
#endif #endif
virtual BOOL IsSneaking() { return m_tSneaking <= gpGlobals->time; } virtual BOOL IsSneaking() { return m_tSneaking <= gpGlobals->time; }

View File

@ -369,7 +369,7 @@ void CRenderFxManager::Spawn()
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
void CRenderFxManager::UpdateOnRemove() void CRenderFxManager::OnDestroy()
{ {
m_RenderGroups.RemoveAll(); m_RenderGroups.RemoveAll();
} }

View File

@ -168,7 +168,7 @@ public:
#ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_FIXES
virtual void Restart(); virtual void Restart();
virtual void UpdateOnRemove(); virtual void OnDestroy();
public: public:
struct RenderGroup_t struct RenderGroup_t

View File

@ -23,8 +23,6 @@ unsigned int seed_table[256] =
25678U, 18555U, 13256U, 23316U, 22407U, 16727U, 991U, 9236U, 5373U, 29402U, 6117U, 15241U, 27715U, 19291U, 19888U, 19847U 25678U, 18555U, 13256U, 23316U, 22407U, 16727U, 991U, 9236U, 5373U, 29402U, 6117U, 15241U, 27715U, 19291U, 19888U, 19847U
}; };
int g_groupmask = 0; int g_groupmask = 0;
int g_groupop = 0; int g_groupop = 0;