mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 15:32:33 +00:00
Consolidate colormap matching into R_GetColormapFromList
This commit is contained in:
parent
85d89287de
commit
c920827032
3 changed files with 66 additions and 52 deletions
|
@ -886,34 +886,12 @@ static void P_NetUnArchiveWorld(void)
|
|||
else
|
||||
{
|
||||
#endif
|
||||
|
||||
for (exc = extra_colormaps; exc; exc = exc->next)
|
||||
{
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
if (exc->lump != LUMPERROR)
|
||||
{
|
||||
//dbg_i++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
if (rgba == exc->rgba
|
||||
&& fadergba == exc->fadergba
|
||||
&& fadestart == exc->fadestart
|
||||
&& fadeend == exc->fadeend
|
||||
&& fog == exc->fog)
|
||||
{
|
||||
// CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||
// dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF,
|
||||
// (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF);
|
||||
break;
|
||||
}
|
||||
//dbg_i++;
|
||||
}
|
||||
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog);
|
||||
|
||||
if (!exc)
|
||||
{
|
||||
// CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||
// dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF,
|
||||
// CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||
// (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF,
|
||||
// (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF);
|
||||
|
||||
exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
|
||||
|
|
78
src/r_data.c
78
src/r_data.c
|
@ -1328,6 +1328,7 @@ void R_ClearColormaps(void)
|
|||
|
||||
//
|
||||
// R_CreateDefaultColormap()
|
||||
// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself!
|
||||
//
|
||||
extracolormap_t *R_CreateDefaultColormap(boolean lighttable)
|
||||
{
|
||||
|
@ -1368,6 +1369,7 @@ extracolormap_t *R_GetDefaultColormap(void)
|
|||
|
||||
//
|
||||
// R_CopyColormap()
|
||||
// NOTE: The result colormap is not added to the extra_colormaps chain. You must do that yourself!
|
||||
//
|
||||
extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable)
|
||||
{
|
||||
|
@ -1455,6 +1457,50 @@ boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean ch
|
|||
);
|
||||
}
|
||||
|
||||
//
|
||||
// R_GetColormapFromListByValues()
|
||||
// NOTE: Returns NULL if no match is found
|
||||
//
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump)
|
||||
#else
|
||||
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog)
|
||||
#endif
|
||||
{
|
||||
extracolormap_t *exc;
|
||||
size_t dbg_i = 0;
|
||||
|
||||
for (exc = extra_colormaps; exc; exc = exc->next)
|
||||
{
|
||||
if (rgba == exc->rgba
|
||||
&& fadergba == exc->fadergba
|
||||
&& fadestart == exc->fadestart
|
||||
&& fadeend == exc->fadeend
|
||||
&& fog == exc->fog
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
&& (lump != LUMPERROR && lump == exc->lump)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "Found Colormap %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||
dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF,
|
||||
(fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF);
|
||||
return exc;
|
||||
}
|
||||
dbg_i++;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap)
|
||||
{
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump);
|
||||
else
|
||||
return R_GetColormapFromListByValues(extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
extracolormap_t *R_ColormapForName(char *name)
|
||||
{
|
||||
|
@ -1465,8 +1511,8 @@ extracolormap_t *R_ColormapForName(char *name)
|
|||
if (lump == LUMPERROR)
|
||||
I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name);
|
||||
|
||||
for (exc = extra_colormaps; exc; exc = exc->next)
|
||||
if (lump == exc->lump)
|
||||
exc = R_GetColormapFromListByValues(0, 0x19000000, 0, 31, 0, lump);
|
||||
if (exc)
|
||||
return exc;
|
||||
|
||||
exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
|
||||
|
@ -1645,8 +1691,6 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3)
|
|||
boolean fog = false;
|
||||
INT32 rgba = 0, fadergba = 0x19000000;
|
||||
|
||||
size_t dbg_i = 0;
|
||||
|
||||
#define HEX2INT(x) (UINT32)(x >= '0' && x <= '9' ? x - '0' : x >= 'a' && x <= 'f' ? x - 'a' + 10 : x >= 'A' && x <= 'F' ? x - 'A' + 10 : 0)
|
||||
#define ALPHA2INT(x) (x >= 'a' && x <= 'z' ? x - 'a' : x >= 'A' && x <= 'Z' ? x - 'A' : x >= '0' && x <= '9' ? 25 : 0)
|
||||
|
||||
|
@ -1764,30 +1808,16 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3)
|
|||
fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24);
|
||||
|
||||
// Look for existing colormaps
|
||||
for (exc = extra_colormaps; exc; exc = exc->next)
|
||||
{
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
if (exc->lump != LUMPERROR)
|
||||
{
|
||||
dbg_i++;
|
||||
continue;
|
||||
}
|
||||
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR);
|
||||
#else
|
||||
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog);
|
||||
#endif
|
||||
if (rgba == exc->rgba
|
||||
&& fadergba == exc->fadergba
|
||||
&& fadestart == exc->fadestart
|
||||
&& fadeend == exc->fadeend
|
||||
&& fog == exc->fog)
|
||||
{
|
||||
CONS_Debug(DBG_RENDER, "R_CreateColormap: Found map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||
dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa);
|
||||
if (exc)
|
||||
return exc;
|
||||
}
|
||||
dbg_i++;
|
||||
}
|
||||
|
||||
CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||
dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa);
|
||||
CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||
cr, cg, cb, ca, cfr, cfg, cfb, cfa);
|
||||
|
||||
extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL);
|
||||
|
||||
|
|
|
@ -110,6 +110,12 @@ extracolormap_t *R_GetDefaultColormap(void);
|
|||
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);
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump);
|
||||
#else
|
||||
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog);
|
||||
#endif
|
||||
extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap);
|
||||
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
|
||||
extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3);
|
||||
#ifdef EXTRACOLORMAPLUMPS
|
||||
|
|
Loading…
Reference in a new issue