mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 15:32:33 +00:00
Merge branch 'colormap-overhaul' into colormap-overhaul-change-ldef
This commit is contained in:
commit
b56ff10ce7
3 changed files with 94 additions and 65 deletions
131
src/p_saveg.c
131
src/p_saveg.c
|
@ -474,6 +474,70 @@ static void P_NetUnArchivePlayers(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SaveExtraColormap(UINT8 *put, extracolormap_t *exc)
|
||||||
|
{
|
||||||
|
WRITEUINT8(put, exc->fadestart);
|
||||||
|
WRITEUINT8(put, exc->fadeend);
|
||||||
|
WRITEUINT8(put, (UINT8)exc->fog);
|
||||||
|
|
||||||
|
WRITEINT32(put, exc->rgba);
|
||||||
|
WRITEINT32(put, exc->fadergba);
|
||||||
|
|
||||||
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
WRITESTRINGN(put, exc->lumpname, 9);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
static extracolormap_t *LoadExtraColormap(UINT8 *get)
|
||||||
|
{
|
||||||
|
extracolormap_t *exc;
|
||||||
|
//size_t dbg_i = 0;
|
||||||
|
|
||||||
|
UINT8 fadestart = READUINT8(get),
|
||||||
|
fadeend = READUINT8(get);
|
||||||
|
|
||||||
|
boolean fog = (boolean)READUINT8(get);
|
||||||
|
|
||||||
|
INT32 rgba = READINT32(get),
|
||||||
|
fadergba = READINT32(get);
|
||||||
|
|
||||||
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
char lumpname[9];
|
||||||
|
READSTRINGN(get, lumpname, 9);
|
||||||
|
|
||||||
|
if (lumpname[0])
|
||||||
|
return R_ColormapForName(lumpname);
|
||||||
|
#endif
|
||||||
|
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog);
|
||||||
|
|
||||||
|
if (!exc)
|
||||||
|
{
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
exc->fadestart = fadestart;
|
||||||
|
exc->fadeend = fadeend;
|
||||||
|
exc->fog = fog;
|
||||||
|
|
||||||
|
exc->rgba = rgba;
|
||||||
|
exc->fadergba = fadergba;
|
||||||
|
|
||||||
|
exc->colormap = R_CreateLightTable(exc);
|
||||||
|
|
||||||
|
R_AddColormapToList(exc);
|
||||||
|
|
||||||
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
exc->lump = LUMPERROR;
|
||||||
|
exc->lumpname[0] = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return exc;
|
||||||
|
}
|
||||||
|
|
||||||
#define SD_FLOORHT 0x01
|
#define SD_FLOORHT 0x01
|
||||||
#define SD_CEILHT 0x02
|
#define SD_CEILHT 0x02
|
||||||
#define SD_FLOORPIC 0x04
|
#define SD_FLOORPIC 0x04
|
||||||
|
@ -657,18 +721,7 @@ static void P_NetArchiveWorld(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff3 & SD_COLORMAP)
|
if (diff3 & SD_COLORMAP)
|
||||||
{
|
SaveExtraColormap(put, ss->extra_colormap);
|
||||||
WRITEUINT8(put, ss->extra_colormap->fadestart);
|
|
||||||
WRITEUINT8(put, ss->extra_colormap->fadeend);
|
|
||||||
WRITEUINT8(put, (UINT8)ss->extra_colormap->fog);
|
|
||||||
|
|
||||||
WRITEINT32(put, ss->extra_colormap->rgba);
|
|
||||||
WRITEINT32(put, ss->extra_colormap->fadergba);
|
|
||||||
|
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
|
||||||
WRITESTRINGN(put, ss->extra_colormap->lumpname, 9);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Special case: save the stats of all modified ffloors along with their ffloor "number"s
|
// Special case: save the stats of all modified ffloors along with their ffloor "number"s
|
||||||
// we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed
|
// we don't bother with ffloors that haven't changed, that would just add to savegame even more than is really needed
|
||||||
|
@ -865,59 +918,7 @@ static void P_NetUnArchiveWorld(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (diff3 & SD_COLORMAP)
|
if (diff3 & SD_COLORMAP)
|
||||||
{
|
sectors[i].extra_colormap = LoadExtraColormap(get);
|
||||||
extracolormap_t *exc;
|
|
||||||
//size_t dbg_i = 0;
|
|
||||||
|
|
||||||
UINT8 fadestart = READUINT8(get),
|
|
||||||
fadeend = READUINT8(get);
|
|
||||||
|
|
||||||
boolean fog = (boolean)READUINT8(get);
|
|
||||||
|
|
||||||
INT32 rgba = READINT32(get),
|
|
||||||
fadergba = READINT32(get);
|
|
||||||
|
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
|
||||||
char lumpname[9];
|
|
||||||
READSTRINGN(get, lumpname, 9);
|
|
||||||
|
|
||||||
if (lumpname[0])
|
|
||||||
sectors[i].extra_colormap = R_ColormapForName(lumpname);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog);
|
|
||||||
|
|
||||||
if (!exc)
|
|
||||||
{
|
|
||||||
// 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);
|
|
||||||
|
|
||||||
exc->fadestart = fadestart;
|
|
||||||
exc->fadeend = fadeend;
|
|
||||||
exc->fog = fog;
|
|
||||||
|
|
||||||
exc->rgba = rgba;
|
|
||||||
exc->fadergba = fadergba;
|
|
||||||
|
|
||||||
exc->colormap = R_CreateLightTable(exc);
|
|
||||||
|
|
||||||
R_AddColormapToList(exc);
|
|
||||||
|
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
|
||||||
exc->lump = LUMPERROR;
|
|
||||||
exc->lumpname[0] = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
sectors[i].extra_colormap = exc;
|
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (diff & SD_FFLOORS)
|
if (diff & SD_FFLOORS)
|
||||||
{
|
{
|
||||||
|
|
27
src/r_data.c
27
src/r_data.c
|
@ -1472,6 +1472,33 @@ boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgb
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams)
|
||||||
|
{
|
||||||
|
// Treat NULL as default colormap
|
||||||
|
// We need this because what if one exc is a default colormap, and the other is NULL? They're really both equal.
|
||||||
|
if (!exc_a)
|
||||||
|
exc_a = R_GetDefaultColormap();
|
||||||
|
if (!exc_b)
|
||||||
|
exc_b = R_GetDefaultColormap();
|
||||||
|
|
||||||
|
if (exc_a == exc_b)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return (
|
||||||
|
(!checkparams ? true :
|
||||||
|
(exc_a->fadestart == exc_b->fadestart
|
||||||
|
&& exc_a->fadeend == exc_b->fadeend
|
||||||
|
&& exc_a->fog == exc_b->fog)
|
||||||
|
)
|
||||||
|
&& (!checkrgba ? true : exc_a->rgba == exc_b->rgba)
|
||||||
|
&& (!checkfadergba ? true : exc_a->fadergba == exc_b->fadergba)
|
||||||
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
&& exc_a->lump == exc_b->lump
|
||||||
|
&& !strncmp(exc_a->lumpname, exc_b->lumpname, 9)
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_GetColormapFromListByValues()
|
// R_GetColormapFromListByValues()
|
||||||
// NOTE: Returns NULL if no match is found
|
// NOTE: Returns NULL if no match is found
|
||||||
|
|
|
@ -120,6 +120,7 @@ boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba,
|
||||||
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog);
|
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog);
|
||||||
#endif
|
#endif
|
||||||
boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams);
|
boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams);
|
||||||
|
boolean R_CheckEqualColormaps(extracolormap_t *exc_a, extracolormap_t *exc_b, boolean checkrgba, boolean checkfadergba, boolean checkparams);
|
||||||
extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap);
|
extracolormap_t *R_GetColormapFromList(extracolormap_t *extra_colormap);
|
||||||
|
|
||||||
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
|
lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap);
|
||||||
|
|
Loading…
Reference in a new issue