diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 0fe10a49..4208c0b9 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -71,7 +71,11 @@ ReGameFuncs_t g_ReGameApiFuncs = { PlantBomb_api, SpawnHeadGib_api, - SpawnRandomGibs_api + SpawnRandomGibs_api, + + UTIL_RestartOther_api, + UTIL_ResetEntities_api, + UTIL_RemoveOther_api, }; GAMEHOOK_REGISTRY(CBasePlayer_Spawn); @@ -204,6 +208,8 @@ GAMEHOOK_REGISTRY(CBasePlayer_Pain); GAMEHOOK_REGISTRY(CBasePlayer_DeathSound); GAMEHOOK_REGISTRY(CBasePlayer_JoiningThink); +GAMEHOOK_REGISTRY(FreeGameRules); + int CReGameApi::GetMajorVersion() { return REGAMEDLL_API_VERSION_MAJOR; } @@ -296,4 +302,17 @@ EXT_FUNC void AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, AddMultiDamage(pevInflictor, pEntity, flDamage, bitsDamageType); } +EXT_FUNC void UTIL_RestartOther_api(const char *szClassname) { + UTIL_RestartOther(szClassname); +} + +EXT_FUNC void UTIL_ResetEntities_api() { + UTIL_ResetEntities(); +} + +EXT_FUNC void UTIL_RemoveOther_api(const char *szClassname, int nCount) +{ + UTIL_RemoveOther(szClassname, nCount); +} + EXPOSE_SINGLE_INTERFACE(CReGameApi, IReGameApi, VRE_GAMEDLL_API_VERSION); diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index 1be3dd23..b430f50c 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -641,6 +641,10 @@ typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBase typedef IHookChainClassImpl CReGameHook_CBasePlayer_JoiningThink; typedef IHookChainRegistryClassImpl CReGameHookRegistry_CBasePlayer_JoiningThink; +// FreeGameRules hook +typedef IHookChainImpl CReGameHook_FreeGameRules; +typedef IHookChainRegistryImpl CReGameHookRegistry_FreeGameRules; + class CReGameHookchains: public IReGameHookchains { public: // CBasePlayer virtual @@ -774,6 +778,8 @@ public: CReGameHookRegistry_CBasePlayer_DeathSound m_CBasePlayer_DeathSound; CReGameHookRegistry_CBasePlayer_JoiningThink m_CBasePlayer_JoiningThink; + CReGameHookRegistry_FreeGameRules m_FreeGameRules; + public: virtual IReGameHookRegistry_CBasePlayer_Spawn *CBasePlayer_Spawn(); virtual IReGameHookRegistry_CBasePlayer_Precache *CBasePlayer_Precache(); @@ -904,6 +910,8 @@ public: virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain(); virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound(); virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink(); + + virtual IReGameHookRegistry_FreeGameRules *FreeGameRules(); }; extern CReGameHookchains g_ReGameHookchains; @@ -937,3 +945,7 @@ void RadiusDamage_api(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAtta void ClearMultiDamage_api(); void ApplyMultiDamage_api(entvars_t *pevInflictor, entvars_t *pevAttacker); void AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType); + +void UTIL_RestartOther_api(const char *szClassname); +void UTIL_ResetEntities_api(); +void UTIL_RemoveOther_api(const char *szClassname, int nCount = 0); diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index 4b122358..d40cb921 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -516,6 +516,21 @@ EXT_FUNC bool CCSPlayer::HintMessageEx(const char *pMessage, float duration, boo return BasePlayer()->HintMessageEx(pMessage, duration, bDisplayIfPlayerDead, bOverride); } +EXT_FUNC void CCSPlayer::Reset() +{ + BasePlayer()->Reset(); +} + +EXT_FUNC void CCSPlayer::OnSpawnEquip(bool addDefault, bool equipGame) +{ + BasePlayer()->OnSpawnEquip(addDefault, equipGame); +} + +EXT_FUNC void CCSPlayer::SetScoreboardAttributes(CBasePlayer *destination) +{ + BasePlayer()->SetScoreboardAttributes(destination); +} + EXT_FUNC bool CCSPlayer::CheckActivityInGame() { const CBasePlayer* pPlayer = BasePlayer(); @@ -528,7 +543,7 @@ EXT_FUNC bool CCSPlayer::CheckActivityInGame() return (fabs(deltaYaw) >= 0.1f && fabs(deltaPitch) >= 0.1f); } -void CCSPlayer::Reset() +void CCSPlayer::ResetVars() { m_szModel[0] = '\0'; diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index e29e400c..cd52b7bc 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -727,7 +727,7 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity) } #ifdef REGAMEDLL_API - pPlayer->CSPlayer()->Reset(); + pPlayer->CSPlayer()->ResetVars(); #endif UTIL_ClientPrintAll(HUD_PRINTNOTIFY, "#Game_connected", (sName[0] != '\0') ? sName : ""); diff --git a/regamedll/dlls/gamerules.cpp b/regamedll/dlls/gamerules.cpp index d31e6b56..45210e21 100644 --- a/regamedll/dlls/gamerules.cpp +++ b/regamedll/dlls/gamerules.cpp @@ -141,3 +141,13 @@ CGameRules *EXT_FUNC __API_HOOK(InstallGameRules)() return new CHalfLifeMultiplay; } + +LINK_HOOK_VOID_CHAIN(FreeGameRules, (CGameRules **pGameRules), pGameRules) + +void EXT_FUNC __API_HOOK(FreeGameRules)(CGameRules **pGameRules) +{ + if (!pGameRules || !(*pGameRules)) + return; + + delete (*pGameRules); +} diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index ed0111a5..5eee3a6d 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -831,9 +831,11 @@ extern CGameRules DLLEXPORT *g_pGameRules; #ifdef REGAMEDLL_API CGameRules *InstallGameRules_OrigFunc(); +void FreeGameRules_OrigFunc(CGameRules **pGameRules); #endif CGameRules *InstallGameRules(); +void FreeGameRules(CGameRules **pGameRules); // Gets us at the CS game rules inline CHalfLifeMultiplay *CSGameRules() diff --git a/regamedll/dlls/world.cpp b/regamedll/dlls/world.cpp index efbb4dcf..55147af0 100644 --- a/regamedll/dlls/world.cpp +++ b/regamedll/dlls/world.cpp @@ -288,11 +288,7 @@ void CWorld::Precache() CVAR_SET_STRING("room_type", "0"); // Set up game rules - if (g_pGameRules) - { - delete g_pGameRules; - } - + FreeGameRules(&g_pGameRules); g_pGameRules = InstallGameRules(); // NOTE: What is the essence of soundent in CS 1.6? I think this is for NPC monsters - s1lent diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 1c592d1a..16150a56 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -100,8 +100,11 @@ public: virtual void SetSpawnProtection(float flProtectionTime); virtual void RemoveSpawnProtection(); virtual bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); + virtual void Reset(); + virtual void OnSpawnEquip(bool addDefault = true, bool equipGame = true); + virtual void SetScoreboardAttributes(CBasePlayer *destination = nullptr); - void Reset(); + void ResetVars(); void OnSpawn(); void OnKilled(); diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index ba7a8517..493736ca 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 21 +#define REGAMEDLL_API_VERSION_MINOR 22 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -520,6 +520,10 @@ typedef IHookChainRegistryClass IReGameHookRegistry_CBa typedef IHookChainClass IReGameHook_CBasePlayer_JoiningThink; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_JoiningThink; +// FreeGameRules hook +typedef IHookChain IReGameHook_FreeGameRules; +typedef IHookChainRegistry IReGameHookRegistry_FreeGameRules; + class IReGameHookchains { public: virtual ~IReGameHookchains() {} @@ -653,6 +657,8 @@ public: virtual IReGameHookRegistry_CBasePlayer_Pain *CBasePlayer_Pain() = 0; virtual IReGameHookRegistry_CBasePlayer_DeathSound *CBasePlayer_DeathSound() = 0; virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink() = 0; + + virtual IReGameHookRegistry_FreeGameRules *FreeGameRules() = 0; }; struct ReGameFuncs_t { @@ -670,6 +676,9 @@ struct ReGameFuncs_t { class CGrenade *(*PlantBomb)(entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity); class CGib *(*SpawnHeadGib)(entvars_t* pevVictim); void (*SpawnRandomGibs)(entvars_t* pevVictim, int cGibs, int human); + void (*UTIL_RestartOther)(const char *szClassname); + void (*UTIL_ResetEntities)(); + void (*UTIL_RemoveOther)(const char *szClassname, int nCount); }; class IReGameApi { diff --git a/regamedll/version/version.h b/regamedll/version/version.h index ba22bb75..b65ba1ab 100644 --- a/regamedll/version/version.h +++ b/regamedll/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 5 -#define VERSION_MINOR 21 +#define VERSION_MINOR 22 #define VERSION_MAINTENANCE 0