mirror of
https://github.com/rehlds/reapi.git
synced 2024-12-28 15:45:31 +03:00
Branch prediction optimization
This commit is contained in:
parent
9fc7607368
commit
f737fd201b
@ -122,7 +122,7 @@ struct hookctx_t
|
||||
char* get_temp_string(AMX* amx)
|
||||
{
|
||||
auto ptr = s_temp_strings.push(amx);
|
||||
if (ptr) {
|
||||
if (likely(ptr)) {
|
||||
tempstrings_used++;
|
||||
return ptr;
|
||||
}
|
||||
@ -154,15 +154,15 @@ NOINLINE void DLLEXPORT _callVoidForward(const hook_t* hook, original_t original
|
||||
|
||||
for (auto fwd : hook->pre)
|
||||
{
|
||||
if (fwd->GetState() == FSTATE_ENABLED)
|
||||
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
||||
{
|
||||
auto ret = g_amxxapi.ExecuteForward(fwd->GetIndex(), args...);
|
||||
|
||||
if (ret == HC_BREAK) {
|
||||
if (unlikely(ret == HC_BREAK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ret > hc_state)
|
||||
if (unlikely(ret > hc_state))
|
||||
hc_state = ret;
|
||||
}
|
||||
}
|
||||
@ -174,10 +174,10 @@ NOINLINE void DLLEXPORT _callVoidForward(const hook_t* hook, original_t original
|
||||
}
|
||||
|
||||
for (auto fwd : hook->post) {
|
||||
if (fwd->GetState() == FSTATE_ENABLED) {
|
||||
if (likely(fwd->GetState() == FSTATE_ENABLED)) {
|
||||
auto ret = g_amxxapi.ExecuteForward(fwd->GetIndex(), args...);
|
||||
|
||||
if (ret == HC_BREAK)
|
||||
if (unlikely(ret == HC_BREAK))
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -207,45 +207,45 @@ NOINLINE R DLLEXPORT _callForward(const hook_t* hook, original_t original, volat
|
||||
|
||||
for (auto fwd : hook->pre)
|
||||
{
|
||||
if (fwd->GetState() == FSTATE_ENABLED)
|
||||
if (likely(fwd->GetState() == FSTATE_ENABLED))
|
||||
{
|
||||
auto ret = g_amxxapi.ExecuteForward(fwd->GetIndex(), args...);
|
||||
|
||||
if (ret == HC_CONTINUE) {
|
||||
if (likely(ret == HC_CONTINUE)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!hookCtx->retVal.set) {
|
||||
if (unlikely(!hookCtx->retVal.set)) {
|
||||
g_amxxapi.LogError(fwd->GetAmx(), AMX_ERR_CALLBACK, "can't suppress original function call without new return value set");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ret == HC_BREAK) {
|
||||
if (unlikely(ret == HC_BREAK)) {
|
||||
return *(R *)&hookCtx->retVal._integer;
|
||||
}
|
||||
|
||||
if (ret > hc_state)
|
||||
if (unlikely(ret > hc_state))
|
||||
hc_state = ret;
|
||||
}
|
||||
}
|
||||
|
||||
if (hc_state != HC_SUPERCEDE)
|
||||
if (likely(hc_state != HC_SUPERCEDE))
|
||||
{
|
||||
g_hookCtx = nullptr;
|
||||
auto retVal = original(args...);
|
||||
g_hookCtx = hookCtx;
|
||||
|
||||
if (hc_state != HC_OVERRIDE)
|
||||
if (likely(hc_state != HC_OVERRIDE))
|
||||
hookCtx->retVal._integer = *(int *)&retVal;
|
||||
|
||||
hookCtx->retVal.set = true;
|
||||
}
|
||||
|
||||
for (auto fwd : hook->post) {
|
||||
if (fwd->GetState() == FSTATE_ENABLED) {
|
||||
if (likely(fwd->GetState() == FSTATE_ENABLED)) {
|
||||
auto ret = g_amxxapi.ExecuteForward(fwd->GetIndex(), args...);
|
||||
|
||||
if (ret == HC_BREAK)
|
||||
if (unlikely(ret == HC_BREAK))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ hook_t hooklist_gamerules[] = {
|
||||
|
||||
hook_t* hooklist_t::getHookSafe(size_t hook)
|
||||
{
|
||||
#define CASE(h) case ht_##h: if (index < arraysize(hooklist_##h)) return &hooklist_##h[index]; else break;
|
||||
#define CASE(h) case ht_##h: if (likely(index < arraysize(hooklist_##h))) return &hooklist_##h[index]; else break;
|
||||
|
||||
const auto table = hooks_tables_e(hook / MAX_REGION_RANGE);
|
||||
const auto index = hook & (MAX_REGION_RANGE - 1);
|
||||
|
@ -1,8 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#define CHECK_ISPLAYER(x) if (params[x] <= 0 || params[x] > gpGlobals->maxClients) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid player index %i [%s]", __FUNCTION__, params[x], #x); return FALSE; }
|
||||
#define CHECK_ISENTITY(x) if (params[x] > gpGlobals->maxEntities) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid entity index %i [%s]", __FUNCTION__, params[x], #x); return FALSE; }
|
||||
#define CHECK_GAMERULES() if (!g_pGameRules) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__); return FALSE; }
|
||||
#define CHECK_ISPLAYER(x) if (unlikely(params[x] <= 0 || params[x] > gpGlobals->maxClients)) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid player index %i [%s]", __FUNCTION__, params[x], #x); return FALSE; }
|
||||
#define CHECK_ISENTITY(x) if (unlikely(params[x] > gpGlobals->maxEntities)) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid entity index %i [%s]", __FUNCTION__, params[x], #x); return FALSE; }
|
||||
#define CHECK_GAMERULES() if (unlikely(!g_pGameRules)) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: gamerules not initialized", __FUNCTION__); return FALSE; }
|
||||
#define CHECK_CONNECTED(x, y) if (unlikely(x == nullptr || x->has_disconnected)) { MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[y]); return FALSE; }
|
||||
|
||||
class CAmxArg
|
||||
{
|
||||
|
@ -19,13 +19,13 @@ cell AMX_NATIVE_CALL RegisterHookChain(AMX *amx, cell *params)
|
||||
int post = params[arg_post];
|
||||
auto hook = g_hookManager.getHook(func);
|
||||
|
||||
if (hook == nullptr)
|
||||
if (unlikely(hook == nullptr))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: function with id (%d) doesn't exist in current API version.", __FUNCTION__, func);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!hook->checkRequirements())
|
||||
if (unlikely(!hook->checkRequirements()))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: function (%s) is not available, %s required.", __FUNCTION__, hook->func_name, hook->depend_name);
|
||||
return 0;
|
||||
@ -33,14 +33,14 @@ cell AMX_NATIVE_CALL RegisterHookChain(AMX *amx, cell *params)
|
||||
|
||||
int funcid;
|
||||
const char *funcname = getAmxString(amx, params[arg_handler]);
|
||||
if (g_amxxapi.amx_FindPublic(amx, funcname, &funcid) != AMX_ERR_NONE)
|
||||
if (unlikely(g_amxxapi.amx_FindPublic(amx, funcname, &funcid) != AMX_ERR_NONE))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: public function \"%s\" not found.", __FUNCTION__, funcname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fwid = hook->registerForward(amx, funcname);
|
||||
if (fwid == -1)
|
||||
if (unlikely(fwid == -1))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: register forward failed.", __FUNCTION__);
|
||||
return 0;
|
||||
@ -64,7 +64,7 @@ cell AMX_NATIVE_CALL EnableHookChain(AMX *amx, cell *params)
|
||||
|
||||
auto hook = g_hookManager.getAmxxHook(params[arg_handle_hook]);
|
||||
|
||||
if (hook == nullptr)
|
||||
if (unlikely(hook == nullptr))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid HookChain handle.", __FUNCTION__);
|
||||
return FALSE;
|
||||
@ -88,7 +88,7 @@ cell AMX_NATIVE_CALL DisableHookChain(AMX *amx, cell *params)
|
||||
|
||||
auto hook = g_hookManager.getAmxxHook(params[arg_handle_hook]);
|
||||
|
||||
if (hook == nullptr)
|
||||
if (unlikely(hook == nullptr))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid HookChain handle.", __FUNCTION__);
|
||||
return FALSE;
|
||||
@ -109,7 +109,7 @@ cell AMX_NATIVE_CALL DisableHookChain(AMX *amx, cell *params)
|
||||
*/
|
||||
cell AMX_NATIVE_CALL SetHookChainReturn(AMX *amx, cell *params)
|
||||
{
|
||||
if (!g_hookCtx)
|
||||
if (unlikely(!g_hookCtx))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: trying to set return value without active hook.", __FUNCTION__);
|
||||
return FALSE;
|
||||
@ -118,7 +118,7 @@ cell AMX_NATIVE_CALL SetHookChainReturn(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_type, arg_value };
|
||||
auto& retVal = g_hookCtx->retVal;
|
||||
|
||||
if (params[arg_type] != retVal.type)
|
||||
if (unlikely(params[arg_type] != retVal.type))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: trying to set return value with incompatible type.", __FUNCTION__);
|
||||
return FALSE;
|
||||
@ -171,7 +171,7 @@ cell AMX_NATIVE_CALL SetHookChainReturn(AMX *amx, cell *params)
|
||||
*/
|
||||
cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params)
|
||||
{
|
||||
if (!g_hookCtx)
|
||||
if (unlikely(!g_hookCtx))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: trying to get return value without active hook.", __FUNCTION__);
|
||||
return FALSE;
|
||||
@ -180,7 +180,7 @@ cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_value, arg_maxlen };
|
||||
auto& retVal = g_hookCtx->retVal;
|
||||
|
||||
if (!retVal.set)
|
||||
if (unlikely(!retVal.set))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: return value isn't set.", __FUNCTION__);
|
||||
return FALSE;
|
||||
@ -227,7 +227,7 @@ cell AMX_NATIVE_CALL GetHookChainReturn(AMX *amx, cell *params)
|
||||
*/
|
||||
cell AMX_NATIVE_CALL SetHookChainArg(AMX *amx, cell *params)
|
||||
{
|
||||
if (!g_hookCtx)
|
||||
if (unlikely(!g_hookCtx))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: trying to get return value without active hook.", __FUNCTION__);
|
||||
return FALSE;
|
||||
@ -236,7 +236,7 @@ cell AMX_NATIVE_CALL SetHookChainArg(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_number, arg_type, arg_value };
|
||||
size_t number = params[arg_number] - 1;
|
||||
|
||||
if (number >= g_hookCtx->args_count)
|
||||
if (unlikely(number >= g_hookCtx->args_count))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: can't set argument %i of hookchain with %i args.", __FUNCTION__, params[arg_number], g_hookCtx->args_count);
|
||||
return FALSE;
|
||||
@ -244,7 +244,7 @@ cell AMX_NATIVE_CALL SetHookChainArg(AMX *amx, cell *params)
|
||||
|
||||
AType type = g_hookCtx->args_type[number];
|
||||
|
||||
if (params[arg_type] != type)
|
||||
if (unlikely(params[arg_type] != type))
|
||||
{
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid argument type provided.", __FUNCTION__);
|
||||
return FALSE;
|
||||
|
@ -6,13 +6,13 @@ cell AMX_NATIVE_CALL set_member(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_index, arg_member, arg_value, arg_elem };
|
||||
member_t *member = memberlist[params[arg_member]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_member]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
edict_t *pEdict = edictByIndexAmx(params[arg_index]);
|
||||
if (pEdict == nullptr || pEdict->pvPrivateData == nullptr) {
|
||||
if (unlikely(pEdict == nullptr || pEdict->pvPrivateData == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid or uninitialized entity", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
@ -23,7 +23,7 @@ cell AMX_NATIVE_CALL set_member(AMX *amx, cell *params)
|
||||
const auto table = memberlist_t::members_tables_e(params[arg_member] / MAX_REGION_RANGE);
|
||||
if (table == memberlist_t::mt_csplayer) {
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(indexOfEdict(pEdict));
|
||||
if (!pPlayer || !pPlayer->CSPlayer()) {
|
||||
if (unlikely(!pPlayer || !pPlayer->CSPlayer())) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -39,13 +39,13 @@ cell AMX_NATIVE_CALL get_member(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_index, arg_member, arg_3, arg_4, arg_5 };
|
||||
member_t *member = memberlist[params[arg_member]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_member]);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
edict_t *pEdict = edictByIndexAmx(params[arg_index]);
|
||||
if (pEdict == nullptr || pEdict->pvPrivateData == nullptr) {
|
||||
if (unlikely(pEdict == nullptr || pEdict->pvPrivateData == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid or uninitialized entity", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
@ -109,7 +109,7 @@ cell AMX_NATIVE_CALL set_member_game(AMX *amx, cell *params)
|
||||
CHECK_GAMERULES();
|
||||
|
||||
member_t *member = memberlist[params[arg_member]];
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_member]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -128,7 +128,7 @@ cell AMX_NATIVE_CALL get_member_game(AMX *amx, cell *params)
|
||||
CHECK_GAMERULES();
|
||||
|
||||
member_t *member = memberlist[params[arg_member]];
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_member]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -178,14 +178,14 @@ cell AMX_NATIVE_CALL set_entvar(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_index, arg_var, arg_value, arg_elem };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_ISENTITY(arg_index);
|
||||
|
||||
edict_t *pEdict = edictByIndexAmx(params[arg_index]);
|
||||
if (pEdict == nullptr || pEdict->pvPrivateData == nullptr) {
|
||||
if (unlikely(pEdict == nullptr || pEdict->pvPrivateData == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid or uninitialized entity", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
@ -202,7 +202,7 @@ cell AMX_NATIVE_CALL get_entvar(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_index, arg_var, arg_3, arg_4 };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -210,7 +210,7 @@ cell AMX_NATIVE_CALL get_entvar(AMX *amx, cell *params)
|
||||
CHECK_ISENTITY(arg_index);
|
||||
|
||||
edict_t *pEdict = edictByIndexAmx(params[arg_index]);
|
||||
if (pEdict == nullptr || &pEdict->v == nullptr) {
|
||||
if (unlikely(pEdict == nullptr || &pEdict->v == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: invalid or uninitialized entity", __FUNCTION__);
|
||||
return FALSE;
|
||||
}
|
||||
@ -253,7 +253,7 @@ cell AMX_NATIVE_CALL set_pmove(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_var, arg_value, arg_elem };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -270,7 +270,7 @@ cell AMX_NATIVE_CALL get_pmove(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_var, arg_2, arg_3 };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -305,7 +305,7 @@ cell AMX_NATIVE_CALL set_movevar(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_var, arg_value };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -320,7 +320,7 @@ cell AMX_NATIVE_CALL get_movevar(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_var, arg_2, arg_3 };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -349,7 +349,7 @@ cell AMX_NATIVE_CALL set_ucmd(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_cmd, arg_var, arg_value };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -365,7 +365,7 @@ cell AMX_NATIVE_CALL get_ucmd(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_cmd, arg_var, arg_3, arg_4 };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -392,7 +392,7 @@ cell AMX_NATIVE_CALL set_pmtrace(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_tr, arg_var, arg_value };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -408,7 +408,7 @@ cell AMX_NATIVE_CALL get_pmtrace(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_tr, arg_var, arg_3, arg_4 };
|
||||
member_t *member = memberlist[params[arg_var]];
|
||||
|
||||
if (member == nullptr) {
|
||||
if (unlikely(member == nullptr)) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: unknown member id %i", __FUNCTION__, params[arg_var]);
|
||||
return FALSE;
|
||||
}
|
||||
@ -620,7 +620,7 @@ cell get_member(void* pdata, const member_t *member, cell* dest, size_t element,
|
||||
case MEMBER_STRING:
|
||||
{
|
||||
// native any:get_member(_index, any:_member, any:output[], maxlength);
|
||||
if (!dest)
|
||||
if (unlikely(!dest))
|
||||
return 0;
|
||||
|
||||
if (member->max_size > sizeof(char*)) {
|
||||
@ -641,7 +641,7 @@ cell get_member(void* pdata, const member_t *member, cell* dest, size_t element,
|
||||
}
|
||||
case MEMBER_QSTRING:
|
||||
{
|
||||
if (!dest)
|
||||
if (unlikely(!dest))
|
||||
return 0;
|
||||
|
||||
string_t str = get_member<string_t>(pdata, member->offset, element);
|
||||
@ -679,7 +679,7 @@ cell get_member(void* pdata, const member_t *member, cell* dest, size_t element,
|
||||
enum { _Signal, _State };
|
||||
|
||||
// native any:get_member(_index, any:_member, signals[2]);
|
||||
if (!dest)
|
||||
if (unlikely(!dest))
|
||||
return 0;
|
||||
|
||||
CUnifiedSignals& signal = get_member<CUnifiedSignals>(pdata, member->offset);
|
||||
|
@ -17,10 +17,7 @@ cell AMX_NATIVE_CALL rg_set_animation(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
pPlayer->CSPlayer()->SetAnimation(CAmxArg(amx, params[arg_anim]));
|
||||
return TRUE;
|
||||
@ -46,10 +43,7 @@ cell AMX_NATIVE_CALL rg_add_account(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
if (static_cast<AccountSet>(params[arg_typeSet]) == AS_SET) {
|
||||
pPlayer->m_iAccount = 0;
|
||||
@ -79,10 +73,7 @@ cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
GiveType type = static_cast<GiveType>(params[arg_type]);
|
||||
const char *itemName = getAmxString(amx, params[arg_item]);
|
||||
@ -138,10 +129,7 @@ cell AMX_NATIVE_CALL rg_give_default_items(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
pPlayer->CSPlayer()->GiveDefaultItems();
|
||||
return TRUE;
|
||||
@ -164,10 +152,7 @@ cell AMX_NATIVE_CALL rg_give_shield(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
pPlayer->CSPlayer()->GiveShield(params[arg_deploy] != 0);
|
||||
return TRUE;
|
||||
@ -582,10 +567,7 @@ cell AMX_NATIVE_CALL rg_find_weapon_bpack_by_name(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
const char *pszWeaponName = getAmxString(amx, params[arg_weapon]);
|
||||
auto pInfo = g_ReGameApi->GetWeaponSlot(pszWeaponName);
|
||||
@ -633,10 +615,7 @@ cell AMX_NATIVE_CALL rg_has_item_by_name(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
const char *pszItemName = getAmxString(amx, params[arg_item]);
|
||||
// item_* and weapon_shield
|
||||
@ -823,10 +802,7 @@ cell AMX_NATIVE_CALL rg_remove_all_items(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
pPlayer->CSPlayer()->RemoveAllItems(params[arg_suit] != 0);
|
||||
return TRUE;
|
||||
@ -849,10 +825,7 @@ cell AMX_NATIVE_CALL rg_remove_item(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
const char* szItemName = getAmxString(amx, params[arg_item_name]);
|
||||
if (pPlayer->CSPlayer()->RemovePlayerItem(szItemName)) {
|
||||
@ -879,10 +852,7 @@ cell AMX_NATIVE_CALL rg_get_user_bpammo(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
WeaponIdType weaponId = static_cast<WeaponIdType>(params[arg_weapon]);
|
||||
if (weaponId < WEAPON_P228 || weaponId > WEAPON_P90 || weaponId == WEAPON_KNIFE)
|
||||
@ -924,10 +894,7 @@ cell AMX_NATIVE_CALL rg_set_user_bpammo(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
WeaponIdType weaponId = static_cast<WeaponIdType>(params[arg_weapon]);
|
||||
if (weaponId < WEAPON_P228 || weaponId > WEAPON_P90 || weaponId == WEAPON_KNIFE)
|
||||
@ -973,18 +940,14 @@ cell AMX_NATIVE_CALL rg_give_defusekit(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
// on the map there is not bomb places
|
||||
if (CSGameRules() != nullptr && !CSGameRules()->m_bMapHasBombTarget && !CSGameRules()->m_bMapHasBombZone) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pPlayer->m_bHasDefuser =
|
||||
pPlayer->pev->body = params[arg_def] != 0;
|
||||
pPlayer->m_bHasDefuser = pPlayer->pev->body = params[arg_def] != 0;
|
||||
|
||||
if (params[arg_def] != 0)
|
||||
{
|
||||
@ -1027,10 +990,7 @@ cell AMX_NATIVE_CALL rg_get_user_armor(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
*getAmxAddr(amx, params[arg_armortype]) = pPlayer->m_iKevlar;
|
||||
return static_cast<cell>(pPlayer->pev->armorvalue);
|
||||
@ -1054,10 +1014,7 @@ cell AMX_NATIVE_CALL rg_set_user_armor(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
ArmorType armorType = static_cast<ArmorType>(params[arg_armortype]);
|
||||
|
||||
@ -1096,10 +1053,7 @@ cell AMX_NATIVE_CALL rg_set_user_team(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
|
||||
@ -1187,10 +1141,7 @@ cell AMX_NATIVE_CALL rg_set_user_model(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
const char* newModel = getAmxString(amx, params[arg_model]);
|
||||
if (*newModel == '\0') {
|
||||
@ -1227,10 +1178,7 @@ cell AMX_NATIVE_CALL rg_reset_user_model(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
pPlayer->CSPlayer()->SetPlayerModelEx("");
|
||||
pPlayer->CSPlayer()->SetPlayerModel(pPlayer->m_bHasC4);
|
||||
@ -1255,10 +1203,7 @@ cell AMX_NATIVE_CALL rg_transfer_c4(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
if (!pPlayer->m_bHasC4 || !pPlayer->CSPlayer()->RemovePlayerItem("weapon_c4"))
|
||||
return FALSE;
|
||||
@ -1270,10 +1215,7 @@ cell AMX_NATIVE_CALL rg_transfer_c4(AMX *amx, cell *params)
|
||||
|
||||
if (params[arg_receiver] != 0 && params[arg_receiver] <= gpGlobals->maxClients) {
|
||||
CBasePlayer *pReceiver = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_receiver]);
|
||||
if (pReceiver == nullptr || pReceiver->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_receiver]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pReceiver, arg_receiver);
|
||||
|
||||
pReceiver->m_bHasC4 = true;
|
||||
pReceiver->CSPlayer()->GiveNamedItemEx("weapon_c4");
|
||||
@ -1306,10 +1248,7 @@ cell AMX_NATIVE_CALL rg_instant_reload_weapons(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
CBasePlayerWeapon *pWeapon = nullptr;
|
||||
if (params[arg_weapon] != 0)
|
||||
@ -1394,10 +1333,7 @@ cell AMX_NATIVE_CALL rg_join_team(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
return (cell)pPlayer->CSPlayer()->JoinTeam(static_cast<TeamName>(params[arg_team]));
|
||||
}
|
||||
@ -1449,10 +1385,7 @@ cell AMX_NATIVE_CALL rg_switch_team(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
pPlayer->CSPlayer()->SwitchTeam();
|
||||
return TRUE;
|
||||
@ -1475,10 +1408,7 @@ cell AMX_NATIVE_CALL rg_switch_weapon(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
auto pWeapon = getPrivate<CBasePlayerWeapon>(params[arg_weapon]);
|
||||
if (pWeapon == nullptr || !pWeapon->IsWeapon()) {
|
||||
@ -1521,10 +1451,7 @@ cell AMX_NATIVE_CALL rg_is_player_can_takedamage(AMX *amx, cell *params)
|
||||
CHECK_ISPLAYER(arg_index);
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
CBaseEntity *pAttacker = getPrivate<CBaseEntity>(params[arg_attacker]);
|
||||
if (!pAttacker) {
|
||||
@ -1579,10 +1506,7 @@ cell AMX_NATIVE_CALL rg_round_respawn(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_index };
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
pPlayer->RoundRespawn();
|
||||
return TRUE;
|
||||
@ -1605,10 +1529,7 @@ cell AMX_NATIVE_CALL rg_send_bartime(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_index, arg_time, arg_observer };
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
if (!args[arg_observer]) {
|
||||
@ -1639,10 +1560,7 @@ cell AMX_NATIVE_CALL rg_send_bartime2(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_index, arg_time, arg_start_percent, arg_observer };
|
||||
|
||||
CBasePlayer *pPlayer = g_ReGameFuncs->UTIL_PlayerByIndex(params[arg_index]);
|
||||
if (pPlayer == nullptr || pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_index]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_index);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
if (!args[arg_observer]) {
|
||||
@ -1846,10 +1764,7 @@ cell AMX_NATIVE_CALL rh_emit_sound2(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_entity, arg_recipient, arg_channel, arg_sample, arg_vol, arg_attn, arg_flags, arg_pitch, arg_emitFlags, arg_origin };
|
||||
|
||||
CBaseEntity *pRecipient = getPrivate<CBaseEntity>(params[arg_recipient]);
|
||||
if (pRecipient && pRecipient->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_recipient]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pRecipient, arg_recipient);
|
||||
|
||||
// ignore recipient of non-player
|
||||
if (params[arg_recipient] != 0 && pRecipient && !pRecipient->IsNetClient()) {
|
||||
@ -1880,10 +1795,7 @@ cell AMX_NATIVE_CALL rh_update_user_info(AMX *amx, cell *params)
|
||||
enum args_e { arg_count, arg_playerEntIndex };
|
||||
|
||||
CBasePlayer *pPlayer = getPrivate<CBasePlayer>(params[arg_playerEntIndex]);
|
||||
if (pPlayer != nullptr && pPlayer->has_disconnected) {
|
||||
MF_LogError(amx, AMX_ERR_NATIVE, "%s: player %i is not connected", __FUNCTION__, params[arg_playerEntIndex]);
|
||||
return FALSE;
|
||||
}
|
||||
CHECK_CONNECTED(pPlayer, arg_playerEntIndex);
|
||||
|
||||
CAmxArgs args(amx, params);
|
||||
g_RehldsFuncs->SV_UpdateUserInfo(args[arg_playerEntIndex]);
|
||||
|
19
reapi/src/platform.h
Normal file
19
reapi/src/platform.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#undef DLLEXPORT
|
||||
#ifdef _WIN32
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#else
|
||||
#define DLLEXPORT __attribute__((visibility("default")))
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#define WINAPI /* */
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
@ -1,37 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
#include <string.h>
|
||||
#include <new>
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h> // for strncpy(), etc
|
||||
|
||||
#include <vector> // std::vector
|
||||
|
||||
#include <extdll.h>
|
||||
#include <cbase.h>
|
||||
#include <pm_defs.h>
|
||||
#include "com_progdefs.h"
|
||||
|
||||
#include "osdep.h" // win32 vsnprintf, etc
|
||||
#include "sdk_util.h"
|
||||
|
||||
#include <eiface.h>
|
||||
#include <meta_api.h>
|
||||
#include "amxxmodule.h"
|
||||
#include "osconfig.h"
|
||||
|
||||
#include "pm_defs.h"
|
||||
#include "pm_movevars.h"
|
||||
#include <cbase.h>
|
||||
#include <pm_defs.h>
|
||||
#include <pm_defs.h>
|
||||
#include <pm_movevars.h>
|
||||
#include <com_progdefs.h>
|
||||
|
||||
#include <osdep.h> // win32 vsnprintf, etc
|
||||
#include <osconfig.h>
|
||||
#include <sdk_util.h>
|
||||
#include <platform.h>
|
||||
|
||||
// regamedll API
|
||||
#include "gamerules.h"
|
||||
#include "regamedll_api.h"
|
||||
#include "mod_regamedll_api.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "reapi_utils.h"
|
||||
|
||||
// rehlds API
|
||||
#include "rehlds_api.h"
|
||||
#include "mod_rehlds_api.h"
|
||||
@ -44,6 +39,11 @@
|
||||
#include "reunion_api.h"
|
||||
#include "mod_reunion_api.h"
|
||||
|
||||
// AmxModX API
|
||||
#include "amxxmodule.h"
|
||||
|
||||
#include "main.h"
|
||||
#include "reapi_utils.h"
|
||||
#include "api_config.h"
|
||||
#include "hook_manager.h"
|
||||
#include "hook_callback.h"
|
||||
@ -54,13 +54,3 @@
|
||||
#include "natives_misc.h"
|
||||
#include "natives_addons.h"
|
||||
#include "natives_helper.h"
|
||||
|
||||
#undef DLLEXPORT
|
||||
#ifdef _WIN32
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#define NOINLINE __declspec(noinline)
|
||||
#else
|
||||
#define DLLEXPORT __attribute__((visibility("default")))
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#define WINAPI /* */
|
||||
#endif
|
||||
|
@ -39,7 +39,9 @@ inline size_t indexOfEdict(entvars_t* pev)
|
||||
inline edict_t* edictByIndexAmx(int index)
|
||||
{
|
||||
auto ed = g_pEdicts + index;
|
||||
return index < 0 ? nullptr : ed;
|
||||
if (unlikely(index < 0))
|
||||
ed = nullptr;
|
||||
return ed;
|
||||
}
|
||||
|
||||
// fast
|
||||
|
Loading…
Reference in New Issue
Block a user