From e96b1bfdce39fd51352170965ff1f3cd95fae0ee Mon Sep 17 00:00:00 2001 From: NepDisk Date: Fri, 13 Feb 2026 23:11:42 -0500 Subject: [PATCH] Make flags field of timers act like a bitfield and add new flags --- src/deh_tables.c | 17 +++++++++++- src/h_timers.cpp | 72 +++++++++++++++++++++++++++++------------------- src/h_timers.h | 21 ++++++++++++-- src/lua_hudlib.c | 2 +- 4 files changed, 78 insertions(+), 34 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 83ecae201..618b8161a 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -1824,7 +1824,22 @@ struct int_const_s const INT_CONST[] = { // item timer stuff {"TIMER_COUNTER", TIMER_COUNTER}, - {"TIMER_BAD", TIMER_BAD}, + {"TIMER_NONUMBER",TIMER_NONUMBER}, + {"TIMER_PURPLE", TIMER_PURPLE}, + {"TIMER_YELLOW", TIMER_YELLOW}, + {"TIMER_GREEN", TIMER_GREEN}, + {"TIMER_BLUE", TIMER_BLUE}, + {"TIMER_RED", TIMER_RED}, + {"TIMER_GRAY", TIMER_GRAY}, + {"TIMER_ORANGE", TIMER_ORANGE}, + {"TIMER_SKY", TIMER_SKY}, + {"TIMER_LAVENDER", TIMER_LAVENDER}, + {"TIMER_GOLD", TIMER_GOLD}, + {"TIMER_AQUA", TIMER_AQUA}, + {"TIMER_MAGENTA", TIMER_MAGENTA}, + {"TIMER_PINK", TIMER_PINK}, + {"TIMER_BROWN", TIMER_BROWN}, + {"TIMER_TAN", TIMER_TAN}, {NULL,0} }; diff --git a/src/h_timers.cpp b/src/h_timers.cpp index 61080e650..86c69101f 100644 --- a/src/h_timers.cpp +++ b/src/h_timers.cpp @@ -44,7 +44,7 @@ typedef struct itimer_s INT32 timer; // current time std::vector patches; // timer graphics (small) INT32 anim_frames = 1; // tic duration for each graphic - UINT8 flags = 0; // settings for timer + UINT32 flags = 0; // settings for timer lua_Integer timer_func_ref = LUA_NOREF; // if set, calls a function from registry to get timer value boolean timer_func_error = false; // don't print error every frame } itimer_t; @@ -143,7 +143,7 @@ void K_AddItemTimerEx( const char **patches, INT32 patches_size, INT32 anim_duration, - UINT8 flags, boolean unsorted) + UINT32 flags, boolean unsorted) { itimer_t t; // woo yeah baby @@ -307,7 +307,7 @@ void K_DisplayItemTimers(void) std::max(stplyr->spinouttimer, stplyr->wipeoutslow), {qche("K_TISPN1"), qche("K_TISPN2"), qche("K_TISPN3"), qche("K_TISPN4")}, 3, - TIMER_BAD, + TIMER_RED, } ); timers.push_back( @@ -316,7 +316,7 @@ void K_DisplayItemTimers(void) std::max(0, -stplyr->growshrinktimer), {qche("K_TISHRK")}, 1, - TIMER_BAD, + static_cast((K_IsAltShrunk(stplyr) ? 0 : TIMER_RED)), } ); timers.push_back( @@ -325,7 +325,7 @@ void K_DisplayItemTimers(void) (INT32)spbTimers[stplyr-players], {qche("K_TISPB")}, 1, - (UINT8)((stplyr->position == K_GetBestRank()) ? TIMER_BAD : 0), + static_cast((stplyr->position == K_GetBestRank()) ? TIMER_RED : 0), } ); // Same with boost stacks @@ -335,7 +335,7 @@ void K_DisplayItemTimers(void) K_StackingActive() ? stplyr->numboosts : 0, {qche("K_TISRK1"), qche("K_TISRK2")}, 2, - TIMER_BAD, + TIMER_GREEN|TIMER_COUNTER, } ); timers.push_back( @@ -411,11 +411,6 @@ void K_DisplayItemTimers(void) textcmap = cmap; } - if (fastcmp(t.name, "boosts")) - { - flags |= V_GREENMAP; - } - if (t.flags & TIMER_COUNTER) // don't show up as time { str = va("%d", timer); @@ -423,27 +418,46 @@ void K_DisplayItemTimers(void) } INT32 width = V_StringScaledWidth(FRACUNIT, FRACUNIT, FRACUNIT, flags|V_MONOSPACE, font, str) >> FRACBITS; - // very bad! - if (t.flags & TIMER_BAD) - { - flags |= V_REDMAP; - //textcmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_CRIMSON, GTC_CACHE); - } +#define COLORTIMER(color) \ + if (t.flags & TIMER_##color) \ + flags |= V_##color##MAP\ + + // Color timers! + COLORTIMER(RED); + COLORTIMER(PURPLE); + COLORTIMER(YELLOW); + COLORTIMER(GREEN); + COLORTIMER(BLUE); + COLORTIMER(RED); + COLORTIMER(GRAY); + COLORTIMER(ORANGE); + COLORTIMER(SKY); + COLORTIMER(LAVENDER); + COLORTIMER(GOLD); + COLORTIMER(AQUA); + COLORTIMER(MAGENTA); + COLORTIMER(PINK); + COLORTIMER(BROWN); + COLORTIMER(TAN); patch_t *item = t.patches[patchnum]; V_DrawFixedPatch((itemx - (item->width/2))<leftoffset) << FRACBITS, - (itemy + 12) << FRACBITS, - FRACUNIT, - FRACUNIT, - FRACUNIT, - FRACUNIT, - flags|V_MONOSPACE, - textcmap, - font, - str - ); + + if (!(t.flags & TIMER_NONUMBER)) + { + V_DrawStringScaledEx( + (itemx - (width/2) - item->leftoffset) << FRACBITS, + (itemy + 12) << FRACBITS, + FRACUNIT, + FRACUNIT, + FRACUNIT, + FRACUNIT, + flags|V_MONOSPACE, + textcmap, + font, + str + ); + } itemx += stepx; } diff --git a/src/h_timers.h b/src/h_timers.h index 4d7494cf5..9643c1965 100644 --- a/src/h_timers.h +++ b/src/h_timers.h @@ -24,8 +24,23 @@ extern "C" { typedef enum timerflags_e { - TIMER_COUNTER = 0x1, - TIMER_BAD = 0x2, + TIMER_COUNTER = 1, + TIMER_NONUMBER = 1<<1, + TIMER_PURPLE = 1<<2, + TIMER_YELLOW = 1<<3, + TIMER_GREEN = 1<<4, + TIMER_BLUE = 1<<5, + TIMER_RED = 1<<6, + TIMER_GRAY = 1<<7, + TIMER_ORANGE = 1<<8, + TIMER_SKY = 1<<9, + TIMER_LAVENDER = 1<<10, + TIMER_GOLD = 1<<11, + TIMER_AQUA = 1<<12, + TIMER_MAGENTA = 1<<13, + TIMER_PINK = 1<<14, + TIMER_BROWN = 1<<15, + TIMER_TAN = 1<<16, } timerflags_t; extern consvar_t cv_itemtimers; @@ -39,7 +54,7 @@ void K_AddItemTimerEx( const char **patches, INT32 patches_size, INT32 anim_duration, - UINT8 flags, boolean unsorted); + UINT32 flags, boolean unsorted); void K_DisplayItemTimers(void); void K_getTimersDrawinfo(drawinfo_t *out); diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index e4d78fe30..edc324c24 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -1790,7 +1790,7 @@ static int lib_hudaddtimer(lua_State *L) INT32 anim_duration = luaL_optinteger(L, 4, 1); - UINT8 flags = (UINT8)luaL_optinteger(L, 5, 0); + UINT32 flags = luaL_optinteger(L, 5, 0); boolean unsorted = lua_toboolean(L, 6);