aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-09 00:04:21 +0100
committerGravatar Michael Smith <mikesmiffy128@gmail.com> 2025-04-09 00:10:32 +0100
commitac876ed2ef1c12f58b3426ffb3cb9d405428c12c (patch)
tree217b7d206613f9c81b13f7164e79f5c6f32216d7
parentd4bd451f8893bb01c11fb54451f0243611bf9bfb (diff)
downloadsst-master.tar.gz
sst-master.zip
Fix mistakes I made integrating Hayden's old codeHEADmaster
Doesn't matter how many history rewrites I do before pushing my local branch, there will always be something I still got wrong.
-rw-r--r--src/chatrate.c8
-rw-r--r--src/l4d1democompat.c10
2 files changed, 9 insertions, 9 deletions
diff --git a/src/chatrate.c b/src/chatrate.c
index 54572a5..9538306 100644
--- a/src/chatrate.c
+++ b/src/chatrate.c
@@ -32,9 +32,9 @@ static uchar *patchedbyte;
// So, instead of adding 0.66 to the current time, we subtract it, and that
// means we can always chat immediately.
-static inline bool find_ratelimit_insn(struct con_cmd *cmd_say) {
+static inline bool find_ratelimit_insn(con_cmdcb say_cb) {
// Find the add instruction
- uchar *insns = (uchar *)cmd_say->cb;
+ uchar *insns = (uchar *)say_cb;
for (uchar *p = insns; p - insns < 128;) {
// find FADD
if (p[0] == X86_FLTBLK5 && p[1] == X86_MODRM(0, 0, 5)) {
@@ -71,8 +71,8 @@ static inline void unpatch_ratelimit_insn() {
INIT {
struct con_cmd *cmd_say = con_findcmd("say");
- if_cold (!cmd_say) return false;
- if (!find_ratelimit_insn(cmd_say)) {
+ if_cold (!cmd_say) return FEAT_INCOMPAT; // should never happen!
+ if (!find_ratelimit_insn(cmd_say->cb)) {
errmsg_errorx("couldn't find chat rate limit instruction");
return FEAT_INCOMPAT;
}
diff --git a/src/l4d1democompat.c b/src/l4d1democompat.c
index 63c67e9..c4dab0c 100644
--- a/src/l4d1democompat.c
+++ b/src/l4d1democompat.c
@@ -49,9 +49,9 @@ static GetHostVersion_func orig_GetHostVersion;
typedef void (*VCALLCONV ReadDemoHeader_func)(void *);
static ReadDemoHeader_func orig_ReadDemoHeader;
-static inline bool find_ReadDemoHeader(con_cmdcb cb) {
+static inline bool find_ReadDemoHeader(con_cmdcb listdemo_cb) {
// Find the call to ReadDemoHeader in the listdemo callback
- const uchar *insns = (const uchar*)cb;
+ const uchar *insns = (const uchar *)listdemo_cb;
for (const uchar *p = insns; p - insns < 192;) {
if (p[0] == X86_LEA && p[1] == X86_MODRM(2, 1, 4) && p[2] == 0x24 &&
p[7] == X86_CALL && p[12] == X86_LEA &&
@@ -135,9 +135,9 @@ static int hook_midpoint() {
}
INIT {
- con_cmdcb orig_listdemo_cb = con_findcmd("listdemo")->cb;
- if_cold (!orig_listdemo_cb) return FEAT_INCOMPAT;
- if_cold (!find_ReadDemoHeader(orig_listdemo_cb)) {
+ struct con_cmd *cmd_listdemo = con_findcmd("listdemo");
+ if_cold (!cmd_listdemo) return FEAT_INCOMPAT; // should never happen!
+ if_cold (!find_ReadDemoHeader(cmd_listdemo->cb)) {
errmsg_errorx("couldn't find ReadDemoHeader function");
return FEAT_INCOMPAT;
}