summaryrefslogtreecommitdiffhomepage
path: root/src/autojump.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2022-07-31 16:02:10 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2022-08-10 22:40:52 +0100
commit5e921bf59373d79d27c322ff86e8b5a37b151e45 (patch)
tree4d40e39543b085ce4c8cb9b1a7b3c0108de680c0 /src/autojump.c
parentc8d7588251fd4fe63ac6afe2a90ca7066c786609 (diff)
Add magical feature codegen system, at long last
Diffstat (limited to 'src/autojump.c')
-rw-r--r--src/autojump.c20
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);
}