summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--compile2
-rw-r--r--compile.bat3
-rw-r--r--src/con_.h4
-rw-r--r--src/fixes.c59
-rw-r--r--src/fixes.h20
-rw-r--r--src/sst.c2
6 files changed, 88 insertions, 2 deletions
diff --git a/compile b/compile
index fa0240e..d48ee0e 100644
--- a/compile
+++ b/compile
@@ -29,6 +29,8 @@ src="\
demorec.c \
dbg.c \
extmalloc.c \
+ fixes.c \
+ gamedata.c \
gameinfo.c \
hook.c \
kv.c \
diff --git a/compile.bat b/compile.bat
index 4fce747..06596b0 100644
--- a/compile.bat
+++ b/compile.bat
@@ -24,7 +24,7 @@ clang -municode -O2 -fuse-ld=lld %warnings% -D_CRT_SECURE_NO_WARNINGS -ladvapi32
-o .build/codegen.exe src/build/codegen.c src/build/cmeta.c src/os.c || exit /b
clang -municode -O2 -fuse-ld=lld %warnings% -D_CRT_SECURE_NO_WARNINGS -ladvapi32 ^
-o .build/mkgamedata.exe src/build/mkgamedata.c src/kv.c src/os.c || exit /b
-.build\codegen.exe src/con_.c src/demorec.c src/dbg.c src/gamedata.c ^
+.build\codegen.exe src/con_.c src/demorec.c src/dbg.c src/fixes.c src/gamedata.c ^
src/gameinfo.c src/hook.c src/kv.c src/os.c src/sst.c src/udis86.c || exit /b
.build\mkgamedata.exe gamedata/engine.kv gamedata/gamelib.kv || exit /b
:: llvm-rc doesn't preprocess, looks like it might later:
@@ -39,6 +39,7 @@ call :cc src/con_.c || exit /b
call :cc src/demorec.c || exit /b
call :cc src/dbg.c || exit /b
call :cc src/extmalloc.c || exit /b
+call :cc src/fixes.c || exit /b
call :cc src/gamedata.c || exit /b
call :cc src/gameinfo.c || exit /b
call :cc src/hook.c || exit /b
diff --git a/src/con_.h b/src/con_.h
index 4c662fe..f6ef161 100644
--- a/src/con_.h
+++ b/src/con_.h
@@ -144,9 +144,11 @@ struct con_var { // ConVar in engine
int minval;
bool hasmax; // just sticking to sdk position for now
int maxval;
- //void *cb; we don't currently bother with callback support. add if needed!
+ //void *cb; // we don't currently bother with callback support. add if needed!
};
+/* The change callback used in most branches of Source. Takes an IConVar :) */
+typedef void (*con_varcb)(void *v, const char *, float);
/*
* These functions get and set the values of console variables in a
diff --git a/src/fixes.c b/src/fixes.c
new file mode 100644
index 0000000..fbab083
--- /dev/null
+++ b/src/fixes.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright © 2021 Michael Smith <mikesmiffy128@gmail.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "con_.h"
+
+static void unhide(const char *name) {
+ struct con_var *v = con_findvar(name);
+ if (v) v->parent->base.flags &= ~(CON_DEVONLY | CON_HIDDEN);
+}
+
+void fixes_apply(void) {
+ // expose all the demo stuff, for games like L4D that hide it for some
+ // reason.
+ unhide("demo_debug");
+ unhide("demo_fastforwardfinalspeed");
+ unhide("demo_fastforwardramptime");
+ unhide("demo_fastforwardstartspeed");
+ unhide("demo_gototick");
+ unhide("demo_interplimit");
+ unhide("demo_legacy_rollback");
+ unhide("demo_pauseatservertick");
+ unhide("demo_quitafterplayback");
+
+ unhide("director_afk_timeout");
+ unhide("mp_restartgame");
+
+ // handy console stuff
+ unhide("con_filter_enable");
+ unhide("con_filter_text");
+ unhide("con_filter_text_out");
+
+ // also, let people just do this lol. why not
+ unhide("developer");
+
+ // L4D2 doesn't let you set sv_cheats in lobbies, but turns out it skips all
+ // the lobby checks if this random command is developer-only, presumably
+ // because that flag is compiled out in debug builds and devs want to be
+ // able to use cheats. Took literally hours of staring at Ghidra to find
+ // this out. Good meme 8/10.
+ unhide("sv_hosting_lobby");
+}
+
+// vi: sw=4 ts=4 noet tw=80 cc=80
diff --git a/src/fixes.h b/src/fixes.h
new file mode 100644
index 0000000..6795b4c
--- /dev/null
+++ b/src/fixes.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright © 2021 Michael Smith <mikesmiffy128@gmail.com>
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+ * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Makes a best-effort attempt to fix up random annoyances in some games. */
+void fixes_apply(void);
+
+// vi: sw=4 ts=4 noet tw=80 cc=80
diff --git a/src/sst.c b/src/sst.c
index dbee4b7..6c60cf3 100644
--- a/src/sst.c
+++ b/src/sst.c
@@ -19,6 +19,7 @@
#include "con_.h"
#include "demorec.h"
#include "factory.h"
+#include "fixes.h"
#include "gamedata.h"
#include "gameinfo.h"
#include "gametype.h"
@@ -108,6 +109,7 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) {
nc: gamedata_init();
// TODO(autojump): we'd init that here
has_demorec = demorec_init();
+ fixes_apply();
con_colourmsg(RGBA(64, 255, 64, 255),
NAME " v" VERSION " successfully loaded");