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

Add ClientConnected hook (#223)

Add `ClientConnected()` hook. Called after processing a client connection request.
This commit is contained in:
bionext03 2021-10-20 16:09:08 +00:00 committed by GitHub
parent 37e7b12ba0
commit 36d6311eaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 21 additions and 2 deletions

View File

@ -53,6 +53,12 @@ enum EngineFunc
* Params: (const client, buffer, const receiver)
*/
RH_SV_WriteFullClientUpdate,
/*
* Description: Called after processing a client connection request.
* Params: (const client)
*/
RH_ClientConnected,
};
/**

View File

@ -63,6 +63,16 @@ void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGame
SV_WriteFullClientUpdate_AMXX(&data, client, (size_t)buffer, receiver);
}
void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl)
{
auto original = [chain](int client)
{
chain->callNext(g_RehldsSvs->GetClient(client - 1));
};
callVoidForward(RH_ClientConnected, original, cl->GetId() + 1);
}
/*
* ReGameDLL functions
*/

View File

@ -331,6 +331,7 @@ void SV_StartSound(IRehldsHook_SV_StartSound *chain, int recipients, edict_t *en
void SV_DropClient(IRehldsHook_SV_DropClient *chain, IGameClient *cl, bool crash, const char *fmt);
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);
struct SV_WriteFullClientUpdate_args_t
{

View File

@ -86,7 +86,8 @@ hook_t hooklist_engine[] = {
ENG(SV_DropClient),
ENG(SV_ActivateServer),
ENG(Cvar_DirectSet),
ENG(SV_WriteFullClientUpdate, _AMXX)
ENG(SV_WriteFullClientUpdate, _AMXX),
ENG(ClientConnected)
};
#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}

View File

@ -97,7 +97,8 @@ enum EngineFunc
RH_SV_DropClient,
RH_SV_ActivateServer,
RH_Cvar_DirectSet,
RH_SV_WriteFullClientUpdate
RH_SV_WriteFullClientUpdate,
RH_ClientConnected
// [...]
};