summaryrefslogtreecommitdiffhomepage
path: root/src/portalcolours.c
diff options
context:
space:
mode:
authorMichael Smith <mikesmiffy128@gmail.com>2023-05-02 19:16:22 +0100
committerMichael Smith <mikesmiffy128@gmail.com>2023-05-04 23:49:27 +0100
commit5194eeb0e7bb5d2a2086c96ed04c2a47f9594d87 (patch)
treea32ab5c832ae312cb8ddd9fb45dc3f894ac39820 /src/portalcolours.c
parentbb5ce99e6cac43414a4bc61a636888e9f1f69b8c (diff)
Refactor the RGBA colour struct into engineapi.h
In both the engine and SST it's used in more places than just console printing, so it makes more sense to give it a more appropriate nanme and location.
Diffstat (limited to 'src/portalcolours.c')
-rw-r--r--src/portalcolours.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/portalcolours.c b/src/portalcolours.c
index 2231da4..48e4ee0 100644
--- a/src/portalcolours.c
+++ b/src/portalcolours.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2022 Michael Smith <mikesmiffy128@gmail.com>
+ * Copyright © 2023 Michael Smith <mikesmiffy128@gmail.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -40,9 +40,7 @@ DEF_CVAR(sst_portal_colour1, "Crosshair colour for left portal (hex)",
"40A0FF", CON_ARCHIVE | CON_HIDDEN)
DEF_CVAR(sst_portal_colour2, "Crosshair colour for right portal (hex)",
"FFA020", CON_ARCHIVE | CON_HIDDEN)
-// XXX: bit weird that this is still con_colour. should we move it back out to
-// engineapi as a general colour struct??
-static struct con_colour colours[3] = {
+static struct rgba colours[3] = {
{242, 202, 167, 255}, {64, 160, 255, 255}, {255, 160, 32, 255}};
static void hexparse(uchar out[static 4], const char *s) {
@@ -89,11 +87,11 @@ static void colourcb(struct con_var *v) {
}
// Original sig is the following but we wanna avoid calling convention weirdness
-//typedef struct con_colour (*UTIL_Portal_Color_func)(int);
-typedef void (*UTIL_Portal_Color_func)(struct con_colour *out, int portal);
+//typedef struct rgba (*UTIL_Portal_Color_func)(int);
+typedef void (*UTIL_Portal_Color_func)(struct rgba *out, int portal);
static UTIL_Portal_Color_func orig_UTIL_Portal_Color;
-static void hook_UTIL_Portal_Color(struct con_colour *out, int portal) {
- if (portal < 0 || portal > 2) *out = (struct con_colour){255, 255, 255, 255};
+static void hook_UTIL_Portal_Color(struct rgba *out, int portal) {
+ if (portal < 0 || portal > 2) *out = (struct rgba){255, 255, 255, 255};
else *out = colours[portal];
}