Skip to content

Commit bf5ec55

Browse files
committed
save m_afButtonDisabled & m_afButtonForced in checkpoints (mainly for player_speedmod)
this makes kz_bhop_genkai a bit more bearable at times this also isn't perfect since restarting doesn't reset them
1 parent 2013968 commit bf5ec55

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

addons/sourcemod/gamedata/shavit.games.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,15 @@
346346
"linux" "\xC7\x80\x2A\x2A\x2A\x2A\x00\x00\x80\x3F\x8B\x03"
347347
"linux64" "\xC7\x80\x2A\x2A\x2A\x2A\x00\x00\x80\x3F\x48\x8B\x07"
348348
}
349+
// search "sv_maxusrcmdprocessticks_warning at server" to find CPlayerMove::RunCommand
350+
// then sig the the `mov REG1,dword ptr [REG2 + OFFSET_TO_BUTTON_DISABLED_HERE]`
351+
"CBasePlayer->m_afButtonDisabled"
352+
{
353+
"windows" "\x8B\x87\x2A\x2A\x2A\x2A\xF7\xD0\x23\xC1"
354+
"windows64" "\x8B\x87\x2A\x2A\x2A\x2A\xF7\xD0"
355+
"linux" "\x8B\x93\x2A\x2A\x2A\x2A\xF7\xD2"
356+
"linux64" "\x8B\x83\x2A\x2A\x2A\x2A\xF7\xD0\x21\xD0"
357+
}
349358
}
350359
}
351360

addons/sourcemod/scripting/include/shavit/checkpoints.inc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ enum struct cp_cache_t
6161
float m_ladderSurpressionTimer[2]; // css only // 0 = duration, 1 = remaining
6262
float m_lastLadderNormal[3]; // css only
6363
float m_lastLadderPos[3]; // css only
64+
65+
// used by player_speedmod
66+
int m_afButtonDisabled;
67+
// used by trigger_playermovement
68+
int m_afButtonForced;
6469
}
6570

6671
/**

addons/sourcemod/scripting/shavit-checkpoints.sp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ int gI_Offset_m_lastStandingPos = 0;
111111
int gI_Offset_m_ladderSurpressionTimer = 0;
112112
int gI_Offset_m_lastLadderNormal = 0;
113113
int gI_Offset_m_lastLadderPos = 0;
114+
int gI_Offset_m_afButtonDisabled = 0;
115+
int gI_Offset_m_afButtonForced = 0;
114116

115117
public Plugin myinfo =
116118
{
@@ -227,7 +229,7 @@ public void OnPluginStart()
227229

228230
void LoadDHooks()
229231
{
230-
Handle hGameData = LoadGameConfigFile("shavit.games");
232+
GameData hGameData = new GameData("shavit.games");
231233

232234
if (hGameData == null)
233235
{
@@ -259,6 +261,18 @@ void LoadDHooks()
259261
}
260262
}
261263

264+
Address buttonsSig = hGameData.GetMemSig("CBasePlayer->m_afButtonDisabled");
265+
if (buttonsSig == Address_Null)
266+
{
267+
SetFailState("Couldn't find signature of CBasePlayer->m_afButtonDisabled");
268+
}
269+
270+
int instr = LoadFromAddress(buttonsSig, NumberType_Int32);
271+
// The lowest two bytes are the beginning of a `mov`.
272+
// The offset is 100% definitely totally always 16-bit.
273+
gI_Offset_m_afButtonDisabled = instr >> 16;
274+
gI_Offset_m_afButtonForced = gI_Offset_m_afButtonDisabled + 4;
275+
262276
delete hGameData;
263277
hGameData = LoadGameConfigFile("sdktools.games");
264278
int iOffset;
@@ -1584,6 +1598,9 @@ void SaveCheckpointCache(int saver, int target, cp_cache_t cpcache, int index, H
15841598
cpcache.m_ignoreLadderJumpTime = GetEntPropFloat(target, Prop_Data, "m_ignoreLadderJumpTime") - GetGameTime();
15851599
}
15861600

1601+
cpcache.m_afButtonDisabled = GetEntData(target, gI_Offset_m_afButtonDisabled);
1602+
cpcache.m_afButtonForced = GetEntData(target, gI_Offset_m_afButtonForced);
1603+
15871604
cpcache.iMoveType = GetEntityMoveType(target);
15881605
cpcache.fGravity = GetEntityGravity(target);
15891606
cpcache.fSpeed = GetEntPropFloat(target, Prop_Send, "m_flLaggedMovementValue");
@@ -1864,6 +1881,9 @@ bool LoadCheckpointCache(int client, cp_cache_t cpcache, int index, bool force =
18641881
SetEntPropFloat(client, Prop_Send, "m_flDuckSpeed", cpcache.fDuckSpeed);
18651882
}
18661883

1884+
SetEntData(client, gI_Offset_m_afButtonDisabled, cpcache.m_afButtonDisabled);
1885+
SetEntData(client, gI_Offset_m_afButtonForced, cpcache.m_afButtonForced);
1886+
18671887
// this is basically the same as normal checkpoints except much less data is used
18681888
if(!isPersistentData && Shavit_GetStyleSettingInt(gI_Style[client], "kzcheckpoints"))
18691889
{

0 commit comments

Comments
 (0)