diff options
Diffstat (limited to 'src/autojump.c')
-rw-r--r-- | src/autojump.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/autojump.c b/src/autojump.c index 284dd85..c4f54f4 100644 --- a/src/autojump.c +++ b/src/autojump.c @@ -19,6 +19,7 @@ #include "con_.h" #include "engineapi.h" #include "errmsg.h" +#include "feature.h" #include "gamedata.h" #include "gametype.h" #include "intdefs.h" @@ -27,6 +28,11 @@ #include "os.h" #include "vcall.h" +FEATURE("autojump") +REQUIRE_GAMEDATA(off_mv) +REQUIRE_GAMEDATA(vtidx_CheckJumpButton) +REQUIRE_GLOBAL(factory_client) // note: server will never be null + DEF_CVAR(sst_autojump, "Jump upon hitting the ground while holding space", 0, CON_REPLICATE | CON_DEMO | CON_HIDDEN) @@ -69,17 +75,7 @@ static bool unprot(void *gm) { return ret; } -bool autojump_init(void) { - // TODO(featgen): auto-check these factories - if (!factory_client || !factory_server) { - errmsg_errorx("missing required factories"); - return false; - } - if (!has_vtidx_CheckJumpButton || !has_off_mv) { - errmsg_errorx("missing gamedata entries for this engine"); - return false; - } - +INIT { gmsv = factory_server("GameMovement001", 0); if (!gmsv) { errmsg_errorx("couldn't get server-side game movement interface"); @@ -111,7 +107,7 @@ bool autojump_init(void) { return true; } -void autojump_end(void) { +END { unhook_vtable(*(void ***)gmsv, vtidx_CheckJumpButton, (void *)origsv); unhook_vtable(*(void ***)gmcl, vtidx_CheckJumpButton, (void *)origcl); } |