From 5e921bf59373d79d27c322ff86e8b5a37b151e45 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Sun, 31 Jul 2022 16:02:10 +0100 Subject: Add magical feature codegen system, at long last --- src/l4dwarp.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/l4dwarp.c') diff --git a/src/l4dwarp.c b/src/l4dwarp.c index 76aa230..5412b64 100644 --- a/src/l4dwarp.c +++ b/src/l4dwarp.c @@ -16,18 +16,23 @@ #define _USE_MATH_DEFINES // ... windows. #include -#include #include "con_.h" #include "engineapi.h" #include "errmsg.h" #include "ent.h" +#include "feature.h" #include "gamedata.h" #include "gametype.h" #include "intdefs.h" #include "mem.h" #include "vcall.h" +FEATURE("Left 4 Dead warp testing") +REQUIRE_GAMEDATA(off_entpos) +REQUIRE_GAMEDATA(off_eyeang) +REQUIRE_GAMEDATA(vtidx_Teleport) + DECL_VFUNC_DYN(void *, GetBaseEntity) DECL_VFUNC_DYN(void, Teleport, const struct vec3f *pos, const struct vec3f *ang, const struct vec3f *vel) @@ -48,12 +53,11 @@ DEF_CCMD_HERE_UNREG(sst_l4d_testwarp, "Simulate a bot warping to you", org->y + shift * sin(yaw), org->z}, 0, &(struct vec3f){0, 0, 0}); } -bool l4dwarp_init(void) { - if (!GAMETYPE_MATCHES(L4Dx)) return false; - if (!has_off_entpos || !has_off_eyeang || !has_vtidx_Teleport) { - errmsg_errorx("missing gamedata entries for this engine"); - return false; - } +PREINIT { + return GAMETYPE_MATCHES(L4Dx); +} + +INIT { con_reg(sst_l4d_testwarp); return true; } -- cgit v1.2.3