mirror of
https://github.com/rehlds/reapi.git
synced 2025-01-16 00:28:17 +03:00
Implement Con_Printf()
hook (#222)
* Implement Con_Printf hook * Update REHLDS_API_VERSION_MINOR * FIX rehlds_api.h * Update rehlds_api.h * Update reapi_engine_const.inc * Update reapi_engine_const.inc * FIX pointer style * FIX pointer style * Update hook_list.cpp * Update reapi/src/hook_list.h Co-authored-by: justgo97 <hamdi2050@live.com> * Apply suggestions from code review Co-authored-by: Sergey Shorokhov <wopox1337@ya.ru> Co-authored-by: justgo97 <hamdi2050@live.com>
This commit is contained in:
parent
866295f111
commit
dd1fdae53b
@ -77,7 +77,6 @@ enum EngineFunc
|
||||
* Params: (const this)
|
||||
*/
|
||||
RH_SV_EmitPings,
|
||||
|
||||
/*
|
||||
* Description: Called when an entity is created.
|
||||
* Return type: Edict * (Entity index)
|
||||
@ -90,6 +89,12 @@ enum EngineFunc
|
||||
* Params: (const entity)
|
||||
*/
|
||||
RH_ED_Free,
|
||||
|
||||
/*
|
||||
* Description: -
|
||||
* Params: (const string[])
|
||||
*/
|
||||
RH_Con_Printf,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -187,8 +187,8 @@ typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s
|
||||
typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHookRegistry_SV_CreatePacketEntities;
|
||||
|
||||
//SV_EmitSound2 hook
|
||||
typedef IHookChain<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHook_SV_EmitSound2;
|
||||
typedef IHookChainRegistry<bool, edict_t *, IGameClient *, int, const char*, float, float, int, int, int, const float*> IRehldsHookRegistry_SV_EmitSound2;
|
||||
typedef IHookChain<bool, edict_t *, IGameClient *, int, const char *, float, float, int, int, int, const float *> IRehldsHook_SV_EmitSound2;
|
||||
typedef IHookChainRegistry<bool, edict_t *, IGameClient *, int, const char *, float, float, int, int, int, const float *> IRehldsHookRegistry_SV_EmitSound2;
|
||||
|
||||
//CreateFakeClient hook
|
||||
typedef IHookChain<edict_t *, const char *> IRehldsHook_CreateFakeClient;
|
||||
@ -203,8 +203,8 @@ typedef IVoidHookChain<> IRehldsHook_SV_Frame;
|
||||
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Frame;
|
||||
|
||||
//SV_ShouldSendConsistencyList hook
|
||||
typedef IHookChain<bool, IGameClient*, bool> IRehldsHook_SV_ShouldSendConsistencyList;
|
||||
typedef IHookChainRegistry<bool, IGameClient*, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList;
|
||||
typedef IHookChain<bool, IGameClient *, bool> IRehldsHook_SV_ShouldSendConsistencyList;
|
||||
typedef IHookChainRegistry<bool, IGameClient *, bool> IRehldsHookRegistry_SV_ShouldSendConsistencyList;
|
||||
|
||||
//GetEntityInit hook
|
||||
typedef IHookChain<ENTITYINIT, char *> IRehldsHook_GetEntityInit;
|
||||
@ -222,6 +222,10 @@ typedef IHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Alloc;
|
||||
typedef IVoidHookChain<edict_t *> IRehldsHook_ED_Free;
|
||||
typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_ED_Free;
|
||||
|
||||
//Con_Printf hook
|
||||
typedef IHookChain<void, const char *> IRehldsHook_Con_Printf;
|
||||
typedef IHookChainRegistry<void, const char *> IRehldsHookRegistry_Con_Printf;
|
||||
|
||||
class IRehldsHookchains {
|
||||
public:
|
||||
virtual ~IRehldsHookchains() { }
|
||||
@ -272,6 +276,7 @@ public:
|
||||
virtual IRehldsHookRegistry_SV_EmitPings* SV_EmitPings() = 0;
|
||||
virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0;
|
||||
virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0;
|
||||
virtual IRehldsHookRegistry_Con_Printf* Con_Printf() = 0;
|
||||
};
|
||||
|
||||
struct RehldsFuncs_t {
|
||||
|
@ -63,6 +63,16 @@ void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGame
|
||||
SV_WriteFullClientUpdate_AMXX(&data, client, (size_t)buffer, receiver);
|
||||
}
|
||||
|
||||
void Con_Printf(IRehldsHook_Con_Printf *chain, const char *string)
|
||||
{
|
||||
auto original = [chain](const char *_string)
|
||||
{
|
||||
chain->callNext(_string);
|
||||
};
|
||||
|
||||
callVoidForward(RH_Con_Printf, original, string);
|
||||
}
|
||||
|
||||
ENTITYINIT GetEntityInit(IRehldsHook_GetEntityInit *chain, char *classname)
|
||||
{
|
||||
auto original = [chain](char *_classname)
|
||||
|
@ -359,6 +359,7 @@ struct SV_EmitPings_args_t
|
||||
using SV_EmitPings_t = hookdata_t<IRehldsHook_SV_EmitPings *, SV_EmitPings_args_t &>;
|
||||
void SV_EmitPings_AMXX(SV_EmitPings_t *data, IGameClient *client);
|
||||
void SV_EmitPings(IRehldsHook_SV_EmitPings *chain, IGameClient *client, sizebuf_t *msg);
|
||||
void Con_Printf(IRehldsHook_Con_Printf *chain, const char *string);
|
||||
|
||||
edict_t *ED_Alloc(IRehldsHook_ED_Alloc* chain);
|
||||
void ED_Free(IRehldsHook_ED_Free* chain, edict_t *entity);
|
||||
|
@ -93,6 +93,7 @@ hook_t hooklist_engine[] = {
|
||||
ENG(SV_EmitPings, _AMXX),
|
||||
ENG(ED_Alloc),
|
||||
ENG(ED_Free),
|
||||
ENG(Con_Printf),
|
||||
};
|
||||
|
||||
#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}
|
||||
|
@ -104,7 +104,8 @@ enum EngineFunc
|
||||
RH_SV_EmitPings,
|
||||
RH_ED_Alloc,
|
||||
RH_ED_Free,
|
||||
|
||||
RH_Con_Printf,
|
||||
|
||||
// [...]
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user