Added option to not read ordinary ticks and BugCheckers are public
This commit is contained in:
parent
faf3567c02
commit
3a3947a3e7
@ -55,6 +55,12 @@ public class Benchy
|
|||||||
SsReplayReader.ReadFull();
|
SsReplayReader.ReadFull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
public void ReadFullWithoutOrdinaryTicks()
|
||||||
|
{
|
||||||
|
SsReplayReader.ReadFull(false);
|
||||||
|
}
|
||||||
|
|
||||||
[GlobalCleanup]
|
[GlobalCleanup]
|
||||||
public void Cleanup()
|
public void Cleanup()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,26 +6,26 @@ namespace SoulstormReplayReader.Core.Domain.Player;
|
|||||||
|
|
||||||
public class PlayerBugChecker
|
public class PlayerBugChecker
|
||||||
{
|
{
|
||||||
private readonly List<BugCheckerBase> _bugCheckers = new();
|
public readonly List<BugCheckerBase> BugCheckers = new();
|
||||||
|
|
||||||
public PlayerBugChecker Add(BugCheckerBase checker)
|
public PlayerBugChecker Add(BugCheckerBase checker)
|
||||||
{
|
{
|
||||||
_bugCheckers.Add(checker);
|
BugCheckers.Add(checker);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Check(IGameAction action)
|
public void Check(IGameAction action)
|
||||||
{
|
{
|
||||||
_bugCheckers.ForEach(bugChecker => bugChecker.Check(action));
|
BugCheckers.ForEach(bugChecker => bugChecker.Check(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool HasAccusations() => _bugCheckers.Any(checker => checker.HasAccusation);
|
public bool HasAccusations() => BugCheckers.Any(checker => checker.HasAccusation);
|
||||||
|
|
||||||
public string GetAccusationsList()
|
public string GetAccusationsList()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
foreach (var checker in _bugCheckers.Where(checker => checker.HasAccusation))
|
foreach (var checker in BugCheckers.Where(checker => checker.HasAccusation))
|
||||||
{
|
{
|
||||||
sb.AppendLine(checker.Accusation);
|
sb.AppendLine(checker.Accusation);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,11 +48,11 @@ public sealed class SsReplayReader(Stream stream) : IDisposable
|
|||||||
public ReplayModel Replay { get; set; }
|
public ReplayModel Replay { get; set; }
|
||||||
public int CurrentTick { get; set; }
|
public int CurrentTick { get; set; }
|
||||||
|
|
||||||
public ReplayModel ReadFull()
|
public ReplayModel ReadFull(bool readOrdinaryTicks = true)
|
||||||
{
|
{
|
||||||
ReadInfo();
|
ReadInfo();
|
||||||
|
|
||||||
ReadTicks();
|
ReadTicks(readOrdinaryTicks);
|
||||||
|
|
||||||
return Replay;
|
return Replay;
|
||||||
}
|
}
|
||||||
@ -371,7 +371,7 @@ public sealed class SsReplayReader(Stream stream) : IDisposable
|
|||||||
return player;
|
return player;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ReadTicks()
|
private void ReadTicks(bool readOrdinaryTicks)
|
||||||
{
|
{
|
||||||
if (Replay.Version < ReplayVersion._1_2) // Действия в старых версиях читаются не правильно
|
if (Replay.Version < ReplayVersion._1_2) // Действия в старых версиях читаются не правильно
|
||||||
{
|
{
|
||||||
@ -387,7 +387,7 @@ public sealed class SsReplayReader(Stream stream) : IDisposable
|
|||||||
|
|
||||||
// Иногда в конце реплея появляются остаточные байты
|
// Иногда в конце реплея появляются остаточные байты
|
||||||
while (_binaryReader.BytesLeft >= 17)
|
while (_binaryReader.BytesLeft >= 17)
|
||||||
ReadTick();
|
ReadTick(readOrdinaryTicks);
|
||||||
|
|
||||||
#if DEBUGLOGGING
|
#if DEBUGLOGGING
|
||||||
if (_binaryReader.HasBytes)
|
if (_binaryReader.HasBytes)
|
||||||
@ -423,14 +423,14 @@ public sealed class SsReplayReader(Stream stream) : IDisposable
|
|||||||
// - - action 2
|
// - - action 2
|
||||||
// - player chunk 2:
|
// - player chunk 2:
|
||||||
// - - action 1
|
// - - action 1
|
||||||
private void ReadTick()
|
private void ReadTick(bool readOrdinaryTicks)
|
||||||
{
|
{
|
||||||
var tickType = (TickType)_binaryReader.ReadInt32();
|
var tickType = (TickType)_binaryReader.ReadInt32();
|
||||||
var tickSize = _binaryReader.ReadInt32();
|
var tickSize = _binaryReader.ReadInt32();
|
||||||
|
|
||||||
if (tickType == TickType.Normal)
|
if (tickType == TickType.Normal)
|
||||||
{
|
{
|
||||||
if (tickSize == 17)
|
if (tickSize == 17 || !readOrdinaryTicks)
|
||||||
{
|
{
|
||||||
_binaryReader.Skip(tickSize); // Всегда 17 байт
|
_binaryReader.Skip(tickSize); // Всегда 17 байт
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user