Add R_CopyColormap

This commit is contained in:
mazmazz 2018-09-11 15:20:30 -04:00
parent 3da58f436c
commit 85d89287de
2 changed files with 49 additions and 16 deletions

View file

@ -1367,26 +1367,35 @@ extracolormap_t *R_GetDefaultColormap(void)
}
//
// R_CheckDefaultColormap()
// R_CopyColormap()
//
boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams)
extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable)
{
extracolormap_t *exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
if (!extra_colormap)
return true;
else
return (
(!checkparams ? true :
(extra_colormap->fadestart == 0
&& extra_colormap->fadeend == 31
&& !extra_colormap->fog)
)
&& (!checkrgba ? true : extra_colormap->rgba == 0)
&& (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000)
extra_colormap = R_GetDefaultColormap();
*exc = *extra_colormap;
exc->next = exc->prev = NULL;
#ifdef EXTRACOLORMAPLUMPS
&& extra_colormap->lump == LUMPERROR
&& extra_colormap->lumpname[0] == 0
strncpy(exc->lumpname, extra_colormap->lumpname, 9);
if (exc->lump != LUMPERROR && lighttable)
{
// aligned on 8 bit for asm code
exc->colormap = Z_MallocAlign(W_LumpLength(lump), PU_LEVEL, NULL, 16);
W_ReadLump(lump, exc->colormap);
}
else
#endif
);
if (lighttable)
exc->colormap = R_CreateLightTable(exc);
else
exc->colormap = NULL;
return exc;
}
//
@ -1423,6 +1432,29 @@ void R_AddColormapToList(extracolormap_t *extra_colormap)
#endif
}
//
// R_CheckDefaultColormap()
//
boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams)
{
if (!extra_colormap)
return true;
else
return (
(!checkparams ? true :
(extra_colormap->fadestart == 0
&& extra_colormap->fadeend == 31
&& !extra_colormap->fog)
)
&& (!checkrgba ? true : extra_colormap->rgba == 0)
&& (!checkfadergba ? true : extra_colormap->fadergba == 0x19000000)
#ifdef EXTRACOLORMAPLUMPS
&& extra_colormap->lump == LUMPERROR
&& extra_colormap->lumpname[0] == 0
#endif
);
}
#ifdef EXTRACOLORMAPLUMPS
extracolormap_t *R_ColormapForName(char *name)
{

View file

@ -107,8 +107,9 @@ void R_ReInitColormaps(UINT16 num);
void R_ClearColormaps(void);
extracolormap_t *R_CreateDefaultColormap(boolean lighttable);
extracolormap_t *R_GetDefaultColormap(void);
boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams);
extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable);
void R_AddColormapToList(extracolormap_t *extra_colormap);
boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams);
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3);
#ifdef EXTRACOLORMAPLUMPS