mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-28 15:45:31 +03:00
Simplification natives members
This commit is contained in:
parent
ecdb7e9f96
commit
f93e992674
@ -1031,7 +1031,7 @@ enum CSGameRules_Members
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: int [100]
|
||||
* Get params: get_member_game(member);
|
||||
* Get params: get_member_game(member, element);
|
||||
* Set params: set_member_game(member, value, element);
|
||||
*/
|
||||
m_iMapVotes,
|
||||
@ -1119,7 +1119,7 @@ enum CSGameRules_Members
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: int [5]
|
||||
* Get params: get_member_game(member);
|
||||
* Get params: get_member_game(member, element);
|
||||
* Set params: set_member_game(member, value, element);
|
||||
*/
|
||||
m_pVIPQueue,
|
||||
@ -1232,8 +1232,8 @@ enum CSGameRules_Members
|
||||
/*
|
||||
* Description: -
|
||||
* Member type: float
|
||||
* Get params: Float:get_member(index, member);
|
||||
* Set params: set_member(index, member, Float:value);
|
||||
* Get params: Float:get_member_game(member);
|
||||
* Set params: set_member_game(member, Float:value);
|
||||
*/
|
||||
m_flEscapeRatio
|
||||
};
|
||||
|
@ -13,7 +13,7 @@ class CAmxxHook
|
||||
{
|
||||
public:
|
||||
CAmxxHook(AMX* amx, int index) : m_index(index), m_state(FSTATE_ENABLED), m_amx(amx) {};
|
||||
|
||||
|
||||
int GetIndex() const;
|
||||
fwdstate GetState() const;
|
||||
AMX* GetAmx() const;
|
||||
|
@ -1,9 +1,17 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
#define CLASS_MEMBERS(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){ decltype(##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;}) : regmember(#pref#mx)
|
||||
#if _MSC_VER <= 1800 && __INTEL_COMPILER < 1500
|
||||
// BUG BUG
|
||||
// http://connect.microsoft.com/VisualStudio/feedbackdetail/view/797682/c-decltype-of-class-member-access-incompletely-implemented
|
||||
#define decltypefx(cx, pref, dt, mx) decltype(std::declval<cx>()dt##pref##mx)
|
||||
#else
|
||||
#define decltypefx(cx, pref, dt, mx) decltype(cx::pref##mx)
|
||||
#endif
|
||||
|
||||
#define CLASS_MEMBERS(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;}) : regmember(#pref#mx)
|
||||
|
||||
#define GM_MEMBERS(mx) CLASS_MEMBERS(CHalfLifeMultiplay, mx, mx,)
|
||||
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(CVoiceGameMgr, mx, mx,)
|
||||
#define GM_VOICE_MEMBERS(mx) CLASS_MEMBERS(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,)
|
||||
@ -38,8 +46,8 @@ inline MType getMemberType(Vector*) { return MEMBER_VECTOR; }
|
||||
inline MType getMemberType(Vector) { return MEMBER_VECTOR; }
|
||||
|
||||
inline MType getMemberType(char*) { return MEMBER_STRING; }
|
||||
inline MType getMemberType(qstring_t) { return MEMBER_QSTRING; }
|
||||
inline MType getMemberType(qstring_t*) { return MEMBER_QSTRING; }
|
||||
inline MType getMemberType(qstring_t) { return MEMBER_QSTRING; }
|
||||
inline MType getMemberType(qstring_t*) { return MEMBER_QSTRING; }
|
||||
|
||||
inline MType getMemberType(char) { return MEMBER_BYTE; }
|
||||
inline MType getMemberType(byte) { return MEMBER_BYTE; }
|
||||
|
@ -71,7 +71,7 @@ cell AMX_NATIVE_CALL get_member(AMX *amx, cell *params)
|
||||
cell* arg3 = getAmxAddr(amx, params[arg_3]);
|
||||
|
||||
if (isTypeReturnable(member->type)) {
|
||||
dest = (member->type != MEMBER_FLOAT) ? nullptr : arg3;
|
||||
dest = nullptr;
|
||||
element = *arg3;
|
||||
}
|
||||
else {
|
||||
@ -123,7 +123,7 @@ cell AMX_NATIVE_CALL set_member_game(AMX *amx, cell *params)
|
||||
// native get_member_game(any:_member, any:...);
|
||||
cell AMX_NATIVE_CALL get_member_game(AMX *amx, cell *params)
|
||||
{
|
||||
enum args_e { arg_count, arg_member, arg_3, arg_4 };
|
||||
enum args_e { arg_count, arg_member, arg_2 };
|
||||
|
||||
CHECK_GAMERULES();
|
||||
|
||||
@ -137,16 +137,11 @@ cell AMX_NATIVE_CALL get_member_game(AMX *amx, cell *params)
|
||||
size_t element;
|
||||
size_t length;
|
||||
|
||||
if (PARAMS_COUNT == 4) {
|
||||
dest = getAmxAddr(amx, params[arg_3]);
|
||||
length = *getAmxAddr(amx, params[arg_4]);
|
||||
element = 0;
|
||||
}
|
||||
else if (PARAMS_COUNT == 3) {
|
||||
cell* arg3 = getAmxAddr(amx, params[arg_3]);
|
||||
|
||||
if (PARAMS_COUNT == 2)
|
||||
{
|
||||
cell* arg3 = getAmxAddr(amx, params[arg_2]);
|
||||
if (isTypeReturnable(member->type)) {
|
||||
dest = (member->type != MEMBER_FLOAT) ? nullptr : arg3;
|
||||
dest = nullptr;
|
||||
element = *arg3;
|
||||
}
|
||||
else {
|
||||
@ -154,22 +149,13 @@ cell AMX_NATIVE_CALL get_member_game(AMX *amx, cell *params)
|
||||
element = 0;
|
||||
}
|
||||
length = 0;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dest = nullptr;
|
||||
element = 0;
|
||||
length = 0;
|
||||
}
|
||||
|
||||
void* data;
|
||||
// members of m_VoiceGameMgr
|
||||
if (params[arg_member] >= m_msgPlayerVoiceMask && params[arg_member] <= m_UpdateInterval) {
|
||||
data = &CSGameRules()->m_VoiceGameMgr;
|
||||
} else {
|
||||
data = g_pGameRules;
|
||||
}
|
||||
|
||||
return get_member(data, member, dest, element, length);
|
||||
return get_member(g_pGameRules, member, dest, element, length);
|
||||
}
|
||||
|
||||
// native set_entvar(const index, const EntVars:var, any:...);
|
||||
@ -227,9 +213,15 @@ cell AMX_NATIVE_CALL get_entvar(AMX *amx, cell *params)
|
||||
else if (PARAMS_COUNT == 3) {
|
||||
cell* arg3 = getAmxAddr(amx, params[arg_3]);
|
||||
|
||||
if (isTypeReturnable(member->type)) {
|
||||
dest = (member->type != MEMBER_FLOAT) ? nullptr : arg3;
|
||||
element = *arg3;
|
||||
if (isTypeReturnable(member->type))
|
||||
{
|
||||
if (member->type == MEMBER_FLOAT) {
|
||||
dest = arg3;
|
||||
element = 0;
|
||||
} else {
|
||||
dest = nullptr;
|
||||
element = *arg3;
|
||||
}
|
||||
}
|
||||
else {
|
||||
dest = arg3;
|
||||
@ -672,8 +664,11 @@ cell get_member(void* pdata, const member_t *member, cell* dest, size_t element,
|
||||
// native any:get_member(_index, any:_member, element);
|
||||
return get_member<bool>(pdata, member->offset, element);
|
||||
case MEMBER_DOUBLE:
|
||||
{
|
||||
// native any:get_member(_index, any:_member, element);
|
||||
return get_member<double>(pdata, member->offset, element);
|
||||
auto ret = (float)get_member<double>(pdata, member->offset, element);
|
||||
return (cell &)ret;
|
||||
}
|
||||
case MEMBER_SIGNALS:
|
||||
{
|
||||
enum { _Signal, _State };
|
||||
|
@ -93,7 +93,7 @@ rootProject.ext.createMsvcConfig = { boolean release, BinaryKind binKind ->
|
||||
'WIN32': null,
|
||||
'_MBCS': null,
|
||||
'_DEBUG': null,
|
||||
'NOMINMAX': null,
|
||||
'NOMINMAX': null
|
||||
]
|
||||
),
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user