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,35 +886,13 @@ static void P_NetUnArchiveWorld(void)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog);
|
||||||
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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!exc)
|
if (!exc)
|
||||||
{
|
{
|
||||||
// CONS_Debug(DBG_RENDER, "P_NetUnArchiveWorld: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
// CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||||
// dbg_i, (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF,
|
// (rgba)&0xFF, (rgba>>8)&0xFF, (rgba>>16)&0xFF, (rgba>>24)&0xFF,
|
||||||
// (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF);
|
// (fadergba)&0xFF, (fadergba>>8)&0xFF, (fadergba>>16)&0xFF, (fadergba>>24)&0xFF);
|
||||||
|
|
||||||
exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
|
exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
|
||||||
|
|
||||||
|
|
82
src/r_data.c
82
src/r_data.c
|
@ -1328,6 +1328,7 @@ void R_ClearColormaps(void)
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_CreateDefaultColormap()
|
// 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)
|
extracolormap_t *R_CreateDefaultColormap(boolean lighttable)
|
||||||
{
|
{
|
||||||
|
@ -1368,6 +1369,7 @@ extracolormap_t *R_GetDefaultColormap(void)
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_CopyColormap()
|
// 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)
|
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
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
extracolormap_t *R_ColormapForName(char *name)
|
extracolormap_t *R_ColormapForName(char *name)
|
||||||
{
|
{
|
||||||
|
@ -1465,9 +1511,9 @@ extracolormap_t *R_ColormapForName(char *name)
|
||||||
if (lump == LUMPERROR)
|
if (lump == LUMPERROR)
|
||||||
I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name);
|
I_Error("R_ColormapForName: Cannot find colormap lump %.8s\n", name);
|
||||||
|
|
||||||
for (exc = extra_colormaps; exc; exc = exc->next)
|
exc = R_GetColormapFromListByValues(0, 0x19000000, 0, 31, 0, lump);
|
||||||
if (lump == exc->lump)
|
if (exc)
|
||||||
return exc;
|
return exc;
|
||||||
|
|
||||||
exc = Z_Calloc(sizeof (*exc), PU_LEVEL, NULL);
|
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;
|
boolean fog = false;
|
||||||
INT32 rgba = 0, fadergba = 0x19000000;
|
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 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)
|
#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);
|
fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24);
|
||||||
|
|
||||||
// Look for existing colormaps
|
// Look for existing colormaps
|
||||||
for (exc = extra_colormaps; exc; exc = exc->next)
|
|
||||||
{
|
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
if (exc->lump != LUMPERROR)
|
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR);
|
||||||
{
|
#else
|
||||||
dbg_i++;
|
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (rgba == exc->rgba
|
if (exc)
|
||||||
&& fadergba == exc->fadergba
|
return exc;
|
||||||
&& 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);
|
|
||||||
return exc;
|
|
||||||
}
|
|
||||||
dbg_i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
CONS_Debug(DBG_RENDER, "R_CreateColormap: Creating map %d: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
CONS_Debug(DBG_RENDER, "Creating Colormap: rgba(%d,%d,%d,%d) fadergba(%d,%d,%d,%d)\n",
|
||||||
dbg_i, cr, cg, cb, ca, cfr, cfg, cfb, cfa);
|
cr, cg, cb, ca, cfr, cfg, cfb, cfa);
|
||||||
|
|
||||||
extra_colormap = Z_Calloc(sizeof (*extra_colormap), PU_LEVEL, NULL);
|
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);
|
extracolormap_t *R_CopyColormap(extracolormap_t *extra_colormap, boolean lighttable);
|
||||||
void R_AddColormapToList(extracolormap_t *extra_colormap);
|
void R_AddColormapToList(extracolormap_t *extra_colormap);
|
||||||
boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams);
|
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);
|
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);
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
|
Loading…
Reference in a new issue