diff --git a/amxmodx/gameconfigs.cpp b/amxmodx/gameconfigs.cpp index d374f6d2..40a7dcb4 100644 --- a/amxmodx/gameconfigs.cpp +++ b/amxmodx/gameconfigs.cpp @@ -54,7 +54,7 @@ static cell AMX_NATIVE_CALL GameConfGetOffset(AMX *amx, cell *params) } int length; - int value; + TypeDescription value; const char *key = get_amxstring(amx, params[2], 0, length); @@ -63,7 +63,7 @@ static cell AMX_NATIVE_CALL GameConfGetOffset(AMX *amx, cell *params) return -1; } - return value; + return value.fieldOffset; } // native GameConfGetClassOffset(GameConfig:handle, const classname[], const key[]); @@ -78,7 +78,7 @@ static cell AMX_NATIVE_CALL GameConfGetClassOffset(AMX *amx, cell *params) } int length; - int value; + TypeDescription value; const char *classname = get_amxstring(amx, params[2], 0, length); const char *key = get_amxstring(amx, params[3], 1, length); @@ -88,7 +88,7 @@ static cell AMX_NATIVE_CALL GameConfGetClassOffset(AMX *amx, cell *params) return -1; } - return value; + return value.fieldOffset; } // native bool:GameConfGetKeyValue(GameConfig:handle, const key[], buffer[], maxlen); diff --git a/modules/cstrike/cstrike/CstrikeHacks.cpp b/modules/cstrike/cstrike/CstrikeHacks.cpp index e5cf68f9..8beb6bb7 100644 --- a/modules/cstrike/cstrike/CstrikeHacks.cpp +++ b/modules/cstrike/cstrike/CstrikeHacks.cpp @@ -39,8 +39,8 @@ UTIL_FindEntityByStringFunc CS_UTIL_FindEntityByString; int CurrentItemId; StringHashMap ItemAliasList; -int TeamOffset; -int MenuOffset; +TypeDescription TeamDesc; +TypeDescription MenuDesc; server_static_t *ServerStatic; server_t *Server; @@ -130,11 +130,11 @@ DETOUR_DECL_STATIC1(C_ClientCommand, void, edict_t*, pEdict) // void ClientComma /* Menu_BuyItem */ { 0, CSI_VEST, CSI_VESTHELM, CSI_FLASHBANG, CSI_HEGRENADE, CSI_SMOKEGRENADE, CSI_NVGS, CSI_DEFUSER, CSI_SHIELDGUN } }; - int menuId = get_pdata(pEdict, MenuOffset); + int menuId = get_pdata(pEdict, MenuDesc.fieldOffset); if (menuId >= Menu_Buy && menuId <= Menu_BuyItem) { - switch (get_pdata(pEdict, TeamOffset)) + switch (get_pdata(pEdict, TeamDesc.fieldOffset)) { case TEAM_T: itemId = menuItemsTe[menuId - 4][slot]; break; // -4 because array is zero-based and Menu_Buy* constants starts from 4. case TEAM_CT:itemId = menuItemsCt[menuId - 4][slot]; break; @@ -278,16 +278,16 @@ void CtrlDetours_ClientCommand(bool set) #if defined(WIN32) - int offset = 0; + TypeDescription type; - if (MainConfig->GetOffset("UseBotArgs", &offset)) + if (MainConfig->GetOffset("UseBotArgs", &type)) { - UseBotArgs = get_pdata(base, offset); + UseBotArgs = get_pdata(base, type.fieldOffset); } - if (MainConfig->GetOffset("BotArgs", &offset)) + if (MainConfig->GetOffset("BotArgs", &type)) { - BotArgs = get_pdata(base, offset); + BotArgs = get_pdata(base, type.fieldOffset); } #elif defined(__linux__) || defined(__APPLE__) @@ -306,10 +306,10 @@ void CtrlDetours_ClientCommand(bool set) #endif ClientCommandDetour = DETOUR_CREATE_STATIC_FIXED(C_ClientCommand, base); - CommonConfig->GetOffsetByClass("CBasePlayer", "m_iTeam", &TeamOffset); - CommonConfig->GetOffsetByClass("CBasePlayer", "m_iMenu", &MenuOffset); + CommonConfig->GetOffsetByClass("CBasePlayer", "m_iTeam", &TeamDesc); + CommonConfig->GetOffsetByClass("CBasePlayer", "m_iMenu", &MenuDesc); - if (!ClientCommandDetour || !UseBotArgs || !BotArgs || !TeamOffset || !MenuOffset) + if (!ClientCommandDetour || !UseBotArgs || !BotArgs || !TeamDesc.fieldOffset || !MenuDesc.fieldOffset) { MF_Log("ClientCommand is not available - forward client_command has been disabled"); } @@ -518,11 +518,11 @@ void InitGlobalVars() #if defined(WIN32) - int offset = 0; + TypeDescription typeDesc; - if (CommonConfig->GetOffset("svs", &offset)) + if (CommonConfig->GetOffset("svs", &typeDesc)) { - uintptr_t base = *reinterpret_cast(reinterpret_cast(g_engfuncs.pfnGetCurrentPlayer) + offset); + uintptr_t base = *reinterpret_cast(reinterpret_cast(g_engfuncs.pfnGetCurrentPlayer) + typeDesc.fieldOffset); ServerStatic = reinterpret_cast(base - 4); } #else diff --git a/modules/cstrike/cstrike/CstrikeUtils.h b/modules/cstrike/cstrike/CstrikeUtils.h index ff10c287..14e19901 100644 --- a/modules/cstrike/cstrike/CstrikeUtils.h +++ b/modules/cstrike/cstrike/CstrikeUtils.h @@ -77,22 +77,26 @@ bool UTIL_CheckForPublic(const char *publicname); #define GET_OFFSET(classname, member) \ static int member = -1; \ if (member == -1) \ - { \ - if (!CommonConfig->GetOffsetByClass(classname, #member, &member) || member < 0)\ + { \ + TypeDescription type; \ + if (!CommonConfig->GetOffsetByClass(classname, #member, &type) || type.fieldOffset < 0)\ { \ MF_LogError(amx, AMX_ERR_NATIVE, "Invalid %s offset. Native %s is disabled", #member, __FUNCTION__);\ return 0; \ } \ + member = type.fieldOffset; \ } #define GET_OFFSET_NO_ERROR(classname, member) \ static int member = -1; \ if (member == -1) \ - { \ - if (!CommonConfig->GetOffsetByClass(classname, #member, &member) || member < 0)\ + { \ + TypeDescription type; \ + if (!CommonConfig->GetOffsetByClass(classname, #member, &type) || type.fieldOffset < 0)\ { \ - return; \ + return; \ } \ + member = type.fieldOffset; \ } template