Skip to content

Commit

Permalink
Improve loading of NUGHUD and Berserk patches
Browse files Browse the repository at this point in the history
Previously, if a patch lump weren't found, it would be looked up continuously. Now, patch lumps will be looked up only once.
  • Loading branch information
MrAlaux committed Apr 25, 2023
1 parent 3a3c1b1 commit 334034d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/st_stuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -850,15 +850,15 @@ void ST_drawWidgets(void)
for (i=0; i<NUMNUGHUDPATCHES; i++)
if (nughud.patches[i].name != NULL)
{
static int lump[NUMNUGHUDPATCHES] = { -1, -1, -1, -1, -1, -1, -1, -1 };
static int lump[NUMNUGHUDPATCHES] = { -2, -2, -2, -2, -2, -2, -2, -2 };

if (lump[i] < 0) {
if (lump[i] == -2) {
lump[i] = (W_CheckNumForName)(nughud.patches[i].name, ns_sprites);
if (lump[i] < 0)
if (lump[i] == -1)
{ lump[i] = (W_CheckNumForName)(nughud.patches[i].name, ns_global); }
}

if (lump[i] > 0)
if (lump[i] >= 0)
{ V_DrawPatch(nughud.patches[i].x + (delta*nughud.patches[i].wide),
nughud.patches[i].y, FG, W_CacheLumpNum(lump[i], PU_CACHE)); }
}
Expand Down Expand Up @@ -890,16 +890,16 @@ void ST_drawWidgets(void)
&& weaponinfo[plyr->readyweapon].ammo == am_noammo // [Nugget] Check for unlimited ammo type
&& plyr->powers[pw_strength])
{
static int lump = -1;
static int lump = -2;
patch_t *patch;

if (lump < 0) {
if (lump == -2) {
lump = (W_CheckNumForName)("PSTRA0", ns_sprites);
if (lump < 0)
if (lump == -1)
{ lump = (W_CheckNumForName)("MEDIA0", ns_sprites); }
}

if (lump > 0) {
if (lump >= 0) {
patch = W_CacheLumpNum(lump, PU_CACHE);

// [crispy] (23,179) is the center of the Ammo widget
Expand Down

0 comments on commit 334034d

Please sign in to comment.