Load palette before map data

Fixes PNG patch conversion crashing when called from vres
at game startup.

Also does not reload palette every time the resolution is
changed. (This had no effect on the SDL backend, don't
worry.)
This commit is contained in:
James R 2022-09-24 21:15:44 -07:00
parent fe49543456
commit 2b9701d01e
3 changed files with 10 additions and 5 deletions

View file

@ -1438,6 +1438,10 @@ void D_SRB2Main(void)
#endif //ifndef DEVELOP
// Do it before P_InitMapData because PNG patch
// conversion sometimes needs the palette
V_ReloadPalette();
//
// search for mainwad maps
//

View file

@ -404,7 +404,7 @@ const char *GetPalette(void)
return "PLAYPAL";
}
static void LoadMapPalette(void)
void V_ReloadPalette(void)
{
LoadPalette(GetPalette());
}
@ -416,7 +416,7 @@ static void LoadMapPalette(void)
void V_SetPalette(INT32 palettenum)
{
if (!pLocalPalette)
LoadMapPalette();
V_ReloadPalette();
#ifdef HWRENDER
if (rendermode == render_opengl)
@ -449,7 +449,7 @@ void V_SetPaletteLump(const char *pal)
static void CV_palette_OnChange(void)
{
// reload palette
LoadMapPalette();
V_ReloadPalette();
V_SetPalette(0);
}
@ -2980,8 +2980,6 @@ void V_Init(void)
UINT8 *base = vid.buffer;
const INT32 screensize = vid.rowbytes * vid.height;
LoadMapPalette();
for (i = 0; i < NUMSCREENS; i++)
screens[i] = NULL;

View file

@ -56,6 +56,9 @@ void InitColorLUT(colorlookup_t *lut, RGBA_t *palette, boolean makecolors);
UINT8 GetColorLUT(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b);
UINT8 GetColorLUTDirect(colorlookup_t *lut, UINT8 r, UINT8 g, UINT8 b);
// Loads the correct palette into memory
void V_ReloadPalette(void);
// Set the current RGB palette lookup to use for palettized graphics
void V_SetPalette(INT32 palettenum);