Nodsoft.WowsReplaysUnpack
3.0.1-beta-gf63fa17372
See the version list below for details.
dotnet add package Nodsoft.WowsReplaysUnpack --version 3.0.1-beta-gf63fa17372
NuGet\Install-Package Nodsoft.WowsReplaysUnpack -Version 3.0.1-beta-gf63fa17372
<PackageReference Include="Nodsoft.WowsReplaysUnpack" Version="3.0.1-beta-gf63fa17372" />
paket add Nodsoft.WowsReplaysUnpack --version 3.0.1-beta-gf63fa17372
#r "nuget: Nodsoft.WowsReplaysUnpack, 3.0.1-beta-gf63fa17372"
// Install Nodsoft.WowsReplaysUnpack as a Cake Addin #addin nuget:?package=Nodsoft.WowsReplaysUnpack&version=3.0.1-beta-gf63fa17372&prerelease // Install Nodsoft.WowsReplaysUnpack as a Cake Tool #tool nuget:?package=Nodsoft.WowsReplaysUnpack&version=3.0.1-beta-gf63fa17372&prerelease
<img align="right" src="logo.png" alt="logo" width="200"/>
WoWS-ReplaysUnpack
A C# file unpacking library for World of Warships Replays, inspired by Monstrofil's replays_unpack.
Information before using the library
The library supports only World of Warships replays starting with version 0.10.10. Trying to use an older replay can result in unexpected errors when processing the replay.
How to install
Install NuGet
Then, install from the package manager console:
PM> Install-Package Nodsoft.WowsReplaysUnpack
Or from the .NET CLI as:
dotnet add package Nodsoft.WowsReplaysUnpack
How to use
Add the service to an IServiceCollection
services.AddWowsReplayUnpacker();
Get the factory, get the unpacker from the factory and call the Unpack
method with either a Stream
or byte[]
ReplayUnpackerFactory replayUnpackerFactory = serviceProvider.GetService<IReplayUnpackerFactory>();
UnpackedReplay unpackedReplay = replayUnpackerFactory
.GetUnpacker()
.Unpack(File.OpenRead("my-replay.wowsreplay"));
Custom Implementations
You can provide custom implementations of certain services.
services.Snippet.AddWowsReplayUnpacker(builder =>
{
builder.AddReplayController<MyCustomReplayController, MyCustomReplay>();
builder.WithReplayDataParser<MyCustomReplayDataParser>();
builder.WithDefinitionLoader<MyCustomDefinitionLoader>();
builder.WithDefinitionStore<MyCustomDefinitionStore>();
})
DefinitionStore
Responsible for managing, giving access and caching the .def
files (used for type and property mapping).
Uses the IDefinitionLoader
for resolving non-cached files once.
Your custom definition store has to implement IDefinitionStore
or extend DefaultDefinitionStore
DefinitionLoader
Responsible for loading the actual definition files.
Your custom definition store has to implement IDefinitionLoader
.
The default loader is the AssemblyDefinitionLoader.
You can optionally use the FileSystemDefinitionLoader
by installing the Nodsoft.WowsReplaysUnpack.FileStore
nuget package.
ReplayDataParser
Responsible for parsing the binary packets to the specific network packets.
Your custom replay data parser has to implement IReplayDataParser
or extend DefaultReplayParser
ReplayController
Responsible for handling parsed network packets and filling the UnpackedReplay with information.
Your custom replay controller has to implement IReplayController<T>
but it is strongly suggested
to use ReplayControllerBase<T>
where T is your custom replay class.
Only one controller can be registered for any replay type.
An example of this is the ExtendedDataController.
To use your custom controller add the replay type to the GetUnpacker()
method.
UnpackedReplay unpackedReplay = replayUnpackerFactory
.GetUnpacker<MyCustomReplay>()
.Unpack(File.OpenRead("my-replay.wowsreplay"));
CVE Check Only Implementation
In the library you get a custom implementation ready to use for when you only want to check the CVE .
CveCheckOnlyController
It skips all network packets except the affected ones.
You can add it with the AddCveCheckController()
method and get the unpacker with GetCveCheckUnpacker()
Extend the replay data
When implementing your own controller and extending ReplayControllerBase<T>
;
The replay class has to extend UnpackedReplay
.
That way you can add extra properties.
You can see this in action here
Method/Property Subscriptions
When implementing your own controller and extending ReplayControllerBase<T>
you can subscribe to EntityMethods
and EntityProperty
calls by adding a method with an attribute.
You will have to install the Nodsoft.WowsReplaysUnpack.Generators
nuget package and add the [ReplayController]
attribute to your controller class.
This will generate the required logic to make the dynamic subscriptions work.
Methods
MethodSubscription("EntityName", "MethodName")
You have a few extra properties on the attribute to configure how the method will be called:
bool IncludeEntity
⇒ When true
it will include the Entity entity
parameter
bool IncludePacketTime
⇒ When true
it will include the float packetTime
parameter
bool ParamsAsDictionary
⇒ When true
the last paremeter will be Dictionary<string, object?> arguments
/ When false
the parameters have to match the actual packet parameters in order and type exactly. When they don't match you will get an exception telling you the required parameters.
bool Priority
⇒ Defines the order in which methods are called when you have multiple subscriptions on the same method. Smaller = Earlier. Don't use -1.
Example:
[MethodSubscription("Avatar", "onArenaStateReceived")]
public void OnArenaStateReceived(Entity entity, float packetTime, ...)
{
}
Properties
PropertySubscription("EntityName", "PropertyName")
There are no extra properties available and the Entity entity
parameter is always there.
Example:
[PropertySubscription("Avatar", "selectedWeapon")]
public void SelectedWeaponChanged(Entity entity, uint selectedWeaponId)
{
}
ExtendedData Library
You can install the Nodsoft.WowsReplaysUnpack.ExtendedData
package from nuget to get a ready to use implementation that fills the replay with more information than the default controller.
Currently included in the ExtendedDataReplay
:
- Player Information
- Chat Messages
How to use
services.AddWowsReplayUnpacker(builder =>
{
builder.AddExtendedData();
});
ExtendedDataReplay unpackedReplay = replayUnpackerFactory
.GetExtendedDataUnpacker()
.Unpack(File.OpenRead("my-replay.wowsreplay"));
Additional Entities
The replay contains a multitude of other entities. If you want to retreive those you have two convenient options we provide.
Option 1 - Extension Methods
// Step 1 - Retreive the entity properties you're interested in
var battleLogicProperties = replay.Entities.Single(e => e.Value.Name == "BattleLogic").Value.Properties;
// Step 2 - Use extension methods to cast the properties to their actual type
battleLogicProperties.GetAsDict("propertyName");
battleLogicProperties.GetAsArr("propertyName");
battleLogicProperties.GetAsValue<short>("propertyName");
An example of this can be seen here in the ManualExtensions
method.
Option 2 - Strong Type Serializing
Requires the Nodsoft.WowsReplaysUnpack.Generators
nuget package.
// Step 1 - Create a class representing the entity annotated with the SerializableEntity attribute
[SerializableEntity]
public class BattleLogic {
[DataMember(Name = "state")]
public State State { get; set; } = null!;
...
}
// Step 2 - Use extension method on the replay to deserialize the entity
var battleLogic = replay.DeserializeEntity<BattleLogic>("BattleLogic");
For collections only List<T>
is currently supported.
The property mapping is case-sensitive. So you either have to name your properties exactly like they are in the entities properties dictionary or use the DataMember
attribute.
An example of this can be seen here in the Serializer
method.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 8.0.1)
- Microsoft.Extensions.Options (>= 8.0.0)
- Nodsoft.WowsReplaysUnpack.Core (>= 3.0.1-beta-gf63fa17372)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Nodsoft.WowsReplaysUnpack:
Package | Downloads |
---|---|
Nodsoft.WowsReplaysUnpack.ExtendedData
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
3.0.17-beta-g0a0d613870 | 81 | 11/28/2024 |
3.0.17-beta | 71 | 11/28/2024 |
3.0.16-beta-g3c4d61f874 | 106 | 11/5/2024 |
3.0.13-beta-gbe279605d9 | 114 | 10/3/2024 |
3.0.12-beta-g568c749ef4 | 104 | 9/5/2024 |
3.0.11-beta-g744c7b79c3 | 157 | 8/8/2024 |
3.0.10-beta-g43912a5a51 | 121 | 7/18/2024 |
3.0.9-beta-gf11948c8ef | 118 | 6/27/2024 |
3.0.8-beta-gd38788540b | 120 | 6/14/2024 |
3.0.7-beta-g06221c5d51 | 128 | 5/17/2024 |
3.0.6-beta-g27322c409e | 119 | 5/17/2024 |
3.0.3-beta-g359d6d93c4 | 112 | 5/16/2024 |
3.0.2-beta-gaca613e98a | 114 | 5/16/2024 |
3.0.1-beta-gf63fa17372 | 74 | 5/11/2024 |
2.0.29-alpha-g987beebb2b | 181 | 8/18/2023 |
2.0.26-alpha-g4e3dff99ff | 144 | 8/17/2023 |
2.0.22-alpha-g89b1099182 | 198 | 7/23/2023 |
2.0.16-alpha-gfaded6094c | 186 | 7/22/2023 |
2.0.15-alpha-g38541b6d25 | 210 | 6/22/2023 |
2.0.14 | 96 | 11/28/2024 |
2.0.14-alpha-g0002f59a1d | 181 | 5/25/2023 |
2.0.13 | 100 | 10/31/2024 |
2.0.13-alpha-g90583dc2c5 | 357 | 4/20/2023 |
2.0.12 | 97 | 10/3/2024 |
2.0.12-alpha-g4b27da27ea | 181 | 4/20/2023 |
2.0.11 | 133 | 9/5/2024 |
2.0.11-alpha-g92d3716eff | 288 | 3/23/2023 |
2.0.10 | 124 | 8/8/2024 |
2.0.10-alpha-g3e240c8566 | 241 | 2/16/2023 |
2.0.9 | 117 | 7/18/2024 |
2.0.9-alpha-g02ef2eaf60 | 198 | 1/19/2023 |
2.0.8 | 111 | 7/11/2024 |
2.0.8-alpha-g2a9a24924f | 176 | 12/12/2022 |
2.0.7 | 119 | 6/26/2024 |
2.0.6 | 149 | 6/13/2024 |
2.0.6-alpha-gcbcb7f6a80 | 183 | 12/8/2022 |
2.0.5 | 165 | 5/16/2024 |
2.0.5-alpha-g7ea078df7a | 227 | 11/19/2022 |
2.0.4 | 199 | 4/11/2024 |
2.0.3 | 200 | 3/14/2024 |
2.0.3-alpha-g12f645426c | 250 | 10/6/2022 |
2.0.2 | 312 | 2/8/2024 |
2.0.2-alpha-g6916206934 | 264 | 9/24/2022 |
2.0.1 | 247 | 1/23/2024 |
2.0.1-g7a94259f07 | 143 | 2/7/2024 |
2.0.1-alpha-g920402ee9e | 207 | 9/9/2022 |
1.1.26 | 140 | 1/23/2024 |
1.1.25-g2832215038 | 113 | 1/23/2024 |
1.1.24-g30ae630d7d | 141 | 1/11/2024 |
1.1.23-g00d5114060 | 135 | 12/7/2023 |
1.1.22-gabca2f1262 | 126 | 12/7/2023 |
1.1.21-g89971f3a87 | 120 | 11/26/2023 |
1.1.20-g5b1471f83c | 125 | 11/26/2023 |
1.1.19-g21acddabf5 | 127 | 11/23/2023 |
1.1.17-gfc59a0dbe8 | 142 | 11/9/2023 |
1.1.16-g03f94d799b | 126 | 10/19/2023 |
1.1.11 | 299 | 10/12/2023 |
1.1.10-gbaec701b3f | 126 | 10/12/2023 |
1.1.9-g60c84b7c31 | 139 | 9/14/2023 |
1.1.8-g3fc29955fd | 163 | 9/14/2023 |
1.1.7 | 191 | 8/21/2023 |
1.1.4 | 215 | 7/21/2023 |
1.1.3 | 187 | 7/21/2023 |
1.1.2 | 247 | 7/6/2023 |
1.0.11 | 640 | 9/8/2022 |
1.0.11-gaf2ec4da01 | 193 | 9/9/2022 |
1.0.10 | 635 | 9/8/2022 |
1.0.10-gf865b963c8 | 210 | 9/8/2022 |
1.0.9-pre-g35415cdef7 | 201 | 9/8/2022 |
1.0.8-pre-g8097eaf5af | 222 | 9/8/2022 |
1.0.7-pre-gba54b08e7a | 200 | 9/8/2022 |
1.0.5-pre-gb7fb7564ee | 223 | 8/5/2022 |
1.0.4-pre-g1025b3c13d | 200 | 8/5/2022 |
1.0.3-pre-g0b9499d17c | 211 | 7/26/2022 |
1.0.0 | 656 | 7/25/2022 |
1.0.0-pre1 | 218 | 7/23/2022 |
0.5.3 | 488 | 7/16/2022 |
0.5.2 | 636 | 5/27/2022 |
0.5.1 | 502 | 3/18/2022 |
0.5.0 | 584 | 1/19/2022 |
0.5.0-pre1 | 286 | 12/9/2021 |
0.4.0 | 356 | 12/5/2021 |
0.3.0 | 1,004 | 12/1/2021 |
0.2.0-dev1 | 1,194 | 11/28/2021 |