add encore variants of maplight

This commit is contained in:
Alug committed 2025-01-11 08:03:59 +01:00
1 parent 23dd5aa1d9
commit fe3bc867bc
4 files changed
+73 -27

No files matched your search

+31 -12
View File
@@ -690,6 +690,20 @@ static const struct {
{NULL, 0}
};
static mapheader_lighting_t *usemaplighting(INT32 mapnum, const char *word)
{
if (fastncmp(word, "ENCORE", 6))
{
mapheaderinfo[mapnum]->use_encore_lighting = true;
return &mapheaderinfo[mapnum]->lighting_encore;
}
else
{
return &mapheaderinfo[mapnum]->lighting;
}
}
static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum)
{
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
@@ -983,29 +997,34 @@ static void readlevelheader(MYFILE *f, INT32 num, INT32 wadnum)
}*/
else if (fastcmp(word, "MOBJSCALE"))
mapheaderinfo[num-1]->mobj_scale = get_number(word2);
else if (fastcmp(word, "LIGHTCONTRAST"))
else if (fastcmp(word, "LIGHTCONTRAST") || fastcmp(word, "ENCORELIGHTCONTRAST"))
{
mapheaderinfo[num-1]->light_contrast = (UINT8)i;
mapheaderinfo[num-1]->use_custom_light = true;
mapheader_lighting_t *lighting = usemaplighting(num-1, word);
lighting->light_contrast = (UINT8)i;
lighting->use_custom_light = true;
}
else if (fastcmp(word, "SPRITEBACKLIGHT"))
else if (fastcmp(word, "SPRITEBACKLIGHT") || fastcmp(word, "ENCORESPRITEBACKLIGHT"))
{
mapheaderinfo[num-1]->sprite_backlight = (SINT8)i;
mapheaderinfo[num-1]->use_custom_light = true;
mapheader_lighting_t *lighting = usemaplighting(num-1, word);
lighting->sprite_backlight = (SINT8)i;
lighting->use_custom_light = true;
}
else if (fastcmp(word, "LIGHTANGLE"))
else if (fastcmp(word, "LIGHTANGLE") || fastcmp(word, "ENCORELIGHTANGLE"))
{
mapheader_lighting_t *lighting = usemaplighting(num-1, word);
if (fastcmp(word2, "EVEN"))
{
mapheaderinfo[num-1]->use_light_angle = false;
mapheaderinfo[num-1]->light_angle = 0;
lighting->use_light_angle = false;
lighting->light_angle = 0;
}
else
{
mapheaderinfo[num-1]->use_light_angle = true;
mapheaderinfo[num-1]->light_angle = FixedAngle(FloatToFixed(atof(word2)));
lighting->use_light_angle = true;
lighting->light_angle = FixedAngle(FloatToFixed(atof(word2)));
}
mapheaderinfo[num-1]->use_custom_light = true;
lighting->use_custom_light = true;
}
// Individual triggers for level flags, for ease of use (and 2.0 compatibility)
+12 -5
View File
@@ -212,6 +212,15 @@ typedef struct
char value[256]; // 255 usable characters. If this seriously isn't enough then wtf.
} customoption_t;
typedef struct
{
boolean use_custom_light;
UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting.
SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only.
boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional.
angle_t light_angle; ///< Angle of directional wall lighting.
} mapheader_lighting_t;
/** Map header information.
*/
typedef struct
@@ -259,11 +268,9 @@ typedef struct
//boolean automap; ///< Displays a level's white map outline in modified games
fixed_t mobj_scale; ///< Replacement for TOL_ERZ3
boolean use_custom_light;
UINT8 light_contrast; ///< Range of wall lighting. 0 is no lighting.
SINT8 sprite_backlight; ///< Subtract from wall lighting for sprites only.
boolean use_light_angle; ///< When false, wall lighting is evenly distributed. When true, wall lighting is directional.
angle_t light_angle; ///< Angle of directional wall lighting.
mapheader_lighting_t lighting; ///< Wall and sprite lighting
mapheader_lighting_t lighting_encore; ///< Alternative lighting for Encore mode
boolean use_encore_lighting; ///< Whether to use separate Encore lighting
// Music stuff.
UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds
+13 -4
View File
@@ -278,6 +278,15 @@ FUNCNORETURN static ATTRNORETURN void CorruptMapError(const char *msg)
#define NUMLAPS_DEFAULT 3
static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting)
{
lighting->light_contrast = 8;
lighting->sprite_backlight = 0;
lighting->use_light_angle = false;
lighting->light_angle = 0;
lighting->use_custom_light = false;
}
/** Clears the data from a single map header.
*
* \param i Map number to clear header for.
@@ -327,10 +336,10 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
mapheaderinfo[num]->customopts = NULL;
mapheaderinfo[num]->numCustomOptions = 0;
mapheaderinfo[num]->light_contrast = 8;
mapheaderinfo[num]->sprite_backlight = 0;
mapheaderinfo[num]->use_light_angle = false;
mapheaderinfo[num]->light_angle = 0;
P_ClearMapHeaderLighting(&mapheaderinfo[num]->lighting);
P_ClearMapHeaderLighting(&mapheaderinfo[num]->lighting_encore);
mapheaderinfo[num]->use_encore_lighting = false;
}
/** Allocates a new map-header structure.
+17 -6
View File
@@ -5232,24 +5232,35 @@ static void P_RunLevelLoadExecutors(void)
static void P_SetupDirectionalLight(void)
{
if (cv_randomdirlight.value && mapheaderinfo[gamemap-1]->use_custom_light == false)
mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting;
if (encoremode && mapheaderinfo[gamemap-1]->use_encore_lighting)
{
lighting = &mapheaderinfo[gamemap-1]->lighting_encore;
}
if (cv_randomdirlight.value && lighting->use_custom_light == false)
{
static INT16 oldmap = 0; // dont reset stuff when you restart a map
if (gamemap != oldmap)
static boolean oldencore = false;
if (gamemap != oldmap || encoremode != oldencore)
{
maplighting.contrast = M_RandomRange(0, 58);
maplighting.backlight = 0;
maplighting.directional = M_RandomRange(0, 1); // either on or off
maplighting.angle = M_RandomRange(-382, 382);
}
oldmap = gamemap;
oldencore = encoremode;
return;
}
maplighting.contrast = mapheaderinfo[gamemap-1]->light_contrast;
maplighting.backlight = mapheaderinfo[gamemap-1]->sprite_backlight;
maplighting.directional = mapheaderinfo[gamemap-1]->use_light_angle;
maplighting.angle = mapheaderinfo[gamemap-1]->light_angle;
maplighting.contrast = lighting->light_contrast;
maplighting.backlight = lighting->sprite_backlight;
maplighting.directional = lighting->use_light_angle;
maplighting.angle = lighting->light_angle;
}
/** After the map has loaded, scans for specials that spawn 3Dfloors and