From 96938aec5587ab0e93cd3fe8bba0352553cf051c Mon Sep 17 00:00:00 2001 From: s1lent Date: Thu, 29 Aug 2019 23:08:24 +0700 Subject: [PATCH] ReGameDLL API: Implement BGetICSEntity/BGetIGameRules for check safe version interface. --- regamedll/dlls/API/CAPI_Impl.cpp | 20 ++++++++++++++++++++ regamedll/dlls/API/CAPI_Impl.h | 2 ++ regamedll/dlls/gamerules.h | 2 ++ regamedll/public/regamedll/API/CSEntity.h | 7 +++++++ regamedll/public/regamedll/regamedll_api.h | 4 +++- 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 777454ec..17ddcb35 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -204,6 +204,26 @@ AmmoInfo *CReGameApi::GetAmmoInfo(AmmoType ammoID) { return &CBasePlayerItem::m_ AmmoInfoStruct *CReGameApi::GetAmmoInfoEx(AmmoType ammoID) { return ::GetAmmoInfo(ammoID); } AmmoInfoStruct *CReGameApi::GetAmmoInfoEx(const char *ammoName) { return ::GetAmmoInfo(ammoName); } +bool CReGameApi::BGetICSEntity(const char *pchVersion) const +{ + if (!Q_stricmp(pchVersion, CSENTITY_API_INTERFACE_VERSION)) + { + return true; + } + + return false; +} + +bool CReGameApi::BGetIGameRules(const char *pchVersion) const +{ + if (!Q_stricmp(pchVersion, GAMERULES_API_INTERFACE_VERSION)) + { + return true; + } + + return false; +} + EXT_FUNC void Regamedll_ChangeString_api(char *&dest, const char *source) { size_t len = Q_strlen(source); diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index ed5e5167..3e8b6a55 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -781,6 +781,8 @@ public: EXT_FUNC virtual AmmoInfo *GetAmmoInfo(AmmoType ammoID); EXT_FUNC virtual AmmoInfoStruct *GetAmmoInfoEx(AmmoType ammoID); EXT_FUNC virtual AmmoInfoStruct *GetAmmoInfoEx(const char *ammoName); + EXT_FUNC virtual bool BGetICSEntity(const char *pchVersion) const; + EXT_FUNC virtual bool BGetIGameRules(const char *pchVersion) const; }; void Regamedll_ChangeString_api(char *&dest, const char *source); diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index aa3ee75b..548dd08f 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -337,6 +337,8 @@ public: bool m_bGameOver; // intermission or finale (deprecated name g_fGameOver) }; +#define GAMERULES_API_INTERFACE_VERSION "GAMERULES_API_INTERFACE_VERSION001" + // CHalfLifeRules - rules for the single player Half-Life game. class CHalfLifeRules: public CGameRules { diff --git a/regamedll/public/regamedll/API/CSEntity.h b/regamedll/public/regamedll/API/CSEntity.h index ef47f30f..2c69f232 100644 --- a/regamedll/public/regamedll/API/CSEntity.h +++ b/regamedll/public/regamedll/API/CSEntity.h @@ -32,6 +32,11 @@ class CBaseEntity; class CCSEntity { public: + CCSEntity() : + m_pContainingEntity(nullptr) + { + } + virtual ~CCSEntity() {} virtual void FireBullets(int iShots, Vector &vecSrc, Vector &vecDirShooting, Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker); virtual Vector FireBullets3(Vector &vecSrc, Vector &vecDirShooting, float vecSpread, float flDistance, int iPenetration, int iBulletType, int iDamage, float flRangeModifier, entvars_t *pevAttacker, bool bPistol, int shared_rand); @@ -63,3 +68,5 @@ class CCSMonster: public CCSToggle public: }; + +#define CSENTITY_API_INTERFACE_VERSION "CSENTITY_API_INTERFACE_VERSION001" diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 2616ef84..20041468 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 10 +#define REGAMEDLL_API_VERSION_MINOR 11 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; @@ -589,6 +589,8 @@ public: virtual struct AmmoInfo *GetAmmoInfo(AmmoType ammoID) = 0; virtual struct AmmoInfoStruct *GetAmmoInfoEx(AmmoType ammoID) = 0; virtual struct AmmoInfoStruct *GetAmmoInfoEx(const char *ammoName) = 0; + virtual bool BGetICSEntity(const char *pchVersion) const = 0; + virtual bool BGetIGameRules(const char *pchVersion) const = 0; }; #define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001"