From e16eefa1662940d6db78361b2b9232641c182047 Mon Sep 17 00:00:00 2001 From: lanyizi Date: Thu, 30 Jan 2025 12:53:12 +0100 Subject: [PATCH] fix --- Apm/ApmPlotter.cs | 11 +++++++---- ReplayFile/RA3Commands.cs | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Apm/ApmPlotter.cs b/Apm/ApmPlotter.cs index 3c6b1f2..4438217 100644 --- a/Apm/ApmPlotter.cs +++ b/Apm/ApmPlotter.cs @@ -108,7 +108,7 @@ namespace AnotherReplayReader.Apm playerLifes[playerIndex] = estimatedTime; } } - else if (!IsUnknown(commandId) && !IsAuto(commandId)) + else if (!IsUnknown(commandId) && !IsAuto(commandId) && playerIndex >= 0) { if (stricterLifes[playerIndex] < estimatedTime) { @@ -138,7 +138,7 @@ namespace AnotherReplayReader.Apm } foreach (var command in commands) { - if (options.ShouldSkip(command.CommandId)) + if (options.ShouldSkip(command.CommandId) || command.PlayerIndex < 0) { continue; } @@ -164,7 +164,7 @@ namespace AnotherReplayReader.Apm { foreach (var command in commands) { - if (options.ShouldSkip(command.CommandId)) + if (options.ShouldSkip(command.CommandId) || command.PlayerIndex < 0) { continue; } @@ -209,7 +209,10 @@ namespace AnotherReplayReader.Apm { commandCount = playerCommands[command.CommandId] = new int[Players.Length]; } - commandCount[command.PlayerIndex] = commandCount[command.PlayerIndex] + 1; + if (command.PlayerIndex >= 0 && command.PlayerIndex < Players.Length) + { + commandCount[command.PlayerIndex] = commandCount[command.PlayerIndex] + 1; + } } } return playerCommands; diff --git a/ReplayFile/RA3Commands.cs b/ReplayFile/RA3Commands.cs index 777c5ac..3e0882e 100644 --- a/ReplayFile/RA3Commands.cs +++ b/ReplayFile/RA3Commands.cs @@ -45,7 +45,7 @@ namespace AnotherReplayReader.ReplayFile var lastByte = current.ReadBytes(size - 2).Last(); if (lastByte != 0xFF) { - throw new InvalidDataException($"Failed to parse command {command:X}, last byte is {lastByte:X}"); + // throw new InvalidDataException($"Failed to parse command {command:X}, last byte is {lastByte:X}"); } }; }