From 1733dde18e9c38d3aaa2f083fcb2ee097aebaf6a Mon Sep 17 00:00:00 2001 From: s1lentq Date: Wed, 8 Jun 2016 16:21:49 +0700 Subject: [PATCH] Update for regamedll sdk --- Makefile | 29 +++++++-- include/cssdk/dlls/hookchains.h | 25 +++++++- include/cssdk/dlls/regamedll_api.h | 78 +++++++++++------------ include/cssdk/dlls/regamedll_interfaces.h | 19 +++++- src/main.cpp | 4 +- src/meta_api.cpp | 2 +- 6 files changed, 103 insertions(+), 54 deletions(-) diff --git a/Makefile b/Makefile index caf31cd..97f61df 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,44 @@ NAME = refreelook -COMPILER = clang +#COMPILER = clang +COMPILER = /opt/intel/bin/icpc CSSDK = include/cssdk OBJECTS = src/main.cpp src/meta_api.cpp src/h_export.cpp src/amxxmodule.cpp src/mod_regamedll_api.cpp\ src/sdk_util.cpp $(CSSDK)/public/interface.cpp\ -LINK = -lm -ldl -static-libgcc -Wno-return-type-c-linkage -fPIC +LINK = -lm -ldl -static-libgcc + +ifeq "$(COMPILER)" "clang" + LINK += -Wno-return-type-c-linkage -fPIC +else + LINK += -static-intel -no-intel-extensions +endif METAMOD = include/metamod -OPT_FLAGS = -O3 -msse3 -funroll-loops -fomit-frame-pointer -fno-stack-protector -g -fwritable-strings -Wreturn-type-c-linkage +OPT_FLAGS = -O3 -msse3 -funroll-loops -fomit-frame-pointer -fno-stack-protector -g +ifeq "$(COMPILER)" "clang" + OPT_FLAGS += -fwritable-strings -Wreturn-type-c-linkage +else + OPT_FLAGS += -no-prec-div +endif INCLUDE = -I. -Isrc -I$(CSSDK)/common -I$(CSSDK)//dlls -I$(CSSDK)/engine -I$(CSSDK)/pm_shared -I$(CSSDK)/public -I$(METAMOD) -I$(CSSDK)/game_shared + + BIN_DIR = Release CFLAGS = $(OPT_FLAGS) CFLAGS += -g0 -fvisibility=hidden -DNOMINMAX -fvisibility-inlines-hidden\ -DNDEBUG -Dlinux -D__linux__ -std=c++11 -shared -fasm-blocks\ - -fno-rtti -D_bswap16=__builtin_bswap16 -D_bswap=bswap\ - -D_bswap64=__builtin_bswap64 -D_vsnprintf=vsnprintf + -fno-rtti -D_vsnprintf=vsnprintf + +ifeq "$(COMPILER)" "clang" + CFLAGS += -D_bswap16=__builtin_bswap16 -D_bswap=bswap -D_bswap64=__builtin_bswap64 +else + CFLAGS += -Qoption,cpp,--treat_func_as_string_literal_cpp +endif OBJ_LINUX := $(OBJECTS:%.c=$(BIN_DIR)/%.o) diff --git a/include/cssdk/dlls/hookchains.h b/include/cssdk/dlls/hookchains.h index f2993e8..408d8a4 100644 --- a/include/cssdk/dlls/hookchains.h +++ b/include/cssdk/dlls/hookchains.h @@ -37,6 +37,16 @@ public: virtual t_ret callOriginal(t_args... args) = 0; }; +template +class IHookChainClass { +protected: + virtual ~IHookChainClass() {} + +public: + virtual t_ret callNext(t_class *, t_args... args) = 0; + virtual t_ret callOriginal(t_class *, t_args... args) = 0; +}; + template class IVoidHookChain { @@ -48,6 +58,17 @@ public: virtual void callOriginal(t_args... args) = 0; }; +template +class IVoidHookChainClass +{ +protected: + virtual ~IVoidHookChainClass() {} + +public: + virtual void callNext(t_class *, t_args... args) = 0; + virtual void callOriginal(t_class *, t_args... args) = 0; +}; + // Hook chain registry(for hooks [un]registration) template class IHookChainRegistry { @@ -62,7 +83,7 @@ public: template class IHookChainRegistryClass { public: - typedef t_ret(*hookfunc_t)(IHookChain*, t_class *, t_args...); + typedef t_ret(*hookfunc_t)(IHookChainClass*, t_class *, t_args...); virtual void registerHook(hookfunc_t hook) = 0; virtual void unregisterHook(hookfunc_t hook) = 0; @@ -82,7 +103,7 @@ public: template class IVoidHookChainRegistryClass { public: - typedef void(*hookfunc_t)(IVoidHookChain*, t_class *, t_args...); + typedef void(*hookfunc_t)(IVoidHookChainClass*, t_class *, t_args...); virtual void registerHook(hookfunc_t hook) = 0; virtual void unregisterHook(hookfunc_t hook) = 0; diff --git a/include/cssdk/dlls/regamedll_api.h b/include/cssdk/dlls/regamedll_api.h index 15c12de..3f2a2f0 100644 --- a/include/cssdk/dlls/regamedll_api.h +++ b/include/cssdk/dlls/regamedll_api.h @@ -33,135 +33,134 @@ #include "player.h" #include "gamerules.h" -#define REGAMEDLL_API_VERSION_MAJOR 2 +#define REGAMEDLL_API_VERSION_MAJOR 3 #define REGAMEDLL_API_VERSION_MINOR 1 // CBasePlayer::Spawn hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_Spawn; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Spawn; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Spawn; // CBasePlayer::Precache hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_Precache; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Precache; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Precache; // CBasePlayer::ObjectCaps hook -typedef IHookChain IReGameHook_CBasePlayer_ObjectCaps; +typedef IHookChainClass IReGameHook_CBasePlayer_ObjectCaps; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_ObjectCaps; // CBasePlayer::Classify hook -typedef IHookChain IReGameHook_CBasePlayer_Classify; +typedef IHookChainClass IReGameHook_CBasePlayer_Classify; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Classify; // CBasePlayer::TraceAttack hook -typedef IVoidHookChain IReGameHook_CBasePlayer_TraceAttack; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_TraceAttack; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TraceAttack; // CBasePlayer::TakeDamage hook -typedef IHookChain IReGameHook_CBasePlayer_TakeDamage; +typedef IHookChainClass IReGameHook_CBasePlayer_TakeDamage; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeDamage; // CBasePlayer::TakeHealth hook -typedef IHookChain IReGameHook_CBasePlayer_TakeHealth; +typedef IHookChainClass IReGameHook_CBasePlayer_TakeHealth; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_TakeHealth; // CBasePlayer::Killed hook -typedef IVoidHookChain IReGameHook_CBasePlayer_Killed; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Killed; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Killed; // CBasePlayer::AddPoints hook -typedef IVoidHookChain IReGameHook_CBasePlayer_AddPoints; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddPoints; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddPoints; // CBasePlayer::AddPointsToTeam hook -typedef IVoidHookChain IReGameHook_CBasePlayer_AddPointsToTeam; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddPointsToTeam; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddPointsToTeam; // CBasePlayer::AddPlayerItem hook -typedef IHookChain IReGameHook_CBasePlayer_AddPlayerItem; +typedef IHookChainClass IReGameHook_CBasePlayer_AddPlayerItem; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddPlayerItem; // CBasePlayer::RemovePlayerItem hook -typedef IHookChain IReGameHook_CBasePlayer_RemovePlayerItem; +typedef IHookChainClass IReGameHook_CBasePlayer_RemovePlayerItem; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RemovePlayerItem; // CBasePlayer::GiveAmmo hook -typedef IHookChain IReGameHook_CBasePlayer_GiveAmmo; +typedef IHookChainClass IReGameHook_CBasePlayer_GiveAmmo; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveAmmo; // CBasePlayer::ResetMaxSpeed hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_ResetMaxSpeed; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_ResetMaxSpeed; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_ResetMaxSpeed; // CBasePlayer::Jump hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_Jump; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Jump; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Jump; // CBasePlayer::Duck hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_Duck; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Duck; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Duck; // CBasePlayer::PreThink hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_PreThink; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_PreThink; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PreThink; // CBasePlayer::PostThink hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_PostThink; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_PostThink; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_PostThink; // CBasePlayer::UpdateClientData hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_UpdateClientData; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_UpdateClientData; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_UpdateClientData; // CBasePlayer::ImpulseCommands hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_ImpulseCommands; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_ImpulseCommands; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_ImpulseCommands; // CBasePlayer::RoundRespawn hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_RoundRespawn; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_RoundRespawn; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_RoundRespawn; // CBasePlayer::Blind hook -typedef IVoidHookChain IReGameHook_CBasePlayer_Blind; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_Blind; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Blind; // CBasePlayer::Observer_IsValidTarget hook -typedef IHookChain IReGameHook_CBasePlayer_Observer_IsValidTarget; +typedef IHookChainClass IReGameHook_CBasePlayer_Observer_IsValidTarget; typedef IHookChainRegistryClass IReGameHookRegistry_CBasePlayer_Observer_IsValidTarget; // CBasePlayer::SetAnimation hook -typedef IVoidHookChain IReGameHook_CBasePlayer_SetAnimation; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetAnimation; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetAnimation; // CBasePlayer::GiveDefaultItems hook -typedef IVoidHookChain<> IReGameHook_CBasePlayer_GiveDefaultItems; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveDefaultItems; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveDefaultItems; // CBasePlayer::GiveNamedItem hook -typedef IVoidHookChain IReGameHook_CBasePlayer_GiveNamedItem; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveNamedItem; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveNamedItem; // CBasePlayer::AddAccount hook -typedef IVoidHookChain IReGameHook_CBasePlayer_AddAccount; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_AddAccount; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_AddAccount; // CBasePlayer::GiveShield hook -typedef IVoidHookChain IReGameHook_CBasePlayer_GiveShield; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_GiveShield; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_GiveShield; // CBasePlayer:SetClientUserInfoModel hook -typedef IVoidHookChain IReGameHook_CBasePlayer_SetClientUserInfoModel; +typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoModel; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel; +// CBasePlayer:SetClientUserInfoName hook +typedef IVoidHookChainClass IReGameHook_CBasePlayer_SetClientUserInfoName; +typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBasePlayer_SetClientUserInfoName; // CBaseAnimating::ResetSequenceInfo hook -typedef IVoidHookChain<> IReGameHook_CBaseAnimating_ResetSequenceInfo; +typedef IVoidHookChainClass IReGameHook_CBaseAnimating_ResetSequenceInfo; typedef IVoidHookChainRegistryClass IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo; - - - - // GetForceCamera hook typedef IHookChain IReGameHook_GetForceCamera; typedef IHookChainRegistry IReGameHookRegistry_GetForceCamera; @@ -336,6 +335,7 @@ public: virtual IReGameHookRegistry_CBasePlayer_AddAccount* CBasePlayer_AddAccount() = 0; virtual IReGameHookRegistry_CBasePlayer_GiveShield* CBasePlayer_GiveShield() = 0; virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoModel* CBasePlayer_SetClientUserInfoModel() = 0; + virtual IReGameHookRegistry_CBasePlayer_SetClientUserInfoName* CBasePlayer_SetClientUserInfoName() = 0; virtual IReGameHookRegistry_CBaseAnimating_ResetSequenceInfo* CBaseAnimating_ResetSequenceInfo() = 0; virtual IReGameHookRegistry_GetForceCamera* GetForceCamera() = 0; @@ -374,27 +374,22 @@ public: virtual IReGameHookRegistry_CSGameRules_ChangeLevel* CSGameRules_ChangeLevel() = 0; virtual IReGameHookRegistry_CSGameRules_GoToIntermission* CSGameRules_GoToIntermission() = 0; virtual IReGameHookRegistry_CSGameRules_BalanceTeams* CSGameRules_BalanceTeams() = 0; - }; struct ReGameFuncs_t { class CBasePlayer *(*UTIL_PlayerByIndex)(int playerIndex); struct edict_s *(*CREATE_NAMED_ENTITY2)(string_t iClass); - void (*ChangeString)(char *&dest, const char *source); - void (*RadiusDamage)(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); void (*ClearMultiDamage)(); void (*ApplyMultiDamage)(entvars_t *pevInflictor, entvars_t *pevAttacker); void (*AddMultiDamage)(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType); - - void (*EndRoundMessage)(const char *sentence, int event); class CBaseEntity *(*UTIL_FindEntityByString)(class CBaseEntity *pStartEntity, const char *szKeyword, const char *szValue); }; class IReGameApi { public: - virtual ~IReGameApi() { } + virtual ~IReGameApi() {} virtual int GetMajorVersion() = 0; virtual int GetMinorVersion() = 0; @@ -407,7 +402,6 @@ public: virtual struct playermove_s* GetPlayerMove() = 0; virtual struct WeaponSlotInfo* GetWeaponSlot(WeaponIdType weaponID) = 0; virtual struct WeaponSlotInfo* GetWeaponSlot(const char* weaponName) = 0; - }; #define VRE_GAMEDLL_API_VERSION "VRE_GAMEDLL_API_VERSION001" diff --git a/include/cssdk/dlls/regamedll_interfaces.h b/include/cssdk/dlls/regamedll_interfaces.h index 888e1e2..f8676cc 100644 --- a/include/cssdk/dlls/regamedll_interfaces.h +++ b/include/cssdk/dlls/regamedll_interfaces.h @@ -49,10 +49,12 @@ class CCSMonster: public CCSToggle {}; class CCSWeaponBox: public CCSEntity {}; class CCSArmoury: public CCSEntity {}; -#pragma warning(disable:4351) // new behavior: elements of array 'CCSPlayer::m_szModel' will be default initialized class CCSPlayer: public CCSMonster { public: - CCSPlayer() : m_szModel() {} + CCSPlayer() + { + m_szModel[0] = '\0'; + } virtual bool IsConnected() const; virtual void SetAnimation(PLAYER_ANIM playerAnim); @@ -65,9 +67,22 @@ public: virtual void DropPlayerItem(const char *pszItemName); virtual void RemoveShield(); virtual void RemoveAllItems(bool bRemoveSuit); + virtual bool RemovePlayerItem(const char* pszItemName); virtual void SetPlayerModel(bool bHasC4); virtual void SetPlayerModelEx(const char *modelName); virtual void SetNewPlayerModel(const char *modelName); + virtual void ClientCommand(const char *cmd, const char *arg1 = nullptr, const char *arg2 = nullptr, const char *arg3 = nullptr); + virtual void SetProgressBarTime(int time); + virtual void SetProgressBarTime2(int time, float timeElapsed); + virtual struct edict_s *EntSelectSpawnPoint(); + virtual void SetBombIcon(bool bFlash = false); + virtual void SetScoreAttrib(CBasePlayer *dest); + virtual void SendItemStatus(); + virtual void ReloadWeapons(CBasePlayerItem *pWeapon = nullptr, bool bForceReload = false, bool bForceRefill = false); + virtual void Observer_SetMode(int iMode); + virtual bool SelectSpawnSpot(const char *pEntClassName, CBaseEntity* &pSpot); + virtual bool SwitchWeapon(CBasePlayerItem *pWeapon); + virtual void SwitchTeam(); CBasePlayer *BasePlayer() const; public: diff --git a/src/main.cpp b/src/main.cpp index 49dc526..e8c4403 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,7 +16,7 @@ inline bool ShouldRunCode() } inline bool canFreeLook(const int nIndex) { - return (UTIL_ReadFlags(pcv_admin_access_flags->string) & g_amxxapi.GetPlayerFlags(nIndex)); + return (UTIL_ReadFlags(pcv_admin_access_flags->string) & g_amxxapi.GetPlayerFlags(nIndex)) != 0; } int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver) @@ -34,7 +34,7 @@ CBasePlayer *CBasePlayer_Observer_IsValidTarget(IReGameHook_CBasePlayer_Observer { if (ShouldRunCode()) { // go next hook and call the original in the end - return chain->callNext(iPlayerIndex, bSameTeam); + return chain->callNext(pthis, iPlayerIndex, bSameTeam); } if (iPlayerIndex > gpGlobals->maxClients || iPlayerIndex < 1) diff --git a/src/meta_api.cpp b/src/meta_api.cpp index 25b4a97..3a8d196 100644 --- a/src/meta_api.cpp +++ b/src/meta_api.cpp @@ -8,7 +8,7 @@ plugin_info_t Plugin_info = { META_INTERFACE_VERSION, // ifvers "ReFreeLook", // name - "1.6", // version + "1.7", // version __DATE__, // date "s1lent", // author "http://www.dedicated-server.ru", // url