File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ using System . Buffers . Binary ;
12using System . Collections . Immutable ;
3+ using System . Runtime . CompilerServices ;
24using System . Runtime . InteropServices ;
5+ using System . Runtime . InteropServices . Marshalling ;
36using System . Security . Cryptography ;
47using Lumina ;
58using Lumina . Data . Files . Excel ;
@@ -76,8 +79,21 @@ [.. files.Where(pair => pair.Item2.Header.Variant == ExcelVariant.Subrows).Selec
7679
7780 public ExcelColumnDefinition [ ] this [ string sheetName ] => Sheets [ sheetName ] ;
7881
79- public uint GetColumnsHash ( string sheetName ) =>
80- Crc32 . Get ( MemoryMarshal . AsBytes ( Sheets [ sheetName ] . AsSpan ( ) ) ) ;
82+ public uint GetColumnsHash ( string sheetName )
83+ {
84+ var data = MemoryMarshal . Cast < ExcelColumnDefinition , ushort > ( Sheets [ sheetName ] . AsSpan ( ) ) ;
85+
86+ // Column hashes are based on the file data, so we need to ensure the endianness matches
87+ if ( BitConverter . IsLittleEndian )
88+ {
89+ var temp = data . ToArray ( ) ;
90+ foreach ( ref var el in temp . AsSpan ( ) )
91+ el = BinaryPrimitives . ReverseEndianness ( el ) ;
92+ data = temp . AsSpan ( ) ;
93+ }
94+
95+ return Crc32 . Get ( MemoryMarshal . Cast < ushort , byte > ( data ) ) ;
96+ }
8197
8298 public void WriteTo ( TextWriter writer )
8399 {
You can’t perform that action at this time.
0 commit comments