2
0
mirror of https://github.com/rehlds/reapi.git synced 2024-12-27 23:25:30 +03:00

set/get_member_s: fix missing check for members CCSPlayer/CCSPlayerWeapon

This commit is contained in:
s1lentq 2020-12-18 04:09:26 +07:00
parent 5ab787460d
commit 97bc56390a
3 changed files with 15 additions and 14 deletions

View File

@ -14,9 +14,10 @@
#define decltypefxdot(cx, pref, mx) decltype(cx::pref.mx)
#endif
#define CLASS_MEMBERS(cx, mx, postf) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, , mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, mx);ptr->type = getMemberType(f);ptr->name = #postf;ptr->pfnIsRefsToClass = [](CBaseEntity *pEntity){ return dynamic_cast<cx *>(pEntity) != nullptr;};}) : regmember(#mx)
#define CLASS_MEMBERS_PREF(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, pref, mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, pref##mx);ptr->type = getMemberType(f);ptr->name = #postf;ptr->pfnIsRefsToClass = [](CBaseEntity *pEntity){ return dynamic_cast<cx *>(pEntity) != nullptr;};}) : regmember(#pref#mx)
#define CLASS_MEMBERS_DOT(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefxdot(cx, pref, mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, pref.mx);ptr->type = getMemberType(f);ptr->name = #postf;ptr->pfnIsRefsToClass = [](CBaseEntity *pEntity){ return dynamic_cast<cx *>(pEntity) != nullptr;};}) : regmember(#pref"."#mx)
#define STRUCT_MEMBERS(cx, mx, postf) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, , mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, mx);ptr->type = getMemberType(f);ptr->name = #postf;}) : regmember(#mx)
#define CLASS_MEMBERS(cx, mx, postf) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, , mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, mx);ptr->type = getMemberType(f);ptr->name = #postf;ptr->pfnIsRefsToClass = [](void *pEntity){ return dynamic_cast<cx *>((cx::BaseClass *)pEntity) != nullptr;};}) : regmember(#mx)
#define CLASS_MEMBERS_PREF(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefx(cx, pref, mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, pref##mx);ptr->type = getMemberType(f);ptr->name = #postf;ptr->pfnIsRefsToClass = [](void *pEntity){ return dynamic_cast<cx *>((cx::BaseClass *)pEntity) != nullptr;};}) : regmember(#pref#mx)
#define CLASS_MEMBERS_DOT(cx, mx, postf, pref) ((!(postf & (MAX_REGION_RANGE - 1)) ? regmember::current_cell = 1, true : false) || (postf & (MAX_REGION_RANGE - 1)) == regmember::current_cell++) ? regmember([](member_t* ptr){ decltypefxdot(cx, pref, mx) f = {};ptr->size = getTypeSize(f);ptr->max_size = sizeof(f);ptr->offset = offsetof(cx, pref.mx);ptr->type = getMemberType(f);ptr->name = #postf;ptr->pfnIsRefsToClass = [](void *pEntity){ return dynamic_cast<cx *>((cx::BaseClass *)pEntity) != nullptr;};}) : regmember(#pref"."#mx)
#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx)
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS_DOT(CHalfLifeMultiplay, mx, mx, m_VoiceGameMgr)
@ -24,11 +25,11 @@
#define ANIM_MEMBERS(mx) CLASS_MEMBERS(CBaseAnimating, mx, mx)
#define MONST_MEMBERS(mx) CLASS_MEMBERS(CBaseMonster, mx, mx)
#define PL_MEMBERS(mx) CLASS_MEMBERS(CBasePlayer, mx, mx)
#define EVAR_MEMBERS(mx) CLASS_MEMBERS(com_entvars, mx, var_##mx)
#define PMOVE_MEMBERS(mx) CLASS_MEMBERS(com_playermove, mx, pm_##mx)
#define MOVEVAR_MEMBERS(mx) CLASS_MEMBERS(movevars_t, mx, mv_##mx)
#define UCMD_MEMBERS(mx) CLASS_MEMBERS(usercmd_s, mx, ucmd_##mx)
#define PMTRACE_MEMBERS(mx) CLASS_MEMBERS(pmtrace_s, mx, pmt_##mx)
#define EVAR_MEMBERS(mx) STRUCT_MEMBERS(com_entvars, mx, var_##mx)
#define PMOVE_MEMBERS(mx) STRUCT_MEMBERS(com_playermove, mx, pm_##mx)
#define MOVEVAR_MEMBERS(mx) STRUCT_MEMBERS(movevars_t, mx, mv_##mx)
#define UCMD_MEMBERS(mx) STRUCT_MEMBERS(usercmd_s, mx, ucmd_##mx)
#define PMTRACE_MEMBERS(mx) STRUCT_MEMBERS(pmtrace_s, mx, pmt_##mx)
#define CSPL_MEMBERS(mx) CLASS_MEMBERS(CCSPlayer, mx, mx)
#define BASEITEM_MEMBERS(mx) CLASS_MEMBERS(CBasePlayerItem, mx, mx)
#define BASEWPN_MEMBERS(mx) CLASS_MEMBERS_PREF(CBasePlayerWeapon, mx, m_Weapon_##mx, m_)
@ -64,7 +65,7 @@
#define KNIFE_MEMBERS(mx) CLASS_MEMBERS_PREF(CKnife, mx, m_Knife_##mx, m_)
#define P90_MEMBERS(mx) CLASS_MEMBERS_PREF(CP90, mx, m_P90_##mx, m_)
#define SHIELD_MEMBERS(mx) CLASS_MEMBERS_PREF(CWShield, mx, m_Shield_##mx, m_)
#define REBUYSTRUCT_MEMBERS(mx) CLASS_MEMBERS(RebuyStruct, mx, mx)
#define REBUYSTRUCT_MEMBERS(mx) STRUCT_MEMBERS(RebuyStruct, mx, mx)
#define MAPINFO_MEMBERS(mx) CLASS_MEMBERS_PREF(CMapInfo, mx, m_MapInfo_##mx, m_)
#define CSPLWPN_MEMBERS(mx) CLASS_MEMBERS_PREF(CCSPlayerWeapon, mx, m_Weapon_##mx, m_)
#define GIB_MEMBERS(mx) CLASS_MEMBERS_PREF(CGib, mx, m_Gib_##mx, m_)

