Change EST files to be sorted and thus work.

This commit is contained in:
Ottermandias 2022-01-06 11:46:53 +01:00
parent 19b295bbc3
commit aa7d71530d

View file

@ -4,10 +4,11 @@ using System.Linq;
using Lumina.Data; using Lumina.Data;
using Penumbra.GameData.Enums; using Penumbra.GameData.Enums;
namespace Penumbra.Meta.Files namespace Penumbra.Meta.Files;
{
// EST Structure: // EST Structure:
// 1x [NumEntries : UInt32] // 1x [NumEntries : UInt32]
// Apparently entries need to be sorted.
// #NumEntries x [SetId : UInt16] [RaceId : UInt16] // #NumEntries x [SetId : UInt16] [RaceId : UInt16]
// #NumEntries x [SkeletonId : UInt16] // #NumEntries x [SkeletonId : UInt16]
public class EstFile public class EstFile
@ -15,17 +16,22 @@ namespace Penumbra.Meta.Files
private const ushort EntryDescSize = 4; private const ushort EntryDescSize = 4;
private const ushort EntrySize = 2; private const ushort EntrySize = 2;
private readonly Dictionary< GenderRace, Dictionary< ushort, ushort > > _entries = new(); private readonly SortedList< GenderRace, SortedList< ushort, ushort > > _entries = new();
private uint NumEntries { get; set; } private uint NumEntries { get; set; }
private EstFile( EstFile clone ) private EstFile( EstFile clone )
{ {
NumEntries = clone.NumEntries; NumEntries = clone.NumEntries;
_entries = new Dictionary< GenderRace, Dictionary< ushort, ushort > >( clone._entries.Count ); _entries = new SortedList< GenderRace, SortedList< ushort, ushort > >( clone._entries.Count );
foreach( var kvp in clone._entries ) foreach( var (genderRace, data) in clone._entries )
{ {
var dict = kvp.Value.ToDictionary( k => k.Key, k => k.Value ); var dict = new SortedList< ushort, ushort >( data.Count );
_entries.Add( kvp.Key, dict ); foreach( var (setId, value) in data )
{
dict.Add( setId, value );
}
_entries.Add( genderRace, dict );
} }
} }
@ -58,7 +64,7 @@ namespace Penumbra.Meta.Files
{ {
if( !_entries.TryGetValue( gr, out var setDict ) ) if( !_entries.TryGetValue( gr, out var setDict ) )
{ {
_entries[ gr ] = new Dictionary< ushort, ushort >(); _entries[ gr ] = new SortedList< ushort, ushort >();
setDict = _entries[ gr ]; setDict = _entries[ gr ];
} }
@ -154,4 +160,3 @@ namespace Penumbra.Meta.Files
} }
} }
} }
}