summaryrefslogtreecommitdiffhomepage
path: root/src/sst.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-03-24 02:06:28 +0000
committerMichael Smith <mikesmiffy128@gmail.com>2022-03-24 04:38:25 +0000
commit00ad7cdd3d05d09a43bda972c823fdc440feabb9 (patch)
tree7f9725341e598f273fc1fb6ca0803c794bb67698 /src/sst.c
parentb18326a75078530df7712667f41b4ea354e1da3e (diff)
Clean up gameinfo_init() and other random stuff
- Just ask the engine for the game directory instead of doing the stupid argv sniffing hacks from the early days of trying to get the damn thing working. - Also add some other path variables, functions and whatnot, and do some other minor tidying up. - Also also, another damn copyright year, somebody please help me. Unfortunate negative effect off this change: con_init() no longer reports the game name, because it has to happen before gameinfo_init(). I've decided I don't really care, though.
Diffstat (limited to 'src/sst.c')
-rw-r--r--src/sst.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/sst.c b/src/sst.c
index aeb7f4c..1d0d18a 100644
--- a/src/sst.c
+++ b/src/sst.c
@@ -35,7 +35,7 @@
u32 _gametype_tag = 0; // spaghetti: no point making a .c file for 1 variable
-static int plugin_ver;
+static int ifacever;
// this is where we start dynamically adding virtual functions, see vtable[]
// array below
static const void **vtable_firstdiff;
@@ -75,6 +75,11 @@ static bool has_demorec_custom = false;
static bool has_rinput = false;
#endif
+// since this is static/global, it only becomes false again when the plugin SO
+// is unloaded/reloaded
+static bool already_loaded = false;
+static bool skip_unload = false;
+
// HACK: later versions of L4D2 show an annoying dialog on every plugin_load.
// We can suppress this by catching the message string that's passed from
// engine.dll to gameui.dll through KeyValuesSystem in vstdlib.dll and just
@@ -147,7 +152,8 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) {
#ifndef __linux__
void *clientlib = 0;
#endif
- if (!gameinfo_init() || !con_init(enginef, plugin_ver)) return false;
+ if (!con_init(enginef, ifacever)) return false;
+ if (!gameinfo_init(enginef)) { con_disconnect(); return false; }
const void **p = vtable_firstdiff;
if (GAMETYPE_MATCHES(Portal2)) *p++ = (void *)&nop_p_v; // ClientFullyConnect
*p++ = (void *)&nop_p_v; // ClientDisconnect
@@ -155,9 +161,9 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) {
*p++ = (void *)&SetCommandClient; // SetCommandClient
*p++ = (void *)&nop_p_v; // ClientSettingsChanged
*p++ = (void *)&nop_5pi_i; // ClientConnect
- *p++ = plugin_ver > 1 ? (void *)&nop_pp_i : (void *)&nop_p_i; // ClientCommand
- *p++ = (void *)&nop_pp_i; // NetworkIDValidated
+ *p++ = ifacever > 1 ? (void *)&nop_pp_i : (void *)&nop_p_i; // ClientCommand
// remaining stuff here is backwards compatible, so added unconditionally
+ *p++ = (void *)&nop_pp_i; // NetworkIDValidated
*p++ = (void *)&nop_ipipp_v; // OnQueryCvarValueFinished (002+)
*p++ = (void *)&nop_p_v; // OnEdictAllocated
*p = (void *)&nop_p_v; // OnEdictFreed
@@ -248,11 +254,6 @@ static void do_unload(void) {
}
}
-// since this is static/global, it only becomes false again when the plugin SO
-// is unloaded/reloaded
-static bool already_loaded = false;
-static bool skip_unload = false;
-
static bool VCALLCONV Load(void *this, ifacefactory enginef,
ifacefactory serverf) {
if (already_loaded) {
@@ -316,7 +317,7 @@ EXPORT const void *CreateInterface(const char *name, int *ret) {
if (!strncmp(name, "ISERVERPLUGINCALLBACKS00", 24)) {
if ((name[24] >= '1' || name[24] <= '3') && name[25] == '\0') {
if (ret) *ret = 0;
- plugin_ver = name[24] - '0';
+ ifacever = name[24] - '0';
return &plugin_obj;
}
}