mirror of
https://github.com/rehlds/reapi.git
synced 2025-03-13 22:10:24 +03:00
SV_CheckUserInfo: Refer to 'userinfo' argument as a pointer instead of an AMX string buffer
Added natives: - set_netadr/get_netaddr - set_key_value_buffer(buffer, "\\name\\ololo") overwrite a entire buffer - get_key_value_buffer(buffer, userinfo, charsmax(userinfo)) get userinfo as AMX string presentation Minor cleanup Bump minor
This commit is contained in:
parent
08210bec75
commit
ed57d7b309
@ -79,7 +79,8 @@ enum members_tables_e
|
|||||||
mt_rebuystruct,
|
mt_rebuystruct,
|
||||||
mt_mapinfo,
|
mt_mapinfo,
|
||||||
mt_csplayerweapon,
|
mt_csplayerweapon,
|
||||||
mt_gib
|
mt_gib,
|
||||||
|
mt_netadr
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ReAPIFunc {EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib, GamedllFunc_CBaseEntity, GamedllFunc_CBotManager}
|
#define ReAPIFunc {EngineFunc, GamedllFunc, GamedllFunc_CBaseAnimating, GamedllFunc_CBasePlayer, GamedllFunc_CSGameRules, GamedllFunc_CGrenade, GamedllFunc_CWeaponBox, ReCheckerFunc, GamedllFunc_CBasePlayerWeapon, GamedllFunc_CGib, GamedllFunc_CBaseEntity, GamedllFunc_CBotManager}
|
||||||
|
@ -30,6 +30,24 @@ native set_ucmd(const ucmd, const UCmd:var, any:...);
|
|||||||
*/
|
*/
|
||||||
native any:get_ucmd(const ucmd, const UCmd:var, any:...);
|
native any:get_ucmd(const ucmd, const UCmd:var, any:...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets a NetAdr var.
|
||||||
|
*
|
||||||
|
* @param var The specified mvar, look at the enum NetAdrVars
|
||||||
|
*
|
||||||
|
* @return 1 on success.
|
||||||
|
*/
|
||||||
|
native set_netadr(const adr, const NetAdrVars:var, any:...);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a NetAdr var
|
||||||
|
*
|
||||||
|
* @param var The specified mvar, look at the enum NetAdrVars
|
||||||
|
*
|
||||||
|
* @return If an integer or boolean or one byte, array or everything else is passed via the 3rd argument and more, look at the argument list for the specified mvar
|
||||||
|
*/
|
||||||
|
native any:get_netadr(const adr, const NetAdrVars:var, any:...);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets value for key in buffer
|
* Gets value for key in buffer
|
||||||
*
|
*
|
||||||
@ -55,6 +73,28 @@ native get_key_value(const pbuffer, const key[], const value[], const maxlen);
|
|||||||
*/
|
*/
|
||||||
native set_key_value(const pbuffer, const key[], const value[]);
|
native set_key_value(const pbuffer, const key[], const value[]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets an AMXX string buffer from a infobuffer pointer
|
||||||
|
*
|
||||||
|
* @param buffer Info string pointer
|
||||||
|
* @param value String to copy value to
|
||||||
|
* @param maxlen Maximum size of the output buffer
|
||||||
|
*
|
||||||
|
* @return Returns a string buffer on infobuffer pointer
|
||||||
|
*/
|
||||||
|
native get_key_value_buffer(const pbuffer, const output[], const maxlen);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets value string to entire buffer
|
||||||
|
*
|
||||||
|
* @param buffer Pointer to buffer
|
||||||
|
* @param value Value to set
|
||||||
|
* @param maxlen Maximum size of the value buffer to set, -1 means copy all characters
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 otherwise
|
||||||
|
*/
|
||||||
|
native set_key_value_buffer(const pbuffer, const value[], const maxlen = -1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets the position of the bone
|
* Gets the position of the bone
|
||||||
*
|
*
|
||||||
@ -156,7 +196,7 @@ native rh_drop_client(const index, const message[] = "");
|
|||||||
* @param len Maximum buffer size
|
* @param len Maximum buffer size
|
||||||
*
|
*
|
||||||
* @noreturn
|
* @noreturn
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
native rh_get_net_from(output[], len);
|
native rh_get_net_from(output[], len);
|
||||||
|
|
||||||
|
@ -115,53 +115,53 @@ enum EngineFunc
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when a player's userinfo is being checked.
|
* Description: Called when a player's userinfo is being checked.
|
||||||
* Params: (adr, userinfo[], bool:reconnect, reconnectSlot, name[])
|
* Params: (adr, buffer, bool:reconnect, reconnectSlot, name[])
|
||||||
*
|
*
|
||||||
* @note Param adr is unused, guaranteed to return nothing also, don't send anything through it.
|
* @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.
|
* @note In order for param name work, hook needs to be registered as Post.
|
||||||
*/
|
*/
|
||||||
RH_SV_CheckUserInfo,
|
RH_SV_CheckUserInfo,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when a generic resource is being added to generic precache list.
|
* Description: Called when a generic resource is being added to generic precache list.
|
||||||
* Return type: int
|
* Return type: int
|
||||||
* Params: (const string[])
|
* Params: (const string[])
|
||||||
*/
|
*/
|
||||||
RH_PF_precache_generic_I,
|
RH_PF_precache_generic_I,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when a model is being added to model precache list.
|
* Description: Called when a model is being added to model precache list.
|
||||||
* Return type: int
|
* Return type: int
|
||||||
* Params: (const string[])
|
* Params: (const string[])
|
||||||
*/
|
*/
|
||||||
RH_PF_precache_model_I,
|
RH_PF_precache_model_I,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when a sound is being added to sound precache list.
|
* Description: Called when a sound is being added to sound precache list.
|
||||||
* Return type: int
|
* Return type: int
|
||||||
* Params: (const string[])
|
* Params: (const string[])
|
||||||
*/
|
*/
|
||||||
RH_PF_precache_sound_I,
|
RH_PF_precache_sound_I,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when an event is being added to event precache list.
|
* Description: Called when an event is being added to event precache list.
|
||||||
* Return type: int
|
* Return type: int
|
||||||
* Params: (const string[])
|
* Params: (const string[])
|
||||||
*/
|
*/
|
||||||
RH_EV_Precache,
|
RH_EV_Precache,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when a resource is being added to resource list.
|
* Description: Called when a resource is being added to resource list.
|
||||||
* Params: (ResourceType_t:type, const filename[], size, flags, index)
|
* Params: (ResourceType_t:type, const filename[], size, flags, index)
|
||||||
*/
|
*/
|
||||||
RH_SV_AddResource,
|
RH_SV_AddResource,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when message is being printed to client console.
|
* Description: Called when message is being printed to client console.
|
||||||
* Params: (const string[])
|
* Params: (const string[])
|
||||||
*/
|
*/
|
||||||
RH_SV_ClientPrintf,
|
RH_SV_ClientPrintf,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when a command is being sent to server.
|
* Description: Called when a command is being sent to server.
|
||||||
* Params: (const cmd[], source, id)
|
* Params: (const cmd[], source, id)
|
||||||
@ -1268,3 +1268,40 @@ enum UCmd
|
|||||||
*/
|
*/
|
||||||
ucmd_impact_position
|
ucmd_impact_position
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum NetAdrType
|
||||||
|
{
|
||||||
|
NA_NULL = 0,
|
||||||
|
NA_LOOPBACK,
|
||||||
|
NA_BROADCAST,
|
||||||
|
NA_IP,
|
||||||
|
NA_IPX, // Deprecated: GoldSrc
|
||||||
|
NA_BROADCAST_IPX, // Deprecated: GoldSrc
|
||||||
|
};
|
||||||
|
|
||||||
|
enum NetAdrVars
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Description: -
|
||||||
|
* Member type: NetAdrType
|
||||||
|
* Get params: get_netadr(const NetAdr:adr, const NetAdrVars:var);
|
||||||
|
* Set params: set_netadr(const NetAdr:adr, const NetAdrVars:var, const value);
|
||||||
|
*/
|
||||||
|
netadr_type = BEGIN_MEMBER_REGION(netadr),
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description: -
|
||||||
|
* Member type: unsigned char [4]
|
||||||
|
* Get params: get_netadr(const NetAdr:adr, const NetAdrVars:var, dest[], const lenght); // Also returns a iplong value
|
||||||
|
* Set params: set_netadr(const NetAdr:adr, const NetAdrVars:var, const iplong_value); // Only iplong can to set
|
||||||
|
*/
|
||||||
|
netadr_ip,
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Description: -
|
||||||
|
* Member type: unsigned short
|
||||||
|
* Get params: get_netadr(const NetAdr:adr, const NetAdrVars:var);
|
||||||
|
* Set params: set_netadr(const NetAdr:adr, const NetAdrVars:var, const value);
|
||||||
|
*/
|
||||||
|
netadr_port
|
||||||
|
};
|
||||||
|
@ -475,7 +475,7 @@ enum GamedllFunc
|
|||||||
RG_ApplyMultiDamage,
|
RG_ApplyMultiDamage,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Description: Called when player buys an item from buy menu (Nightvision, Kevlar, etc.)
|
* Description: Called when player buys an item from buy menu (Nightvision, Kevlar, etc.)
|
||||||
* Params: (const pPlayer, iSlot)
|
* Params: (const pPlayer, iSlot)
|
||||||
*/
|
*/
|
||||||
RG_BuyItem,
|
RG_BuyItem,
|
||||||
|
@ -150,14 +150,19 @@ bool SV_AllowPhysent(IRehldsHook_SV_AllowPhysent* chain, edict_t* check, edict_t
|
|||||||
return callForward<bool>(RH_SV_AllowPhysent, original, indexOfEdict(check), indexOfEdict(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)
|
BOOL SV_CheckUserInfo_AMXX(IRehldsHook_SV_CheckUserInfo *chain, netadr_t *adr, size_t userinfo, qboolean bIsReconnecting, int iReconnectSlot, char *name)
|
||||||
{
|
{
|
||||||
auto original = [chain](netadr_t *_adr, char *_userinfo, qboolean _bIsReconnecting, int _iReconnectSlot, char *_name)
|
auto original = [chain](netadr_t *_adr, cell _userinfo, qboolean _bIsReconnecting, int _iReconnectSlot, char *_name)
|
||||||
{
|
{
|
||||||
return chain->callNext(_adr, _userinfo, _bIsReconnecting, _iReconnectSlot, _name);
|
return chain->callNext(_adr, (char *)_userinfo, _bIsReconnecting, _iReconnectSlot, _name);
|
||||||
};
|
};
|
||||||
|
|
||||||
return callForward<int>(RH_SV_CheckUserInfo, original, adr, userinfo, bIsReconnecting, iReconnectSlot, name);
|
return callForward<BOOL>(RH_SV_CheckUserInfo, original, adr, userinfo, bIsReconnecting, iReconnectSlot, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL SV_CheckUserInfo(IRehldsHook_SV_CheckUserInfo *chain, netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int iReconnectSlot, char *name)
|
||||||
|
{
|
||||||
|
return SV_CheckUserInfo_AMXX(chain, adr, (size_t)userinfo, bIsReconnecting, iReconnectSlot, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PF_precache_generic_I(IRehldsHook_PF_precache_generic_I *chain, const char *s)
|
int PF_precache_generic_I(IRehldsHook_PF_precache_generic_I *chain, const char *s)
|
||||||
@ -1614,7 +1619,7 @@ void CSGameRules_Think(IReGameHook_CSGameRules_Think *chain)
|
|||||||
|
|
||||||
callVoidForward(RG_CSGameRules_Think, original);
|
callVoidForward(RG_CSGameRules_Think, original);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL CSGameRules_TeamFull(IReGameHook_CSGameRules_TeamFull *chain, int team_id)
|
BOOL CSGameRules_TeamFull(IReGameHook_CSGameRules_TeamFull *chain, int team_id)
|
||||||
{
|
{
|
||||||
auto original = [chain](int _team_id)
|
auto original = [chain](int _team_id)
|
||||||
|
@ -338,7 +338,8 @@ void SV_ActivateServer(IRehldsHook_SV_ActivateServer *chain, int runPhysics);
|
|||||||
void Cvar_DirectSet(IRehldsHook_Cvar_DirectSet *chain, cvar_t *var, const char *value);
|
void Cvar_DirectSet(IRehldsHook_Cvar_DirectSet *chain, cvar_t *var, const char *value);
|
||||||
void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl);
|
void ClientConnected(IRehldsHook_ClientConnected* chain, IGameClient* cl);
|
||||||
void SV_ConnectClient(IRehldsHook_SV_ConnectClient* chain);
|
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);
|
BOOL SV_CheckUserInfo(IRehldsHook_SV_CheckUserInfo *chain, netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int iReconnectSlot, char *name);
|
||||||
|
BOOL SV_CheckUserInfo_AMXX(IRehldsHook_SV_CheckUserInfo *chain, netadr_t *adr, size_t userinfo, qboolean bIsReconnecting, int iReconnectSlot, char *name);
|
||||||
|
|
||||||
struct SV_WriteFullClientUpdate_args_t
|
struct SV_WriteFullClientUpdate_args_t
|
||||||
{
|
{
|
||||||
@ -547,14 +548,14 @@ void ClearMultiDamage(IReGameHook_ClearMultiDamage *chain);
|
|||||||
void AddMultiDamage(IReGameHook_AddMultiDamage *chain, entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
|
void AddMultiDamage(IReGameHook_AddMultiDamage *chain, entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType);
|
||||||
void ApplyMultiDamage(IReGameHook_ApplyMultiDamage *chain, entvars_t *pevInflictor, entvars_t *pevAttacker);
|
void ApplyMultiDamage(IReGameHook_ApplyMultiDamage *chain, entvars_t *pevInflictor, entvars_t *pevAttacker);
|
||||||
void BuyItem(IReGameHook_BuyItem *chain, CBasePlayer *pPlayer, int iSlot);
|
void BuyItem(IReGameHook_BuyItem *chain, CBasePlayer *pPlayer, int iSlot);
|
||||||
void CSGameRules_Think(IReGameHook_CSGameRules_Think *chain);
|
void CSGameRules_Think(IReGameHook_CSGameRules_Think *chain);
|
||||||
BOOL CSGameRules_TeamFull(IReGameHook_CSGameRules_TeamFull *chain, int team_id);
|
BOOL CSGameRules_TeamFull(IReGameHook_CSGameRules_TeamFull *chain, int team_id);
|
||||||
BOOL CSGameRules_TeamStacked(IReGameHook_CSGameRules_TeamStacked *chain, int newTeam_id, int curTeam_id);
|
BOOL CSGameRules_TeamStacked(IReGameHook_CSGameRules_TeamStacked *chain, int newTeam_id, int curTeam_id);
|
||||||
void CSGameRules_PlayerGotWeapon(IReGameHook_CSGameRules_PlayerGotWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
void CSGameRules_PlayerGotWeapon(IReGameHook_CSGameRules_PlayerGotWeapon *chain, CBasePlayer *pPlayer, CBasePlayerItem *pWeapon);
|
||||||
void CBotManager_OnEvent(IReGameHook_CBotManager_OnEvent *chain, GameEventType event, CBaseEntity* pEntity, CBaseEntity* pOther);
|
void CBotManager_OnEvent(IReGameHook_CBotManager_OnEvent *chain, GameEventType event, CBaseEntity* pEntity, CBaseEntity* pOther);
|
||||||
void CBasePlayer_CheckTimeBasedDamage(IReGameHook_CBasePlayer_CheckTimeBasedDamage *chain, CBasePlayer *pthis);
|
void CBasePlayer_CheckTimeBasedDamage(IReGameHook_CBasePlayer_CheckTimeBasedDamage *chain, CBasePlayer *pthis);
|
||||||
edict_t *CBasePlayer_EntSelectSpawnPoint(IReGameHook_CBasePlayer_EntSelectSpawnPoint *chain, CBasePlayer *pthis);
|
edict_t *CBasePlayer_EntSelectSpawnPoint(IReGameHook_CBasePlayer_EntSelectSpawnPoint *chain, CBasePlayer *pthis);
|
||||||
void CBasePlayerWeapon_ItemPostFrame(IReGameHook_CBasePlayerWeapon_ItemPostFrame *chain, CBasePlayerWeapon *pthis);
|
void CBasePlayerWeapon_ItemPostFrame(IReGameHook_CBasePlayerWeapon_ItemPostFrame *chain, CBasePlayerWeapon *pthis);
|
||||||
void CBasePlayerWeapon_KickBack(IReGameHook_CBasePlayerWeapon_KickBack *chain, CBasePlayerWeapon *pthis, float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change);
|
void CBasePlayerWeapon_KickBack(IReGameHook_CBasePlayerWeapon_KickBack *chain, CBasePlayerWeapon *pthis, float up_base, float lateral_base, float up_modifier, float lateral_modifier, float up_max, float lateral_max, int direction_change);
|
||||||
void CBasePlayerWeapon_SendWeaponAnim(IReGameHook_CBasePlayerWeapon_SendWeaponAnim *chain, CBasePlayerWeapon *pthis, int iAnim, int skiplocal);
|
void CBasePlayerWeapon_SendWeaponAnim(IReGameHook_CBasePlayerWeapon_SendWeaponAnim *chain, CBasePlayerWeapon *pthis, int iAnim, int skiplocal);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ hook_t hooklist_engine[] = {
|
|||||||
ENG(ED_Alloc),
|
ENG(ED_Alloc),
|
||||||
ENG(ED_Free),
|
ENG(ED_Free),
|
||||||
ENG(Con_Printf),
|
ENG(Con_Printf),
|
||||||
ENG(SV_CheckUserInfo),
|
ENG(SV_CheckUserInfo, _AMXX),
|
||||||
ENG(PF_precache_generic_I),
|
ENG(PF_precache_generic_I),
|
||||||
ENG(PF_precache_model_I),
|
ENG(PF_precache_model_I),
|
||||||
ENG(PF_precache_sound_I),
|
ENG(PF_precache_sound_I),
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#define MOVEVAR_MEMBERS(mx) STRUCT_MEMBERS(movevars_t, mx, mv_##mx)
|
#define MOVEVAR_MEMBERS(mx) STRUCT_MEMBERS(movevars_t, mx, mv_##mx)
|
||||||
#define UCMD_MEMBERS(mx) STRUCT_MEMBERS(usercmd_s, mx, ucmd_##mx)
|
#define UCMD_MEMBERS(mx) STRUCT_MEMBERS(usercmd_s, mx, ucmd_##mx)
|
||||||
#define PMTRACE_MEMBERS(mx) STRUCT_MEMBERS(pmtrace_s, mx, pmt_##mx)
|
#define PMTRACE_MEMBERS(mx) STRUCT_MEMBERS(pmtrace_s, mx, pmt_##mx)
|
||||||
|
#define NETADR_MEMBERS(mx) STRUCT_MEMBERS(netadr_t, mx, netadr_##mx)
|
||||||
#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx)
|
#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx)
|
||||||
#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx)
|
#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx)
|
||||||
#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS_PREF(CBasePlayerWeapon, mx, m_Weapon_##mx, m_)
|
#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS_PREF(CBasePlayerWeapon, mx, m_Weapon_##mx, m_)
|
||||||
@ -111,6 +112,7 @@ inline MType getMemberType(MONSTERSTATE) { return MEMBER_INTEGER; }
|
|||||||
inline MType getMemberType(ArmorType) { return MEMBER_INTEGER; }
|
inline MType getMemberType(ArmorType) { return MEMBER_INTEGER; }
|
||||||
inline MType getMemberType(ArmouryItemPack) { return MEMBER_INTEGER; }
|
inline MType getMemberType(ArmouryItemPack) { return MEMBER_INTEGER; }
|
||||||
inline MType getMemberType(InfoMapBuyParam) { return MEMBER_INTEGER; }
|
inline MType getMemberType(InfoMapBuyParam) { return MEMBER_INTEGER; }
|
||||||
|
inline MType getMemberType(netadrtype_t) { return MEMBER_INTEGER; }
|
||||||
|
|
||||||
inline MType getMemberType(TraceResult) { return MEMBER_TRACERESULT; }
|
inline MType getMemberType(TraceResult) { return MEMBER_TRACERESULT; }
|
||||||
|
|
||||||
@ -1048,6 +1050,12 @@ member_t memberlist_gib[] = {
|
|||||||
GIB_MEMBERS(lifeTime),
|
GIB_MEMBERS(lifeTime),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
member_t memberlist_netadr[] = {
|
||||||
|
NETADR_MEMBERS(type),
|
||||||
|
NETADR_MEMBERS(ip),
|
||||||
|
NETADR_MEMBERS(port)
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
#endif // #ifdef __GNUC__
|
#endif // #ifdef __GNUC__
|
||||||
@ -1111,6 +1119,7 @@ member_t *memberlist_t::operator[](size_t members) const
|
|||||||
CASE(mapinfo)
|
CASE(mapinfo)
|
||||||
CASE(csplayerweapon)
|
CASE(csplayerweapon)
|
||||||
CASE(gib)
|
CASE(gib)
|
||||||
|
CASE(netadr)
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef CASE
|
#undef CASE
|
||||||
|
@ -83,6 +83,7 @@ struct memberlist_t
|
|||||||
mt_mapinfo,
|
mt_mapinfo,
|
||||||
mt_csplayerweapon,
|
mt_csplayerweapon,
|
||||||
mt_gib,
|
mt_gib,
|
||||||
|
mt_netadr
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -735,6 +736,13 @@ enum PMTrace
|
|||||||
pmt_hitgroup
|
pmt_hitgroup
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum NetAdr
|
||||||
|
{
|
||||||
|
netadr_type = BEGIN_MEMBER_REGION(netadr),
|
||||||
|
netadr_ip,
|
||||||
|
netadr_port
|
||||||
|
};
|
||||||
|
|
||||||
// CCSPlayer
|
// CCSPlayer
|
||||||
enum CSPlayer_Members
|
enum CSPlayer_Members
|
||||||
{
|
{
|
||||||
|
@ -113,6 +113,61 @@ cell AMX_NATIVE_CALL amx_get_viewent(AMX *amx, cell *params)
|
|||||||
return indexOfEdictAmx(pClient->pViewEntity);
|
return indexOfEdictAmx(pClient->pViewEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets value string to entire buffer
|
||||||
|
*
|
||||||
|
* @param buffer Pointer to buffer
|
||||||
|
* @param value Value to set
|
||||||
|
* @param maxlen Maximum size of the value buffer to set, -1 means copy all characters
|
||||||
|
*
|
||||||
|
* @return 1 on success, 0 otherwise
|
||||||
|
*
|
||||||
|
* native set_key_value_buffer(const pbuffer, const value[], const maxlen = -1);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL amx_set_key_value_buffer(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_buffer, arg_value, arg_maxlen };
|
||||||
|
|
||||||
|
char *buffer = reinterpret_cast<char *>(params[arg_buffer]);
|
||||||
|
if (!buffer)
|
||||||
|
{
|
||||||
|
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid buffer", __FUNCTION__);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t maxlen = (params[arg_maxlen] > 0) ? min(params[arg_maxlen], MAX_INFO_STRING) : MAX_INFO_STRING;
|
||||||
|
char infobuf[MAX_INFO_STRING];
|
||||||
|
const char *value = getAmxString(amx, params[arg_value], infobuf);
|
||||||
|
size_t len = min<size_t>(Q_strlen(value) + 1, maxlen);
|
||||||
|
Q_strnlcpy(buffer, value, len);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Gets an AMXX string buffer from a infobuffer pointer
|
||||||
|
*
|
||||||
|
* @param buffer Info string pointer
|
||||||
|
* @param value String to copy value to
|
||||||
|
* @param maxlen Maximum size of the output buffer
|
||||||
|
*
|
||||||
|
* @return Returns a string buffer on infobuffer pointer
|
||||||
|
*
|
||||||
|
* native get_key_value_buffer(const pbuffer, const output[], const maxlen);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL amx_get_key_value_buffer(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_buffer, arg_output, arg_maxlen };
|
||||||
|
|
||||||
|
char *buffer = reinterpret_cast<char *>(params[arg_buffer]);
|
||||||
|
if (!buffer)
|
||||||
|
{
|
||||||
|
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid buffer", __FUNCTION__);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_amxxapi.SetAmxString(amx, params[arg_output], buffer, params[arg_maxlen]);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Gets value for key in buffer
|
* Gets value for key in buffer
|
||||||
*
|
*
|
||||||
@ -480,19 +535,21 @@ cell AMX_NATIVE_CALL amx_SetMoveDone(AMX *amx, cell *params)
|
|||||||
|
|
||||||
AMX_NATIVE_INFO Natives_Common[] =
|
AMX_NATIVE_INFO Natives_Common[] =
|
||||||
{
|
{
|
||||||
{ "FClassnameIs", amx_FClassnameIs },
|
{ "FClassnameIs", amx_FClassnameIs },
|
||||||
{ "GetGrenadeType", amx_GetGrenadeType },
|
{ "GetGrenadeType", amx_GetGrenadeType },
|
||||||
{ "engset_view", amx_engset_view },
|
{ "engset_view", amx_engset_view },
|
||||||
{ "get_viewent", amx_get_viewent },
|
{ "get_viewent", amx_get_viewent },
|
||||||
{ "get_key_value", amx_get_key_value },
|
{ "get_key_value", amx_get_key_value },
|
||||||
{ "set_key_value", amx_set_key_value },
|
{ "set_key_value", amx_set_key_value },
|
||||||
{ "GetBonePosition", amx_GetBonePosition },
|
{ "get_key_value_buffer", amx_get_key_value_buffer },
|
||||||
{ "GetAttachment", amx_GetAttachment },
|
{ "set_key_value_buffer", amx_set_key_value_buffer },
|
||||||
{ "SetThink", amx_SetThink },
|
{ "GetBonePosition", amx_GetBonePosition },
|
||||||
{ "SetTouch", amx_SetTouch },
|
{ "GetAttachment", amx_GetAttachment },
|
||||||
{ "SetUse", amx_SetUse },
|
{ "SetThink", amx_SetThink },
|
||||||
{ "SetBlocked", amx_SetBlocked },
|
{ "SetTouch", amx_SetTouch },
|
||||||
{ "SetMoveDone", amx_SetMoveDone },
|
{ "SetUse", amx_SetUse },
|
||||||
|
{ "SetBlocked", amx_SetBlocked },
|
||||||
|
{ "SetMoveDone", amx_SetMoveDone },
|
||||||
|
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
@ -667,6 +667,96 @@ cell AMX_NATIVE_CALL get_pmtrace(AMX *amx, cell *params)
|
|||||||
return get_member(tr, member, dest, element);
|
return get_member(tr, member, dest, element);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sets a NetAdr var.
|
||||||
|
*
|
||||||
|
* @param var The specified mvar, look at the enum NetAdrVars
|
||||||
|
*
|
||||||
|
* @return 1 on success.
|
||||||
|
*
|
||||||
|
* native set_netadr(const adr, const NetAdrVars:var, any:...);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL set_netadr(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_adr, arg_var, arg_value };
|
||||||
|
member_t *member = memberlist[params[arg_var]];
|
||||||
|
|
||||||
|
if (unlikely(member == nullptr)) {
|
||||||
|
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
netadr_t *adr = (netadr_t *)params[arg_adr];
|
||||||
|
if (unlikely(adr == nullptr)) {
|
||||||
|
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid network address", __FUNCTION__);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (params[arg_var])
|
||||||
|
{
|
||||||
|
case netadr_type:
|
||||||
|
adr->type = (netadrtype_t)params[arg_value];
|
||||||
|
break;
|
||||||
|
case netadr_port:
|
||||||
|
adr->port = ntohs(params[arg_value] & 0xFFFF); // cap short
|
||||||
|
break;
|
||||||
|
case netadr_ip:
|
||||||
|
*(size_t *)adr->ip = htonl(params[arg_value] & 0xFFFFFFFF); // cap int
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a NetAdr var
|
||||||
|
*
|
||||||
|
* @param var The specified mvar, look at the enum NetAdrVars
|
||||||
|
*
|
||||||
|
* @return If an integer or boolean or one byte, array or everything else is passed via the 3rd argument and more, look at the argument list for the specified mvar
|
||||||
|
*
|
||||||
|
* native any:get_netadr(const adr, const NetAdrVars:var, any:...);
|
||||||
|
*/
|
||||||
|
cell AMX_NATIVE_CALL get_netadr(AMX *amx, cell *params)
|
||||||
|
{
|
||||||
|
enum args_e { arg_count, arg_adr, arg_var, arg_3, arg_4 };
|
||||||
|
member_t *member = memberlist[params[arg_var]];
|
||||||
|
|
||||||
|
if (unlikely(member == nullptr)) {
|
||||||
|
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
netadr_t *adr = (netadr_t *)params[arg_adr];
|
||||||
|
if (unlikely(adr == nullptr)) {
|
||||||
|
AMXX_LogError(amx, AMX_ERR_NATIVE, "%s: Invalid network address", __FUNCTION__);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (params[arg_var])
|
||||||
|
{
|
||||||
|
case netadr_type: return adr->type;
|
||||||
|
case netadr_port: return ntohs(adr->port);
|
||||||
|
case netadr_ip:
|
||||||
|
{
|
||||||
|
if (PARAMS_COUNT == 4)
|
||||||
|
{
|
||||||
|
cell *dest = getAmxAddr(amx, params[arg_3]);
|
||||||
|
size_t length = *getAmxAddr(amx, params[arg_4]);
|
||||||
|
setAmxString(dest, NET_AdrToString(*adr, true /*no port*/), length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return htonl(*(size_t *)adr->ip);
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sets a RebuyStruct member.
|
* Sets a RebuyStruct member.
|
||||||
*
|
*
|
||||||
@ -757,6 +847,9 @@ AMX_NATIVE_INFO ReGameVars_Natives[] =
|
|||||||
{ "set_pmtrace", set_pmtrace },
|
{ "set_pmtrace", set_pmtrace },
|
||||||
{ "get_pmtrace", get_pmtrace },
|
{ "get_pmtrace", get_pmtrace },
|
||||||
|
|
||||||
|
{ "set_netadr", set_netadr },
|
||||||
|
{ "get_netadr", get_netadr },
|
||||||
|
|
||||||
{ nullptr, nullptr }
|
{ nullptr, nullptr }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1010,7 +1010,7 @@ cell AMX_NATIVE_CALL rg_drop_item(AMX *amx, cell *params)
|
|||||||
|
|
||||||
char item[256];
|
char item[256];
|
||||||
auto pEntity = pPlayer->CSPlayer()->DropPlayerItem(getAmxString(amx, params[arg_item_name], item));
|
auto pEntity = pPlayer->CSPlayer()->DropPlayerItem(getAmxString(amx, params[arg_item_name], item));
|
||||||
|
|
||||||
if (pEntity)
|
if (pEntity)
|
||||||
return indexOfPDataAmx(pEntity);
|
return indexOfPDataAmx(pEntity);
|
||||||
|
|
||||||
@ -2230,7 +2230,7 @@ cell AMX_NATIVE_CALL rg_get_iteminfo(AMX *amx, cell *params)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a parameter of the global CBasePlayerItem::m_ItemInfoArray array
|
* Sets a parameter of the global CBasePlayerItem::m_ItemInfoArray array
|
||||||
* @note To have effect on client side (i.g. ammo size on HUD) you should
|
* @note To have effect on client side (i.g. ammo size on HUD) you should
|
||||||
* alter this value BEFORE WeaponList message is sent to client, or
|
* alter this value BEFORE WeaponList message is sent to client, or
|
||||||
* force it's alteration by sending again to the specific client.
|
* force it's alteration by sending again to the specific client.
|
||||||
* Hooking WeaponList message with AMXX's register_message is a choice.
|
* Hooking WeaponList message with AMXX's register_message is a choice.
|
||||||
@ -2299,7 +2299,7 @@ cell AMX_NATIVE_CALL rg_get_global_iteminfo(AMX *amx, cell *params)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ItemInfo_e type = static_cast<ItemInfo_e>(params[arg_type]);
|
ItemInfo_e type = static_cast<ItemInfo_e>(params[arg_type]);
|
||||||
if ((type == ItemInfo_pszAmmo1 || type == ItemInfo_pszAmmo2 || type == ItemInfo_pszName) && PARAMS_COUNT != 4)
|
if ((type == ItemInfo_pszAmmo1 || type == ItemInfo_pszAmmo2 || type == ItemInfo_pszName) && PARAMS_COUNT != 4)
|
||||||
{
|
{
|
||||||
AMXX_LogError(amx, AMX_ERR_NATIVE, "Bad arg count. Expected %d, got %d.", 4, PARAMS_COUNT);
|
AMXX_LogError(amx, AMX_ERR_NATIVE, "Bad arg count. Expected %d, got %d.", 4, PARAMS_COUNT);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -2861,7 +2861,7 @@ cell AMX_NATIVE_CALL rh_get_net_from(AMX* amx, cell* params)
|
|||||||
enum args_e { arg_count, arg_output, arg_maxlen };
|
enum args_e { arg_count, arg_output, arg_maxlen };
|
||||||
|
|
||||||
cell *dest = getAmxAddr(amx, params[arg_output]);
|
cell *dest = getAmxAddr(amx, params[arg_output]);
|
||||||
char *addr = NET_AdrToString(*g_RehldsData->GetNetFrom());
|
const char *addr = NET_AdrToString(*g_RehldsData->GetNetFrom());
|
||||||
|
|
||||||
setAmxString(dest, addr, params[arg_maxlen]);
|
setAmxString(dest, addr, params[arg_maxlen]);
|
||||||
|
|
||||||
|
@ -262,7 +262,7 @@ const char *getATypeStr(AType type)
|
|||||||
return s_ATypes[type];
|
return s_ATypes[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
char* NET_AdrToString(const netadr_t& a)
|
const char *NET_AdrToString(const netadr_t &a, bool onlyBase)
|
||||||
{
|
{
|
||||||
static char s[64];
|
static char s[64];
|
||||||
|
|
||||||
@ -270,8 +270,14 @@ char* NET_AdrToString(const netadr_t& a)
|
|||||||
|
|
||||||
if (a.type == NA_LOOPBACK)
|
if (a.type == NA_LOOPBACK)
|
||||||
Q_snprintf(s, sizeof(s), "loopback");
|
Q_snprintf(s, sizeof(s), "loopback");
|
||||||
|
|
||||||
else if (a.type == NA_IP)
|
else if (a.type == NA_IP)
|
||||||
Q_snprintf(s, sizeof(s), "%i.%i.%i.%i:%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3], ntohs(a.port));
|
{
|
||||||
|
if (onlyBase)
|
||||||
|
Q_snprintf(s, sizeof(s), "%i.%i.%i.%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3]);
|
||||||
|
else
|
||||||
|
Q_snprintf(s, sizeof(s), "%i.%i.%i.%i:%i", a.ip[0], a.ip[1], a.ip[2], a.ip[3], ntohs(a.port));
|
||||||
|
}
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
else // NA_IPX
|
else // NA_IPX
|
||||||
Q_snprintf(s, sizeof(s), "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%i", a.ipx[0], a.ipx[1], a.ipx[2], a.ipx[3], a.ipx[4], a.ipx[5], a.ipx[6], a.ipx[7], a.ipx[8], a.ipx[9], ntohs(a.port));
|
Q_snprintf(s, sizeof(s), "%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%i", a.ipx[0], a.ipx[1], a.ipx[2], a.ipx[3], a.ipx[4], a.ipx[5], a.ipx[6], a.ipx[7], a.ipx[8], a.ipx[9], ntohs(a.port));
|
||||||
|
@ -59,6 +59,6 @@ void RemoveOrDropItem(CBasePlayer *pPlayer, CBasePlayerItem *pItem, GiveType typ
|
|||||||
|
|
||||||
const char *getATypeStr(AType type);
|
const char *getATypeStr(AType type);
|
||||||
|
|
||||||
char *NET_AdrToString(const netadr_t& a);
|
const char *NET_AdrToString(const netadr_t &a, bool onlyBase = false);
|
||||||
|
|
||||||
extern void NORETURN UTIL_SysError(const char *fmt, ...);
|
extern void NORETURN UTIL_SysError(const char *fmt, ...);
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#define VERSION_MAJOR 5
|
#define VERSION_MAJOR 5
|
||||||
#define VERSION_MINOR 23
|
#define VERSION_MINOR 24
|
||||||
#define VERSION_MAINTENANCE 0
|
#define VERSION_MAINTENANCE 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user