View File

@ -95,7 +95,7 @@ struct member_t
size_t offset;
const char *name;
MType type;
bool (*pfnIsRefsToClass)(class CBaseEntity *pEntity);
bool (*pfnIsRefsToClass)(void *pEntity);
};
inline bool member_t::isTypeReturnable() const

View File

@ -136,7 +136,7 @@ cell AMX_NATIVE_CALL set_member_s(AMX *amx, cell *params)
cell* value = getAmxAddr(amx, params[arg_value]);
size_t element = (PARAMS_COUNT == 4) ? *getAmxAddr(amx, params[arg_elem]) : 0;
CBaseEntity *pEntity = getPrivate<CBaseEntity>(pEdict);
void *pEntity = get_pdata_custom(getPrivate<CBaseEntity>(pEdict), params[arg_member]);
if (!member->pfnIsRefsToClass(pEntity))
{
@ -145,7 +145,7 @@ cell AMX_NATIVE_CALL set_member_s(AMX *amx, cell *params)
}
return set_member(
get_pdata_custom(pEntity, params[arg_member]),
pEntity,
member,
value,
element
@ -216,7 +216,7 @@ cell AMX_NATIVE_CALL get_member_s(AMX *amx, cell *params)
break;
}
CBaseEntity *pEntity = getPrivate<CBaseEntity>(pEdict);
void *pEntity = get_pdata_custom(getPrivate<CBaseEntity>(pEdict), params[arg_member]);
if (!member->pfnIsRefsToClass(pEntity))
{
@ -225,7 +225,7 @@ cell AMX_NATIVE_CALL get_member_s(AMX *amx, cell *params)
}
return get_member(
get_pdata_custom(pEntity, params[arg_member]),
pEntity,
member,
dest,
element,