From ac7e7d0f21978afc70fe3ef76db69d575742b974 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 17 Jun 2025 20:18:48 +0100 Subject: Separate our command callbacks from Source's This improves the ergonomics of a few different things, and sets us up somewhat for the fact OE had a different interface for commands too (it was v1 only and had a separate API call for getting the args). --- src/sst.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/sst.c') diff --git a/src/sst.c b/src/sst.c index ef14aca..4f9445d 100644 --- a/src/sst.c +++ b/src/sst.c @@ -419,7 +419,7 @@ DEF_EVENT(PluginLoaded) DEF_EVENT(PluginUnloaded) static struct con_cmd *cmd_plugin_load, *cmd_plugin_unload; -static con_cmdcb orig_plugin_load_cb, orig_plugin_unload_cb; +static con_cmdcbv2 orig_plugin_load_cb, orig_plugin_unload_cb; static int ownidx; // XXX: super hacky way of getting this to do_unload() @@ -518,11 +518,11 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) { if (!deferinit()) { do_featureinit(); fixes_apply(); } if_hot (pluginhandler) { cmd_plugin_load = con_findcmd("plugin_load"); - orig_plugin_load_cb = cmd_plugin_load->cb; - cmd_plugin_load->cb = &hook_plugin_load_cb; + orig_plugin_load_cb = cmd_plugin_load->cb_v2; + cmd_plugin_load->cb_v2 = &hook_plugin_load_cb; cmd_plugin_unload = con_findcmd("plugin_unload"); - orig_plugin_unload_cb = cmd_plugin_unload->cb; - cmd_plugin_unload->cb = &hook_plugin_unload_cb; + orig_plugin_unload_cb = cmd_plugin_unload->cb_v2; + cmd_plugin_unload->cb_v2 = &hook_plugin_unload_cb; } return true; } @@ -530,8 +530,8 @@ static bool do_load(ifacefactory enginef, ifacefactory serverf) { static void do_unload() { // slow path: reloading shouldn't happen all the time, prioritise fast exit if_cold (sst_userunloaded) { // note: if we're here, pluginhandler is set - cmd_plugin_load->cb = orig_plugin_load_cb; - cmd_plugin_unload->cb = orig_plugin_unload_cb; + cmd_plugin_load->cb_v2 = orig_plugin_load_cb; + cmd_plugin_unload->cb_v2 = orig_plugin_unload_cb; #ifdef _WIN32 // this bit is only relevant in builds that predate linux support struct CPlugin **plugins = pluginhandler->plugins.m.mem; // see comment in CPlugin struct. setting this to the real handle right -- cgit v1.2.3-54-g00ecf