Clear colormaps properly (resolve sigsegv crash)

This commit is contained in:
mazmazz 2018-09-11 13:46:34 -04:00
parent 506ce43627
commit 4ef016e40f
2 changed files with 12 additions and 12 deletions

View File

@ -1322,29 +1322,28 @@ void R_ReInitColormaps(UINT16 num)
// //
void R_ClearColormaps(void) void R_ClearColormaps(void)
{ {
extracolormap_t *exc, *exc_next; // Purged by PU_LEVEL, just overwrite the pointer
extra_colormaps = R_CreateDefaultColormap(true);
}
for (exc = extra_colormaps; exc; exc = exc_next) //
{ // R_CreateDefaultColormap()
exc_next = exc->next; //
memset(exc, 0, sizeof(*exc)); extracolormap_t *R_CreateDefaultColormap(boolean lighttable)
} {
extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
// make a default extra_colormap
exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
exc->fadestart = 0; exc->fadestart = 0;
exc->fadeend = 31; exc->fadeend = 31;
exc->fog = 0; exc->fog = 0;
exc->rgba = 0; exc->rgba = 0;
exc->fadergba = 0x19000000; exc->fadergba = 0x19000000;
exc->colormap = R_CreateLightTable(exc); exc->colormap = lighttable ? R_CreateLightTable(exc) : NULL;
#ifdef EXTRACOLORMAPLUMPS #ifdef EXTRACOLORMAPLUMPS
exc->lump = LUMPERROR; exc->lump = LUMPERROR;
exc->lumpname[0] = 0; exc->lumpname[0] = 0;
#endif #endif
exc->next = exc->prev = NULL; exc->next = exc->prev = NULL;
return exc;
extra_colormaps = exc;
} }
// //

View File

@ -105,6 +105,7 @@ INT32 R_CheckTextureNumForName(const char *name);
void R_ReInitColormaps(UINT16 num); void R_ReInitColormaps(UINT16 num);
void R_ClearColormaps(void); void R_ClearColormaps(void);
extracolormap_t *R_CreateDefaultColormap(boolean lighttable);
void R_AddColormapToList(extracolormap_t *extra_colormap); void R_AddColormapToList(extracolormap_t *extra_colormap);
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap); lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3); extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3);