From 8bad1d7bd28203af95f301c7e03efcbebb7f45cf Mon Sep 17 00:00:00 2001 From: Brad Harding Date: Tue, 3 Sep 2024 18:12:52 +1000 Subject: [PATCH] Look for `DRHUDWPx` lumps --- src/hu_stuff.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 4b863a73b..780806ab4 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -883,29 +883,33 @@ static void HU_AltInit(void) for (int i = 0, numweapons = NUMWEAPONS - (gamemode != commercial); i < numweapons; i++) { - const spritenum_t sprite = weaponinfo[i].weaponsprite; + M_snprintf(buffer, sizeof(buffer), "DRHUDWP%i", i); - if (!sprite) - weaponinfo[i].weaponpatch = NULL; + if (W_CheckNumForName(buffer) >= 0) + { + weaponinfo[i].weaponpatch = W_CacheLumpName(buffer); + weaponinfo[i].weapony = ALTHUD_Y + 11 - SHORT(weaponinfo[i].weaponpatch->height) / 2; + } else - for (int j = numstates; j >= 0; j--) - { - state_t *state = &states[j]; + { + const spritenum_t sprite = weaponinfo[i].weaponsprite; - if (state->sprite == sprite) + if (!sprite) + weaponinfo[i].weaponpatch = NULL; + else + for (int j = numstates; j >= 0; j--) { - weaponinfo[i].weaponpatch = W_CacheLumpNum(firstspritelump - + sprites[state->sprite].spriteframes[state->frame & FF_FRAMEMASK].lump[0]); - weaponinfo[i].weapony = ALTHUD_Y + 11 - SHORT(weaponinfo[i].weaponpatch->height) / 2; - break; - } - } - } + state_t *state = &states[j]; - if (!weaponinfo[wp_pistol].weaponpatch && HU_DefaultPistolSprites()) - { - weaponinfo[wp_pistol].weaponpatch = W_CacheLumpName("DRHUDWP1"); - weaponinfo[wp_pistol].weapony = ALTHUD_Y + 11 - SHORT(weaponinfo[wp_pistol].weaponpatch->height) / 2; + if (state->sprite == sprite) + { + weaponinfo[i].weaponpatch = W_CacheLumpNum(firstspritelump + + sprites[state->sprite].spriteframes[state->frame & FF_FRAMEMASK].lump[0]); + weaponinfo[i].weapony = ALTHUD_Y + 11 - SHORT(weaponinfo[i].weaponpatch->height) / 2; + break; + } + } + } } gray = nearestcolors[GRAY1];