mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 21:20:54 +00:00
Don't set sector's extra_colormap if we just made a default clone
* Allow colormap parsing to proceed in p_setup always * Add R_CheckDefaultColormap * Add R_GetRgbaR/G/B/A macros
This commit is contained in:
parent
bb6cf6a807
commit
f703c19502
3 changed files with 61 additions and 50 deletions
|
@ -1438,7 +1438,6 @@ static inline void P_LoadSideDefs(lumpnum_t lumpnum)
|
||||||
static void P_LoadRawSideDefs2(void *data)
|
static void P_LoadRawSideDefs2(void *data)
|
||||||
{
|
{
|
||||||
UINT16 i;
|
UINT16 i;
|
||||||
INT32 num;
|
|
||||||
|
|
||||||
for (i = 0; i < numsides; i++)
|
for (i = 0; i < numsides; i++)
|
||||||
{
|
{
|
||||||
|
@ -1473,32 +1472,9 @@ static void P_LoadRawSideDefs2(void *data)
|
||||||
case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18
|
case 447: // Change colormap of tagged sectors! -- Monster Iestyn 14/06/18
|
||||||
// SoM: R_CreateColormap will only create a colormap in software mode...
|
// SoM: R_CreateColormap will only create a colormap in software mode...
|
||||||
// Perhaps we should just call it instead of doing the calculations here.
|
// Perhaps we should just call it instead of doing the calculations here.
|
||||||
if (msd->toptexture[0] == '#' || msd->bottomtexture[0] == '#'
|
sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
||||||
|| (msd->toptexture[0] >= 'a' && msd->toptexture[0] <= 'z' && !msd->toptexture[1])
|
msd->bottomtexture);
|
||||||
|| (msd->toptexture[0] >= 'A' && msd->toptexture[0] <= 'Z' && !msd->toptexture[1])
|
sd->toptexture = sd->midtexture = sd->bottomtexture = 0;
|
||||||
|| (msd->bottomtexture[0] >= 'a' && msd->bottomtexture[0] <= 'z' && !msd->bottomtexture[1])
|
|
||||||
|| (msd->bottomtexture[0] >= 'A' && msd->bottomtexture[0] <= 'Z' && !msd->bottomtexture[1])
|
|
||||||
)
|
|
||||||
{
|
|
||||||
sec->extra_colormap = sec->spawn_extra_colormap = R_CreateColormap(msd->toptexture, msd->midtexture,
|
|
||||||
msd->bottomtexture);
|
|
||||||
sd->toptexture = sd->bottomtexture = 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((num = R_CheckTextureNumForName(msd->toptexture)) == -1)
|
|
||||||
sd->toptexture = 0;
|
|
||||||
else
|
|
||||||
sd->toptexture = num;
|
|
||||||
if ((num = R_CheckTextureNumForName(msd->midtexture)) == -1)
|
|
||||||
sd->midtexture = 0;
|
|
||||||
else
|
|
||||||
sd->midtexture = num;
|
|
||||||
if ((num = R_CheckTextureNumForName(msd->bottomtexture)) == -1)
|
|
||||||
sd->bottomtexture = 0;
|
|
||||||
else
|
|
||||||
sd->bottomtexture = num;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 413: // Change music
|
case 413: // Change music
|
||||||
|
|
68
src/r_data.c
68
src/r_data.c
|
@ -1435,26 +1435,41 @@ void R_AddColormapToList(extracolormap_t *extra_colormap)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// R_CheckDefaultColormap()
|
// R_CheckDefaultColormapByValues()
|
||||||
//
|
//
|
||||||
boolean R_CheckDefaultColormapValues(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams)
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams,
|
||||||
|
INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump)
|
||||||
|
#else
|
||||||
|
boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams,
|
||||||
|
INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
return (
|
||||||
|
(!checkparams ? true :
|
||||||
|
(fadestart == 0
|
||||||
|
&& fadeend == 31
|
||||||
|
&& !fog)
|
||||||
|
)
|
||||||
|
&& (!checkrgba ? true : rgba == 0)
|
||||||
|
&& (!checkfadergba ? true : fadergba == 0x19000000)
|
||||||
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
&& lump == LUMPERROR
|
||||||
|
&& extra_colormap->lumpname[0] == 0
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean R_CheckDefaultColormap(extracolormap_t *extra_colormap, boolean checkrgba, boolean checkfadergba, boolean checkparams)
|
||||||
{
|
{
|
||||||
if (!extra_colormap)
|
if (!extra_colormap)
|
||||||
return true;
|
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
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
&& extra_colormap->lump == LUMPERROR
|
return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog, extra_colormap->lump);
|
||||||
&& extra_colormap->lumpname[0] == 0
|
#else
|
||||||
|
return R_CheckDefaultColormapByValues(checkrgba, checkfadergba, checkparams, extra_colormap->rgba, extra_colormap->fadergba, extra_colormap->fadestart, extra_colormap->fadeend, extra_colormap->fog);
|
||||||
#endif
|
#endif
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1557,14 +1572,14 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap)
|
||||||
double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb;
|
double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb;
|
||||||
double maskamt = 0, othermask = 0;
|
double maskamt = 0, othermask = 0;
|
||||||
|
|
||||||
UINT8 cr = (extra_colormap->rgba) & 0xFF,
|
UINT8 cr = R_GetRgbaR(extra_colormap->rgba),
|
||||||
cg = (extra_colormap->rgba >> 8) & 0xFF,
|
cg = R_GetRgbaG(extra_colormap->rgba),
|
||||||
cb = (extra_colormap->rgba >> 16) & 0xFF,
|
cb = R_GetRgbaB(extra_colormap->rgba),
|
||||||
ca = (extra_colormap->rgba >> 24) & 0xFF,
|
ca = R_GetRgbaA(extra_colormap->rgba),
|
||||||
cfr = (extra_colormap->fadergba) & 0xFF,
|
cfr = R_GetRgbaR(extra_colormap->fadergba),
|
||||||
cfg = (extra_colormap->fadergba >> 8) & 0xFF,
|
cfg = R_GetRgbaG(extra_colormap->fadergba),
|
||||||
cfb = (extra_colormap->fadergba >> 16) & 0xFF;
|
cfb = R_GetRgbaB(extra_colormap->fadergba);
|
||||||
// cfa = (extra_colormap->fadergba >> 24) & 0xFF; // unused in software
|
// cfa = R_GetRgbaA(extra_colormap->fadergba); // unused in software
|
||||||
|
|
||||||
UINT8 fadestart = extra_colormap->fadestart,
|
UINT8 fadestart = extra_colormap->fadestart,
|
||||||
fadedist = extra_colormap->fadeend - extra_colormap->fadestart;
|
fadedist = extra_colormap->fadeend - extra_colormap->fadestart;
|
||||||
|
@ -1807,6 +1822,15 @@ extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3)
|
||||||
rgba = cr + (cg << 8) + (cb << 16) + (ca << 24);
|
rgba = cr + (cg << 8) + (cb << 16) + (ca << 24);
|
||||||
fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24);
|
fadergba = cfr + (cfg << 8) + (cfb << 16) + (cfa << 24);
|
||||||
|
|
||||||
|
// Did we just make a default colormap?
|
||||||
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog, LUMPERROR))
|
||||||
|
return NULL;
|
||||||
|
#else
|
||||||
|
if (R_CheckDefaultColormapByValues(true, true, true, rgba, fadergba, fadestart, fadeend, fog))
|
||||||
|
return NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Look for existing colormaps
|
// Look for existing colormaps
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR);
|
exc = R_GetColormapFromListByValues(rgba, fadergba, fadestart, fadeend, fog, LUMPERROR);
|
||||||
|
|
13
src/r_data.h
13
src/r_data.h
|
@ -109,13 +109,19 @@ extracolormap_t *R_CreateDefaultColormap(boolean lighttable);
|
||||||
extracolormap_t *R_GetDefaultColormap(void);
|
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);
|
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams,
|
||||||
|
INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump);
|
||||||
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump);
|
extracolormap_t *R_GetColormapFromListByValues(INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog, lumpnum_t lump);
|
||||||
#else
|
#else
|
||||||
|
boolean R_CheckDefaultColormapByValues(boolean checkrgba, boolean checkfadergba, boolean checkparams,
|
||||||
|
INT32 rgba, INT32 fadergba, UINT8 fadestart, UINT8 fadeend, boolean fog);
|
||||||
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);
|
||||||
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);
|
||||||
extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3);
|
extracolormap_t *R_CreateColormap(char *p1, char *p2, char *p3);
|
||||||
#ifdef EXTRACOLORMAPLUMPS
|
#ifdef EXTRACOLORMAPLUMPS
|
||||||
|
@ -123,6 +129,11 @@ extracolormap_t *R_ColormapForName(char *name);
|
||||||
const char *R_NameForColormap(extracolormap_t *extra_colormap);
|
const char *R_NameForColormap(extracolormap_t *extra_colormap);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define R_GetRgbaR(rgba) (rgba & 0xFF)
|
||||||
|
#define R_GetRgbaG(rgba) ((rgba >> 8) & 0xFF)
|
||||||
|
#define R_GetRgbaB(rgba) ((rgba >> 16) & 0xFF)
|
||||||
|
#define R_GetRgbaA(rgba) ((rgba >> 24) & 0xFF)
|
||||||
|
|
||||||
extern INT32 numtextures;
|
extern INT32 numtextures;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue