summaryrefslogtreecommitdiffhomepage
path: root/src/portalcolours.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/portalcolours.c
parentc8d7588251fd4fe63ac6afe2a90ca7066c786609 (diff)
Add magical feature codegen system, at long last
Diffstat (limited to 'src/portalcolours.c')
-rw-r--r--src/portalcolours.c14
1 files changed, 11 insertions, 3 deletions
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);
}