diff --git a/src/g_game.c b/src/g_game.c index a927f8ef2..692dbf439 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -720,14 +720,14 @@ void G_SetNightsRecords(void) I_Error("Out of memory for replay filepath\n"); sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); - snprintf(lastdemo, 255, "%s-last.lmp", gpath); + snprintf(lastdemo, 255, "%s-%s-last.lmp", gpath, skins[cv_chooseskin.value-1].name); if (FIL_FileExists(lastdemo)) { UINT8 *buf; size_t len = FIL_ReadFile(lastdemo, &buf); - snprintf(bestdemo, 255, "%s-time-best.lmp", gpath); + snprintf(bestdemo, 255, "%s-%s-time-best.lmp", gpath, skins[cv_chooseskin.value-1].name);; if (!FIL_FileExists(bestdemo) || G_CmpDemoTime(bestdemo, lastdemo) & 1) { // Better time, save this demo. if (FIL_FileExists(bestdemo)) @@ -736,7 +736,7 @@ void G_SetNightsRecords(void) CONS_Printf("\x83%s\x80 %s '%s'\n", M_GetText("NEW RECORD TIME!"), M_GetText("Saved replay as"), bestdemo); } - snprintf(bestdemo, 255, "%s-score-best.lmp", gpath); + snprintf(bestdemo, 255, "%s-%s-score-best.lmp", gpath, skins[cv_chooseskin.value-1].name); if (!FIL_FileExists(bestdemo) || (G_CmpDemoTime(bestdemo, lastdemo) & (1<<1))) { // Better score, save this demo. if (FIL_FileExists(bestdemo)) diff --git a/src/m_menu.c b/src/m_menu.c index f684354a5..a470b4021 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2300,7 +2300,7 @@ void Nextmap_OnChange(void) SP_NightsAttackMenu[naghost].status = IT_DISABLED; // Check if file exists, if not, disable REPLAY option - sprintf(tabase,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s",srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)); + sprintf(tabase,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s",srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name); for (i = 0; i < 4; i++) { SP_NightsReplayMenu[i].status = IT_DISABLED; SP_NightsGuestReplayMenu[i].status = IT_DISABLED; @@ -2320,7 +2320,7 @@ void Nextmap_OnChange(void) SP_NightsGuestReplayMenu[2].status = IT_WHITESTRING|IT_CALL; active = true; } - if (FIL_FileExists(va("%s-guest.lmp", tabase))) { + if (FIL_FileExists(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value)))) { SP_NightsReplayMenu[3].status = IT_WHITESTRING|IT_CALL; SP_NightsGuestReplayMenu[3].status = IT_WHITESTRING|IT_CALL; active = true; @@ -10126,6 +10126,8 @@ static void M_NightsAttack(INT32 choice) // Player has selected the "START" from the nights attack screen static void M_ChooseNightsAttack(INT32 choice) { + char *gpath; + const size_t glen = strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char nameofdemo[256]; (void)choice; emeralds = 0; @@ -10136,14 +10138,18 @@ static void M_ChooseNightsAttack(INT32 choice) I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); - snprintf(nameofdemo, sizeof nameofdemo, "replay"PATHSEP"%s"PATHSEP"%s-last", timeattackfolder, G_BuildMapName(cv_nextmap.value)); + if ((gpath = malloc(glen)) == NULL) + I_Error("Out of memory for replay filepath\n"); + + sprintf(gpath,"replay"PATHSEP"%s"PATHSEP"%s", timeattackfolder, G_BuildMapName(cv_nextmap.value)); + snprintf(nameofdemo, sizeof nameofdemo, "%s-%s-last", gpath, skins[cv_chooseskin.value-1].name); if (!cv_autorecord.value) remove(va("%s"PATHSEP"%s.lmp", srb2home, nameofdemo)); else G_RecordDemo(nameofdemo); - G_DeferedInitNew(false, G_BuildMapName(cv_nextmap.value), 0, false, false); + G_DeferedInitNew(false, G_BuildMapName(cv_nextmap.value), (UINT8)(cv_chooseskin.value-1), false, false); } // Player has selected the "START" from the time attack screen @@ -10220,11 +10226,10 @@ static void M_ReplayTimeAttack(INT32 choice) which = "last"; break; case 3: // guest - which = "guest"; - break; + G_DoPlayDemo(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value))); + return; } - // srb2/replay/main/map01-score-best.lmp - G_DoPlayDemo(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), which)); + G_DoPlayDemo(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name, which)); } } @@ -10242,15 +10247,13 @@ static void M_EraseGuest(INT32 choice) M_StartMessage(M_GetText("Guest replay data erased.\n"),NULL,MM_NOTHING); } -static void M_OverwriteGuest(const char *which, boolean nights) +static void M_OverwriteGuest(const char *which) { char *rguest = Z_StrDup(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-guest.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value))); UINT8 *buf; size_t len; - if (!nights) - len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name, which), &buf); - else - len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), which), &buf); + len = FIL_ReadFile(va("%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s-%s-%s.lmp", srb2home, timeattackfolder, G_BuildMapName(cv_nextmap.value), skins[cv_chooseskin.value-1].name, which), &buf); + if (!len) { return; } @@ -10271,25 +10274,25 @@ static void M_OverwriteGuest(const char *which, boolean nights) static void M_OverwriteGuest_Time(INT32 choice) { (void)choice; - M_OverwriteGuest("time-best", currentMenu == &SP_NightsGuestReplayDef); + M_OverwriteGuest("time-best"); } static void M_OverwriteGuest_Score(INT32 choice) { (void)choice; - M_OverwriteGuest("score-best", currentMenu == &SP_NightsGuestReplayDef); + M_OverwriteGuest("score-best"); } static void M_OverwriteGuest_Rings(INT32 choice) { (void)choice; - M_OverwriteGuest("rings-best", false); + M_OverwriteGuest("rings-best"); } static void M_OverwriteGuest_Last(INT32 choice) { (void)choice; - M_OverwriteGuest("last", currentMenu == &SP_NightsGuestReplayDef); + M_OverwriteGuest("last"); } static void M_SetGuestReplay(INT32 choice) diff --git a/src/p_setup.c b/src/p_setup.c index 5027bab0c..d088f3a20 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3157,6 +3157,7 @@ static void P_LoadNightsGhosts(void) { const size_t glen = strlen(srb2home)+1+strlen("replay")+1+strlen(timeattackfolder)+1+strlen("MAPXX")+1; char *gpath = malloc(glen); + INT32 i; if (!gpath) return; @@ -3164,16 +3165,43 @@ static void P_LoadNightsGhosts(void) sprintf(gpath,"%s"PATHSEP"replay"PATHSEP"%s"PATHSEP"%s", srb2home, timeattackfolder, G_BuildMapName(gamemap)); // Best Score ghost - if (cv_ghost_bestscore.value && FIL_FileExists(va("%s-score-best.lmp", gpath))) - G_AddGhost(va("%s-score-best.lmp", gpath)); + if (cv_ghost_bestscore.value) + { + for (i = 0; i < numskins; ++i) + { + if (cv_ghost_bestscore.value == 1 && players[consoleplayer].skin != i) + continue; + + if (FIL_FileExists(va("%s-%s-score-best.lmp", gpath, skins[i].name))) + G_AddGhost(va("%s-%s-score-best.lmp", gpath, skins[i].name)); + } + } // Best Time ghost - if (cv_ghost_besttime.value && FIL_FileExists(va("%s-time-best.lmp", gpath))) - G_AddGhost(va("%s-time-best.lmp", gpath)); + if (cv_ghost_besttime.value) + { + for (i = 0; i < numskins; ++i) + { + if (cv_ghost_besttime.value == 1 && players[consoleplayer].skin != i) + continue; + + if (FIL_FileExists(va("%s-%s-time-best.lmp", gpath, skins[i].name))) + G_AddGhost(va("%s-%s-time-best.lmp", gpath, skins[i].name)); + } + } // Last ghost - if (cv_ghost_last.value && FIL_FileExists(va("%s-last.lmp", gpath))) - G_AddGhost(va("%s-last.lmp", gpath)); + if (cv_ghost_last.value) + { + for (i = 0; i < numskins; ++i) + { + if (cv_ghost_last.value == 1 && players[consoleplayer].skin != i) + continue; + + if (FIL_FileExists(va("%s-%s-last.lmp", gpath, skins[i].name))) + G_AddGhost(va("%s-%s-last.lmp", gpath, skins[i].name)); + } + } // Guest ghost if (cv_ghost_guest.value && FIL_FileExists(va("%s-guest.lmp", gpath)))