@@ -26,18 +26,20 @@ public void SaveIndex(string indexFile)
26
26
27
27
public void SaveIndex ( string indexFile , JsonSerializerOptions options )
28
28
=> File . WriteAllText ( indexFile , JsonSerializer . Serialize ( this , options ) ) ;
29
+
29
30
public static async Task < ObjectIndexEntry > GetDatFileInfoFromBytesAsync ( ( string Filename , byte [ ] Data ) file )
30
31
=> await Task . Run ( ( ) => GetDatFileInfoFromBytes ( file ) ) ;
31
32
32
- public static async Task < ObjectIndex ? > LoadOrCreateIndexAsync ( string directory , IProgress < float > ? progress = null )
33
+ public static async Task < ObjectIndex > LoadOrCreateIndexAsync ( string directory , IProgress < float > ? progress = null )
33
34
{
34
35
var indexPath = Path . Combine ( directory , DefaultIndexFileName ) ;
35
- ObjectIndex ? index ;
36
+ ObjectIndex ? index = null ;
36
37
if ( File . Exists ( indexPath ) )
37
38
{
38
39
index = LoadIndex ( indexPath ) ;
39
40
}
40
- else
41
+
42
+ if ( index == null )
41
43
{
42
44
index = await CreateIndexAsync ( directory , progress ) ;
43
45
index . SaveIndex ( indexPath ) ;
@@ -46,7 +48,7 @@ public static async Task<ObjectIndexEntry> GetDatFileInfoFromBytesAsync((string
46
48
return index ;
47
49
}
48
50
49
- public static ObjectIndex ? LoadOrCreateIndex ( string directory , IProgress < float > ? progress = null )
51
+ public static ObjectIndex LoadOrCreateIndex ( string directory , IProgress < float > ? progress = null )
50
52
=> LoadOrCreateIndexAsync ( directory , progress ) . Result ;
51
53
52
54
public static Task < ObjectIndex > CreateIndexAsync ( string directory , IProgress < float > ? progress = null )
@@ -107,16 +109,16 @@ public static ObjectIndexEntry GetDatFileInfoFromBytes((string Filename, byte[]
107
109
}
108
110
109
111
var remainingData = file . Data [ ( S5Header . StructLength + ObjectHeader . StructLength ) ..] ;
110
- var isVanilla = hdrs . S5 . IsVanilla ( ) ;
112
+ var source = OriginalObjectFiles . GetFileSource ( hdrs . S5 . Name , hdrs . S5 . Checksum ) ;
111
113
112
114
if ( hdrs . S5 . ObjectType == ObjectType . Vehicle )
113
115
{
114
116
var decoded = SawyerStreamReader . Decode ( hdrs . Obj . Encoding , remainingData , 4 ) ; // only need 4 bytes since vehicle type is in the 4th byte of a vehicle object
115
- return new ObjectIndexEntry ( file . Filename , hdrs . S5 . Name , hdrs . S5 . Checksum , hdrs . S5 . ObjectType , isVanilla , ( VehicleType ) decoded [ 3 ] ) ;
117
+ return new ObjectIndexEntry ( file . Filename , hdrs . S5 . Name , hdrs . S5 . Checksum , hdrs . S5 . ObjectType , source , ( VehicleType ) decoded [ 3 ] ) ;
116
118
}
117
119
else
118
120
{
119
- return new ObjectIndexEntry ( file . Filename , hdrs . S5 . Name , hdrs . S5 . Checksum , hdrs . S5 . ObjectType , isVanilla ) ;
121
+ return new ObjectIndexEntry ( file . Filename , hdrs . S5 . Name , hdrs . S5 . Checksum , hdrs . S5 . ObjectType , source ) ;
120
122
}
121
123
}
122
124
}
@@ -126,6 +128,6 @@ public record ObjectIndexEntry(
126
128
string DatName ,
127
129
uint32_t DatChecksum ,
128
130
ObjectType ObjectType ,
129
- bool IsVanilla ,
131
+ ObjectSource ObjectSource ,
130
132
VehicleType ? VehicleType = null ) ;
131
133
}
0 commit comments