From 40133898fa90ef729fd7ccb5421d5f87be927ad6 Mon Sep 17 00:00:00 2001 From: UncraftedName Date: Sun, 9 Jul 2023 11:03:06 -0700 Subject: [PATCH] Add botched CM timing for portal 2 --- .../src/DemoArgProcessing/Options/OptTime.cs | 18 ++++++++++++++++++ DemoParser/src/Parser/DemoInfo.cs | 2 ++ 2 files changed, 20 insertions(+) diff --git a/ConsoleApp/src/DemoArgProcessing/Options/OptTime.cs b/ConsoleApp/src/DemoArgProcessing/Options/OptTime.cs index 14b238f..263affb 100644 --- a/ConsoleApp/src/DemoArgProcessing/Options/OptTime.cs +++ b/ConsoleApp/src/DemoArgProcessing/Options/OptTime.cs @@ -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; @@ -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() + .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(); } diff --git a/DemoParser/src/Parser/DemoInfo.cs b/DemoParser/src/Parser/DemoInfo.cs index 5f89853..63282ab 100644 --- a/DemoParser/src/Parser/DemoInfo.cs +++ b/DemoParser/src/Parser/DemoInfo.cs @@ -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; }