Skip to content

Commit

Permalink
Small gamedata update
Browse files Browse the repository at this point in the history
Updated CBasePlayer::m_surfaceFriction offset for CSGO, and some minor update for glib/memutils include.
  • Loading branch information
GAMMACASE committed Jul 28, 2020
1 parent 7548a2e commit 4037f73
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 22 deletions.
8 changes: 5 additions & 3 deletions addons/sourcemod/gamedata/momsurffix2.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
53 changes: 41 additions & 12 deletions addons/sourcemod/scripting/include/glib/memutils.inc
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
#if defined _memutils_include
#if defined _memutils_included
#endinput
#else
#define _memutils_include
#endif
#define _memutils_included
#if !defined SNAME
#define __SNAME ""
#else
#define __SNAME SNAME
#endif
#define MEM_LEN_SAFE_THRESHOLD 1000
#define MEM_LEN_SAFE_THRESHOLD 2000
//-==ASSERTS
#define ASSERT_FMT_STRING_LEN 512
Expand Down Expand Up @@ -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]);
Expand All @@ -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<Address>(StringToInt(buff));
view_as<PatchHandler>(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!!
Expand Down Expand Up @@ -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==-
//Other util functions==-
#undef MEM_LEN_SAFE_THRESHOLD
20 changes: 16 additions & 4 deletions addons/sourcemod/scripting/momsurffix/baseplayer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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().");
Expand Down
4 changes: 1 addition & 3 deletions addons/sourcemod/scripting/momsurffix2.sp
Original file line number Diff line number Diff line change
Expand Up @@ -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_/"
};

Expand Down Expand Up @@ -118,8 +118,6 @@ public void OnMapStart()
public void OnPluginEnd()
{
CleanUpUtils();
if(gASMPatch.Address != Address_Null)
gASMPatch.Restore();
}

#if defined DEBUG_MEMTEST
Expand Down

0 comments on commit 4037f73

Please sign in to comment.