From aa2caacf4cb866c9a4047280a26c61cbaf9d4730 Mon Sep 17 00:00:00 2001 From: Arkshine Date: Thu, 25 Feb 2016 22:44:44 +0100 Subject: [PATCH] Replace INDEXENT and ENTINDEX by TypeConversion for consistency --- modules/cstrike/cstrike/CstrikeItemsInfos.cpp | 2 +- modules/cstrike/cstrike/CstrikeNatives.cpp | 46 +++++++++---------- modules/cstrike/cstrike/CstrikePlayer.cpp | 4 +- modules/cstrike/cstrike/CstrikePlayer.h | 4 +- .../cstrike/cstrike/CstrikeUserMessages.cpp | 4 +- modules/cstrike/cstrike/CstrikeUtils.h | 6 +-- 6 files changed, 33 insertions(+), 33 deletions(-) diff --git a/modules/cstrike/cstrike/CstrikeItemsInfos.cpp b/modules/cstrike/cstrike/CstrikeItemsInfos.cpp index 715aece7..44644bd5 100644 --- a/modules/cstrike/cstrike/CstrikeItemsInfos.cpp +++ b/modules/cstrike/cstrike/CstrikeItemsInfos.cpp @@ -200,7 +200,7 @@ bool CsItemInfo::GetAliasInfosFromName(const char *name, AliasInfo *info) name += prefix_item_length + 1; } - for (size_t id = 0; id < ARRAYSIZE(WeaponNameList); ++id) + for (size_t id = 0; id < ARRAYSIZE(WeaponsList); ++id) { const char *weapon = WeaponsList[id].name.chars(); diff --git a/modules/cstrike/cstrike/CstrikeNatives.cpp b/modules/cstrike/cstrike/CstrikeNatives.cpp index f7420888..8bb65684 100644 --- a/modules/cstrike/cstrike/CstrikeNatives.cpp +++ b/modules/cstrike/cstrike/CstrikeNatives.cpp @@ -115,7 +115,7 @@ static cell AMX_NATIVE_CALL cs_get_hostage_id(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pHostage = INDEXENT(index); + edict_t *pHostage = TypeConversion.id_to_edict(index); CHECK_HOSTAGE(pHostage); @@ -131,7 +131,7 @@ static cell AMX_NATIVE_CALL cs_get_weapon_silenced(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pWeapon = INDEXENT(index); + edict_t *pWeapon = TypeConversion.id_to_edict(index); switch (get_pdata(pWeapon, m_iId)) { @@ -162,7 +162,7 @@ static cell AMX_NATIVE_CALL cs_get_weapon_id(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pWeapon = INDEXENT(index); + edict_t *pWeapon = TypeConversion.id_to_edict(index); return get_pdata(pWeapon, m_iId); } @@ -177,7 +177,7 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) int silence = params[2]; CHECK_NONPLAYER(index); - edict_t *pWeapon = INDEXENT(index); + edict_t *pWeapon = TypeConversion.id_to_edict(index); int draw_animation = 1; @@ -231,7 +231,7 @@ static cell AMX_NATIVE_CALL cs_set_weapon_silenced(AMX *amx, cell *params) if (draw_animation > 0 && UTIL_IsPlayer(pPlayer)) { - int currentWeapon = *static_cast(MF_PlayerPropAddr(ENTINDEX(pPlayer), Player_CurrentWeapon)); + int currentWeapon = *static_cast(MF_PlayerPropAddr(TypeConversion.edict_to_id(pPlayer), Player_CurrentWeapon)); if (currentWeapon != weaponType) { @@ -299,7 +299,7 @@ static cell AMX_NATIVE_CALL cs_get_weapon_burstmode(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pWeapon = INDEXENT(index); + edict_t *pWeapon = TypeConversion.id_to_edict(index); int flag = 0; @@ -327,7 +327,7 @@ static cell AMX_NATIVE_CALL cs_set_weapon_burstmode(AMX *amx, cell *params) int burst = params[2]; CHECK_NONPLAYER(index); - edict_t *pWeapon = INDEXENT(index); + edict_t *pWeapon = TypeConversion.id_to_edict(index); int weaponState = get_pdata(pWeapon, m_iWeaponState); int weaponNewState = weaponState; @@ -908,7 +908,7 @@ static cell AMX_NATIVE_CALL cs_get_hostage_follow(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t* pHostage = INDEXENT(index); + edict_t* pHostage = TypeConversion.id_to_edict(index); CHECK_HOSTAGE(pHostage); @@ -932,7 +932,7 @@ static cell AMX_NATIVE_CALL cs_get_hostage_follow(AMX *amx, cell *params) pEntity = get_pdata(pHostage, m_hTargetEnt).Get(); } - return pEntity ? ENTINDEX(pEntity) : 0; + return pEntity ? TypeConversion.edict_to_id(pEntity) : 0; } // native cs_set_hostage_foll(index, followedindex = 0); @@ -945,7 +945,7 @@ static cell AMX_NATIVE_CALL cs_set_hostage_follow(AMX *amx, cell *params) int target = params[2]; CHECK_NONPLAYER(index); - edict_t* pHostage = INDEXENT(index); + edict_t* pHostage = TypeConversion.id_to_edict(index); if (target != 0) { @@ -996,7 +996,7 @@ static cell AMX_NATIVE_CALL cs_get_weapon_ammo(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pWeapon = INDEXENT(index); + edict_t *pWeapon = TypeConversion.id_to_edict(index); return get_pdata(pWeapon, m_iClip); } @@ -1010,7 +1010,7 @@ static cell AMX_NATIVE_CALL cs_set_weapon_ammo(AMX *amx, cell *params) int ammo = params[2]; CHECK_NONPLAYER(index); - edict_t *pWeapon = INDEXENT(index); + edict_t *pWeapon = TypeConversion.id_to_edict(index); set_pdata(pWeapon, m_iClip, ammo); @@ -1185,7 +1185,7 @@ static cell AMX_NATIVE_CALL cs_get_armoury_type(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pArmoury = INDEXENT(index); + edict_t *pArmoury = TypeConversion.id_to_edict(index); if (strcmp(STRING(pArmoury->v.classname), "armoury_entity")) { @@ -1243,7 +1243,7 @@ static cell AMX_NATIVE_CALL cs_set_armoury_type(AMX *amx, cell *params) int type = params[2]; CHECK_NONPLAYER(index); - edict_t *pArmoury = INDEXENT(index); + edict_t *pArmoury = TypeConversion.id_to_edict(index); if (strcmp(STRING(pArmoury->v.classname), "armoury_entity")) { @@ -1509,7 +1509,7 @@ static cell AMX_NATIVE_CALL cs_get_hostage_lastuse(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pHostage = INDEXENT(index); + edict_t *pHostage = TypeConversion.id_to_edict(index); CHECK_HOSTAGE(pHostage); @@ -1535,7 +1535,7 @@ static cell AMX_NATIVE_CALL cs_set_hostage_lastuse(AMX *amx, cell *params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pHostage = INDEXENT(index); + edict_t *pHostage = TypeConversion.id_to_edict(index); CHECK_HOSTAGE(pHostage); @@ -1562,7 +1562,7 @@ static cell AMX_NATIVE_CALL cs_get_hostage_nextuse(AMX* amx, cell* params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pHostage = INDEXENT(index); + edict_t *pHostage = TypeConversion.id_to_edict(index); CHECK_HOSTAGE(pHostage); @@ -1577,7 +1577,7 @@ static cell AMX_NATIVE_CALL cs_set_hostage_nextuse(AMX* amx, cell* params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pHostage = INDEXENT(index); + edict_t *pHostage = TypeConversion.id_to_edict(index); CHECK_HOSTAGE(pHostage); @@ -1594,7 +1594,7 @@ static cell AMX_NATIVE_CALL cs_get_c4_explode_time(AMX* amx, cell* params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pC4 = INDEXENT(index); + edict_t *pC4 = TypeConversion.id_to_edict(index); if (strcmp(STRING(pC4->v.classname), "grenade") != 0) { @@ -1613,7 +1613,7 @@ static cell AMX_NATIVE_CALL cs_set_c4_explode_time(AMX* amx, cell* params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pC4 = INDEXENT(index); + edict_t *pC4 = TypeConversion.id_to_edict(index); if (strcmp(STRING(pC4->v.classname), "grenade") != 0) { @@ -1634,7 +1634,7 @@ static cell AMX_NATIVE_CALL cs_get_c4_defusing(AMX* amx, cell* params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pC4 = INDEXENT(index); + edict_t *pC4 = TypeConversion.id_to_edict(index); if (strcmp(STRING(pC4->v.classname), "grenade") != 0) { @@ -1653,7 +1653,7 @@ static cell AMX_NATIVE_CALL cs_set_c4_defusing(AMX* amx, cell* params) int index = params[1]; CHECK_NONPLAYER(index); - edict_t *pC4 = INDEXENT(index); + edict_t *pC4 = TypeConversion.id_to_edict(index); if (strcmp(STRING(pC4->v.classname), "grenade") != 0) { @@ -1682,7 +1682,7 @@ static cell AMX_NATIVE_CALL cs_create_entity(AMX* amx, cell* params) if (!FNullEnt(pEnt)) { - return ENTINDEX(pEnt); + return TypeConversion.edict_to_id(pEnt); } return 0; diff --git a/modules/cstrike/cstrike/CstrikePlayer.cpp b/modules/cstrike/cstrike/CstrikePlayer.cpp index 05099bce..690d1a90 100644 --- a/modules/cstrike/cstrike/CstrikePlayer.cpp +++ b/modules/cstrike/cstrike/CstrikePlayer.cpp @@ -18,7 +18,7 @@ ke::Vector ModelsUpdateQueue; void ClientDisconnect(edict_t *pEntity) { - int index = ENTINDEX(pEntity); + int index = TypeConversion.edict_to_id(pEntity); Players[index].ResetModel(); Players[index].ResetZoom(); @@ -30,7 +30,7 @@ void ClientUserInfoChanged(edict_t *pEntity, char *infobuffer) { if (pEntity->pvPrivateData) { - Players[ENTINDEX(pEntity)].UpdateModel(pEntity); + Players[TypeConversion.edict_to_id(pEntity)].UpdateModel(pEntity); } RETURN_META(MRES_IGNORED); diff --git a/modules/cstrike/cstrike/CstrikePlayer.h b/modules/cstrike/cstrike/CstrikePlayer.h index 8fdd34bf..c3bf2e60 100644 --- a/modules/cstrike/cstrike/CstrikePlayer.h +++ b/modules/cstrike/cstrike/CstrikePlayer.h @@ -70,7 +70,7 @@ class CPlayer { MDLL_ClientUserInfoChanged(pPlayer, GETINFOKEYBUFFER(pPlayer)); - PostponeModelUpdate(ENTINDEX(pPlayer) - 1); + PostponeModelUpdate(TypeConversion.edict_to_id(pPlayer) - 1); } } @@ -85,7 +85,7 @@ class CPlayer if (strcmp(GETCLIENTKEYVALUE(infobuffer, "model"), m_Model) != 0) { - int index = ENTINDEX(pPlayer); + int index = TypeConversion.edict_to_id(pPlayer); SETCLIENTKEYVALUE(index, infobuffer, "model", m_Model); diff --git a/modules/cstrike/cstrike/CstrikeUserMessages.cpp b/modules/cstrike/cstrike/CstrikeUserMessages.cpp index 75a57e5c..e05329d1 100644 --- a/modules/cstrike/cstrike/CstrikeUserMessages.cpp +++ b/modules/cstrike/cstrike/CstrikeUserMessages.cpp @@ -87,7 +87,7 @@ void OnMessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *p { if (msg_type == MessageIdSetFOV) { - int index = ENTINDEX(pEntity); + int index = TypeConversion.edict_to_id(pEntity); int zoom = Players[index].GetZoom(); if (zoom) @@ -107,7 +107,7 @@ void OnMessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *p } else if (msg_type == MessageIdResetHUD) { - int index = ENTINDEX(pEntity); + int index = TypeConversion.edict_to_id(pEntity); if (Players[index].GetZoom()) { diff --git a/modules/cstrike/cstrike/CstrikeUtils.h b/modules/cstrike/cstrike/CstrikeUtils.h index 34e3d103..c5b9acdc 100644 --- a/modules/cstrike/cstrike/CstrikeUtils.h +++ b/modules/cstrike/cstrike/CstrikeUtils.h @@ -33,7 +33,7 @@ void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength); MF_LogError(amx, AMX_ERR_NATIVE, "Entity out of range (%d)", x); \ return 0; \ } else { \ - if (x != 0 && FNullEnt(INDEXENT(x))) { \ + if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ return 0; \ } \ @@ -50,7 +50,7 @@ void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength); return 0; \ } \ } else { \ - if (x != 0 && FNullEnt(INDEXENT(x))) { \ + if (x != 0 && FNullEnt(TypeConversion.id_to_edict(x))) { \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid entity %d", x); \ return 0; \ } \ @@ -73,7 +73,7 @@ void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength); MF_LogError(amx, AMX_ERR_NATIVE, "Non-player entity %d out of range", x); \ return 0; \ } else { \ - if (FNullEnt(INDEXENT(x))) { \ + if (FNullEnt(TypeConversion.id_to_edict(x))) { \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid non-player entity %d", x); \ return 0; \ } \