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/portalcolours.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/portalcolours.c') diff --git a/src/portalcolours.c b/src/portalcolours.c index 750ee19..231aa01 100644 --- a/src/portalcolours.c +++ b/src/portalcolours.c @@ -21,13 +21,18 @@ #include "engineapi.h" #include "errmsg.h" #include "gametype.h" +#include "feature.h" #include "hook.h" #include "intdefs.h" #include "mem.h" #include "os.h" #include "ppmagic.h" +#include "sst.h" #include "vcall.h" +FEATURE("portal gun colour customisation") +REQUIRE_GLOBAL(clientlib) + // It's like the thing Portal Tools does, but at runtime! DEF_CVAR(sst_portal_colour0, "Crosshair colour for gravity beam (hex)", @@ -119,8 +124,11 @@ static bool find_UTIL_Portal_Color(void *base) { return false; } -bool portalcolours_init(void *clientlib) { // ... should libs be globals? - if (!GAMETYPE_MATCHES(Portal)) return false; +PREINIT { + return GAMETYPE_MATCHES(Portal1); +} + +INIT { #ifdef _WIN32 if (!find_UTIL_Portal_Color(clientlib)) { errmsg_errorx("couldn't find UTIL_Portal_Color"); @@ -145,7 +153,7 @@ bool portalcolours_init(void *clientlib) { // ... should libs be globals? #endif } -void portalcolours_end(void) { +END { unhook_inline((void *)orig_UTIL_Portal_Color); } -- cgit v1.2.3