From c49b22e15289c64d1db0f337e2c28a98335266a0 Mon Sep 17 00:00:00 2001 From: craftycodie Date: Sat, 24 Aug 2024 01:29:24 +0100 Subject: [PATCH] Parse more stats chunks --- WarthogInc/BlfChunks/Author.cs | 2 +- WarthogInc/BlfChunks/BLFChunkReader.cs | 11 +- .../Halo3/BlfChunkNameMap12070.cs | 4 + WarthogInc/BlfChunks/ContentHeader.cs | 2 +- WarthogInc/BlfChunks/EndOfFile.cs | 2 +- WarthogInc/BlfChunks/FileQueue.cs | 2 +- WarthogInc/BlfChunks/GameSet1.cs | 2 +- WarthogInc/BlfChunks/GameSet15.cs | 2 +- WarthogInc/BlfChunks/GameSet2.cs | 2 +- WarthogInc/BlfChunks/GameSet3.cs | 2 +- WarthogInc/BlfChunks/GameSet6.cs | 2 +- WarthogInc/BlfChunks/GameVariant.cs | 2 +- .../BlfChunks/HopperConfigurationTable11.cs | 2 +- .../BlfChunks/HopperConfigurationTable2.cs | 2 +- .../BlfChunks/HopperConfigurationTable27.cs | 2 +- .../BlfChunks/HopperConfigurationTable8.cs | 2 +- .../BlfChunks/HopperConfigurationTable9.cs | 2 +- WarthogInc/BlfChunks/IBLFChunk.cs | 2 +- .../BlfChunks/MachineNetworkStatistics.cs | 2 +- WarthogInc/BlfChunks/Manifest.cs | 2 +- WarthogInc/BlfChunks/Manifest_PC.cs | 2 +- WarthogInc/BlfChunks/MapManifest.cs | 2 +- WarthogInc/BlfChunks/MapVariant.cs | 2 +- .../BlfChunks/MatchmakingBanhammerMessages.cs | 2 +- .../MatchmakingHopperDescriptions1.cs | 2 +- .../MatchmakingHopperDescriptions2.cs | 2 +- .../MatchmakingHopperDescriptions3.cs | 2 +- .../BlfChunks/MatchmakingHopperStatistics.cs | 2 +- .../MatchmakingHopperStatistics_PC.cs | 2 +- WarthogInc/BlfChunks/MatchmakingOptions.cs | 31 +- WarthogInc/BlfChunks/MatchmakingTips.cs | 2 +- WarthogInc/BlfChunks/MessageOfTheDay.cs | 2 +- WarthogInc/BlfChunks/MessageOfTheDayPopup.cs | 2 +- .../BlfChunks/MessageOfTheDayPopup_PC.cs | 2 +- .../BlfChunks/MultiplayerPlayerStatistics.cs | 569 ++++++++++++++++++ .../MultiplayerPlayerVsPlayerStatistics.cs | 85 +++ WarthogInc/BlfChunks/MultiplayerPlayers.cs | 2 +- .../BlfChunks/MultiplayerTeamStatistics.cs | 170 ++++++ WarthogInc/BlfChunks/MultiplayerTeams.cs | 2 +- WarthogInc/BlfChunks/NagMessage.cs | 2 +- WarthogInc/BlfChunks/NetworkConfiguration.cs | 2 +- WarthogInc/BlfChunks/PackedGameVariant10.cs | 2 +- WarthogInc/BlfChunks/PackedGameVariant2.cs | 2 +- WarthogInc/BlfChunks/PackedMapVariant.cs | 2 +- WarthogInc/BlfChunks/Parent.cs | 59 ++ WarthogInc/BlfChunks/RecentPlayers.cs | 2 +- WarthogInc/BlfChunks/ServiceRecordIdentity.cs | 2 +- WarthogInc/BlfChunks/StartOfFile.cs | 2 +- WarthogInc/BlfChunks/UserBanhammer.cs | 2 +- WarthogInc/BlfChunks/UserPlayerData.cs | 2 +- WarthogInc/BlfFile.cs | 4 +- 51 files changed, 959 insertions(+), 60 deletions(-) create mode 100644 WarthogInc/BlfChunks/MultiplayerPlayerStatistics.cs create mode 100644 WarthogInc/BlfChunks/MultiplayerPlayerVsPlayerStatistics.cs create mode 100644 WarthogInc/BlfChunks/MultiplayerTeamStatistics.cs create mode 100644 WarthogInc/BlfChunks/Parent.cs diff --git a/WarthogInc/BlfChunks/Author.cs b/WarthogInc/BlfChunks/Author.cs index 20403f2..94b4d5b 100644 --- a/WarthogInc/BlfChunks/Author.cs +++ b/WarthogInc/BlfChunks/Author.cs @@ -65,7 +65,7 @@ public void WriteChunk(ref BitStream hoppersStream) } } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { var buildNameBytes = new byte[16]; var buildNameLen = -1; diff --git a/WarthogInc/BlfChunks/BLFChunkReader.cs b/WarthogInc/BlfChunks/BLFChunkReader.cs index 396992a..58d6749 100644 --- a/WarthogInc/BlfChunks/BLFChunkReader.cs +++ b/WarthogInc/BlfChunks/BLFChunkReader.cs @@ -12,7 +12,14 @@ namespace SunriseBlfTool.BlfChunks { public class BLFChunkReader { - public IBLFChunk ReadChunk(ref BitStream outputStream, AbstractBlfChunkNameMap chunkNameMap) + AbstractBlfChunkNameMap chunkNameMap; + + public BLFChunkReader(AbstractBlfChunkNameMap chunkNameMap) + { + this.chunkNameMap = chunkNameMap; + } + + public IBLFChunk ReadChunk(ref BitStream outputStream) { int chunkStartOffset = outputStream.ByteOffset; BLFChunkHeader header = new BLFChunkHeader(); @@ -24,7 +31,7 @@ public IBLFChunk ReadChunk(ref BitStream outputStream, Abstrac try { IBLFChunk chunk = chunkNameMap.GetChunk(header.blfChunkName); - chunk.ReadChunk(ref outputStream); + chunk.ReadChunk(ref outputStream, this); // In case the full chunk isn't read (perhaps it's zero-padded), we ensure we're moved on to the next chunk. outputStream.Seek(chunkStartOffset + (int)header.chunkLength); diff --git a/WarthogInc/BlfChunks/ChunkNameMaps/Halo3/BlfChunkNameMap12070.cs b/WarthogInc/BlfChunks/ChunkNameMaps/Halo3/BlfChunkNameMap12070.cs index ab404a7..44ccd12 100644 --- a/WarthogInc/BlfChunks/ChunkNameMaps/Halo3/BlfChunkNameMap12070.cs +++ b/WarthogInc/BlfChunks/ChunkNameMaps/Halo3/BlfChunkNameMap12070.cs @@ -38,8 +38,12 @@ private void RegisterChunks() RegisterChunk(); RegisterChunk(); RegisterChunk(); + RegisterChunk(); + RegisterChunk(); + RegisterChunk(); RegisterChunk(); RegisterChunk(); + RegisterChunk(); } public override string GetVersion() diff --git a/WarthogInc/BlfChunks/ContentHeader.cs b/WarthogInc/BlfChunks/ContentHeader.cs index c410c12..e963cc2 100644 --- a/WarthogInc/BlfChunks/ContentHeader.cs +++ b/WarthogInc/BlfChunks/ContentHeader.cs @@ -100,7 +100,7 @@ public void WriteChunk(ref BitStream hoppersStream) hoppersStream.WriteLong(gameId, 64); } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { buildNumber = hoppersStream.Read(16); mapVersion = hoppersStream.Read(16); diff --git a/WarthogInc/BlfChunks/EndOfFile.cs b/WarthogInc/BlfChunks/EndOfFile.cs index def463f..dbc4117 100644 --- a/WarthogInc/BlfChunks/EndOfFile.cs +++ b/WarthogInc/BlfChunks/EndOfFile.cs @@ -37,7 +37,7 @@ public void WriteChunk(ref BitStream hoppersStream) //hoppersStream.Seek(hoppersStream.NextByteIndex); } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { lengthUpToEOF = hoppersStream.Read(32); unknown = hoppersStream.Read(8); diff --git a/WarthogInc/BlfChunks/FileQueue.cs b/WarthogInc/BlfChunks/FileQueue.cs index 2fb8e79..85f1f52 100644 --- a/WarthogInc/BlfChunks/FileQueue.cs +++ b/WarthogInc/BlfChunks/FileQueue.cs @@ -36,7 +36,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/GameSet1.cs b/WarthogInc/BlfChunks/GameSet1.cs index 051f4cb..3bc09fb 100644 --- a/WarthogInc/BlfChunks/GameSet1.cs +++ b/WarthogInc/BlfChunks/GameSet1.cs @@ -55,7 +55,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/GameSet15.cs b/WarthogInc/BlfChunks/GameSet15.cs index fcd3c48..4d1eebc 100644 --- a/WarthogInc/BlfChunks/GameSet15.cs +++ b/WarthogInc/BlfChunks/GameSet15.cs @@ -77,7 +77,7 @@ private void WriteCompressedHopperData(ref BitStream hoppersSt hoppersStream.SeekRelative(compressedHopperTableLength + 4); } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { var decompressedStream = ReadCompressedHopperData(ref hoppersStream); diff --git a/WarthogInc/BlfChunks/GameSet2.cs b/WarthogInc/BlfChunks/GameSet2.cs index c3bea3d..7b46c37 100644 --- a/WarthogInc/BlfChunks/GameSet2.cs +++ b/WarthogInc/BlfChunks/GameSet2.cs @@ -55,7 +55,7 @@ public ushort GetVersion() return 2; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/GameSet3.cs b/WarthogInc/BlfChunks/GameSet3.cs index 275a63c..65f6714 100644 --- a/WarthogInc/BlfChunks/GameSet3.cs +++ b/WarthogInc/BlfChunks/GameSet3.cs @@ -56,7 +56,7 @@ public ushort GetVersion() return 3; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/GameSet6.cs b/WarthogInc/BlfChunks/GameSet6.cs index cce33b1..1e24d8e 100644 --- a/WarthogInc/BlfChunks/GameSet6.cs +++ b/WarthogInc/BlfChunks/GameSet6.cs @@ -39,7 +39,7 @@ public ushort GetVersion() return 6; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { byte gameEntryCount = hoppersStream.Read(6); gameEntries = new GameEntry[gameEntryCount]; diff --git a/WarthogInc/BlfChunks/GameVariant.cs b/WarthogInc/BlfChunks/GameVariant.cs index b6226cf..f004941 100644 --- a/WarthogInc/BlfChunks/GameVariant.cs +++ b/WarthogInc/BlfChunks/GameVariant.cs @@ -94,7 +94,7 @@ public ushort GetVersion() return 3; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); diff --git a/WarthogInc/BlfChunks/HopperConfigurationTable11.cs b/WarthogInc/BlfChunks/HopperConfigurationTable11.cs index ab06db8..3ac1128 100644 --- a/WarthogInc/BlfChunks/HopperConfigurationTable11.cs +++ b/WarthogInc/BlfChunks/HopperConfigurationTable11.cs @@ -43,7 +43,7 @@ public ushort GetVersion() return 11; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { byte categoryCount = hoppersStream.Read(3); categories = new HopperCategory[categoryCount]; diff --git a/WarthogInc/BlfChunks/HopperConfigurationTable2.cs b/WarthogInc/BlfChunks/HopperConfigurationTable2.cs index b5c1a0c..cbd136a 100644 --- a/WarthogInc/BlfChunks/HopperConfigurationTable2.cs +++ b/WarthogInc/BlfChunks/HopperConfigurationTable2.cs @@ -175,7 +175,7 @@ public ushort GetVersion() return 2; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/HopperConfigurationTable27.cs b/WarthogInc/BlfChunks/HopperConfigurationTable27.cs index cd61c80..e851c60 100644 --- a/WarthogInc/BlfChunks/HopperConfigurationTable27.cs +++ b/WarthogInc/BlfChunks/HopperConfigurationTable27.cs @@ -80,7 +80,7 @@ private void WriteCompressedHopperData(ref BitStream hoppersSt hoppersStream.SeekRelative(compressedHopperTableLength + 4); } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { var decompressedStream = ReadCompressedHopperData(ref hoppersStream); diff --git a/WarthogInc/BlfChunks/HopperConfigurationTable8.cs b/WarthogInc/BlfChunks/HopperConfigurationTable8.cs index fc7dfe2..9f9ec4f 100644 --- a/WarthogInc/BlfChunks/HopperConfigurationTable8.cs +++ b/WarthogInc/BlfChunks/HopperConfigurationTable8.cs @@ -217,7 +217,7 @@ public ushort GetVersion() return 8; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/HopperConfigurationTable9.cs b/WarthogInc/BlfChunks/HopperConfigurationTable9.cs index 9e1af85..0ff949b 100644 --- a/WarthogInc/BlfChunks/HopperConfigurationTable9.cs +++ b/WarthogInc/BlfChunks/HopperConfigurationTable9.cs @@ -220,7 +220,7 @@ public ushort GetVersion() return 9; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/IBLFChunk.cs b/WarthogInc/BlfChunks/IBLFChunk.cs index 38adbb8..affb664 100644 --- a/WarthogInc/BlfChunks/IBLFChunk.cs +++ b/WarthogInc/BlfChunks/IBLFChunk.cs @@ -15,6 +15,6 @@ public interface IBLFChunk public string GetName(); public uint GetLength(); public void WriteChunk(ref BitStream hoppersStream); - public void ReadChunk(ref BitStream hoppersStream); + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader); } } diff --git a/WarthogInc/BlfChunks/MachineNetworkStatistics.cs b/WarthogInc/BlfChunks/MachineNetworkStatistics.cs index 3fa4242..1def39a 100644 --- a/WarthogInc/BlfChunks/MachineNetworkStatistics.cs +++ b/WarthogInc/BlfChunks/MachineNetworkStatistics.cs @@ -54,7 +54,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/Manifest.cs b/WarthogInc/BlfChunks/Manifest.cs index 3af251c..15ec0a1 100644 --- a/WarthogInc/BlfChunks/Manifest.cs +++ b/WarthogInc/BlfChunks/Manifest.cs @@ -49,7 +49,7 @@ public void SetFileHash(string filePath, byte[] hash) } } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { int fileCount = hoppersStream.Read(32); files = new FileEntry[fileCount]; diff --git a/WarthogInc/BlfChunks/Manifest_PC.cs b/WarthogInc/BlfChunks/Manifest_PC.cs index b230fde..0621443 100644 --- a/WarthogInc/BlfChunks/Manifest_PC.cs +++ b/WarthogInc/BlfChunks/Manifest_PC.cs @@ -50,7 +50,7 @@ public void SetFileHash(string filePath, byte[] hash) } } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/MapManifest.cs b/WarthogInc/BlfChunks/MapManifest.cs index e9c5282..5f5d61b 100644 --- a/WarthogInc/BlfChunks/MapManifest.cs +++ b/WarthogInc/BlfChunks/MapManifest.cs @@ -37,7 +37,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { int mapCount = hoppersStream.Read(32); mapRSAs = new MapEntry[mapCount]; diff --git a/WarthogInc/BlfChunks/MapVariant.cs b/WarthogInc/BlfChunks/MapVariant.cs index ecc2585..4562f38 100644 --- a/WarthogInc/BlfChunks/MapVariant.cs +++ b/WarthogInc/BlfChunks/MapVariant.cs @@ -84,7 +84,7 @@ public ushort GetVersion() return 12; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { metadata = new BaseGameVariant.VariantMetadata(ref hoppersStream); mapVariantVersion = hoppersStream.Read(16); diff --git a/WarthogInc/BlfChunks/MatchmakingBanhammerMessages.cs b/WarthogInc/BlfChunks/MatchmakingBanhammerMessages.cs index dba487a..816066c 100644 --- a/WarthogInc/BlfChunks/MatchmakingBanhammerMessages.cs +++ b/WarthogInc/BlfChunks/MatchmakingBanhammerMessages.cs @@ -37,7 +37,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { int tipCount = hoppersStream.Read(32); messages = new string[tipCount]; diff --git a/WarthogInc/BlfChunks/MatchmakingHopperDescriptions1.cs b/WarthogInc/BlfChunks/MatchmakingHopperDescriptions1.cs index 970ab14..03a8e56 100644 --- a/WarthogInc/BlfChunks/MatchmakingHopperDescriptions1.cs +++ b/WarthogInc/BlfChunks/MatchmakingHopperDescriptions1.cs @@ -49,7 +49,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/MatchmakingHopperDescriptions2.cs b/WarthogInc/BlfChunks/MatchmakingHopperDescriptions2.cs index a9eb34e..8383705 100644 --- a/WarthogInc/BlfChunks/MatchmakingHopperDescriptions2.cs +++ b/WarthogInc/BlfChunks/MatchmakingHopperDescriptions2.cs @@ -49,7 +49,7 @@ public ushort GetVersion() return 2; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/MatchmakingHopperDescriptions3.cs b/WarthogInc/BlfChunks/MatchmakingHopperDescriptions3.cs index 0895194..055a1ec 100644 --- a/WarthogInc/BlfChunks/MatchmakingHopperDescriptions3.cs +++ b/WarthogInc/BlfChunks/MatchmakingHopperDescriptions3.cs @@ -39,7 +39,7 @@ public ushort GetVersion() return 3; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { byte descriptionCount = hoppersStream.Read(6); descriptions = new HopperDescription[descriptionCount]; diff --git a/WarthogInc/BlfChunks/MatchmakingHopperStatistics.cs b/WarthogInc/BlfChunks/MatchmakingHopperStatistics.cs index 0ea7fdc..9bb6fe1 100644 --- a/WarthogInc/BlfChunks/MatchmakingHopperStatistics.cs +++ b/WarthogInc/BlfChunks/MatchmakingHopperStatistics.cs @@ -36,7 +36,7 @@ public ushort GetVersion() return 3; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { totalPlayers = hoppersStream.Read(32); statistics = new HopperPopulation[32]; diff --git a/WarthogInc/BlfChunks/MatchmakingHopperStatistics_PC.cs b/WarthogInc/BlfChunks/MatchmakingHopperStatistics_PC.cs index e4979ef..d18ed34 100644 --- a/WarthogInc/BlfChunks/MatchmakingHopperStatistics_PC.cs +++ b/WarthogInc/BlfChunks/MatchmakingHopperStatistics_PC.cs @@ -45,7 +45,7 @@ public ushort GetVersion() return 3; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { totalPlayers = hoppersStream.Read(32); statistics = new HopperPopulation[32]; diff --git a/WarthogInc/BlfChunks/MatchmakingOptions.cs b/WarthogInc/BlfChunks/MatchmakingOptions.cs index bc316b8..5218f52 100644 --- a/WarthogInc/BlfChunks/MatchmakingOptions.cs +++ b/WarthogInc/BlfChunks/MatchmakingOptions.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json.Converters; using Sewer56.BitStream; using Sewer56.BitStream.ByteStreams; +using SunriseBlfTool.Extensions; using System; using System.Collections.Generic; using System.Linq; @@ -17,11 +18,11 @@ public class MatchmakingOptions : IBLFChunk public bool isRanked; public bool teamsEnabled; public string hopperName; - public ulong drawProbability; - public ulong beta; - public ulong tau; - public ulong expBaseIncrement; - public ulong expPenaltyDecrement; + public int drawProbability; + public float beta; + public float tau; + public int expBaseIncrement; + public int expPenaltyDecrement; public ushort GetAuthentication() { @@ -43,20 +44,16 @@ public uint GetLength() return 0x5C; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { - Console.ForegroundColor = ConsoleColor.DarkYellow; - Console.WriteLine("Warning: mpmo chunk definition is incomplete."); - Console.ResetColor(); - hopperIdentifier = hoppersStream.Read(16); LinkedList nameBytes = new LinkedList(); - for (int si = 0; si < 16; si++) + for (int si = 0; si < 32; si++) { byte left = hoppersStream.Read(8); byte right = hoppersStream.Read(8); - if (((left == 0 && right == 0) || si == 16) && hopperName == null) + if (((left == 0 && right == 0) || si == 32) && hopperName == null) { hopperName = Encoding.BigEndianUnicode.GetString(nameBytes.ToArray()); } @@ -64,7 +61,15 @@ public void ReadChunk(ref BitStream hoppersStream) nameBytes.AddLast(right); } - hoppersStream.SeekRelative(0x3A); + isRanked = hoppersStream.Read(8) > 0; + teamsEnabled = hoppersStream.Read(8) > 0; + xLastIndex = hoppersStream.Read(8); + drawProbability = hoppersStream.Read(32); + beta = hoppersStream.ReadFloat(32); + tau = hoppersStream.ReadFloat(32); + expBaseIncrement = hoppersStream.Read(32); + expPenaltyDecrement = hoppersStream.Read(32); + } public void WriteChunk(ref BitStream hoppersStream) { diff --git a/WarthogInc/BlfChunks/MatchmakingTips.cs b/WarthogInc/BlfChunks/MatchmakingTips.cs index 02fc6c4..83858e3 100644 --- a/WarthogInc/BlfChunks/MatchmakingTips.cs +++ b/WarthogInc/BlfChunks/MatchmakingTips.cs @@ -37,7 +37,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { int tipCount = hoppersStream.Read(32); tips = new string[tipCount]; diff --git a/WarthogInc/BlfChunks/MessageOfTheDay.cs b/WarthogInc/BlfChunks/MessageOfTheDay.cs index 603dc2f..6c564cb 100644 --- a/WarthogInc/BlfChunks/MessageOfTheDay.cs +++ b/WarthogInc/BlfChunks/MessageOfTheDay.cs @@ -35,7 +35,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { uint motdLength = hoppersStream.Read(32); byte[] motdBytes = new byte[motdLength]; diff --git a/WarthogInc/BlfChunks/MessageOfTheDayPopup.cs b/WarthogInc/BlfChunks/MessageOfTheDayPopup.cs index d291b36..412cc4e 100644 --- a/WarthogInc/BlfChunks/MessageOfTheDayPopup.cs +++ b/WarthogInc/BlfChunks/MessageOfTheDayPopup.cs @@ -57,7 +57,7 @@ public ushort GetVersion() return 4; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { motdIdentifier = hoppersStream.Read(32); acceptWaitMilliseconds = hoppersStream.Read(32); diff --git a/WarthogInc/BlfChunks/MessageOfTheDayPopup_PC.cs b/WarthogInc/BlfChunks/MessageOfTheDayPopup_PC.cs index 539d17d..9d574cf 100644 --- a/WarthogInc/BlfChunks/MessageOfTheDayPopup_PC.cs +++ b/WarthogInc/BlfChunks/MessageOfTheDayPopup_PC.cs @@ -64,7 +64,7 @@ public ushort GetVersion() return 4; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/MultiplayerPlayerStatistics.cs b/WarthogInc/BlfChunks/MultiplayerPlayerStatistics.cs new file mode 100644 index 0000000..3c3e3fc --- /dev/null +++ b/WarthogInc/BlfChunks/MultiplayerPlayerStatistics.cs @@ -0,0 +1,569 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Sewer56.BitStream; +using Sewer56.BitStream.ByteStreams; +using SunriseBlfTool.BlfChunks; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace SunriseBlfTool +{ + public class MultiplayerPlayerStatistics : IBLFChunk + { + public PlayerStatistics[] players; + + public ushort GetAuthentication() + { + return 1; + } + + public uint GetLength() + { + return 0x4184; + } + + public string GetName() + { + return "mps1"; + } + + public ushort GetVersion() + { + return 2; + } + + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) + { + byte playerCount = 16; + + hoppersStream.SeekRelative(4); + + players = new PlayerStatistics[playerCount]; + for (int i = 0; i < playerCount; i++) + { + players[i] = new PlayerStatistics(ref hoppersStream); + } + hoppersStream.Seek(hoppersStream.NextByteIndex, 0); + } + + public void WriteChunk(ref BitStream hoppersStream) + { + throw new NotImplementedException(); + } + } + + public class Statistics + { + public short games_played; + public short games_completed; + public short games_won; + public short games_tied; + public short rounds_completed; + public short rounds_won; + public short in_round_score; + public short in_game_total_score; + public short kills; + public short assists; + public short deaths; + public short betrayals; + public short suicides; + public short most_kills_in_a_row; + public short seconds_alive; + public short ctf_flag_scores; + public short ctf_flag_grabs; + public short ctf_flag_carrier_kills; + public short ctf_flag_returns; + public short assault_bomb_arms; + public short assault_bomb_grabs; + public short assault_bomb_disarms; + public short assault_bomb_detonations; + public short oddball_time_with_ball; + public short oddball_unused; + public short oddball_kills_as_carrier; + public short oddball_ball_carrier_kills; + public short king_time_on_hill; + public short king_total_control_time; + public short king_unused0; + public short king_unused1; + public short unused0; + public short unused1; + public short unused2; + public short vip_takedowns; + public short vip_kills_as_vip; + public short vip_guard_time; + public short vip_time_as_vip; + public short vip_lives_as_vip; + public short juggernaut_kills; + public short juggernaut_kills_as_juggernaut; + public short juggernaut_total_control_time; + public short total_wp; + public short juggernaut_unused; + public short territories_owned; + public short territories_captures; + public short territories_ousts; + public short territories_time_in_territory; + public short infection_zombie_kills; + public short infection_infections; + public short infection_time_as_human; + + public Statistics(ref BitStream stream) + { + games_played = (short)(stream.Read(16) >> 1); + games_completed = (short)(stream.Read(16) >> 1); + games_won = (short)(stream.Read(16) >> 1); + games_tied = (short)(stream.Read(16) >> 1); + rounds_completed = (short)(stream.Read(16) >> 1); + rounds_won = (short)(stream.Read(16) >> 1); + in_round_score = (short)(stream.Read(16) >> 1); + in_game_total_score = (short)(stream.Read(16) >> 1); + kills = (short)(stream.Read(16) >> 1); + assists = (short)(stream.Read(16) >> 1); + deaths = (short)(stream.Read(16) >> 1); + betrayals = (short)(stream.Read(16) >> 1); + suicides = (short)(stream.Read(16) >> 1); + most_kills_in_a_row = (short)(stream.Read(16) >> 1); + seconds_alive = (short)(stream.Read(16) >> 1); + ctf_flag_scores = (short)(stream.Read(16) >> 1); + ctf_flag_grabs = (short)(stream.Read(16) >> 1); + ctf_flag_carrier_kills = (short)(stream.Read(16) >> 1); + ctf_flag_returns = (short)(stream.Read(16) >> 1); + assault_bomb_arms = (short)(stream.Read(16) >> 1); + assault_bomb_grabs = (short)(stream.Read(16) >> 1); + assault_bomb_disarms = (short)(stream.Read(16) >> 1); + assault_bomb_detonations = (short)(stream.Read(16) >> 1); + oddball_time_with_ball = (short)(stream.Read(16) >> 1); + oddball_unused = (short)(stream.Read(16) >> 1); + oddball_kills_as_carrier = (short)(stream.Read(16) >> 1); + oddball_ball_carrier_kills = (short)(stream.Read(16) >> 1); + king_time_on_hill = (short)(stream.Read(16) >> 1); + king_total_control_time = (short)(stream.Read(16) >> 1); + king_unused0 = (short)(stream.Read(16) >> 1); + king_unused1 = (short)(stream.Read(16) >> 1); + unused0 = (short)(stream.Read(16) >> 1); + unused1 = (short)(stream.Read(16) >> 1); + unused2 = (short)(stream.Read(16) >> 1); + vip_takedowns = (short)(stream.Read(16) >> 1); + vip_kills_as_vip = (short)(stream.Read(16) >> 1); + vip_guard_time = (short)(stream.Read(16) >> 1); + vip_time_as_vip = (short)(stream.Read(16) >> 1); + vip_lives_as_vip = (short)(stream.Read(16) >> 1); + juggernaut_kills = (short)(stream.Read(16) >> 1); + juggernaut_kills_as_juggernaut = (short)(stream.Read(16) >> 1); + juggernaut_total_control_time = (short)(stream.Read(16) >> 1); + total_wp = (short)(stream.Read(16) >> 1); + juggernaut_unused = (short)(stream.Read(16) >> 1); + territories_owned = (short)(stream.Read(16) >> 1); + territories_captures = (short)(stream.Read(16) >> 1); + territories_ousts = (short)(stream.Read(16) >> 1); + territories_time_in_territory = (short)(stream.Read(16) >> 1); + infection_zombie_kills = (short)(stream.Read(16) >> 1); + infection_infections = (short)(stream.Read(16) >> 1); + infection_time_as_human = (short)(stream.Read(16) >> 1); + } + } + + + public class Medals + { + public short extermination; + public short perfection; + public short multiple_kill_2; + public short multiple_kill_3; + public short multiple_kill_4; + public short multiple_kill_5; + public short multiple_kill_6; + public short multiple_kill_7; + public short multiple_kill_8; + public short multiple_kill_9; + public short multiple_kill_10; + public short kills_in_a_row_5; + public short kills_in_a_row_10; + public short kills_in_a_row_15; + public short kills_in_a_row_20; + public short kills_in_a_row_25; + public short kills_in_a_row_30; + public short sniper_kill_5; + public short sniper_kill_10; + public short shotgun_kill_5; + public short shotgun_kill_10; + public short collision_kill_5; + public short collision_kill_10; + public short sword_kill_5; + public short sword_kill_10; + public short juggernaut_kill_5; + public short juggernaut_kill_10; + public short zombie_kill_5; + public short zombie_kill_10; + public short human_kill_5; + public short human_kill_10; + public short human_kill_15; + public short koth_kill_5; + public short shotgun_kill_sword; + public short vehicle_impact_kill; + public short vehicle_hijack; + public short aircraft_hijack; + public short deadplayer_kill; + public short player_kill_spreeplayer; + public short spartanlaser_kill; + public short stickygrenade_kill; + public short sniper_kill; + public short bashbehind_kill; + public short bash_kill; + public short flame_kill; + public short driver_assist_gunner; + public short assault_bomb_planted; + public short assault_player_kill_carrier; + public short vip_player_kill_vip; + public short juggernaut_player_kill_juggernaut; + public short oddball_carrier_kill_player; + public short ctf_flag_captured; + public short ctf_flag_player_kill_carrier; + public short ctf_flag_carrier_kill_player; + public short infection_survive; + public short nemesis; + public short avenger; + public short unused3; + + public Medals(ref BitStream stream) + { + extermination = (short)(stream.Read(16) >> 1); + perfection = (short)(stream.Read(16) >> 1); + multiple_kill_2 = (short)(stream.Read(16) >> 1); + multiple_kill_3 = (short)(stream.Read(16) >> 1); + multiple_kill_4 = (short)(stream.Read(16) >> 1); + multiple_kill_5 = (short)(stream.Read(16) >> 1); + multiple_kill_6 = (short)(stream.Read(16) >> 1); + multiple_kill_7 = (short)(stream.Read(16) >> 1); + multiple_kill_8 = (short)(stream.Read(16) >> 1); + multiple_kill_9 = (short)(stream.Read(16) >> 1); + multiple_kill_10 = (short)(stream.Read(16) >> 1); + kills_in_a_row_5 = (short)(stream.Read(16) >> 1); + kills_in_a_row_10 = (short)(stream.Read(16) >> 1); + kills_in_a_row_15 = (short)(stream.Read(16) >> 1); + kills_in_a_row_20 = (short)(stream.Read(16) >> 1); + kills_in_a_row_25 = (short)(stream.Read(16) >> 1); + kills_in_a_row_30 = (short)(stream.Read(16) >> 1); + sniper_kill_5 = (short)(stream.Read(16) >> 1); + sniper_kill_10 = (short)(stream.Read(16) >> 1); + shotgun_kill_5 = (short)(stream.Read(16) >> 1); + shotgun_kill_10 = (short)(stream.Read(16) >> 1); + collision_kill_5 = (short)(stream.Read(16) >> 1); + collision_kill_10 = (short)(stream.Read(16) >> 1); + sword_kill_5 = (short)(stream.Read(16) >> 1); + sword_kill_10 = (short)(stream.Read(16) >> 1); + juggernaut_kill_5 = (short)(stream.Read(16) >> 1); + juggernaut_kill_10 = (short)(stream.Read(16) >> 1); + zombie_kill_5 = (short)(stream.Read(16) >> 1); + zombie_kill_10 = (short)(stream.Read(16) >> 1); + human_kill_5 = (short)(stream.Read(16) >> 1); + human_kill_10 = (short)(stream.Read(16) >> 1); + human_kill_15 = (short)(stream.Read(16) >> 1); + koth_kill_5 = (short)(stream.Read(16) >> 1); + shotgun_kill_sword = (short)(stream.Read(16) >> 1); + vehicle_impact_kill = (short)(stream.Read(16) >> 1); + vehicle_hijack = (short)(stream.Read(16) >> 1); + aircraft_hijack = (short)(stream.Read(16) >> 1); + deadplayer_kill = (short)(stream.Read(16) >> 1); + player_kill_spreeplayer = (short)(stream.Read(16) >> 1); + spartanlaser_kill = (short)(stream.Read(16) >> 1); + stickygrenade_kill = (short)(stream.Read(16) >> 1); + sniper_kill = (short)(stream.Read(16) >> 1); + bashbehind_kill = (short)(stream.Read(16) >> 1); + bash_kill = (short)(stream.Read(16) >> 1); + flame_kill = (short)(stream.Read(16) >> 1); + driver_assist_gunner = (short)(stream.Read(16) >> 1); + assault_bomb_planted = (short)(stream.Read(16) >> 1); + assault_player_kill_carrier = (short)(stream.Read(16) >> 1); + vip_player_kill_vip = (short)(stream.Read(16) >> 1); + juggernaut_player_kill_juggernaut = (short)(stream.Read(16) >> 1); + oddball_carrier_kill_player = (short)(stream.Read(16) >> 1); + ctf_flag_captured = (short)(stream.Read(16) >> 1); + ctf_flag_player_kill_carrier = (short)(stream.Read(16) >> 1); + ctf_flag_carrier_kill_player = (short)(stream.Read(16) >> 1); + infection_survive = (short)(stream.Read(16) >> 1); + nemesis = (short)(stream.Read(16) >> 1); + avenger = (short)(stream.Read(16) >> 1); + unused3 = (short)(stream.Read(16) >> 1); + } + } + + public class Achievements + { + public short landfall; + public short holdout; + public short the_road; + public short assault; + public short cleansing; + public short refuge; + public short last_stand; + public short the_key; + [JsonPropertyName("return")] + public short _return; + public short campaign_complete_normal; + public short campaign_complete_heroic; + public short campaign_complete_legendary; + public short iron; + public short black_eye; + public short tough_luck; + [JsonPropertyName("catch")] + public short _catch; + public short fog; + public short famine; + public short thunderstorm; + public short tilt; + public short mythic; + public short marathon_man; + public short guerilla; + public short demon; + public short cavalier; + public short askar; + public short exterminator; + public short ranger; + public short vanguard; + public short orpheus; + public short reclaimer; + public short graduate; + public short unsc_spartan; + public short spartan_officer; + public short two_for_one; + public short triple_kill; + public short overkill; + public short lee_r_wilson_memorial; + public short killing_frenzy; + public short steppin_razor; + public short mongoose_mowdown; + public short up_close_and_personal; + public short mvp; + public short maybe_next_time_buddy; + public short too_close_to_the_sun; + public short we_re_in_for_some_chop; + public short fear_the_pink_mist; + public short headshot_honcho; + public short used_car_salesman; + + public Achievements(ref BitStream stream) + { + landfall = (short)(stream.Read(16) >> 1); + holdout = (short)(stream.Read(16) >> 1); + the_road = (short)(stream.Read(16) >> 1); + assault = (short)(stream.Read(16) >> 1); + cleansing = (short)(stream.Read(16) >> 1); + refuge = (short)(stream.Read(16) >> 1); + last_stand = (short)(stream.Read(16) >> 1); + the_key = (short)(stream.Read(16) >> 1); + _return = (short)(stream.Read(16) >> 1); + campaign_complete_normal = (short)(stream.Read(16) >> 1); + campaign_complete_heroic = (short)(stream.Read(16) >> 1); + campaign_complete_legendary = (short)(stream.Read(16) >> 1); + iron = (short)(stream.Read(16) >> 1); + black_eye = (short)(stream.Read(16) >> 1); + tough_luck = (short)(stream.Read(16) >> 1); + _catch = (short)(stream.Read(16) >> 1); + fog = (short)(stream.Read(16) >> 1); + famine = (short)(stream.Read(16) >> 1); + thunderstorm = (short)(stream.Read(16) >> 1); + tilt = (short)(stream.Read(16) >> 1); + mythic = (short)(stream.Read(16) >> 1); + marathon_man = (short)(stream.Read(16) >> 1); + guerilla = (short)(stream.Read(16) >> 1); + demon = (short)(stream.Read(16) >> 1); + cavalier = (short)(stream.Read(16) >> 1); + askar = (short)(stream.Read(16) >> 1); + exterminator = (short)(stream.Read(16) >> 1); + ranger = (short)(stream.Read(16) >> 1); + vanguard = (short)(stream.Read(16) >> 1); + orpheus = (short)(stream.Read(16) >> 1); + reclaimer = (short)(stream.Read(16) >> 1); + graduate = (short)(stream.Read(16) >> 1); + unsc_spartan = (short)(stream.Read(16) >> 1); + spartan_officer = (short)(stream.Read(16) >> 1); + two_for_one = (short)(stream.Read(16) >> 1); + triple_kill = (short)(stream.Read(16) >> 1); + overkill = (short)(stream.Read(16) >> 1); + lee_r_wilson_memorial = (short)(stream.Read(16) >> 1); + killing_frenzy = (short)(stream.Read(16) >> 1); + steppin_razor = (short)(stream.Read(16) >> 1); + mongoose_mowdown = (short)(stream.Read(16) >> 1); + up_close_and_personal = (short)(stream.Read(16) >> 1); + mvp = (short)(stream.Read(16) >> 1); + maybe_next_time_buddy = (short)(stream.Read(16) >> 1); + too_close_to_the_sun = (short)(stream.Read(16) >> 1); + we_re_in_for_some_chop = (short)(stream.Read(16) >> 1); + fear_the_pink_mist = (short)(stream.Read(16) >> 1); + headshot_honcho = (short)(stream.Read(16) >> 1); + used_car_salesman = (short)(stream.Read(16) >> 1); + } + } + + public class DamageStatistics + { + public class DamageSourceStatistics + { + public bool valid; + public short kills; + public short deaths; + public short betrayals; + public short suicides; + public short headshots; + + public DamageSourceStatistics(ref BitStream stream) + { + valid = stream.Read(8) > 0; + stream.SeekRelative(8); + kills = (short)(stream.Read(16) >> 1); + deaths = (short)(stream.Read(16) >> 1); + betrayals = (short)(stream.Read(16) >> 1); + suicides = (short)(stream.Read(16) >> 1); + headshots = (short)(stream.Read(16) >> 1); + } + } + + public DamageSourceStatistics guardians; + public DamageSourceStatistics falling_damage; + public DamageSourceStatistics generic_collision_damage; + public DamageSourceStatistics generic_melee_damage; + public DamageSourceStatistics generic_explosion; + public DamageSourceStatistics magnum_pistol; + public DamageSourceStatistics plasma_pistol; + public DamageSourceStatistics needler; + public DamageSourceStatistics excavator; + public DamageSourceStatistics smg; + public DamageSourceStatistics plasma_rifle; + public DamageSourceStatistics battle_rifle; + public DamageSourceStatistics carbine; + public DamageSourceStatistics shotgun; + public DamageSourceStatistics sniper_rifle; + public DamageSourceStatistics beam_rifle; + public DamageSourceStatistics assault_rifle; + public DamageSourceStatistics spike_rifle; + public DamageSourceStatistics flak_cannon; + public DamageSourceStatistics missile_launcher; + public DamageSourceStatistics rocket_launcher; + public DamageSourceStatistics spartan_laser; + public DamageSourceStatistics brute_shot; + public DamageSourceStatistics flame_thrower; + public DamageSourceStatistics sentinal_gun; + public DamageSourceStatistics energy_sword; + public DamageSourceStatistics gravity_hammer; + public DamageSourceStatistics frag_grenade; + public DamageSourceStatistics plasma_grenade; + public DamageSourceStatistics claymore_grenade; + public DamageSourceStatistics firebomb_grenade; + public DamageSourceStatistics flag_melee_damage; + public DamageSourceStatistics bomb_melee_damage; + public DamageSourceStatistics bomb_explosion_damage; + public DamageSourceStatistics ball_melee_damage; + public DamageSourceStatistics human_turret; + public DamageSourceStatistics plasma_cannon; + public DamageSourceStatistics plasma_mortar; + public DamageSourceStatistics plasma_turret; + public DamageSourceStatistics shade_turret; + public DamageSourceStatistics banshee; + public DamageSourceStatistics ghost; + public DamageSourceStatistics mongoose; + public DamageSourceStatistics scorpion; + public DamageSourceStatistics scorpion_gunner; + public DamageSourceStatistics spectre_driver; + public DamageSourceStatistics spectre_gunner; + public DamageSourceStatistics warthog_driver; + public DamageSourceStatistics warthog_gunner; + public DamageSourceStatistics warthog_gunner_gauss; + public DamageSourceStatistics wraith; + public DamageSourceStatistics wraith_anti_infantry; + public DamageSourceStatistics tank; + public DamageSourceStatistics chopper; + public DamageSourceStatistics hornet; + public DamageSourceStatistics mantis; + public DamageSourceStatistics mauler; + public DamageSourceStatistics sentinel_beam; + public DamageSourceStatistics sentinel_rpg; + public DamageSourceStatistics teleporter; + public DamageSourceStatistics prox_mine; + + public DamageStatistics(ref BitStream stream) + { + guardians = new DamageSourceStatistics(ref stream); + falling_damage = new DamageSourceStatistics(ref stream); + generic_collision_damage = new DamageSourceStatistics(ref stream); + generic_melee_damage = new DamageSourceStatistics(ref stream); + generic_explosion = new DamageSourceStatistics(ref stream); + magnum_pistol = new DamageSourceStatistics(ref stream); + plasma_pistol = new DamageSourceStatistics(ref stream); + needler = new DamageSourceStatistics(ref stream); + excavator = new DamageSourceStatistics(ref stream); + smg = new DamageSourceStatistics(ref stream); + plasma_rifle = new DamageSourceStatistics(ref stream); + battle_rifle = new DamageSourceStatistics(ref stream); + carbine = new DamageSourceStatistics(ref stream); + shotgun = new DamageSourceStatistics(ref stream); + sniper_rifle = new DamageSourceStatistics(ref stream); + beam_rifle = new DamageSourceStatistics(ref stream); + assault_rifle = new DamageSourceStatistics(ref stream); + spike_rifle = new DamageSourceStatistics(ref stream); + flak_cannon = new DamageSourceStatistics(ref stream); + missile_launcher = new DamageSourceStatistics(ref stream); + rocket_launcher = new DamageSourceStatistics(ref stream); + spartan_laser = new DamageSourceStatistics(ref stream); + brute_shot = new DamageSourceStatistics(ref stream); + flame_thrower = new DamageSourceStatistics(ref stream); + sentinal_gun = new DamageSourceStatistics(ref stream); + energy_sword = new DamageSourceStatistics(ref stream); + gravity_hammer = new DamageSourceStatistics(ref stream); + frag_grenade = new DamageSourceStatistics(ref stream); + plasma_grenade = new DamageSourceStatistics(ref stream); + claymore_grenade = new DamageSourceStatistics(ref stream); + firebomb_grenade = new DamageSourceStatistics(ref stream); + flag_melee_damage = new DamageSourceStatistics(ref stream); + bomb_melee_damage = new DamageSourceStatistics(ref stream); + bomb_explosion_damage = new DamageSourceStatistics(ref stream); + ball_melee_damage = new DamageSourceStatistics(ref stream); + human_turret = new DamageSourceStatistics(ref stream); + plasma_cannon = new DamageSourceStatistics(ref stream); + plasma_mortar = new DamageSourceStatistics(ref stream); + plasma_turret = new DamageSourceStatistics(ref stream); + shade_turret = new DamageSourceStatistics(ref stream); + banshee = new DamageSourceStatistics(ref stream); + ghost = new DamageSourceStatistics(ref stream); + mongoose = new DamageSourceStatistics(ref stream); + scorpion = new DamageSourceStatistics(ref stream); + scorpion_gunner = new DamageSourceStatistics(ref stream); + spectre_driver = new DamageSourceStatistics(ref stream); + spectre_gunner = new DamageSourceStatistics(ref stream); + warthog_driver = new DamageSourceStatistics(ref stream); + warthog_gunner = new DamageSourceStatistics(ref stream); + warthog_gunner_gauss = new DamageSourceStatistics(ref stream); + wraith = new DamageSourceStatistics(ref stream); + wraith_anti_infantry = new DamageSourceStatistics(ref stream); + tank = new DamageSourceStatistics(ref stream); + chopper = new DamageSourceStatistics(ref stream); + hornet = new DamageSourceStatistics(ref stream); + mantis = new DamageSourceStatistics(ref stream); + mauler = new DamageSourceStatistics(ref stream); + sentinel_beam = new DamageSourceStatistics(ref stream); + sentinel_rpg = new DamageSourceStatistics(ref stream); + teleporter = new DamageSourceStatistics(ref stream); + prox_mine = new DamageSourceStatistics(ref stream); + } + } + + public class PlayerStatistics + { + public Statistics statistics; + public Medals medals; + public Achievements achievements; + public DamageStatistics damageStatistics; + + public PlayerStatistics(ref BitStream stream) + { + statistics = new Statistics(ref stream); + medals = new Medals(ref stream); + achievements = new Achievements(ref stream); + damageStatistics = new DamageStatistics(ref stream); + } + } +} \ No newline at end of file diff --git a/WarthogInc/BlfChunks/MultiplayerPlayerVsPlayerStatistics.cs b/WarthogInc/BlfChunks/MultiplayerPlayerVsPlayerStatistics.cs new file mode 100644 index 0000000..a33a8d3 --- /dev/null +++ b/WarthogInc/BlfChunks/MultiplayerPlayerVsPlayerStatistics.cs @@ -0,0 +1,85 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Sewer56.BitStream; +using Sewer56.BitStream.ByteStreams; +using SunriseBlfTool.BlfChunks; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace SunriseBlfTool +{ + public class MultiplayerPlayerVsPlayerStatistics : IBLFChunk + { + public PlayerVsPlayerStatistics[] players; + + public ushort GetAuthentication() + { + return 1; + } + + public uint GetLength() + { + return 0x404; + } + + public string GetName() + { + return "mps2"; + } + + public ushort GetVersion() + { + return 2; + } + + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) + { + byte playerCount = 16; + + hoppersStream.SeekRelative(4); + + players = new PlayerVsPlayerStatistics[playerCount]; + for (int i = 0; i < playerCount; i++) + { + players[i] = new PlayerVsPlayerStatistics(ref hoppersStream); + } + hoppersStream.Seek(hoppersStream.NextByteIndex, 0); + } + + public void WriteChunk(ref BitStream hoppersStream) + { + throw new NotImplementedException(); + } + } + + public class PlayerVsPlayerStatistics + { + public class VsPlayerStatistics + { + public short kills; + public short deaths; + + public VsPlayerStatistics(ref BitStream stream) + { + kills = (short)(stream.Read(16) >> 1); + deaths = (short)(stream.Read(16) >> 1); + } + } + + public VsPlayerStatistics[] vs_players; + + public PlayerVsPlayerStatistics(ref BitStream stream) + { + vs_players = new VsPlayerStatistics[16]; + for (int i = 0; i < 16; i++) + { + vs_players[i] = new VsPlayerStatistics(ref stream); + } + } + } +} \ No newline at end of file diff --git a/WarthogInc/BlfChunks/MultiplayerPlayers.cs b/WarthogInc/BlfChunks/MultiplayerPlayers.cs index 873699e..9a03b22 100644 --- a/WarthogInc/BlfChunks/MultiplayerPlayers.cs +++ b/WarthogInc/BlfChunks/MultiplayerPlayers.cs @@ -37,7 +37,7 @@ public ushort GetVersion() return 2; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { byte playerCount = 16; byte validPlayerCount = 0; diff --git a/WarthogInc/BlfChunks/MultiplayerTeamStatistics.cs b/WarthogInc/BlfChunks/MultiplayerTeamStatistics.cs new file mode 100644 index 0000000..0b148a5 --- /dev/null +++ b/WarthogInc/BlfChunks/MultiplayerTeamStatistics.cs @@ -0,0 +1,170 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using Sewer56.BitStream; +using Sewer56.BitStream.ByteStreams; +using SunriseBlfTool.BlfChunks; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace SunriseBlfTool +{ + public class MultiplayerTeamStatistics : IBLFChunk + { + public Statistics[] team_statistics; + + public ushort GetAuthentication() + { + return 1; + } + + public uint GetLength() + { + return 0x664; + } + + public string GetName() + { + return "mps3"; + } + + public ushort GetVersion() + { + return 2; + } + + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) + { + byte teamCount = 16; + + hoppersStream.SeekRelative(4); + + team_statistics = new Statistics[teamCount]; + for (int i = 0; i < teamCount; i++) + { + team_statistics[i] = new Statistics(ref hoppersStream); + } + hoppersStream.Seek(hoppersStream.NextByteIndex, 0); + } + + public void WriteChunk(ref BitStream hoppersStream) + { + throw new NotImplementedException(); + } + + + public class Statistics + { + public short games_played; + public short games_completed; + public short games_won; + public short games_tied; + public short rounds_completed; + public short rounds_won; + public short in_round_score; + public short in_game_total_score; + public short kills; + public short assists; + public short deaths; + public short betrayals; + public short suicides; + public short most_kills_in_a_row; + public short seconds_alive; + public short ctf_flag_scores; + public short ctf_flag_grabs; + public short ctf_flag_carrier_kills; + public short ctf_flag_returns; + public short assault_bomb_arms; + public short assault_bomb_grabs; + public short assault_bomb_disarms; + public short assault_bomb_detonations; + public short oddball_time_with_ball; + public short oddball_unused; + public short oddball_kills_as_carrier; + public short oddball_ball_carrier_kills; + public short king_time_on_hill; + public short king_total_control_time; + public short king_unused0; + public short king_unused1; + public short unused0; + public short unused1; + public short unused2; + public short vip_takedowns; + public short vip_kills_as_vip; + public short vip_guard_time; + public short vip_time_as_vip; + public short vip_lives_as_vip; + public short juggernaut_kills; + public short juggernaut_kills_as_juggernaut; + public short juggernaut_total_control_time; + public short total_wp; + public short juggernaut_unused; + public short territories_owned; + public short territories_captures; + public short territories_ousts; + public short territories_time_in_territory; + public short infection_zombie_kills; + public short infection_infections; + public short infection_time_as_human; + + public Statistics(ref BitStream stream) + { + games_played = (short)(stream.Read(16) >> 1); + games_completed = (short)(stream.Read(16) >> 1); + games_won = (short)(stream.Read(16) >> 1); + games_tied = (short)(stream.Read(16) >> 1); + rounds_completed = (short)(stream.Read(16) >> 1); + rounds_won = (short)(stream.Read(16) >> 1); + in_round_score = (short)(stream.Read(16) >> 1); + in_game_total_score = (short)(stream.Read(16) >> 1); + kills = (short)(stream.Read(16) >> 1); + assists = (short)(stream.Read(16) >> 1); + deaths = (short)(stream.Read(16) >> 1); + betrayals = (short)(stream.Read(16) >> 1); + suicides = (short)(stream.Read(16) >> 1); + most_kills_in_a_row = (short)(stream.Read(16) >> 1); + seconds_alive = (short)(stream.Read(16) >> 1); + ctf_flag_scores = (short)(stream.Read(16) >> 1); + ctf_flag_grabs = (short)(stream.Read(16) >> 1); + ctf_flag_carrier_kills = (short)(stream.Read(16) >> 1); + ctf_flag_returns = (short)(stream.Read(16) >> 1); + assault_bomb_arms = (short)(stream.Read(16) >> 1); + assault_bomb_grabs = (short)(stream.Read(16) >> 1); + assault_bomb_disarms = (short)(stream.Read(16) >> 1); + assault_bomb_detonations = (short)(stream.Read(16) >> 1); + oddball_time_with_ball = (short)(stream.Read(16) >> 1); + oddball_unused = (short)(stream.Read(16) >> 1); + oddball_kills_as_carrier = (short)(stream.Read(16) >> 1); + oddball_ball_carrier_kills = (short)(stream.Read(16) >> 1); + king_time_on_hill = (short)(stream.Read(16) >> 1); + king_total_control_time = (short)(stream.Read(16) >> 1); + king_unused0 = (short)(stream.Read(16) >> 1); + king_unused1 = (short)(stream.Read(16) >> 1); + unused0 = (short)(stream.Read(16) >> 1); + unused1 = (short)(stream.Read(16) >> 1); + unused2 = (short)(stream.Read(16) >> 1); + vip_takedowns = (short)(stream.Read(16) >> 1); + vip_kills_as_vip = (short)(stream.Read(16) >> 1); + vip_guard_time = (short)(stream.Read(16) >> 1); + vip_time_as_vip = (short)(stream.Read(16) >> 1); + vip_lives_as_vip = (short)(stream.Read(16) >> 1); + juggernaut_kills = (short)(stream.Read(16) >> 1); + juggernaut_kills_as_juggernaut = (short)(stream.Read(16) >> 1); + juggernaut_total_control_time = (short)(stream.Read(16) >> 1); + total_wp = (short)(stream.Read(16) >> 1); + juggernaut_unused = (short)(stream.Read(16) >> 1); + territories_owned = (short)(stream.Read(16) >> 1); + territories_captures = (short)(stream.Read(16) >> 1); + territories_ousts = (short)(stream.Read(16) >> 1); + territories_time_in_territory = (short)(stream.Read(16) >> 1); + infection_zombie_kills = (short)(stream.Read(16) >> 1); + infection_infections = (short)(stream.Read(16) >> 1); + infection_time_as_human = (short)(stream.Read(16) >> 1); + } + } + } +} \ No newline at end of file diff --git a/WarthogInc/BlfChunks/MultiplayerTeams.cs b/WarthogInc/BlfChunks/MultiplayerTeams.cs index 5ae0d74..f3a11ee 100644 --- a/WarthogInc/BlfChunks/MultiplayerTeams.cs +++ b/WarthogInc/BlfChunks/MultiplayerTeams.cs @@ -37,7 +37,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { byte teamCount = 16; byte validTeamCount = 0; diff --git a/WarthogInc/BlfChunks/NagMessage.cs b/WarthogInc/BlfChunks/NagMessage.cs index 41c61d0..98b6dc8 100644 --- a/WarthogInc/BlfChunks/NagMessage.cs +++ b/WarthogInc/BlfChunks/NagMessage.cs @@ -61,7 +61,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { motdIdentifier = hoppersStream.Read(32); acceptWaitMilliseconds = hoppersStream.Read(32); diff --git a/WarthogInc/BlfChunks/NetworkConfiguration.cs b/WarthogInc/BlfChunks/NetworkConfiguration.cs index dd9416b..92a0e87 100644 --- a/WarthogInc/BlfChunks/NetworkConfiguration.cs +++ b/WarthogInc/BlfChunks/NetworkConfiguration.cs @@ -26,7 +26,7 @@ public uint GetLength() return 8300; } - public void ReadChunk(ref BitStream hopperStream) + public void ReadChunk(ref BitStream hopperStream, BLFChunkReader reader) { unknown0 = hopperStream.Read(32); unknown4 = hopperStream.Read(32); diff --git a/WarthogInc/BlfChunks/PackedGameVariant10.cs b/WarthogInc/BlfChunks/PackedGameVariant10.cs index 5974294..cd16a75 100644 --- a/WarthogInc/BlfChunks/PackedGameVariant10.cs +++ b/WarthogInc/BlfChunks/PackedGameVariant10.cs @@ -94,7 +94,7 @@ public ushort GetVersion() return 10; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { VariantGameEngine variantGameEngineIndex = (VariantGameEngine)hoppersStream.Read(4); switch (variantGameEngineIndex) diff --git a/WarthogInc/BlfChunks/PackedGameVariant2.cs b/WarthogInc/BlfChunks/PackedGameVariant2.cs index 2d66a26..9da400c 100644 --- a/WarthogInc/BlfChunks/PackedGameVariant2.cs +++ b/WarthogInc/BlfChunks/PackedGameVariant2.cs @@ -124,7 +124,7 @@ public ushort GetVersion() return 2; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/PackedMapVariant.cs b/WarthogInc/BlfChunks/PackedMapVariant.cs index 1c289a7..23947bf 100644 --- a/WarthogInc/BlfChunks/PackedMapVariant.cs +++ b/WarthogInc/BlfChunks/PackedMapVariant.cs @@ -85,7 +85,7 @@ public ushort GetVersion() return 12; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { metadata = new PackedBaseGameVariant10.VariantMetadata(ref hoppersStream); mapVariantVersion = hoppersStream.Read(8); diff --git a/WarthogInc/BlfChunks/Parent.cs b/WarthogInc/BlfChunks/Parent.cs new file mode 100644 index 0000000..01042d8 --- /dev/null +++ b/WarthogInc/BlfChunks/Parent.cs @@ -0,0 +1,59 @@ +using Sewer56.BitStream; +using Sewer56.BitStream.ByteStreams; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ZLibDotNet; + +namespace SunriseBlfTool.BlfChunks +{ + class Parent : IBLFChunk + { + public Dictionary chunks; + + public ushort GetAuthentication() + { + return 1; + } + + public string GetName() + { + return "_par"; + } + + public ushort GetVersion() + { + return 1; + } + + public uint GetLength() + { + throw new NotImplementedException(); + } + + public void WriteChunk(ref BitStream stream) + { + throw new NotImplementedException(); + } + + public void ReadChunk(ref BitStream stream, BLFChunkReader reader) + { + chunks = new Dictionary(); + int chunksCount = stream.Read(32); + for (int i = 0; i < chunksCount; i++) + { + IBLFChunk chunk = reader.ReadChunk(ref stream); + if (chunk != null) + chunks.Add(chunk.GetName(), chunk); + } + } + + public Parent() + { + + } + } +} diff --git a/WarthogInc/BlfChunks/RecentPlayers.cs b/WarthogInc/BlfChunks/RecentPlayers.cs index 3c58475..6d4ece9 100644 --- a/WarthogInc/BlfChunks/RecentPlayers.cs +++ b/WarthogInc/BlfChunks/RecentPlayers.cs @@ -40,7 +40,7 @@ public ushort GetVersion() return 2; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/ServiceRecordIdentity.cs b/WarthogInc/BlfChunks/ServiceRecordIdentity.cs index e101552..f5c5a1c 100644 --- a/WarthogInc/BlfChunks/ServiceRecordIdentity.cs +++ b/WarthogInc/BlfChunks/ServiceRecordIdentity.cs @@ -32,7 +32,7 @@ public uint GetLength() return 0x5C; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/StartOfFile.cs b/WarthogInc/BlfChunks/StartOfFile.cs index e5766d3..45f193a 100644 --- a/WarthogInc/BlfChunks/StartOfFile.cs +++ b/WarthogInc/BlfChunks/StartOfFile.cs @@ -55,7 +55,7 @@ public void WriteChunk(ref BitStream hoppersStream) } } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { byteOrder = (ByteOrder)hoppersStream.Read(16); for (int i = 0; i < 0x22; i++) diff --git a/WarthogInc/BlfChunks/UserBanhammer.cs b/WarthogInc/BlfChunks/UserBanhammer.cs index c092606..4e7ad98 100644 --- a/WarthogInc/BlfChunks/UserBanhammer.cs +++ b/WarthogInc/BlfChunks/UserBanhammer.cs @@ -41,7 +41,7 @@ public ushort GetVersion() return 1; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfChunks/UserPlayerData.cs b/WarthogInc/BlfChunks/UserPlayerData.cs index f6e2888..b7609fe 100644 --- a/WarthogInc/BlfChunks/UserPlayerData.cs +++ b/WarthogInc/BlfChunks/UserPlayerData.cs @@ -43,7 +43,7 @@ public ushort GetVersion() return 3; } - public void ReadChunk(ref BitStream hoppersStream) + public void ReadChunk(ref BitStream hoppersStream, BLFChunkReader reader) { throw new NotImplementedException(); } diff --git a/WarthogInc/BlfFile.cs b/WarthogInc/BlfFile.cs index 688ab34..4cedd41 100644 --- a/WarthogInc/BlfFile.cs +++ b/WarthogInc/BlfFile.cs @@ -65,7 +65,7 @@ public void ReadFile(string path, AbstractBlfChunkNameMap chunkNameMap) var fs = new FileStream(path, FileMode.Open); var blfFileIn = new BitStream(new StreamByteStream(fs)); - BLFChunkReader chunkReader = new BLFChunkReader(); + BLFChunkReader chunkReader = new BLFChunkReader(chunkNameMap); // If it has an x360 save content header skip to blf if (blfFileIn.Read(32) == 0x434F4E20) @@ -77,7 +77,7 @@ public void ReadFile(string path, AbstractBlfChunkNameMap chunkNameMap) } while (fs.Position < fs.Length) { - IBLFChunk chunk = chunkReader.ReadChunk(ref blfFileIn, chunkNameMap); + IBLFChunk chunk = chunkReader.ReadChunk(ref blfFileIn); if (chunk == null) continue;