diff --git a/reapi/src/member_list.cpp b/reapi/src/member_list.cpp index 0a03a8fb..4497d269 100644 --- a/reapi/src/member_list.cpp +++ b/reapi/src/member_list.cpp @@ -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(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(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(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::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::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::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_) diff --git a/reapi/src/member_list.h b/reapi/src/member_list.h index 50e1f477..0c1f8ad2 100644 --- a/reapi/src/member_list.h +++ b/reapi/src/member_list.h @@ -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 diff --git a/reapi/src/natives/natives_members.cpp b/reapi/src/natives/natives_members.cpp index 6b075b6a..b04562ff 100644 --- a/reapi/src/natives/natives_members.cpp +++ b/reapi/src/natives/natives_members.cpp @@ -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(pEdict); + void *pEntity = get_pdata_custom(getPrivate(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(pEdict); + void *pEntity = get_pdata_custom(getPrivate(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,