Merge branch 'encore-directional-lighting' into 'master'

Add encore variants of LightContrast, LightAngle and SpriteBacklight to level header

Closes #593

See merge request KartKrew/Kart!1388
This commit is contained in:
Oni 2023-08-13 06:21:12 +00:00
commit aeb6d6740f
5 changed files with 60 additions and 21 deletions

View file

@ -925,6 +925,20 @@ void readgametype(MYFILE *f, char *gtname)
CONS_Printf("Added gametype %s\n", gtname);
}
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;
}
}
void readlevelheader(MYFILE *f, char * name)
{
char *s = Z_Malloc(MAXLINELEN, PU_STATIC, NULL);
@ -1277,25 +1291,27 @@ void readlevelheader(MYFILE *f, char * name)
mapheaderinfo[num]->mobj_scale = get_number(word2);
else if (fastcmp(word, "DEFAULTWAYPOINTRADIUS"))
mapheaderinfo[num]->default_waypoint_radius = get_number(word2);
else if (fastcmp(word, "LIGHTCONTRAST"))
else if (fastcmp(word, "LIGHTCONTRAST") || fastcmp(word, "ENCORELIGHTCONTRAST"))
{
mapheaderinfo[num]->light_contrast = (UINT8)i;
usemaplighting(num, word)->light_contrast = (UINT8)i;
}
else if (fastcmp(word, "SPRITEBACKLIGHT"))
else if (fastcmp(word, "SPRITEBACKLIGHT") || fastcmp(word, "ENCORESPRITEBACKLIGHT"))
{
mapheaderinfo[num]->sprite_backlight = (SINT8)i;
usemaplighting(num, word)->sprite_backlight = (SINT8)i;
}
else if (fastcmp(word, "LIGHTANGLE"))
else if (fastcmp(word, "LIGHTANGLE") || fastcmp(word, "ENCORELIGHTANGLE"))
{
mapheader_lighting_t *lighting = usemaplighting(num, word);
if (fastcmp(word2, "EVEN"))
{
mapheaderinfo[num]->use_light_angle = false;
mapheaderinfo[num]->light_angle = 0;
lighting->use_light_angle = false;
lighting->light_angle = 0;
}
else
{
mapheaderinfo[num]->use_light_angle = true;
mapheaderinfo[num]->light_angle = FixedAngle(FloatToFixed(atof(word2)));
lighting->use_light_angle = true;
lighting->light_angle = FixedAngle(FloatToFixed(atof(word2)));
}
}
// Individual triggers for level flags, for ease of use (and 2.0 compatibility)

View file

@ -439,6 +439,14 @@ struct staffbrief_t
#define MAXMUSNAMES 3 // maximum definable music tracks per level
#define MAXHEADERFOLLOWERS 32
struct mapheader_lighting_t
{
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.
};
/** Map header information.
*/
struct mapheader_t
@ -506,10 +514,10 @@ struct mapheader_t
// Visual information
UINT16 palette; ///< PAL lump to use on this map
UINT16 encorepal; ///< PAL for encore mode
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
// Audience information
UINT8 numFollowers; ///< Internal. For audience support.

View file

@ -398,6 +398,14 @@ void P_DeleteHeaderFollowers(UINT16 i)
#define NUMLAPS_DEFAULT 3
static void P_ClearMapHeaderLighting(mapheader_lighting_t *lighting)
{
lighting->light_contrast = 16;
lighting->sprite_backlight = 0;
lighting->use_light_angle = false;
lighting->light_angle = 0;
}
/** Clears the data from a single map header.
*
* \param i Map number to clear header for.
@ -438,10 +446,9 @@ static void P_ClearSingleMapHeaderInfo(INT16 num)
mapheaderinfo[num]->menuflags = 0;
mapheaderinfo[num]->mobj_scale = FRACUNIT;
mapheaderinfo[num]->default_waypoint_radius = 0;
mapheaderinfo[num]->light_contrast = 16;
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;
#if 1 // equivalent to "Followers = DEFAULT"
P_SetDefaultHeaderFollowers(num);
#else

View file

@ -6736,6 +6736,13 @@ static void P_RunLevelLoadExecutors(void)
*/
void P_InitSpecials(void)
{
mapheader_lighting_t *lighting = &mapheaderinfo[gamemap-1]->lighting;
if (encoremode && cv_kartencoremap.value && mapheaderinfo[gamemap-1]->use_encore_lighting)
{
lighting = &mapheaderinfo[gamemap-1]->lighting_encore;
}
// Set the map object scale
mapobjectscale = mapheaderinfo[gamemap-1]->mobj_scale;
@ -6743,10 +6750,10 @@ void P_InitSpecials(void)
gravity = mapheaderinfo[gamemap-1]->gravity;
// Set map lighting settings.
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;
CheckForBustableBlocks = CheckForBouncySector = CheckForQuicksand = CheckForMarioBlocks = CheckForFloatBob = CheckForReverseGravity = false;

View file

@ -129,6 +129,7 @@ TYPEDEF (customoption_t);
TYPEDEF (gametype_t);
TYPEDEF (staffbrief_t);
TYPEDEF (mapheader_t);
TYPEDEF (mapheader_lighting_t);
TYPEDEF (unloaded_mapheader_t);
TYPEDEF (tolinfo_t);
TYPEDEF (cupheader_t);