diff --git a/src/g_game.c b/src/g_game.c index bb10672b0..9397dbe7b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -582,6 +582,12 @@ static void G_UpdateRecordReplays(void) { char *gpath; char lastdemo[256], bestdemo[256]; + const char *modeprefix = ""; + + if (modeattacking & ATTACKING_SPB) + { + modeprefix = "spb-"; + } if (players[consoleplayer].pflags & PF_NOCONTEST) { @@ -601,7 +607,7 @@ static void G_UpdateRecordReplays(void) strcat(gpath, PATHSEP); strcat(gpath, G_BuildMapName(gamemap)); - snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, cv_skin[0].string); + snprintf(lastdemo, 255, "%s-%s-%slast.lmp", gpath, cv_skin[0].string, modeprefix); if (modeattacking != ATTACKING_NONE && FIL_FileExists(lastdemo)) { @@ -614,7 +620,7 @@ static void G_UpdateRecordReplays(void) if (modeattacking & ATTACKING_TIME) { - snprintf(bestdemo, 255, "%s-%s-time-best.lmp", gpath, cv_skin[0].string); + snprintf(bestdemo, 255, "%s-%s-%stime-best.lmp", gpath, cv_skin[0].string, modeprefix); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1) { // Better time, save this demo. if (FIL_FileExists(bestdemo)) @@ -626,7 +632,7 @@ static void G_UpdateRecordReplays(void) if (modeattacking & ATTACKING_LAP) { - snprintf(bestdemo, 255, "%s-%s-lap-best.lmp", gpath, cv_skin[0].string); + snprintf(bestdemo, 255, "%s-%s-%slap-best.lmp", gpath, cv_skin[0].string, modeprefix); if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & (1<<1)) { // Better lap time, save this demo. if (FIL_FileExists(bestdemo)) diff --git a/src/menus/play-local-race-time-attack.c b/src/menus/play-local-race-time-attack.c index 482ad3e27..50e211224 100644 --- a/src/menus/play-local-race-time-attack.c +++ b/src/menus/play-local-race-time-attack.c @@ -11,12 +11,6 @@ #include "../z_zone.h" // Z_StrDup/Z_Free #include "../m_cond.h" -void CV_SPBAttackChanged(void); -void CV_SPBAttackChanged(void) -{ - G_UpdateTimeStickerMedals(levellist.choosemap, false); -} - struct timeattackmenu_s timeattackmenu; void M_TimeAttackTick(void) @@ -214,40 +208,24 @@ menu_t PLAY_TAGhostsDef = { NULL }; -// time attack stuff... -void M_PrepareTimeAttack(INT32 choice) +void CV_SPBAttackChanged(void); +void CV_SPBAttackChanged(void) { - (void) choice; - - timeattackmenu.ticker = 0; - - // Gametype guess - if (levellist.guessgt != MAXGAMETYPES) - { - levellist.newgametype = levellist.guessgt; - if (!(gametypes[levellist.newgametype]->tol & mapheaderinfo[levellist.choosemap]->typeoflevel)) - { - INT32 guess = G_GuessGametypeByTOL(mapheaderinfo[levellist.choosemap]->typeoflevel); - if (guess != -1) - levellist.newgametype = guess; - } - } - - if (levellist.levelsearch.timeattack == false || levellist.newgametype != GT_RACE || !M_SecretUnlocked(SECRET_SPBATTACK, true)) - CV_SetValue(&cv_dummyspbattack, 0); - - // Time-sticker Medals G_UpdateTimeStickerMedals(levellist.choosemap, false); // Menu options { // see also p_setup.c's P_LoadRecordGhosts char *gpath = Z_StrDup(va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(levellist.choosemap+1))); + const char *modeprefix = ""; UINT8 active; if (!gpath) return; + if (cv_dummyspbattack.value) + modeprefix = "spb-"; + active = false; PLAY_TimeAttack[ta_guest].status = IT_DISABLED; PLAY_TimeAttack[ta_replay].status = IT_DISABLED; @@ -256,11 +234,11 @@ void M_PrepareTimeAttack(INT32 choice) // Check if file exists, if not, disable options PLAY_TAReplay[tareplay_besttime].status = PLAY_TAReplayGuest[taguest_besttime].status = IT_DISABLED; - if (FIL_FileExists(va("%s-%s-time-best.lmp", gpath, cv_skin[0].string))) + if (FIL_FileExists(va("%s-%s-%stime-best.lmp", gpath, cv_skin[0].string, modeprefix))) { PLAY_TAReplay[tareplay_besttime].status = IT_STRING|IT_CALL; PLAY_TAReplayGuest[taguest_besttime].status = IT_STRING|IT_CALL; - active |= (1|2|4); + active |= (1|2|4|8); } else if (PLAY_TAReplayGuestDef.lastOn == taguest_besttime) PLAY_TAReplayGuestDef.lastOn = taguest_back; @@ -270,23 +248,23 @@ void M_PrepareTimeAttack(INT32 choice) PLAY_TAGhosts[taghost_bestlap].status = IT_DISABLED; if ((gametypes[levellist.newgametype]->rules & GTR_CIRCUIT) && (mapheaderinfo[levellist.choosemap]->numlaps != 1) - && FIL_FileExists(va("%s-%s-lap-best.lmp", gpath, cv_skin[0].string))) + && FIL_FileExists(va("%s-%s-%slap-best.lmp", gpath, cv_skin[0].string, modeprefix))) { PLAY_TAReplay[tareplay_bestlap].status = IT_STRING|IT_CALL; PLAY_TAReplayGuest[taguest_bestlap].status = IT_STRING|IT_CALL; PLAY_TAGhosts[taghost_bestlap].status = IT_STRING|IT_CVAR; - active |= (1|2|4); + active |= (1|2|4|8); } else if (PLAY_TAReplayGuestDef.lastOn == taguest_bestlap) PLAY_TAReplayGuestDef.lastOn = taguest_back; PLAY_TAReplay[tareplay_last].status = PLAY_TAReplayGuest[taguest_last].status = IT_DISABLED; - if (FIL_FileExists(va("%s-%s-last.lmp", gpath, cv_skin[0].string))) + if (FIL_FileExists(va("%s-%s-%slast.lmp", gpath, cv_skin[0].string, modeprefix))) { PLAY_TAReplay[tareplay_last].status = IT_STRING|IT_CALL; PLAY_TAReplayGuest[taguest_last].status = IT_STRING|IT_CALL; - active |= (1|2|4); + active |= (1|2|4|8); } else if (PLAY_TAReplayGuestDef.lastOn == taguest_last) PLAY_TAReplayGuestDef.lastOn = taguest_back; @@ -314,6 +292,9 @@ void M_PrepareTimeAttack(INT32 choice) active |= 1|4; } + if (currentMenu == &PLAY_TimeAttackDef) + PLAY_TimeAttackDef.lastOn = itemOn; + if (active & 1) PLAY_TimeAttack[ta_replay].status = IT_STRING|IT_SUBMENU; else if (PLAY_TimeAttackDef.lastOn == ta_replay) @@ -327,10 +308,42 @@ void M_PrepareTimeAttack(INT32 choice) /*else if (PLAY_TimeAttackDef.lastOn == ta_ghosts) PLAY_TimeAttackDef.lastOn = ta_start;*/ + if ((active & 8) && levellist.newgametype == GT_RACE && M_SecretUnlocked(SECRET_SPBATTACK, true)) + PLAY_TAReplay[tareplay_header].status = IT_HEADER; + + if (currentMenu == &PLAY_TimeAttackDef) + itemOn = PLAY_TimeAttackDef.lastOn; + Z_Free(gpath); } } +// time attack stuff... +void M_PrepareTimeAttack(INT32 choice) +{ + (void) choice; + + timeattackmenu.ticker = 0; + + // Gametype guess + if (levellist.guessgt != MAXGAMETYPES) + { + levellist.newgametype = levellist.guessgt; + if (!(gametypes[levellist.newgametype]->tol & mapheaderinfo[levellist.choosemap]->typeoflevel)) + { + INT32 guess = G_GuessGametypeByTOL(mapheaderinfo[levellist.choosemap]->typeoflevel); + if (guess != -1) + levellist.newgametype = guess; + } + } + + if (levellist.levelsearch.timeattack == false || levellist.newgametype != GT_RACE || !M_SecretUnlocked(SECRET_SPBATTACK, true)) + CV_StealthSetValue(&cv_dummyspbattack, 0); + + // Menu options / Time-sticker medals + CV_SPBAttackChanged(); +} + void M_HandleStaffReplay(INT32 choice) { if (choice == 2) @@ -383,7 +396,12 @@ void M_ReplayTimeAttack(INT32 choice) return; } - G_DoPlayDemo(va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(levellist.choosemap+1), cv_skin[0].string, which)); + const char *modeprefix = ""; + + if (cv_dummyspbattack.value) + modeprefix = "spb-"; + + G_DoPlayDemo(va("%s"PATHSEP"media"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s%s.lmp", srb2home, timeattackfolder, G_BuildMapName(levellist.choosemap+1), cv_skin[0].string, modeprefix, which)); } static const char *TA_GuestReplay_Str = NULL; @@ -402,7 +420,12 @@ static void M_WriteGuestReplay(INT32 ch) if (TA_GuestReplay_Str != NULL) { - len = FIL_ReadFile(va("%s-%s-%s.lmp", gpath, cv_skin[0].string, TA_GuestReplay_Str), &buf); + const char *modeprefix = ""; + + if (cv_dummyspbattack.value) + modeprefix = "spb-"; + + len = FIL_ReadFile(va("%s-%s-%s%s.lmp", gpath, cv_skin[0].string, modeprefix, TA_GuestReplay_Str), &buf); if (!len) { M_StartMessage("Guest Replay", "Replay to copy no longer exists!", NULL, MM_NOTHING, NULL, NULL); @@ -468,6 +491,7 @@ void M_StartTimeAttack(INT32 choice) { char *gpath; char nameofdemo[256]; + const char *modeprefix = ""; (void)choice; @@ -482,6 +506,7 @@ void M_StartTimeAttack(INT32 choice) if (cv_dummyspbattack.value) { modeattacking |= ATTACKING_SPB; + modeprefix = "spb-"; } // Still need to reset devmode @@ -516,7 +541,7 @@ void M_StartTimeAttack(INT32 choice) strcat(gpath, PATHSEP); strcat(gpath, G_BuildMapName(levellist.choosemap+1)); - snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, cv_skin[0].string); + snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-%slast", gpath, cv_skin[0].string, modeprefix); if (!cv_autorecord.value) remove(va("%s"PATHSEP"%s.lmp", srb2home, nameofdemo)); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index f70f552ca..43171ba9e 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -7785,10 +7785,14 @@ static void P_LoadRecordGhosts(void) { // see also /menus/play-local-race-time-attack.c's M_PrepareTimeAttack char *gpath; + const char *modeprefix = ""; INT32 i; gpath = Z_StrDup(va("%s" PATHSEP "media" PATHSEP "replay" PATHSEP "%s" PATHSEP "%s", srb2home, timeattackfolder, G_BuildMapName(gamemap))); + if (modeattacking & ATTACKING_SPB) + modeprefix = "spb-"; + // Best Time ghost if (modeattacking & ATTACKING_TIME) { @@ -7799,7 +7803,7 @@ static void P_LoadRecordGhosts(void) if (cv_ghost_besttime.value == 1 && players[consoleplayer].skin != i) continue; - P_TryAddExternalGhost(va("%s-%s-time-best.lmp", gpath, skins[i].name)); + P_TryAddExternalGhost(va("%s-%s-%stime-best.lmp", gpath, skins[i].name, modeprefix)); } } } @@ -7814,7 +7818,7 @@ static void P_LoadRecordGhosts(void) if (cv_ghost_bestlap.value == 1 && players[consoleplayer].skin != i) continue; - P_TryAddExternalGhost(va("%s-%s-lap-best.lmp", gpath, skins[i].name)); + P_TryAddExternalGhost(va("%s-%s-%slap-best.lmp", gpath, skins[i].name, modeprefix)); } } } @@ -7827,7 +7831,7 @@ static void P_LoadRecordGhosts(void) if (cv_ghost_last.value == 1 && players[consoleplayer].skin != i) continue; - P_TryAddExternalGhost(va("%s-%s-last.lmp", gpath, skins[i].name)); + P_TryAddExternalGhost(va("%s-%s-%slast.lmp", gpath, skins[i].name, modeprefix)); } }