diff --git a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc index 3c8cd50c..b40be50f 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_engine_const.inc @@ -13,6 +13,23 @@ enum MapNameType MNT_SET // return the name of the current map }; +/* +* For RH_SV_AddResource hook +*/ +enum ResourceType_t +{ + t_sound = 0, + t_skin, + t_model, + t_decal, + t_generic, + t_eventscript, + t_world, // Fake type for world, is really t_model + rt_unk, + + rt_max +}; + /** * rh_emit_sound2 flags */ @@ -91,10 +108,60 @@ enum EngineFunc RH_ED_Free, /* - * Description: - + * Description: Called when a message is being sent to the server's console. * Params: (const string[]) */ RH_Con_Printf, + + /* + * Description: Called when a player's userinfo is being checked. + * Params: (adr, userinfo[], bool:reconnect, reconnectSlot, name[]) + * + * @note Param adr is unused, guaranteed to return nothing also, don't send anything through it. + * @note In order for param name work, hook needs to be registered as Post. + */ + RH_SV_CheckUserInfo, + + /* + * Description: Called when a generic resource is being added to generic precache list. + * Return type: int + * Params: (const string[]) + */ + RH_PF_precache_generic_I, + + /* + * Description: Called when a model is being added to model precache list. + * Return type: int + * Params: (const string[]) + */ + RH_PF_precache_model_I, + + /* + * Description: Called when a sound is being added to sound precache list. + * Return type: int + * Params: (const string[]) + */ + RH_PF_precache_sound_I, + + /* + * Description: Called when an event is being added to event precache list. + * Return type: int + * Params: (const string[]) + */ + RH_EV_Precache, + + /* + * Description: Called when a resource is being added to resource list. + * Params: (ResourceType_t:type, const filename[], size, flags, index) + */ + RH_SV_AddResource, + + /* + * Description: Called when message is being printed to client console. + * Params: (const string[]) + */ + RH_SV_ClientPrintf, + }; /** diff --git a/reapi/include/cssdk/engine/rehlds_api.h b/reapi/include/cssdk/engine/rehlds_api.h index ab1cd9e2..a76ec9f9 100644 --- a/reapi/include/cssdk/engine/rehlds_api.h +++ b/reapi/include/cssdk/engine/rehlds_api.h @@ -36,7 +36,7 @@ #include "pr_dlls.h" #define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 11 +#define REHLDS_API_VERSION_MINOR 12 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -226,6 +226,34 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_ED_Free; typedef IHookChain IRehldsHook_Con_Printf; typedef IHookChainRegistry IRehldsHookRegistry_Con_Printf; +//SV_CheckUserInfo hook +typedef IHookChain IRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckUserInfo; + +//PF_precache_generic_I hook +typedef IHookChain IRehldsHook_PF_precache_generic_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_generic_I; + +//PF_precache_model_I hook +typedef IHookChain IRehldsHook_PF_precache_model_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; + +//PF_precache_sound_I hook +typedef IHookChain IRehldsHook_PF_precache_sound_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_sound_I; + +//EV_Precache hook +typedef IHookChain IRehldsHook_EV_Precache; +typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; + +//SV_AddResource hook +typedef IVoidHookChain IRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; + +//SV_ClientPrintf hook +typedef IVoidHookChain IRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -277,6 +305,13 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0; virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0; virtual IRehldsHookRegistry_Con_Printf* Con_Printf() = 0; + virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo() = 0; + virtual IRehldsHookRegistry_PF_precache_generic_I* PF_precache_generic_I() = 0; + virtual IRehldsHookRegistry_PF_precache_model_I* PF_precache_model_I() = 0; + virtual IRehldsHookRegistry_PF_precache_sound_I* PF_precache_sound_I() = 0; + virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0; + virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; + virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; }; struct RehldsFuncs_t { diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 78b3a5c4..67fe1d12 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -115,7 +115,6 @@ void SV_EmitPings_AMXX(SV_EmitPings_t* data, IGameClient* cl) void SV_EmitPings(IRehldsHook_SV_EmitPings *chain, IGameClient *cl, sizebuf_t *msg) { - SV_EmitPings_args_t args(cl, msg); SV_EmitPings_t data(chain, args); SV_EmitPings_AMXX(&data, cl); @@ -141,6 +140,83 @@ void ED_Free(IRehldsHook_ED_Free* chain, edict_t *entity) callVoidForward(RH_ED_Free, original, indexOfEdict(entity)); } +int SV_CheckUserInfo(IRehldsHook_SV_CheckUserInfo *chain, netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int iReconnectSlot, char *name) +{ + auto original = [chain](netadr_t *_adr, char *_userinfo, qboolean _bIsReconnecting, int _iReconnectSlot, char *_name) + { + return chain->callNext(_adr, _userinfo, _bIsReconnecting, _iReconnectSlot, _name); + }; + + return callForward(RH_SV_CheckUserInfo, original, adr, userinfo, bIsReconnecting, iReconnectSlot, name); +} + +int PF_precache_generic_I(IRehldsHook_PF_precache_generic_I *chain, const char *s) +{ + auto original = [chain](const char *_s) + { + return chain->callNext(_s); + }; + + return callForward(RH_PF_precache_generic_I, original, s); +} + +int PF_precache_model_I(IRehldsHook_PF_precache_model_I *chain, char *s) +{ + auto original = [chain](char *_s) + { + return chain->callNext(_s); + }; + + return callForward(RH_PF_precache_model_I, original, s); +} + +int PF_precache_sound_I(IRehldsHook_PF_precache_sound_I *chain, const char *s) +{ + auto original = [chain](const char *_s) + { + return chain->callNext(_s); + }; + + return callForward(RH_PF_precache_sound_I, original, s); +} + +unsigned short EV_Precache_AMXX(EventPrecache_t *data, const char *psz) +{ + auto original = [data](const char *_psz) + { + return data->m_chain->callNext(data->m_args.type, _psz); + }; + + return callForward(RH_EV_Precache, original, psz); +} + +unsigned short EV_Precache(IRehldsHook_EV_Precache *chain, int type, const char *psz) +{ + EventPrecache_args_t args(type); + EventPrecache_t data(chain, args); + return EV_Precache_AMXX(&data, psz); +} + +void SV_AddResource(IRehldsHook_SV_AddResource *chain, resourcetype_t type, const char *name, int size, unsigned char flags, int index) +{ + auto original = [chain](resourcetype_t _type, const char *_name, int _size, unsigned char _flags, int _index) + { + chain->callNext(_type, _name, _size, _flags, _index); + }; + + callVoidForward(RH_SV_AddResource, original, type, name, size, flags, index); +} + +void SV_ClientPrintf(IRehldsHook_SV_ClientPrintf *chain, const char *string) +{ + auto original = [chain](const char *_string) + { + chain->callNext(_string); + }; + + callVoidForward(RH_SV_ClientPrintf, original, string); +} + /* * ReGameDLL functions */ diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 9925b729..3ebec5f2 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -334,6 +334,7 @@ void SV_ActivateServer(IRehldsHook_SV_ActivateServer *chain, int runPhysics); void Cvar_DirectSet(IRehldsHook_Cvar_DirectSet *chain, cvar_t *var, const char *value); void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl); void SV_ConnectClient(IRehldsHook_SV_ConnectClient* chain); +int SV_CheckUserInfo(IRehldsHook_SV_CheckUserInfo* chain, netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int iReconnectSlot, char *name); struct SV_WriteFullClientUpdate_args_t { @@ -360,9 +361,23 @@ using SV_EmitPings_t = hookdata_t; +unsigned short EV_Precache_AMXX(EventPrecache_t *data, const char *psz); +unsigned short EV_Precache(IRehldsHook_EV_Precache *chain, int type, const char *psz); +void SV_AddResource(IRehldsHook_SV_AddResource *chain, resourcetype_t type, const char *name, int size, unsigned char flags, int index); edict_t *ED_Alloc(IRehldsHook_ED_Alloc* chain); void ED_Free(IRehldsHook_ED_Free* chain, edict_t *entity); +void SV_ClientPrintf(IRehldsHook_SV_ClientPrintf* chain, const char *string); // regamedll functions int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver); diff --git a/reapi/src/hook_list.cpp b/reapi/src/hook_list.cpp index 2b9df5cb..32b7dc29 100644 --- a/reapi/src/hook_list.cpp +++ b/reapi/src/hook_list.cpp @@ -20,6 +20,8 @@ inline size_t getFwdParamType(void(*)(float&)) { return FP_FLOA inline size_t getFwdParamType(void(*)(const char *)) { return FP_STRING; } inline size_t getFwdParamType(void(*)(char *)) { return FP_STRING; } inline size_t getFwdParamType(void(*)(IResourceBuffer*)) { return FP_CELL; } +inline size_t getFwdParamType(void(*)(unsigned char)) { return FP_CELL; } +inline size_t getFwdParamType(void(*)(resourcetype_t)) { return FP_CELL; } template inline size_t getFwdParamType(void(*)(T *)) { return FP_CELL; } @@ -94,6 +96,14 @@ hook_t hooklist_engine[] = { ENG(ED_Alloc), ENG(ED_Free), ENG(Con_Printf), + ENG(SV_CheckUserInfo), + ENG(PF_precache_generic_I), + ENG(PF_precache_model_I), + ENG(PF_precache_sound_I), + ENG(EV_Precache, _AMXX), + ENG(SV_AddResource), + ENG(SV_ClientPrintf), + }; #define DLL(h,...) { {}, {}, #h, "ReGameDLL", [](){ return api_cfg.hasReGameDLL(); }, ((!(RG_##h & (MAX_REGION_RANGE - 1)) ? regfunc::current_cell = 1, true : false) || (RG_##h & (MAX_REGION_RANGE - 1)) == regfunc::current_cell++) ? regfunc(h##__VA_ARGS__) : regfunc(#h#__VA_ARGS__), [](){ g_ReGameHookchains->h()->registerHook(&h); }, [](){ g_ReGameHookchains->h()->unregisterHook(&h); }, false} diff --git a/reapi/src/hook_list.h b/reapi/src/hook_list.h index bf798827..fad1da67 100644 --- a/reapi/src/hook_list.h +++ b/reapi/src/hook_list.h @@ -105,6 +105,13 @@ enum EngineFunc RH_ED_Alloc, RH_ED_Free, RH_Con_Printf, + RH_SV_CheckUserInfo, + RH_PF_precache_generic_I, + RH_PF_precache_model_I, + RH_PF_precache_sound_I, + RH_EV_Precache, + RH_SV_AddResource, + RH_SV_ClientPrintf, // [...] }; diff --git a/reapi/version/version.h b/reapi/version/version.h index ba22bb75..b65ba1ab 100644 --- a/reapi/version/version.h +++ b/reapi/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