2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-28 07:35:31 +03:00

Implement RH_SV_AllowPhysent hook (#265)

This commit is contained in:
Hamdi 2023-02-11 11:44:28 +00:00 committed by GitHub
parent 7d9bd65e4f
commit aeabd1fa10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 2 deletions

View File

@ -162,6 +162,13 @@ enum EngineFunc
*/
RH_SV_ClientPrintf,
/*
* Description: Called before adding an entity to the physents of a player.
* Return type: bool
* Params: (const entity, const client)
*/
RH_SV_AllowPhysent,
};
/**

View File

@ -36,7 +36,7 @@
#include "pr_dlls.h"
#define REHLDS_API_VERSION_MAJOR 3
#define REHLDS_API_VERSION_MINOR 12
#define REHLDS_API_VERSION_MINOR 13
//Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -254,6 +254,10 @@ typedef IVoidHookChainRegistry<resourcetype_t, const char *, int, unsigned char,
typedef IVoidHookChain<const char *> IRehldsHook_SV_ClientPrintf;
typedef IVoidHookChainRegistry<const char *> IRehldsHookRegistry_SV_ClientPrintf;
//SV_AllowPhysent hook
typedef IHookChain<bool, edict_t*, edict_t*> IRehldsHook_SV_AllowPhysent;
typedef IHookChainRegistry<bool, edict_t*, edict_t*> IRehldsHookRegistry_SV_AllowPhysent;
class IRehldsHookchains {
public:
virtual ~IRehldsHookchains() { }
@ -312,6 +316,7 @@ public:
virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0;
virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0;
virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0;
virtual IRehldsHookRegistry_SV_AllowPhysent* SV_AllowPhysent() = 0;
};
struct RehldsFuncs_t {

View File

@ -140,6 +140,16 @@ void ED_Free(IRehldsHook_ED_Free* chain, edict_t *entity)
callVoidForward(RH_ED_Free, original, indexOfEdict(entity));
}
bool SV_AllowPhysent(IRehldsHook_SV_AllowPhysent* chain, edict_t* check, edict_t* sv_player)
{
auto original = [chain](int _check, int _sv_player)
{
return chain->callNext(edictByIndexAmx(_check), edictByIndexAmx(_sv_player));
};
return callForward<bool>(RH_SV_AllowPhysent, original, indexOfEdict(check), indexOfEdict(sv_player));
}
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)

View File

@ -378,6 +378,7 @@ void SV_AddResource(IRehldsHook_SV_AddResource *chain, resourcetype_t type, cons
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);
bool SV_AllowPhysent(IRehldsHook_SV_AllowPhysent* chain, edict_t* check, edict_t* sv_player);
// regamedll functions
int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver);

View File

@ -103,6 +103,7 @@ hook_t hooklist_engine[] = {
ENG(EV_Precache, _AMXX),
ENG(SV_AddResource),
ENG(SV_ClientPrintf),
ENG(SV_AllowPhysent),
};

View File

@ -112,6 +112,7 @@ enum EngineFunc
RH_EV_Precache,
RH_SV_AddResource,
RH_SV_ClientPrintf,
RH_SV_AllowPhysent,
// [...]
};

View File

@ -6,5 +6,5 @@
#pragma once
#define VERSION_MAJOR 5
#define VERSION_MINOR 22
#define VERSION_MINOR 23
#define VERSION_MAINTENANCE 0