Skip to content

Commit

Permalink
Add botched CM timing for portal 2
Browse files Browse the repository at this point in the history
  • Loading branch information
UncraftedName committed Jul 9, 2023
1 parent 4d6eb13 commit 4013389
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ConsoleApp/src/DemoArgProcessing/Options/OptTime.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using DemoParser.Parser;
using DemoParser.Parser.Components;
using DemoParser.Parser.Components.Messages;
using DemoParser.Parser.Components.Messages.UserMessages;
using DemoParser.Utils;
using static System.Text.RegularExpressions.RegexOptions;

Expand Down Expand Up @@ -216,6 +217,23 @@ public static void WriteAdjustedTime(SourceDemo demo, TextWriter tw, bool timeFi
tw.Write($"{"Adjusted ticks ",FmtIdt}: {demo.AdjustedTickCount(tfs)}");
tw.WriteLine($" ({demo.StartAdjustmentTick}-{demo.EndAdjustmentTick})");
}

// another hack until we time things better :)
if (demo.DemoInfo.IsPortal2()) {
ScoreboardTempUpdate? lastScoreBoard =
demo.FilterForUserMessage<ScoreboardTempUpdate>()
.Select(tuple => tuple.userMessage)
.LastOrDefault();

if (lastScoreBoard != null) {
float cmTime = lastScoreBoard.TimeTaken / 100f;
float numPortals = lastScoreBoard.NumPortals;
tw.WriteLine($"{"CM time ",FmtIdt}: {Utils.FormatTime(cmTime)}");
tw.WriteLine($"{"CM ticks ",FmtIdt}: {(int)Math.Round(cmTime / tickInterval)}");
tw.WriteLine($"{"CM portals ",FmtIdt}: {numPortals}");
}
}

Utils.PopForegroundColor();
}

Expand Down
2 changes: 2 additions & 0 deletions DemoParser/src/Parser/DemoInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ public DemoInfo(SourceDemo demo) {

public bool IsPortal1() => Game >= PORTAL_1_3420 && Game <= PORTAL_1_1910503;

public bool IsPortal2() => Game == PORTAL_2;

public bool IsHL2() => Game == HL2_OE;
}

Expand Down

0 comments on commit 4013389

Please sign in to comment.