Files
pkNX/pkNX.Structures/Item/ItemHash8.cs
sora10pls 59351b2422 Fix SWSH field/hidden item randomization
Item hash table contains stubbed items with an associated item ID of 0, and two entries for Reins of Unity (1607). Prevent duplicate keys/hashes in the dictionary, as well as any stubbed items
2025-04-29 12:01:26 -04:00

25 lines
743 B
C#

using System;
using System.Collections.Generic;
using static System.Buffers.Binary.BinaryPrimitives;
namespace pkNX.Structures;
public static class ItemHash8
{
public static Dictionary<int, ulong> GetItemHashTable(ReadOnlySpan<byte> data)
{
int count = ReadInt32LittleEndian(data);
var hashes = new Dictionary<int, ulong>(count);
data = data[4..];
for (int i = 0; i < count; i++)
{
var hash = ReadUInt64LittleEndian(data);
var key = ReadInt32LittleEndian(data[8..]);
if (!hashes.ContainsKey(key) && !hashes.ContainsValue(hash) && key is not 0)
hashes.Add(key, hash);
data = data[0x10..];
}
return hashes;
}
}