@@ -55,13 +55,25 @@ public class GameStateRunActivity : GameState
5555 static string logFileName { get { return Program . logFileName ; } set { Program . logFileName = value ; } }
5656 static string EvaluationFilename { get { return Program . EvaluationFilename ; } set { Program . EvaluationFilename = value ; } }
5757
58+ /// <summary>
59+ /// A set of save files all have the same filestem but a specific extension:
60+ /// *.save for the binary data containing the simulation values at the time of saving.
61+ /// *.txt for the log file, provided only for reference.
62+ /// *.png for the screenshot taken automatically at the moment of saving and shown in minature in the Resume menu.
63+ /// *.replay for binary data containing the user's commands so the simulation can be replayed if required.
64+ /// *.evaluation.txt for the text evaluation if an activity evaluation has been requested.
65+ /// </summary>
66+ public class SaveSet
67+ {
68+ public string FileStem { get ; }
69+
5870 // Prefix with the activity filename so that, when resuming from the Menu.exe, we can quickly find those Saves
5971 // that are likely to match the previously chosen route and activity.
6072 // Append the current date and time, so that each file is unique.
6173 // This is the "sortable" date format, ISO 8601, but with "." in place of the ":" which is not valid in filenames.
62- public static string FileStem
63- { get
64- { return String . Format ( "{0} {1} {2:yyyy-MM-dd HH.mm.ss}" ,
74+ public SaveSet ( )
75+ {
76+ FileStem = String . Format ( "{0} {1} {2:yyyy-MM-dd HH.mm.ss}" ,
6577 Simulator . Activity != null
6678 ? Simulator . ActivityFileName
6779 : ( String . IsNullOrEmpty ( Simulator . TimetableFileName )
@@ -376,7 +388,8 @@ public static void Save()
376388 // (!String.IsNullOrEmpty(Simulator.TimetableFileName) ? Simulator.RoutePathName + " " + Simulator.TimetableFileName : Simulator.RoutePathName),
377389 // MPManager.IsMultiPlayer() && MPManager.IsServer() ? "$Multipl$ " : "" , DateTime.Now);
378390
379- using ( BinaryWriter outf = new BinaryWriter ( new FileStream ( UserSettings . UserDataFolder + "\\ " + FileStem + ".save" , FileMode . Create , FileAccess . Write ) ) )
391+ var saveSet = new SaveSet ( ) ; // Sets the filestem for the set of Save files
392+ using ( BinaryWriter outf = new BinaryWriter ( new FileStream ( UserSettings . UserDataFolder + "\\ " + saveSet . FileStem + ".save" , FileMode . Create , FileAccess . Write ) ) )
380393 {
381394 // Save some version identifiers so we can validate on load.
382395 outf . Write ( VersionInfo . Version ) ;
@@ -402,7 +415,7 @@ public static void Save()
402415 outf . Write ( Acttype ) ;
403416
404417 Simulator . Save ( outf ) ;
405- Viewer . Save ( outf , FileStem ) ;
418+ Viewer . Save ( outf , saveSet . FileStem ) ;
406419 // Save multiplayer parameters
407420 if ( MPManager . IsMultiPlayer ( ) && MPManager . IsServer ( ) )
408421 MPManager . OnlineTrains . Save ( outf ) ;
@@ -416,15 +429,15 @@ public static void Save()
416429 // Having written .save file, write other files: .replay, .txt, .evaluation.txt
417430
418431 // The Save command is the only command that doesn't take any action. It just serves as a marker.
419- new SaveCommand ( Simulator . Log , FileStem ) ;
420- Simulator . Log . SaveLog ( Path . Combine ( UserSettings . UserDataFolder , FileStem + ".replay" ) ) ;
432+ new SaveCommand ( Simulator . Log , saveSet . FileStem ) ;
433+ Simulator . Log . SaveLog ( Path . Combine ( UserSettings . UserDataFolder , saveSet . FileStem + ".replay" ) ) ;
421434
422435 // Copy the logfile to the save folder
423- CopyLog ( Path . Combine ( UserSettings . UserDataFolder , FileStem + ".txt" ) ) ;
436+ CopyLog ( Path . Combine ( UserSettings . UserDataFolder , saveSet . FileStem + ".txt" ) ) ;
424437
425438 // Copy the evaluation file to the save folder
426439 if ( File . Exists ( Program . EvaluationFilename ) )
427- File . Copy ( Program . EvaluationFilename , Path . Combine ( UserSettings . UserDataFolder , FileStem + ".evaluation.txt" ) , true ) ;
440+ File . Copy ( Program . EvaluationFilename , Path . Combine ( UserSettings . UserDataFolder , saveSet . FileStem + ".evaluation.txt" ) , true ) ;
428441 }
429442
430443 private static void SaveEvaluation ( BinaryWriter outf )
0 commit comments