@@ -55,13 +55,25 @@ public class GameStateRunActivity : GameState
55
55
static string logFileName { get { return Program . logFileName ; } set { Program . logFileName = value ; } }
56
56
static string EvaluationFilename { get { return Program . EvaluationFilename ; } set { Program . EvaluationFilename = value ; } }
57
57
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
+
58
70
// Prefix with the activity filename so that, when resuming from the Menu.exe, we can quickly find those Saves
59
71
// that are likely to match the previously chosen route and activity.
60
72
// Append the current date and time, so that each file is unique.
61
73
// 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}" ,
65
77
Simulator . Activity != null
66
78
? Simulator . ActivityFileName
67
79
: ( String . IsNullOrEmpty ( Simulator . TimetableFileName )
@@ -376,7 +388,8 @@ public static void Save()
376
388
// (!String.IsNullOrEmpty(Simulator.TimetableFileName) ? Simulator.RoutePathName + " " + Simulator.TimetableFileName : Simulator.RoutePathName),
377
389
// MPManager.IsMultiPlayer() && MPManager.IsServer() ? "$Multipl$ " : "" , DateTime.Now);
378
390
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 ) ) )
380
393
{
381
394
// Save some version identifiers so we can validate on load.
382
395
outf . Write ( VersionInfo . Version ) ;
@@ -402,7 +415,7 @@ public static void Save()
402
415
outf . Write ( Acttype ) ;
403
416
404
417
Simulator . Save ( outf ) ;
405
- Viewer . Save ( outf , FileStem ) ;
418
+ Viewer . Save ( outf , saveSet . FileStem ) ;
406
419
// Save multiplayer parameters
407
420
if ( MPManager . IsMultiPlayer ( ) && MPManager . IsServer ( ) )
408
421
MPManager . OnlineTrains . Save ( outf ) ;
@@ -416,15 +429,15 @@ public static void Save()
416
429
// Having written .save file, write other files: .replay, .txt, .evaluation.txt
417
430
418
431
// 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" ) ) ;
421
434
422
435
// Copy the logfile to the save folder
423
- CopyLog ( Path . Combine ( UserSettings . UserDataFolder , FileStem + ".txt" ) ) ;
436
+ CopyLog ( Path . Combine ( UserSettings . UserDataFolder , saveSet . FileStem + ".txt" ) ) ;
424
437
425
438
// Copy the evaluation file to the save folder
426
439
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 ) ;
428
441
}
429
442
430
443
private static void SaveEvaluation ( BinaryWriter outf )
0 commit comments