From 9cd1233c3224bf2000180a1ce866348c4bdd268f Mon Sep 17 00:00:00 2001 From: GenericHeroGuy <86008856+GenericHeroGuy@users.noreply.github.com> Date: Thu, 23 May 2024 16:36:26 +0200 Subject: [PATCH] Dust this crap off a bit --- src/lua_hud.h | 10 +++++----- src/lua_hudlib_drawlist.c | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/lua_hud.h b/src/lua_hud.h index ccaed738d..5d1f41c83 100644 --- a/src/lua_hud.h +++ b/src/lua_hud.h @@ -42,11 +42,11 @@ enum hud { extern boolean hud_running; -extern boolean hud_interpolate; -extern UINT8 hud_interptag; -extern UINT32 hud_interpcounter; -extern boolean hud_interpstring; -extern boolean hud_interplatch; +extern boolean hud_interpolate; // interpolation enabled +extern UINT8 hud_interptag; // current tag +extern UINT32 hud_interpcounter; // number of HUD hooks ran +extern boolean hud_interpstring; // string mode +extern boolean hud_interplatch; // string mode was toggled boolean LUA_HudEnabled(enum hud option); diff --git a/src/lua_hudlib_drawlist.c b/src/lua_hudlib_drawlist.c index c621512ba..98f0d45e7 100644 --- a/src/lua_hudlib_drawlist.c +++ b/src/lua_hudlib_drawlist.c @@ -318,6 +318,7 @@ static void CalcFillCoords(drawitem_t *item) #define INTERP_LATCH 1 #define INTERP_STRING 2 +#define INTERP_FLAGS 3 // all bits combined static UINT64 GetItemId(void) { @@ -325,7 +326,7 @@ static UINT64 GetItemId(void) return 0; // leave bits 0 and 1 free for the string mode - UINT64 id = ((UINT64)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); + UINT64 id = ((uintptr_t)gL->savedpc << 32) | (hud_interpcounter << 10) | (hud_interptag << 2); if (hud_interplatch) { @@ -580,7 +581,8 @@ void LUA_HUD_DrawList(huddrawlist_h list) drawitem_t *olditem = NULL; const char *itemstr = &list->strbuf[item->stroffset]; - if (item->id) { + if (item->id) + { // find the old one too // this is kinda cursed... we need to check every item // but stop when the first-checked item is reached again @@ -595,16 +597,19 @@ void LUA_HUD_DrawList(huddrawlist_h list) break; } drawitem_t *old = &list->olditems[j++]; - if ((old->id & ~3) == (item->id & ~3)) + if ((old->id & ~INTERP_FLAGS) == (item->id & ~INTERP_FLAGS)) // don't include flags in search { // gotcha! olditem = old; - if (item->id & INTERP_LATCH) { + if (item->id & INTERP_LATCH) + { lerpx = FixedMul(frac, item->x - olditem->x); lerpy = FixedMul(frac, item->y - olditem->y); latchitem = item; oldlatchitem = olditem; - } else if (!(item->id & INTERP_STRING)) { + } + else if (!(item->id & INTERP_STRING)) + { lerpx = FixedMul(frac, item->x - olditem->x); lerpy = FixedMul(frac, item->y - olditem->y); latchitem = NULL; @@ -614,7 +619,9 @@ void LUA_HUD_DrawList(huddrawlist_h list) if (j == stop) break; } - } else { + } + else + { lerpx = lerpy = 0; latchitem = NULL; }