Skip to content

Commit

Permalink
set/get_member_s: fix missing check for members CCSPlayer/CCSPlayerWe…
Browse files Browse the repository at this point in the history
…apon
  • Loading branch information
s1lentq committed Dec 17, 2020
1 parent 5ab7874 commit 97bc563
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
19 changes: 10 additions & 9 deletions reapi/src/member_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
#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)
#define BASE_MEMBERS(mx) CLASS_MEMBERS(CBaseEntity, mx, mx)
#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_)
Expand Down Expand Up @@ -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_)
Expand Down
2 changes: 1 addition & 1 deletion reapi/src/member_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions reapi/src/natives/natives_members.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand All @@ -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
Expand Down Expand Up @@ -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))
{
Expand All @@ -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,
Expand Down

0 comments on commit 97bc563

Please sign in to comment.