feat: Adds housing.bin support (#2329)

### Summary

Changes component verification so the order is now housing.bin, then txt files in client, then txt files in Data/Components folder on the server.
This commit is contained in:
Kamron Batman 2026-02-08 19:10:23 -08:00 • committed by GitHub
parent b191498569
commit a9d2b0c01f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 340 additions and 267 deletions

View file

@ -1,6 +1,6 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Copyright 2019-2026 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: MultiData.cs *
* *
@ -25,6 +25,9 @@ namespace Server;
public static class MultiData
{
public static string HousingUOPPath { get; private set; }
public static UOPEntry HousingEntry { get; private set; }
public static void Configure()
{
var multiUOPPath = Core.FindDataFile("MultiCollection.uop", false);
@ -53,8 +56,10 @@ public static class MultiData
{
using var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
// TODO: Find out if housing.bin is needed and read that.
var uopEntries = UOPFiles.ReadUOPIndexes(stream, ".bin", 0x10000, 4, 6);
var housingHash = UOPFiles.HashLittle2("build/multicollection/housing.bin");
var additionalHashes = new Dictionary<ulong, UOPEntry> { [housingHash] = default };
var uopEntries = UOPFiles.ReadUOPIndexes(stream, ".bin", 0x10000, 4, 6, additionalHashes);
var compressionBuffer = STArrayPool<byte>.Shared.Rent(0x10000);
var buffer = STArrayPool<byte>.Shared.Rent(0x10000);
@ -120,6 +125,12 @@ public static class MultiData
STArrayPool<byte>.Shared.Return(buffer);
STArrayPool<byte>.Shared.Return(compressionBuffer);
if (additionalHashes.TryGetValue(housingHash, out var housingEntry) && housingEntry.Size > 0)
{
HousingUOPPath = path;
HousingEntry = housingEntry;
}
}
private static void LoadMul(bool postHSMulFormat)

View file

@ -22,7 +22,8 @@ namespace Server;
public static class UOPFiles
{
public static Dictionary<int, UOPEntry> ReadUOPIndexes(
FileStream stream, string fileExt, int entryCount = 0x14000, int expectedVersion = -1, int precision = 8
FileStream stream, string fileExt, int entryCount = 0x14000, int expectedVersion = -1, int precision = 8,
Dictionary<ulong, UOPEntry> additionalHashes = null
)
{
var reader = new BinaryReader(stream);
@ -70,8 +71,12 @@ public static class UOPFiles
var compressed = reader.ReadInt16() == 1;
if (offset != 0 && hashes.TryGetValue(fileNameHash, out var fileIndex) && compressedLength > 0 &&
decompressedLength > 0)
if (offset == 0 || compressedLength <= 0 || decompressedLength <= 0)
{
continue;
}
if (hashes.TryGetValue(fileNameHash, out var fileIndex))
{
entries[fileIndex] = new UOPEntry(offset + headerLength, decompressedLength)
{
@ -79,6 +84,14 @@ public static class UOPFiles
CompressedSize = compressedLength
};
}
else if (additionalHashes != null && additionalHashes.ContainsKey(fileNameHash))
{
additionalHashes[fileNameHash] = new UOPEntry(offset + headerLength, decompressedLength)
{
Compressed = compressed,
CompressedSize = compressedLength
};
}
}
}
while (nextBlock != 0 && nextBlock < length);