From 9bee1f7edf2ea38d0365aefb05dfa2c5b2b69951 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Wed, 7 Oct 2015 22:31:01 +0200 Subject: [PATCH] Consistency: Replace GETEDICT with HLTypeConversion in core --- amxmodx/amxmodx.cpp | 2 +- amxmodx/amxmodx.h | 3 ++- amxmodx/messages.cpp | 4 ++-- amxmodx/meta_api.cpp | 3 +++ amxmodx/vector.cpp | 2 +- modules/fakemeta/misc.cpp | 2 +- public/HLTypeConversion.h | 5 +++-- 7 files changed, 13 insertions(+), 8 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 70def496..9de5bdfc 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -83,7 +83,7 @@ static cell AMX_NATIVE_CALL emit_sound(AMX *amx, cell *params) /* 7 param */ EMIT_SOUND_DYN2(pPlayer->pEdict, channel, szSample, vol, att, flags, pitch); } } else { - edict_t* pEdict = GETEDICT(params[1]); + edict_t* pEdict = TypeConversion.id_to_edict(params[1]); if (!FNullEnt(pEdict)) EMIT_SOUND_DYN2(pEdict, channel, szSample, vol, att, flags, pitch); diff --git a/amxmodx/amxmodx.h b/amxmodx/amxmodx.h index 1ecafcf5..e7f939ea 100755 --- a/amxmodx/amxmodx.h +++ b/amxmodx/amxmodx.h @@ -52,6 +52,7 @@ #include "CvarManager.h" #include "CoreConfig.h" #include +#include #define AMXXLOG_Log g_log.Log #define AMXXLOG_Error g_log.LogError @@ -145,7 +146,6 @@ void UTIL_TrimRight(char *buffer); #define GET_PLAYER_POINTER(e) (&g_players[ENTINDEX(e)]) //#define GET_PLAYER_POINTER(e) (&g_players[(((int)e-g_edict_point)/sizeof(edict_t))]) #define GET_PLAYER_POINTER_I(i) (&g_players[i]) -#define GETEDICT(n) ((n >= 1 && n <= gpGlobals->maxClients) ? GET_PLAYER_POINTER_I(n)->pEdict : INDEXENT(n)) struct WeaponsVault { @@ -369,5 +369,6 @@ enum PrintColor }; extern enginefuncs_t *g_pEngTable; +extern HLTypeConversion TypeConversion; #endif // AMXMODX_H diff --git a/amxmodx/messages.cpp b/amxmodx/messages.cpp index 7e105e38..703f8431 100755 --- a/amxmodx/messages.cpp +++ b/amxmodx/messages.cpp @@ -423,7 +423,7 @@ static cell _message_begin(AMX *amx, cell *params, bool useFloat) /* 4 param */ return 0; } - MESSAGE_BEGIN(params[1], params[2], NULL, GETEDICT(params[4])); + MESSAGE_BEGIN(params[1], params[2], NULL, TypeConversion.id_to_edict(params[4])); break; } @@ -771,7 +771,7 @@ static cell _emessage_begin(AMX *amx, cell *params, bool useFloat) return 0; } - g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, GETEDICT(params[4])); + g_pEngTable->pfnMessageBegin(params[1], params[2], NULL, TypeConversion.id_to_edict(params[4])); break; } diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index ec19f877..a23bc472 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -147,6 +147,7 @@ int FF_ClientAuthorized = -1; int FF_ChangeLevel = -1; IFileSystem* g_FileSystem; +HLTypeConversion TypeConversion; bool ColoredMenus(const char *ModName) { @@ -518,6 +519,8 @@ int C_Spawn(edict_t *pent) modules_callPluginsLoaded(); + TypeConversion.init(); + // ###### Call precache forward function g_dontprecache = false; executeForwards(FF_PluginPrecache); diff --git a/amxmodx/vector.cpp b/amxmodx/vector.cpp index 5966f080..6b037ba1 100644 --- a/amxmodx/vector.cpp +++ b/amxmodx/vector.cpp @@ -63,7 +63,7 @@ static cell AMX_NATIVE_CALL VelocityByAim(AMX *amx, cell *params) } pEnt = GET_PLAYER_POINTER_I(iEnt)->pEdict; } else { - pEnt = INDEXENT(iEnt); + pEnt = TypeConversion.id_to_edict(iEnt); } } diff --git a/modules/fakemeta/misc.cpp b/modules/fakemeta/misc.cpp index 1389d06f..8c38c4c6 100644 --- a/modules/fakemeta/misc.cpp +++ b/modules/fakemeta/misc.cpp @@ -47,7 +47,7 @@ static cell AMX_NATIVE_CALL lookup_sequence(AMX* amx, cell* params) for (int i = 0; i < pstudiohdr->numseq; i++) { - if (stricmp( pseqdesc[i].label, label ) == 0) + if (strcasecmp( pseqdesc[i].label, label ) == 0) { REAL* FrameRate = reinterpret_cast(MF_GetAmxAddr(amx, params[3])); cell* Loops = MF_GetAmxAddr(amx, params[4]); diff --git a/public/HLTypeConversion.h b/public/HLTypeConversion.h index 0aa6c466..2c135b11 100644 --- a/public/HLTypeConversion.h +++ b/public/HLTypeConversion.h @@ -9,8 +9,9 @@ #ifndef _HL_CONVERSION_TYPE_H_ #define _HL_CONVERSION_TYPE_H_ -#include // size_t -#include // edict_t, etc. +#include // size_t +#include // edict_t, etc. +#include // FNullEnt, INDEXENT, etc. template static inline T& ref_pdata(void *pPrivateData, int offset, int element = 0) {