File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change
1
+ using System . Buffers . Binary ;
1
2
using System . Collections . Immutable ;
3
+ using System . Runtime . CompilerServices ;
2
4
using System . Runtime . InteropServices ;
5
+ using System . Runtime . InteropServices . Marshalling ;
3
6
using System . Security . Cryptography ;
4
7
using Lumina ;
5
8
using Lumina . Data . Files . Excel ;
@@ -76,8 +79,21 @@ [.. files.Where(pair => pair.Item2.Header.Variant == ExcelVariant.Subrows).Selec
76
79
77
80
public ExcelColumnDefinition [ ] this [ string sheetName ] => Sheets [ sheetName ] ;
78
81
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
+ }
81
97
82
98
public void WriteTo ( TextWriter writer )
83
99
{
You can’t perform that action at this time.
0 commit comments