Read offset from gamedata instead of hardcoded.

This commit is contained in:
zaCade 2019-09-27 17:23:39 +02:00
parent dfc024b3d8
commit e83239e053
3 changed files with 22 additions and 16 deletions

View File

@ -1,3 +1,17 @@
"Games" "Games"
{ {
"cstrike"
{
"Offsets"
{
// CCSPlayer::m_LastHitGroup
// CCSPlayer::OnTakeDamage_Alive(CTakeDamageInfo const&)+122 mov ecx, [ebp+this]
// CCSPlayer::OnTakeDamage_Alive(CTakeDamageInfo const&)+125 mov edx, [ecx+4444]
// CCSPlayer::OnTakeDamage_Alive(CTakeDamageInfo const&)+12B mov dword ptr [esp+4], offset aHitgroup ; "hitgroup"
"m_LastHitGroup"
{
"linux" "4444"
}
}
}
} }

View File

@ -92,27 +92,27 @@ ToolsFindOffsets()
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_iFOV\" was not found."); LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBasePlayer::m_iFOV\" was not found.");
} }
// If offset "m_hActiveWeapon" can't be found, then stop the plugin.
g_iActiveWeapon = FindSendPropInfo("CBaseCombatCharacter", "m_hActiveWeapon"); g_iActiveWeapon = FindSendPropInfo("CBaseCombatCharacter", "m_hActiveWeapon");
if (g_iActiveWeapon == -1) if (g_iActiveWeapon == -1)
{ {
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBaseCombatCharacter::m_hActiveWeapon\" was not found."); LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Offset \"CBaseCombatCharacter::m_hActiveWeapon\" was not found.");
} }
// CCSPlayer::m_LastHitGroup
// CCSPlayer::OnTakeDamage_Alive(CTakeDamageInfo const&)+122 mov ecx, [ebp+this]
// CCSPlayer::OnTakeDamage_Alive(CTakeDamageInfo const&)+125 mov edx, [ecx+4444]
// CCSPlayer::OnTakeDamage_Alive(CTakeDamageInfo const&)+12B mov dword ptr [esp+4], offset aHitgroup ; "hitgroup"
g_iToolsLastHitGroup = 4444;
Handle hGameConf = LoadGameConfigFile("zombiereloaded"); Handle hGameConf = LoadGameConfigFile("zombiereloaded");
if (hGameConf != INVALID_HANDLE) if (hGameConf != INVALID_HANDLE)
{ {
// Reserved // If offset "m_LastHitGroup" can't be found, then stop the plugin.
g_iToolsLastHitGroup = GameConfGetOffset(hGameConf, "m_LastHitGroup");
if (g_iToolsLastHitGroup == -1)
{
LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Gamedata Offset \"CCSPlayer::m_LastHitGroup\" was not found.");
}
CloseHandle(hGameConf); CloseHandle(hGameConf);
} }
else else
LogEvent(false, LogType_Error, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Couldn't load zombiereloaded game config!"); LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Tools, "Offsets", "Couldn't load zombiereloaded game config!");
// Forward event to modules. // Forward event to modules.
WeaponsOnOffsetsFound(); WeaponsOnOffsetsFound();

View File

@ -268,10 +268,6 @@ stock int ToolsGetClientActiveWeapon(int client)
*/ */
stock int ToolsGetClientLastHitGroup(int client) stock int ToolsGetClientLastHitGroup(int client)
{ {
/* WRONG OFFSET
if (g_iToolsLastHitGroup == -1)
g_iToolsLastHitGroup = FindDataMapInfo(client, "m_LastHitGroup");
*/
return GetEntData(client, g_iToolsLastHitGroup, 4); return GetEntData(client, g_iToolsLastHitGroup, 4);
} }
@ -283,9 +279,5 @@ stock int ToolsGetClientLastHitGroup(int client)
*/ */
stock void ToolsSetClientLastHitGroup(int client, int hitgroup) stock void ToolsSetClientLastHitGroup(int client, int hitgroup)
{ {
/* WRONG OFFSET
if (g_iToolsLastHitGroup == -1)
g_iToolsLastHitGroup = FindDataMapInfo(client, "m_LastHitGroup");
*/
SetEntData(client, g_iToolsLastHitGroup, hitgroup, 4); SetEntData(client, g_iToolsLastHitGroup, hitgroup, 4);
} }