diff options
-rw-r--r-- | src/build/codegen.c | 19 | ||||
-rw-r--r-- | src/con_.c | 10 | ||||
-rw-r--r-- | src/con_.h | 13 | ||||
-rw-r--r-- | src/dbg.c | 7 | ||||
-rw-r--r-- | src/engineapi.h | 12 | ||||
-rw-r--r-- | src/portalcolours.c | 14 | ||||
-rw-r--r-- | src/rinput.c | 12 | ||||
-rw-r--r-- | src/sst.c | 8 |
8 files changed, 47 insertions, 48 deletions
diff --git a/src/build/codegen.c b/src/build/codegen.c index 391f572..bf3ae1e 100644 --- a/src/build/codegen.c +++ b/src/build/codegen.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 @@ -415,18 +415,17 @@ F( "static bool has_%s = false;", f->modname) } _( "") _( "static void initfeatures(void) {") - for (struct feature *f = features.x[0]; f; f = f->hdr.x[0]) { - featdfs(out, f); - } + for (struct feature *f = features.x[0]; f; f = f->hdr.x[0]) featdfs(out, f); _( "") // note: old success message is moved in here, to get the ordering right -_( " con_colourmsg(RGBA(64, 255, 64, 255),") +_( " con_colourmsg(&(struct rgba){64, 255, 64, 255},") _( " LONGNAME \" v\" VERSION \" successfully loaded\");") -_( " con_colourmsg(RGBA(255, 255, 255, 255), \" for game \");") -_( " con_colourmsg(RGBA(0, 255, 255, 255), \"%s\\n\", gameinfo_title);") -_( " struct con_colour white = {255, 255, 255, 255};") -_( " struct con_colour green = {128, 255, 128, 255};") -_( " struct con_colour red = {255, 128, 128, 255};") +_( " con_colourmsg(&(struct rgba){255, 255, 255, 255}, \" for game \");") +_( " con_colourmsg(&(struct rgba){0, 255, 255, 255}, \"%s\\n\", ") +_( " gameinfo_title);") +_( " struct rgba white = {255, 255, 255, 255};") +_( " struct rgba green = {128, 255, 128, 255};") +_( " struct rgba red = {255, 128, 128, 255};") _( " con_colourmsg(&white, \"---- List of plugin features ---\\n\");"); for (const struct feature *f = features_bydesc.x[0]; f; f = f->hdr_bydesc.x[0]) { @@ -21,7 +21,7 @@ #include "abi.h" #include "con_.h" -#include "engineapi.h" // only for factories - XXX: do we care this is circular? +#include "engineapi.h" // for factories and rgba - XXX: is this a bit circular? #include "extmalloc.h" #include "gametype.h" #include "mem.h" @@ -46,7 +46,7 @@ int con_cmdclient; // these have to be extern because of varargs nonsense - they get wrapped in a // macro for the actual api (con_colourmsg) void *_con_iface; -void (*_con_colourmsgf)(void *this, const struct con_colour *c, const char *fmt, +void (*_con_colourmsgf)(void *this, const struct rgba *c, const char *fmt, ...) _CON_PRINTF(3, 4); // bootstrap hackery, see "GENIUS HACK" comment below :) @@ -67,7 +67,7 @@ DECL_VFUNC_DYN(void, CallGlobalChangeCallbacks, struct con_var *, const char *, // can't pass varargs to other varargs of course). we only get a pointer to it // via VFUNC so just declare the typedef here - I don't wanna write any more // macros today. -typedef void (*ConsoleColorPrintf_func)(void *, const struct con_colour *, +typedef void (*ConsoleColorPrintf_func)(void *, const struct rgba *, const char *, ...); static inline void initval(struct con_var *v) { @@ -229,7 +229,7 @@ static void VCALLCONV InternalSetIntValue_impl(struct con_var *this, int v) { DECL_VFUNC_DYN(void, InternalSetValue, const char *) DECL_VFUNC_DYN(void, InternalSetFloatValue, float) DECL_VFUNC_DYN(void, InternalSetIntValue, int) -DECL_VFUNC_DYN(void, InternalSetColorValue, struct con_colour) +DECL_VFUNC_DYN(void, InternalSetColorValue, struct rgba) // Hack: IConVar things get this-adjusted pointers, we just reverse the offset // to get the top pointer. @@ -248,7 +248,7 @@ static void VCALLCONV SetValue_i_thunk(void *thisoff, int v) { -offsetof(struct con_var, vtable_iconvar)); InternalSetIntValue(&this->parent->base, v); } -static void VCALLCONV SetValue_colour_thunk(void *thisoff, struct con_colour v) { +static void VCALLCONV SetValue_colour_thunk(void *thisoff, struct rgba v) { struct con_var *this = mem_offset(thisoff, -offsetof(struct con_var, vtable_iconvar)); InternalSetColorValue(&this->parent->base, v); @@ -38,15 +38,6 @@ struct con_cmdargs { const char *argv[CON_CMD_MAX_ARGC]; }; -/* an RGBA colour, passed to con_colourmsg */ -struct con_colour { - union { - struct { u8 r, g, b, a; }; - u32 val; - uchar bytes[4]; - }; -}; - #define CON_CMD_MAXCOMPLETE 64 #define CON_CMD_MAXCOMPLLEN 64 @@ -196,8 +187,10 @@ void con_warn(const char *fmt, ...) _CON_PRINTF(1, 2) __asm__("Warning"); #error Need an equivalent of asm names for your compiler! #endif +struct rgba; // in engineapi.h - forward declare here to avoid warnings + extern void *_con_iface; -extern void (*_con_colourmsgf)(void *this, const struct con_colour *c, +extern void (*_con_colourmsgf)(void *this, const struct rgba *c, const char *fmt, ...) _CON_PRINTF(3, 4); /* * This provides the same functionality as ConColorMsg which was removed from @@ -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 @@ -19,12 +19,13 @@ #endif #include "con_.h" +#include "engineapi.h" #include "intdefs.h" #include "ppmagic.h" #include "udis86.h" void dbg_hexdump(char *name, const void *p, int len) { - struct con_colour nice_colour = {160, 64, 200, 255}; // a nice purple colour + struct rgba nice_colour = {160, 64, 200, 255}; // a nice purple colour con_colourmsg(&nice_colour, "Hex dump \"%s\" (%p):", name, p); for (const uchar *cp = p; cp - (uchar *)p < len; ++cp) { // group into words and wrap every 8 words @@ -38,7 +39,7 @@ void dbg_hexdump(char *name, const void *p, int len) { } void dbg_asmdump(char *name, const void *p, int len) { - struct con_colour nice_colour = {40, 160, 140, 255}; // a nice teal colour + struct rgba nice_colour = {40, 160, 140, 255}; // a nice teal colour struct ud udis; ud_init(&udis); ud_set_mode(&udis, 32); diff --git a/src/engineapi.h b/src/engineapi.h index 05f47ea..d740c8c 100644 --- a/src/engineapi.h +++ b/src/engineapi.h @@ -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 @@ -70,6 +70,16 @@ struct edict { }; struct vec3f { float x, y, z; }; + +/* an RGBA colour, used for colour console messages as well as VGUI/HUD stuff */ +struct rgba { + union { + struct { u8 r, g, b, a; }; + u32 val; + uchar bytes[4]; + }; +}; + struct CMoveData { bool firstrun : 1, gamecodemoved : 1; ulong playerhandle; 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]; } diff --git a/src/rinput.c b/src/rinput.c index e24fc1c..53c16e3 100644 --- a/src/rinput.c +++ b/src/rinput.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 @@ -22,11 +22,11 @@ #include <Windows.h> #include "con_.h" -#include "gamedata.h" -#include "hook.h" #include "engineapi.h" #include "errmsg.h" #include "feature.h" +#include "gamedata.h" +#include "hook.h" #include "intdefs.h" #include "mem.h" #include "vcall.h" @@ -149,9 +149,9 @@ INIT { .lpszClassName = L"RInput" }; if (!RegisterClassExW(&wc)) { - struct con_colour gold = {255, 210, 0, 255}; - struct con_colour blue = {45, 190, 190, 255}; - struct con_colour white = {200, 200, 200, 255}; + struct rgba gold = {255, 210, 0, 255}; + struct rgba blue = {45, 190, 190, 255}; + struct rgba white = {200, 200, 200, 255}; con_colourmsg(&gold, "SST PROTIP! "); con_colourmsg(&blue, "It appears you're using RInput.exe.\n" "Consider launching without that and using "); @@ -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 @@ -179,8 +179,6 @@ static const void *const *const plugin_obj; static bool already_loaded = false, skip_unload = false; -#define RGBA(r, g, b, a) (&(struct con_colour){(r), (g), (b), (a)}) - // auto-update message. see below in do_featureinit() static const char *updatenotes = "\ * various internal cleanup\n\ @@ -201,8 +199,8 @@ static void do_featureinit(void) { #else unsetenv("SST_UPDATED"); #endif - struct con_colour gold = {255, 210, 0, 255}; - struct con_colour white = {255, 255, 255, 255}; + struct rgba gold = {255, 210, 0, 255}; + struct rgba white = {255, 255, 255, 255}; con_colourmsg(&white, "\n" NAME " was just "); con_colourmsg(&gold, "UPDATED"); con_colourmsg(&white, " to version "); |