Skip to content

Commit

Permalink
Parse more stats chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
craftycodie committed Aug 24, 2024
1 parent 0386b96 commit c49b22e
Show file tree
Hide file tree
Showing 51 changed files with 959 additions and 60 deletions.
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/Author.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void WriteChunk(ref BitStream<StreamByteStream> hoppersStream)
}
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
var buildNameBytes = new byte[16];
var buildNameLen = -1;
Expand Down
11 changes: 9 additions & 2 deletions WarthogInc/BlfChunks/BLFChunkReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ namespace SunriseBlfTool.BlfChunks
{
public class BLFChunkReader
{
public IBLFChunk ReadChunk(ref BitStream<StreamByteStream> outputStream, AbstractBlfChunkNameMap chunkNameMap)
AbstractBlfChunkNameMap chunkNameMap;

public BLFChunkReader(AbstractBlfChunkNameMap chunkNameMap)
{
this.chunkNameMap = chunkNameMap;
}

public IBLFChunk ReadChunk(ref BitStream<StreamByteStream> outputStream)
{
int chunkStartOffset = outputStream.ByteOffset;
BLFChunkHeader header = new BLFChunkHeader();
Expand All @@ -24,7 +31,7 @@ public IBLFChunk ReadChunk(ref BitStream<StreamByteStream> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ private void RegisterChunks()
RegisterChunk<MachineNetworkStatistics>();
RegisterChunk<MessageOfTheDay>();
RegisterChunk<MultiplayerPlayers>();
RegisterChunk<MultiplayerPlayerStatistics>();
RegisterChunk<MultiplayerPlayerVsPlayerStatistics>();
RegisterChunk<MultiplayerTeamStatistics>();
RegisterChunk<MultiplayerTeams>();
RegisterChunk<MatchmakingOptions>();
RegisterChunk<Parent>();
}

public override string GetVersion()
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/ContentHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void WriteChunk(ref BitStream<StreamByteStream> hoppersStream)
hoppersStream.WriteLong(gameId, 64);
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
buildNumber = hoppersStream.Read<short>(16);
mapVersion = hoppersStream.Read<short>(16);
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/EndOfFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void WriteChunk(ref BitStream<StreamByteStream> hoppersStream)
//hoppersStream.Seek(hoppersStream.NextByteIndex);
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
lengthUpToEOF = hoppersStream.Read<int>(32);
unknown = hoppersStream.Read<byte>(8);
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/FileQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/GameSet1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/GameSet15.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ private void WriteCompressedHopperData(ref BitStream<StreamByteStream> hoppersSt
hoppersStream.SeekRelative(compressedHopperTableLength + 4);
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
var decompressedStream = ReadCompressedHopperData(ref hoppersStream);

Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/GameSet2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public ushort GetVersion()
return 2;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/GameSet3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public ushort GetVersion()
return 3;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/GameSet6.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ushort GetVersion()
return 6;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
byte gameEntryCount = hoppersStream.Read<byte>(6);
gameEntries = new GameEntry[gameEntryCount];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/GameVariant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ushort GetVersion()
return 3;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();

Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/HopperConfigurationTable11.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public ushort GetVersion()
return 11;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
byte categoryCount = hoppersStream.Read<byte>(3);
categories = new HopperCategory[categoryCount];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/HopperConfigurationTable2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public ushort GetVersion()
return 2;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/HopperConfigurationTable27.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private void WriteCompressedHopperData(ref BitStream<StreamByteStream> hoppersSt
hoppersStream.SeekRelative(compressedHopperTableLength + 4);
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
var decompressedStream = ReadCompressedHopperData(ref hoppersStream);

Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/HopperConfigurationTable8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public ushort GetVersion()
return 8;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/HopperConfigurationTable9.cs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public ushort GetVersion()
return 9;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/IBLFChunk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public interface IBLFChunk
public string GetName();
public uint GetLength();
public void WriteChunk(ref BitStream<StreamByteStream> hoppersStream);
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream);
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader);
}
}
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MachineNetworkStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/Manifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void SetFileHash(string filePath, byte[] hash)
}
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
int fileCount = hoppersStream.Read<int>(32);
files = new FileEntry[fileCount];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/Manifest_PC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void SetFileHash(string filePath, byte[] hash)
}
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MapManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
int mapCount = hoppersStream.Read<int>(32);
mapRSAs = new MapEntry[mapCount];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MapVariant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public ushort GetVersion()
return 12;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
metadata = new BaseGameVariant.VariantMetadata(ref hoppersStream);
mapVariantVersion = hoppersStream.Read<short>(16);
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MatchmakingBanhammerMessages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
int tipCount = hoppersStream.Read<int>(32);
messages = new string[tipCount];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MatchmakingHopperDescriptions1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MatchmakingHopperDescriptions2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public ushort GetVersion()
return 2;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MatchmakingHopperDescriptions3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public ushort GetVersion()
return 3;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
byte descriptionCount = hoppersStream.Read<byte>(6);
descriptions = new HopperDescription[descriptionCount];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MatchmakingHopperStatistics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public ushort GetVersion()
return 3;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
totalPlayers = hoppersStream.Read<uint>(32);
statistics = new HopperPopulation[32];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MatchmakingHopperStatistics_PC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ushort GetVersion()
return 3;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
totalPlayers = hoppersStream.Read<uint>(32);
statistics = new HopperPopulation[32];
Expand Down
31 changes: 18 additions & 13 deletions WarthogInc/BlfChunks/MatchmakingOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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()
{
Expand All @@ -43,28 +44,32 @@ public uint GetLength()
return 0x5C;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine("Warning: mpmo chunk definition is incomplete.");
Console.ResetColor();

hopperIdentifier = hoppersStream.Read<ushort>(16);

LinkedList<byte> nameBytes = new LinkedList<byte>();
for (int si = 0; si < 16; si++)
for (int si = 0; si < 32; si++)
{
byte left = hoppersStream.Read<byte>(8);
byte right = hoppersStream.Read<byte>(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());
}
nameBytes.AddLast(left);
nameBytes.AddLast(right);
}

hoppersStream.SeekRelative(0x3A);
isRanked = hoppersStream.Read<byte>(8) > 0;
teamsEnabled = hoppersStream.Read<byte>(8) > 0;
xLastIndex = hoppersStream.Read<byte>(8);
drawProbability = hoppersStream.Read<int>(32);
beta = hoppersStream.ReadFloat(32);
tau = hoppersStream.ReadFloat(32);
expBaseIncrement = hoppersStream.Read<int>(32);
expPenaltyDecrement = hoppersStream.Read<int>(32);

}
public void WriteChunk(ref BitStream<StreamByteStream> hoppersStream)
{
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MatchmakingTips.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
int tipCount = hoppersStream.Read<int>(32);
tips = new string[tipCount];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MessageOfTheDay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public ushort GetVersion()
return 1;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
uint motdLength = hoppersStream.Read<uint>(32);
byte[] motdBytes = new byte[motdLength];
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MessageOfTheDayPopup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public ushort GetVersion()
return 4;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
motdIdentifier = hoppersStream.Read<uint>(32);
acceptWaitMilliseconds = hoppersStream.Read<uint>(32);
Expand Down
2 changes: 1 addition & 1 deletion WarthogInc/BlfChunks/MessageOfTheDayPopup_PC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public ushort GetVersion()
return 4;
}

public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream)
public void ReadChunk(ref BitStream<StreamByteStream> hoppersStream, BLFChunkReader reader)
{
throw new NotImplementedException();
}
Expand Down
Loading

0 comments on commit c49b22e

Please sign in to comment.