Skip to content

Commit

Permalink
ignore text comments
Browse files Browse the repository at this point in the history
  • Loading branch information
stewieoO committed Nov 5, 2024
1 parent 9f10013 commit b748c14
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Nodsoft.WowsReplaysUnpack.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Nodsoft.WowsReplaysUnpack.Console.Samples.EntitySerializer;
using Nodsoft.WowsReplaysUnpack.Console.Tests;

// await new SyncTest().ExecuteAsync();
await new EntitySerializerSample().ExecuteAsync();
//await new EntitySerializerSample().ExecuteAsync();
new BrokenReplayTests().Execute();
27 changes: 27 additions & 0 deletions Nodsoft.WowsReplaysUnpack.Console/Tests/BrokenReplayTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.Extensions.DependencyInjection;
using Nodsoft.WowsReplaysUnpack.Services;
using System.IO;

namespace Nodsoft.WowsReplaysUnpack.Console.Tests;

public class BrokenReplayTests
{
public void Execute()
{
var services = new ServiceCollection();
services.AddLogging();
services.AddWowsReplayUnpacker();
var sp = services.BuildServiceProvider();

var path = @"E:\Downloads\20241104_185414_PWSB719-Niord_19_OC_prey.wowsreplay";
// var path =
// @"E:\Downloads\5915c052ee734ef68f0b6b0065a0fe52-20241027_003342_PHSD509-Groningen_45_Zigzag.wowsreplay";
var fs = File.OpenRead(path);

var replay = sp.GetRequiredService<IReplayUnpackerFactory>()
.GetUnpacker()
.Unpack(fs);

System.Console.WriteLine();
}
}
15 changes: 10 additions & 5 deletions Nodsoft.WowsReplaysUnpack.Core/Definitions/EntityDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Nodsoft.WowsReplaysUnpack.Core.Definitions;
public sealed class EntityDefinition : BaseDefinition
{
private const string ENTITY_DEFS = "entity_defs";

private List<EntityMethodDefinition> CellMethods { get; set; } = new();
// public List<EntityMethodDefinition> BaseMethods { get; set; } = new();

Expand All @@ -18,8 +18,10 @@ public sealed class EntityDefinition : BaseDefinition
/// </summary>
public List<EntityMethodDefinition> ClientMethods { get; private set; } = new();

private EntityDefinition(Version clientVersion, IDefinitionStore definitionStore, string name)
: base(clientVersion, definitionStore, name, ENTITY_DEFS) { }
private EntityDefinition(Version clientVersion, IDefinitionStore definitionStore, string name)
: base(clientVersion, definitionStore, name, ENTITY_DEFS)
{
}

public static EntityDefinition Create(Version clientVersion, IDefinitionStore definitionStore, string name)
{
Expand All @@ -28,11 +30,12 @@ public static EntityDefinition Create(Version clientVersion, IDefinitionStore de
{
throw new Exception("XmlDocument has to be set");
}

definition.ParseDefinitionFile(definition.XmlDocument);
definition.XmlDocument = null; // Xml does not need to stay in memory
return definition;
}

/// <summary>
/// Parses a .def file for the entity definition.
/// </summary>
Expand All @@ -57,7 +60,9 @@ private void ParseMethods(XmlNode? methodsNode, ICollection<EntityMethodDefiniti

foreach (XmlNode node in methodsNode.ChildNodes())
{
if (node is not XmlElement)
continue;
methods.Add(new(ClientVersion, DefinitionStore, node));
}
}
}
}

0 comments on commit b748c14

Please sign in to comment.