summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-05-12 16:38:53 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-05-12 16:38:53 +0100
commit829dece47f305979bd1375300ebc14fc2e264c0a (patch)
treeece92f21916bcdc893ff21034ab8599d895c0071
parenta0138ff3772e71f338d04668076ec1eb9d44f8f4 (diff)
Rerun L4D1 console spam fix after config loading
This was the simplest way I could think of to solve this issue. Thanks again Aciidz for pointing the issue out, and thanks Turtle Rock for shipping such a broken game.
-rw-r--r--src/fixes.c8
-rw-r--r--src/fixes.h7
-rw-r--r--src/sst.c16
3 files changed, 31 insertions, 0 deletions
diff --git a/src/fixes.c b/src/fixes.c
index d055ba8..a90d878 100644
--- a/src/fixes.c
+++ b/src/fixes.c
@@ -161,4 +161,12 @@ void fixes_apply(void) {
else if (GAMETYPE_MATCHES(L4D2x)) l4d2specific();
}
+void fixes_tryagainlater(void) {
+ if (GAMETYPE_MATCHES(L4D1)) {
+ // whatever dll this is in seems to load late (mm_l4d_debug is fine)
+ struct con_var *v = con_findvar("ui_l4d_debug");
+ if (v) con_setvari(v, 0);
+ }
+}
+
// vi: sw=4 ts=4 noet tw=80 cc=80
diff --git a/src/fixes.h b/src/fixes.h
index ae863a8..54d8d06 100644
--- a/src/fixes.h
+++ b/src/fixes.h
@@ -20,4 +20,11 @@
*/
void fixes_apply(void);
+/*
+ * Applies specific fixes *again*, in cases where they wouldn't work very early
+ * in game startup (like if the plugin is loaded via VDF). Isn't guaranteed to
+ * be called if the plugin is loaded later, so must do things redundantly.
+ */
+void fixes_tryagainlater(void);
+
// vi: sw=4 ts=4 noet tw=80 cc=80
diff --git a/src/sst.c b/src/sst.c
index 5a7ca31..edd083f 100644
--- a/src/sst.c
+++ b/src/sst.c
@@ -160,6 +160,15 @@ static const char *VCALLCONV GetStringForSymbol_hook(void *this, int s) {
return ret;
}
+// by hooking stuffcmds, we get a callback after the last of the startup
+// commands have run (the command line ones)
+static struct con_cmd *cmd_stuffcmds = 0;
+static con_cmdcb orig_stuffcmds_cb;
+static void hook_stuffcmds_cb(const struct con_cmdargs *args) {
+ orig_stuffcmds_cb(args);
+ fixes_tryagainlater();
+}
+
// vstdlib symbol, only currently used in l4d2 but exists everywhere so oh well
IMPORT void *KeyValuesSystem(void);
@@ -277,6 +286,12 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) {
(void *)GetStringForSymbol_hook);
}
+ cmd_stuffcmds = con_findcmd("stuffcmds");
+ if (cmd_stuffcmds) {
+ orig_stuffcmds_cb = cmd_stuffcmds->cb;
+ cmd_stuffcmds->cb = hook_stuffcmds_cb;
+ }
+
e: con_colourmsg(RGBA(64, 255, 64, 255),
LONGNAME " v" VERSION " successfully loaded");
con_colourmsg(RGBA(255, 255, 255, 255), " for game ");
@@ -338,6 +353,7 @@ static void do_unload(void) {
if (orig_GetStringForSymbol) {
unhook_vtable(kvsvt, 4, (void *)orig_GetStringForSymbol);
}
+ if (cmd_stuffcmds) cmd_stuffcmds->cb = orig_stuffcmds_cb;
}
static bool VCALLCONV Load(void *this, ifacefactory enginef,