@@ -442,6 +442,12 @@ public async Task<byte[]> GetType2Data(string internalPath, bool forceOriginal)
442
442
/// <returns>Byte array containing the decompressed type 2 data.</returns>
443
443
public async Task < byte [ ] > GetType2Data ( long offset , XivDataFile dataFile )
444
444
{
445
+ if ( offset <= 0 )
446
+ {
447
+ throw new InvalidDataException ( "Cannot get file data without valid offset." ) ;
448
+ }
449
+
450
+
445
451
var type2Bytes = new List < byte > ( ) ;
446
452
447
453
// This formula is used to obtain the dat number in which the offset is located
@@ -770,6 +776,10 @@ public async Task<byte[]> CreateType2Data(byte[] dataToCreate)
770
776
/// <returns>A tuple containing the mesh count, material count, and decompressed data</returns>
771
777
public async Task < ( int MeshCount , int MaterialCount , byte [ ] Data ) > GetType3Data ( long offset , XivDataFile dataFile )
772
778
{
779
+ if ( offset <= 0 )
780
+ {
781
+ throw new InvalidDataException ( "Cannot get file data without valid offset." ) ;
782
+ }
773
783
774
784
// This formula is used to obtain the dat number in which the offset is located
775
785
var datNum = ( int ) ( ( offset / 8 ) & 0x0F ) / 2 ;
@@ -934,6 +944,11 @@ public async Task<XivTex> GetType4Data(string internalPath, bool forceOriginal)
934
944
935
945
public async Task < int > GetCompressedFileSize ( long offset , XivDataFile dataFile )
936
946
{
947
+ if ( offset <= 0 )
948
+ {
949
+ throw new InvalidDataException ( "Cannot get file size data without valid offset." ) ;
950
+ }
951
+
937
952
938
953
var xivTex = new XivTex ( ) ;
939
954
@@ -1079,6 +1094,11 @@ public async Task<int> GetCompressedFileSize(long offset, XivDataFile dataFile)
1079
1094
/// <returns>An XivTex containing all the type 4 texture data</returns>
1080
1095
public async Task < XivTex > GetType4Data ( long offset , XivDataFile dataFile )
1081
1096
{
1097
+ if ( offset <= 0 )
1098
+ {
1099
+ throw new InvalidDataException ( "Cannot get file size data without valid offset." ) ;
1100
+ }
1101
+
1082
1102
var xivTex = new XivTex ( ) ;
1083
1103
1084
1104
var decompressedData = new List < byte > ( ) ;
0 commit comments