From 4037f73f53566859edc9361f02b512a98f74ce4e Mon Sep 17 00:00:00 2001 From: GAMMACASE Date: Tue, 28 Jul 2020 12:45:04 +0300 Subject: [PATCH] Small gamedata update Updated CBasePlayer::m_surfaceFriction offset for CSGO, and some minor update for glib/memutils include. --- .../sourcemod/gamedata/momsurffix2.games.txt | 8 +-- .../scripting/include/glib/memutils.inc | 53 ++++++++++++++----- .../scripting/momsurffix/baseplayer.sp | 20 +++++-- addons/sourcemod/scripting/momsurffix2.sp | 4 +- 4 files changed, 63 insertions(+), 22 deletions(-) diff --git a/addons/sourcemod/gamedata/momsurffix2.games.txt b/addons/sourcemod/gamedata/momsurffix2.games.txt index fffdf1c..f50d0c8 100644 --- a/addons/sourcemod/gamedata/momsurffix2.games.txt +++ b/addons/sourcemod/gamedata/momsurffix2.games.txt @@ -109,7 +109,8 @@ "CEntInfo::size" "16" //CBasePlayer - "CBasePlayer::m_surfaceFriction" "3832" + //Offset is relative to m_szLastPlaceName netprop and will be added to it + "CBasePlayer::m_surfaceFriction" "104" //Ray_t "Ray_t::m_Start" "0" @@ -299,9 +300,10 @@ "CMoveData::m_vecVelocity" "64" //... "CMoveData::m_vecAbsOrigin" "172" - + //CBasePlayer - "CBasePlayer::m_surfaceFriction" "4660" + //Offset is relative to m_ubEFNoInterpParity netprop and will be substracted from it + "CBasePlayer::m_surfaceFriction" "8" //Ray_t "Ray_t::m_Start" "0" diff --git a/addons/sourcemod/scripting/include/glib/memutils.inc b/addons/sourcemod/scripting/include/glib/memutils.inc index 2583b4b..05b31a5 100644 --- a/addons/sourcemod/scripting/include/glib/memutils.inc +++ b/addons/sourcemod/scripting/include/glib/memutils.inc @@ -1,8 +1,7 @@ -#if defined _memutils_include +#if defined _memutils_included #endinput -#else -#define _memutils_include #endif +#define _memutils_included #if !defined SNAME #define __SNAME "" @@ -10,7 +9,7 @@ #define __SNAME SNAME #endif -#define MEM_LEN_SAFE_THRESHOLD 1000 +#define MEM_LEN_SAFE_THRESHOLD 2000 //-==ASSERTS #define ASSERT_FMT_STRING_LEN 512 @@ -154,14 +153,15 @@ methodmap PatchHandler public void Restore() { - ASSERT(gPatchStack); + if(!gPatchStack) + return; char buff[32]; IntToString(this.Any, buff, sizeof(buff)); int arrSize[1]; - gPatchStack.GetArray(buff, arrSize, sizeof(arrSize)); - ASSERT(arrSize[0] > 0 && arrSize[0] < MEM_LEN_SAFE_THRESHOLD); + if(!gPatchStack.GetArray(buff, arrSize, sizeof(arrSize))) + return; int[] arr = new int[arrSize[0]]; gPatchStack.GetArray(buff, arr, arrSize[0]); @@ -174,29 +174,56 @@ methodmap PatchHandler delete gPatchStack; } } + +public void OnPluginEnd() +{ + if(gPatchStack) + { + StringMapSnapshot sms = gPatchStack.Snapshot(); + char buff[32]; + Address addr; + + for(int i = 0; i < sms.Length; i++) + { + sms.GetKey(i, buff, sizeof(buff)); + addr = view_as
(StringToInt(buff)); + view_as(addr).Restore(); + } + } + +#if !defined MEMUTILS_NOPLENDCALL + OnPluginEnd_MemUtilsRedefined(); +#endif +} +#undef OnPluginEnd +#define OnPluginEnd OnPluginEnd_MemUtilsRedefined //PatchHandling methodmap==- //-==Other util functions stock void DumpOnAddress(Address addr, int len, int columns = 10) { - char buff[128]; + char buff[128], buff2[128]; ASSERT(addr != Address_Null); ASSERT(len > 0 && len < MEM_LEN_SAFE_THRESHOLD); Format(buff, sizeof(buff), "[0x%08X]", addr); + char chr; for(int i = 0; i < len; i++) { - Format(buff, sizeof(buff), "%s %02X", buff, LoadFromAddress(addr + i, NumberType_Int8)); + chr = LoadFromAddress(addr + i, NumberType_Int8); + Format(buff, sizeof(buff), "%s %02X", buff, chr); + Format(buff2, sizeof(buff2), "%s%c", buff2, (chr > ' ' && chr != 0x7F && chr != 0xFF ? chr : '.')); if(i % columns == columns - 1) { - PrintToServer(__SNAME..."%s", buff); + PrintToServer(__SNAME..."%s %s", buff, buff2); Format(buff, sizeof(buff), "[0x%08X]", addr + i); + buff2[0] = '\0'; } } if((len - 1) % columns != columns - 1) - PrintToServer(__SNAME..."%s", buff); + PrintToServer(__SNAME..."%s %s", buff, buff2); } //NO OVERLAPPING!! @@ -246,4 +273,6 @@ stock void PatchArea(Address addr, int len, char byte = 0x90) for(int i = 0; i < len; i++) StoreToAddress(addr + i, byte, NumberType_Int8); } -//Other util functions==- \ No newline at end of file +//Other util functions==- + +#undef MEM_LEN_SAFE_THRESHOLD \ No newline at end of file diff --git a/addons/sourcemod/scripting/momsurffix/baseplayer.sp b/addons/sourcemod/scripting/momsurffix/baseplayer.sp index 9f56c01..de64a17 100644 --- a/addons/sourcemod/scripting/momsurffix/baseplayer.sp +++ b/addons/sourcemod/scripting/momsurffix/baseplayer.sp @@ -136,11 +136,23 @@ stock bool InitBasePlayer(GameData gd) //CBaseHandle ASSERT_FMT(gd.GetKeyValue("CBaseHandle::m_Index", buff, sizeof(buff)), "Can't get \"CBaseHandle::m_Index\" offset from gamedata."); offsets.cbhoffsets.m_Index = StringToInt(buff); + + //CBasePlayer + ASSERT_FMT(gd.GetKeyValue("CBasePlayer::m_surfaceFriction", buff, sizeof(buff)), "Can't get \"CBasePlayer::m_surfaceFriction\" offset from gamedata."); + int offs = StringToInt(buff); + int prop_offs = FindSendPropInfo("CBasePlayer", "m_szLastPlaceName"); + ASSERT_FMT(prop_offs > 0, "Can't get \"CBasePlayer::m_szLastPlaceName\" offset from FindSendPropInfo()."); + offsets.cbpoffsets.m_surfaceFriction = prop_offs + offs; + } + else if(gEngineVersion == Engine_CSGO) + { + //CBasePlayer + ASSERT_FMT(gd.GetKeyValue("CBasePlayer::m_surfaceFriction", buff, sizeof(buff)), "Can't get \"CBasePlayer::m_surfaceFriction\" offset from gamedata."); + int offs = StringToInt(buff); + int prop_offs = FindSendPropInfo("CBasePlayer", "m_ubEFNoInterpParity"); + ASSERT_FMT(prop_offs > 0, "Can't get \"CBasePlayer::m_ubEFNoInterpParity\" offset from FindSendPropInfo()."); + offsets.cbpoffsets.m_surfaceFriction = prop_offs - offs; } - - //CBasePlayer - ASSERT_FMT(gd.GetKeyValue("CBasePlayer::m_surfaceFriction", buff, sizeof(buff)), "Can't get \"CBasePlayer::m_surfaceFriction\" offset from gamedata."); - offsets.cbpoffsets.m_surfaceFriction = StringToInt(buff); offsets.cbpoffsets.m_hGroundEntity = FindSendPropInfo("CBasePlayer", "m_hGroundEntity"); ASSERT_FMT(offsets.cbpoffsets.m_hGroundEntity > 0, "Can't get \"CBasePlayer::m_hGroundEntity\" offset from FindSendPropInfo()."); diff --git a/addons/sourcemod/scripting/momsurffix2.sp b/addons/sourcemod/scripting/momsurffix2.sp index 553b2c1..359a9ec 100644 --- a/addons/sourcemod/scripting/momsurffix2.sp +++ b/addons/sourcemod/scripting/momsurffix2.sp @@ -12,7 +12,7 @@ public Plugin myinfo = { name = "Momentum surf fix \'2", author = "GAMMA CASE", description = "Ported surf fix from momentum mod.", - version = "1.1.2", + version = "1.1.3", url = "http://steamcommunity.com/id/_GAMMACASE_/" }; @@ -118,8 +118,6 @@ public void OnMapStart() public void OnPluginEnd() { CleanUpUtils(); - if(gASMPatch.Address != Address_Null) - gASMPatch.Restore(); } #if defined DEBUG_MEMTEST