mirror of
https://github.com/kwsch/pkNX.git
synced 2026-09-29 12:46:59 -05:00
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
25 lines
743 B
C#
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;
|
|
}
|
|
}
|