Skip to content

Commit bcc0da3

Browse files
authored
Merge pull request #992 from cjakeman/log-location-on-Save
adds LogLocation() to Save()
2 parents 5455559 + 1e30c4e commit bcc0da3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Source/RunActivity/Viewer3D/Processes/GameStateRunActivity.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ public static void Save()
428428
outf.Write(outf.BaseStream.Position);
429429
}
430430

431+
LogLocation();
432+
431433
// Having written .save file, write other files: .replay, .txt, .evaluation.txt
432434

433435
// The Save command is the only command that doesn't take any action. It just serves as a marker.
@@ -442,6 +444,20 @@ public static void Save()
442444
File.Copy(Program.EvaluationFilename, Path.Combine(UserSettings.UserDataFolder, saveSet.FileStem + ".evaluation.txt"), true);
443445
}
444446

447+
448+
/// <summary>
449+
/// Append time and location to the log for potential use in an ACT file. E.g.:
450+
/// "Location ( -6112 15146 78.15 -672.81 10 )"
451+
/// </summary>
452+
private static void LogLocation()
453+
{
454+
var t = Simulator.Trains[0].FrontTDBTraveller;
455+
var location = $"Location ( {t.TileX} {t.TileZ} {t.X:F2} {t.Z:F2}";
456+
location += $" 10 )"; // Matches location if within this 10 meter radius
457+
var clockTime = FormatStrings.FormatTime(Simulator.ClockTime);
458+
Console.WriteLine($"\nSave after {(int)Simulator.GameTime} secs at {clockTime}, EventCategoryLocation = {location}");
459+
}
460+
445461
private static void SaveEvaluation(BinaryWriter outf)
446462
{
447463
outf.Write(ActivityTaskPassengerStopAt.DbfEvalDepartBeforeBoarding.Count);

0 commit comments

Comments
 (0)