diff --git a/src/deh_soc.c b/src/deh_soc.c index 2193cd875..175a5ede6 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -1528,6 +1528,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")) { diff --git a/src/doomstat.h b/src/doomstat.h index fdd0d0b83..4c99c896b 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -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[9]; ///< Zig zag patch. diff --git a/src/p_setup.c b/src/p_setup.c index e289b8346..d6ba11dbb 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -355,6 +355,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'; @@ -522,6 +524,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 // diff --git a/src/p_setup.h b/src/p_setup.h index c6f4f741c..ef162b923 100644 --- a/src/p_setup.h +++ b/src/p_setup.h @@ -123,5 +123,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 diff --git a/src/p_user.c b/src/p_user.c index 3b2c60e3a..5fba17500 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -774,7 +774,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) @@ -795,6 +795,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_STARTDASH|PF_GLIDING|PF_JUMPED|PF_NOJUMPDAMAGE|PF_THOKKED|PF_SHIELDABILITY|PF_SPINNING|PF_DRILLING); player->homing = 0; player->mo->fuse = 0;