Merge branch 'maretimers' into 'next'

Allow per-mare time limits in NiGHTS

See merge request STJr/SRB2!2137
This commit is contained in:
sphere 2024-03-13 13:03:29 +00:00
commit a3165cbbee
5 changed files with 39 additions and 1 deletions

View file

@ -1543,6 +1543,12 @@ void readlevelheader(MYFILE *f, INT32 num)
P_AddGradesForMare((INT16)(num-1), mare-1, word2);
}
// NiGHTS time limits (per mare)
else if (fastncmp(word, "NIGHTSTIME", 10))
{
P_AddNiGHTSTimes((INT16)(num-1), word2);
}
// Strings that can be truncated
else if (fastcmp(word, "SELECTHEADING"))
{

View file

@ -335,6 +335,7 @@ typedef struct
INT32 sstimer; ///< Timer for special stages.
UINT32 ssspheres; ///< Sphere requirement in special stages.
fixed_t gravity; ///< Map-wide gravity.
UINT16 nightstimer[8]; ///< Per-mare time limits for NiGHTS stages.
// Title card.
char ltzzpatch[8+1]; ///< Zig zag patch.

View file

@ -358,6 +358,8 @@ static void P_ClearSingleMapHeaderInfo(INT16 i)
mapheaderinfo[num]->marathonnext = 0;
mapheaderinfo[num]->startrings = 0;
mapheaderinfo[num]->sstimer = 90;
for (UINT8 n = 0; n < 8; n++)
mapheaderinfo[num]->nightstimer[n] = 0;
mapheaderinfo[num]->ssspheres = 1;
mapheaderinfo[num]->gravity = FRACUNIT/2;
mapheaderinfo[num]->keywords[0] = '\0';
@ -525,6 +527,29 @@ UINT32 P_GetScoreForGradeOverall(INT16 map, UINT8 grade)
return score;
}
void P_AddNiGHTSTimes(INT16 i, char *gtext)
{
char *spos = gtext;
for (UINT8 n = 0; n < 8; n++)
{
if (spos != NULL)
{
mapheaderinfo[i]->nightstimer[n] = atoi(spos);
CONS_Debug(DBG_SETUP, "%u ", atoi(spos));
// Grab next comma
spos = strchr(spos, ',');
if (spos)
++spos;
}
else
{
mapheaderinfo[i]->nightstimer[n] = 0;
}
}
}
//
// levelflats
//

View file

@ -87,5 +87,6 @@ UINT8 P_GetGrade(UINT32 pscore, INT16 map, UINT8 mare);
UINT8 P_HasGrades(INT16 map, UINT8 mare);
UINT32 P_GetScoreForGrade(INT16 map, UINT8 mare, UINT8 grade);
UINT32 P_GetScoreForGradeOverall(INT16 map, UINT8 grade);
void P_AddNiGHTSTimes(INT16 i, char *gtext);
#endif

View file

@ -776,7 +776,7 @@ static void P_DeNightserizePlayer(player_t *player)
// NiGHTS Time!
void P_NightserizePlayer(player_t *player, INT32 nighttime)
{
UINT8 oldmare, oldmarelap, oldmarebonuslap;
UINT8 oldmare, oldmarelap, oldmarebonuslap, newmare;
// Bots can't be NiGHTSerized, silly!1 :P
if (player->bot)
@ -797,6 +797,11 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
}
}
// Use mare-specific time limit if specified
newmare = P_FindLowestMare();
if (mapheaderinfo[gamemap-1]->nightstimer[newmare] > 0)
nighttime = mapheaderinfo[gamemap-1]->nightstimer[newmare];
player->pflags &= ~(PF_SPINDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_SHIELDDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED|PF_SHIELDABILITY|PF_SPINNING|PF_DRILLING);
player->homing = 0;
player->mo->fuse = 0;