mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-29 08:05:36 +03:00
Add hook for SV_WriteFullClientUpdate
(cherry picked from commit 77f6cfb8a713937c0ab424353a6ab83c08fb977d) # Conflicts: # reapi/src/hook_list.cpp
This commit is contained in:
parent
b9f817a5ae
commit
b06b1915eb
@ -1,3 +1,3 @@
|
||||
majorVersion=5
|
||||
minorVersion=1
|
||||
minorVersion=2
|
||||
maintenanceVersion=0
|
||||
|
@ -88,3 +88,28 @@ native bool:rh_emit_sound2(const entity, const recipient, const channel, const s
|
||||
* @noreturn
|
||||
*/
|
||||
native rh_update_user_info(playerEntIndex);
|
||||
|
||||
/*
|
||||
* Gets value for key in buffer
|
||||
*
|
||||
* @param pbuffer Pointer to buffer
|
||||
* @param key Key string
|
||||
* @param value Buffer to copy value to
|
||||
* @param maxlen Maximum size of the buffer
|
||||
*
|
||||
* @return Number of cells written to buffer
|
||||
* @error If the index is not within the range of 1 to MaxClients or
|
||||
* the client is not connected, an error will be thrown.
|
||||
*/
|
||||
native rh_get_key_value(const pbuffer, const key[], value[], maxlen)
|
||||
|
||||
/*
|
||||
* Sets value for key in buffer
|
||||
*
|
||||
* @param pbuffer Pointer to buffer
|
||||
* @param key Key string
|
||||
* @param value Value to set
|
||||
*
|
||||
* @noreturn
|
||||
*/
|
||||
native rh_set_key_value(const pbuffer, const key[], const value[])
|
||||
|
@ -40,6 +40,12 @@ enum EngineFunc
|
||||
* Params: (pcvar, const value[])
|
||||
*/
|
||||
RH_Cvar_DirectSet,
|
||||
|
||||
/*
|
||||
* Description: Receiver is player index or 0 when update will be sended to all.
|
||||
* Params: (client, receiver, pinfo)
|
||||
*/
|
||||
RH_SV_WriteFullClientUpdate,
|
||||
};
|
||||
|
||||
enum EntVars
|
||||
|
@ -46,6 +46,26 @@ void Cvar_DirectSet(IRehldsHook_Cvar_DirectSet *chain, cvar_t *var, const char *
|
||||
callVoidForward(RH_Cvar_DirectSet, original, var, value);
|
||||
}
|
||||
|
||||
void SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGameClient *client, char *info, size_t maxlen, sizebuf_t *sb, IGameClient *receiver)
|
||||
{
|
||||
int receiver_id = 0;
|
||||
if (receiver)
|
||||
receiver_id = receiver->GetId() + 1;
|
||||
|
||||
auto original = [chain, sb](int _client, int _receiver, int _pinfo)
|
||||
{
|
||||
sizebuf_t* dest = sb;
|
||||
IGameClient* receiver = nullptr;
|
||||
if (_receiver) {
|
||||
receiver = g_RehldsSvs->GetClient(_receiver - 1);
|
||||
dest = receiver->GetNetChan()->GetMessageBuf();
|
||||
}
|
||||
chain->callNext(g_RehldsSvs->GetClient(_client - 1), (char *)_pinfo, MAX_INFO_STRING, dest, receiver);
|
||||
};
|
||||
|
||||
callVoidForward(RH_SV_WriteFullClientUpdate, original, client->GetId() + 1, receiver_id, int(info));
|
||||
}
|
||||
|
||||
/*
|
||||
* ReGameDLL functions
|
||||
*/
|
||||
|
@ -299,6 +299,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 SV_WriteFullClientUpdate(IRehldsHook_SV_WriteFullClientUpdate *chain, IGameClient *client, char *info, size_t maxlen, sizebuf_t *sb, IGameClient *receiver);
|
||||
|
||||
// regamedll functions
|
||||
int GetForceCamera(IReGameHook_GetForceCamera *chain, CBasePlayer *pObserver);
|
||||
|
@ -1,13 +1,13 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
inline size_t getFwdParamType(void(*)(int)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(short)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(bool)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(uint32)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(Vector&)) { return FP_ARRAY; }
|
||||
inline size_t getFwdParamType(void(*)(PLAYER_ANIM)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(WeaponIdType)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(RewardType)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(int)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(size_t)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(short)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(bool)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(Vector&)) { return FP_ARRAY; }
|
||||
inline size_t getFwdParamType(void(*)(PLAYER_ANIM)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(WeaponIdType)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(RewardType)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(ScenarioEventEndRound)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(ItemID)) { return FP_CELL; }
|
||||
inline size_t getFwdParamType(void(*)(ItemRestType)) { return FP_CELL; }
|
||||
@ -74,7 +74,8 @@ hook_t hooklist_engine[] = {
|
||||
ENG(SV_StartSound),
|
||||
ENG(SV_DropClient),
|
||||
ENG(SV_ActivateServer),
|
||||
ENG(Cvar_DirectSet)
|
||||
ENG(Cvar_DirectSet),
|
||||
ENG(SV_WriteFullClientUpdate)
|
||||
};
|
||||
|
||||
#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) : regfunc(#h), [](){ g_ReGameHookchains->##h##()->registerHook(&##h); }, [](){ g_ReGameHookchains->##h##()->unregisterHook(&##h); }}
|
||||
|
@ -80,6 +80,7 @@ enum EngineFunc
|
||||
RH_SV_DropClient,
|
||||
RH_SV_ActivateServer,
|
||||
RH_Cvar_DirectSet,
|
||||
RH_SV_WriteFullClientUpdate
|
||||
|
||||
// [...]
|
||||
};
|
||||
|
@ -2012,6 +2012,28 @@ cell AMX_NATIVE_CALL rh_update_user_info(AMX *amx, cell *params)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cell AMX_NATIVE_CALL rh_get_key_value(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_buffer, arg_key, arg_value, arg_maxlen };
|
||||
|
||||
char *buffer = getAmxString(amx, params[arg_buffer]);
|
||||
const char *key = getAmxString(amx, params[arg_key]);
|
||||
|
||||
return g_amxxapi.SetAmxString(amx, params[arg_value], g_engfuncs.pfnInfoKeyValue(buffer, key), params[arg_maxlen]);
|
||||
}
|
||||
|
||||
cell AMX_NATIVE_CALL rh_set_key_value(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_buffer, arg_key, arg_value };
|
||||
|
||||
char *buffer = getAmxString(amx, params[arg_buffer]);
|
||||
const char *key = getAmxString(amx, params[arg_key]);
|
||||
const char *value = getAmxString(amx, params[arg_value]);
|
||||
|
||||
g_engfuncs.pfnSetKeyValue(buffer, key, value);
|
||||
return 1;
|
||||
}
|
||||
|
||||
AMX_NATIVE_INFO Misc_Natives_RH[] =
|
||||
{
|
||||
{ "rh_set_mapname", rh_set_mapname },
|
||||
@ -2019,6 +2041,8 @@ AMX_NATIVE_INFO Misc_Natives_RH[] =
|
||||
{ "rh_reset_mapname", rh_reset_mapname },
|
||||
{ "rh_emit_sound2", rh_emit_sound2 },
|
||||
{ "rh_update_user_info", rh_update_user_info },
|
||||
{ "rh_get_key_value", rh_get_key_value },
|
||||
{ "rh_set_key_value", rh_set_key_value },
|
||||
|
||||
{ nullptr, nullptr }
|
||||
};
|
||||
|
@ -1,5 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_KV_LEN = 127,
|
||||
MAX_INFO_STRING = 256
|
||||
};
|
||||
|
||||
enum WpnInfo
|
||||
{
|
||||
WI_ID,
|
||||
|
Loading…
Reference in New Issue
Block a user