Fix "mpindex=4" UB cases for various view gadgets

This commit is contained in:
GreaseMonkey committed 2023-08-29 13:15:42 +12:00
1 parent 889ae950fe
commit 43a91b2b4b
1 file changed
+18
+18
View File
@@ -1952,6 +1952,9 @@ Gfx *bviewDrawNvLens(Gfx *gdl)
s32 viewbottom = viewtop + viewheight;
s32 brightness;
s32 y;
#ifdef AVOID_UB
u32 mpindex = g_Vars.currentplayerstats->mpindex % MAX_PLAYERS;
#endif
var8007f840++;
@@ -1973,9 +1976,15 @@ Gfx *bviewDrawNvLens(Gfx *gdl)
skySetOverexposure(brightness, brightness, brightness);
}
#ifdef AVOID_UB
if (g_Menus[mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0x00ff0000, 0x60);
}
#else
if (g_Menus[g_Vars.currentplayerstats->mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0x00ff0000, 0x60);
}
#endif
gDPPipeSync(gdl++);
@@ -2034,6 +2043,9 @@ Gfx *bviewDrawIrLens(Gfx *gdl)
s32 viewcentrey;
f32 viewheightf;
s32 a0;
#ifdef AVOID_UB
u32 mpindex = g_Vars.currentplayerstats->mpindex % MAX_PLAYERS;
#endif
#if VERSION < VERSION_NTSC_1_0
static s32 fsscanline = 0;
@@ -2198,9 +2210,15 @@ Gfx *bviewDrawIrLens(Gfx *gdl)
#endif
}
#ifdef AVOID_UB
if (g_Menus[mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0xff000000, 0x40);
}
#else
if (g_Menus[g_Vars.currentplayerstats->mpindex].curdialog == NULL) {
gdl = bviewDrawMotionBlur(gdl, 0xff000000, 0x40);
}
#endif
return gdl;
}