diff --git a/Apm/DataRow.cs b/Apm/DataRow.cs index e43273a..a5ca21f 100644 --- a/Apm/DataRow.cs +++ b/Apm/DataRow.cs @@ -116,13 +116,21 @@ namespace AnotherReplayReader.Apm dataList.Add(new("局域网 IP", plotter.Players.Select(GetIpAndName))); } apmRowIndex = dataList.Count; + // kill-death ratio + if (plotter.Replay.Footer?.TryGetKillDeathRatios() is { } kdRatios) + { + var texts = kdRatios + .Take(plotter.Players.Length) + .Select(x => $"{x:0.##}"); + dataList.Add(new("击杀阵亡比(存疑)", texts)); + } // get commands var commandCounts = plotter.GetCommandCounts(begin, end); // add commands in the order specified by the list foreach (var command in orderedCommands) { - var counts = commandCounts.TryGetValue(command, out var stored) - ? stored + var counts = commandCounts.TryGetValue(command, out var stored) + ? stored : new int[plotter.Players.Length]; if (!isPartial || counts.Any(x => x > 0)) { diff --git a/ApmWindow.xaml.cs b/ApmWindow.xaml.cs index dfdcc37..183fb15 100644 --- a/ApmWindow.xaml.cs +++ b/ApmWindow.xaml.cs @@ -112,13 +112,13 @@ namespace AnotherReplayReader } return plotter.PlayerLifes[i] < begin ? "玩家已战败" - : $"{v:#.##}"; + : $"{v:0.##}"; } - list.Insert(apmIndex, new(DataRow.PartialApmRow, + list.Insert(apmIndex, new(DataRow.PartialApmRow, instantApms.Select(PartialApmToString))); } - list.Insert(apmIndex, new(DataRow.AverageApmRow, - avg.Select(v => $"{v:#.##}"))); + list.Insert(apmIndex, new(DataRow.AverageApmRow, + avg.Select(v => $"{v:0.##}"))); return (list, data, plotter.ReplayLength, isPartial); }); @@ -203,7 +203,7 @@ namespace AnotherReplayReader private int NormalizeResolutionInput(string text) { - if(!int.TryParse(text, out var value)) + if (!int.TryParse(text, out var value)) { value = (int)PlotResolution.TotalSeconds; } diff --git a/ReplayFile/ReplayFooter.cs b/ReplayFile/ReplayFooter.cs index 55e661a..df99320 100644 --- a/ReplayFile/ReplayFooter.cs +++ b/ReplayFile/ReplayFooter.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; @@ -62,18 +61,21 @@ namespace AnotherReplayReader.ReplayFile _data = new byte[] { 0x02, 0x1A, 0x00, 0x00, 0x00 }; } - List? TryGetKillDeathRatio() + public float[]? TryGetKillDeathRatios() { if (_data.Length < 24) { return null; } - var ratios = new List(); + var ratios = new float[6]; using var stream = new MemoryStream(_data, _data.Length - 24, 24); using var reader = new BinaryReader(stream); - ratios.Add(reader.ReadSingle()); - throw new NotImplementedException(); + for (var i = 0; i < ratios.Length; ++i) + { + ratios[i] = reader.ReadSingle(); + } + return ratios; } public void WriteTo(BinaryWriter writer)