@@ -13,7 +13,8 @@ use crate::misc::resource_id::ResourceID;
1313use crate :: resource:: pdefs:: PackageDefinitionSource :: { HM2 , HM2016 , HM3 } ;
1414use crate :: resource:: pdefs:: PartitionType :: { Dlc , LanguageDlc , LanguageStandard , Standard } ;
1515use crate :: resource:: resource_partition:: PatchId ;
16- use crate :: WoaVersion ;
16+ use crate :: { utils, WoaVersion } ;
17+ use crate :: resource:: pdefs:: GameDiscoveryError :: InvalidRuntimePath ;
1718
1819pub mod h2016_parser;
1920pub mod hm2_parser;
@@ -164,16 +165,16 @@ impl Display for PartitionId {
164165#[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
165166pub struct PartitionInfo {
166167 /// The name of the partition, if available.
167- name : Option < String > ,
168+ pub name : Option < String > ,
168169 /// The parent partition's identifier, if any.
169- parent : Option < PartitionId > ,
170+ pub parent : Option < PartitionId > ,
170171 /// The identifier of the partition.
171172 /// Example: "chunk9", "dlc12" or "dlc5langjp"
172- id : PartitionId ,
173+ pub id : PartitionId ,
173174 /// The patch level of the partition. Note: This is used an an upper bound, any patch above this level will be ignored.
174- patch_level : usize ,
175+ pub patch_level : usize ,
175176 /// The list of resource IDs associated with this partition.
176- roots : Vec < ResourceID > ,
177+ pub roots : Vec < ResourceID > ,
177178}
178179
179180impl PartitionInfo {
@@ -191,26 +192,34 @@ impl PartitionInfo {
191192 self . id . to_filename ( patch_index)
192193 }
193194
195+ #[ deprecated( since="1.1.0" , note="you can push to the roots field directly" ) ]
194196 pub fn add_root ( & mut self , resource_id : ResourceID ) {
195197 self . roots . push ( resource_id) ;
196198 }
199+ #[ deprecated( since="1.1.0" , note="prefer direct access through the roots field" ) ]
197200 pub fn roots ( & self ) -> & Vec < ResourceID > {
198201 & self . roots
199202 }
200203
204+ #[ deprecated( since="1.1.0" , note="prefer direct access through the name field" ) ]
201205 pub fn name ( & self ) -> & Option < String > {
202206 & self . name
203207 }
208+
209+ #[ deprecated( since="1.1.0" , note="prefer direct access through the parent field" ) ]
204210 pub fn parent ( & self ) -> & Option < PartitionId > {
205211 & self . parent
206212 }
213+
214+ #[ deprecated( since="1.1.0" , note="prefer direct access through the id field" ) ]
207215 pub fn id ( & self ) -> PartitionId {
208216 self . id . clone ( )
209217 }
218+ #[ deprecated( since="1.1.0" , note="prefer direct access through the patch_level field" ) ]
210219 pub fn max_patch_level ( & self ) -> usize {
211220 self . patch_level
212221 }
213-
222+
214223 pub fn set_max_patch_level ( & mut self , patch_level : usize ) {
215224 self . patch_level = patch_level
216225 }
@@ -284,6 +293,9 @@ pub enum GameDiscoveryError {
284293
285294 #[ error( "No PROJECT_PATH found in thumbs.dat" ) ]
286295 NoProjectPath ,
296+
297+ #[ error( "The Runtime path cannot be found" ) ]
298+ InvalidRuntimePath ,
287299
288300 #[ error( "Failed to parse the thumbs.dat file: {0}" ) ]
289301 FailedToParseThumbsFile ( #[ from] IniFileError ) ,
@@ -310,9 +322,14 @@ impl GamePaths {
310322 . options ( )
311323 . get ( "RUNTIME_PATH" )
312324 . ok_or ( GameDiscoveryError :: NoRuntimePath ) ?;
313- let runtime_path = retail_directory
314- . join ( project_path)
325+ let mut runtime_path = retail_directory
326+ . join ( project_path. replace ( " \\ " , "/" ) )
315327 . join ( relative_runtime_path) ;
328+ if !runtime_path. exists ( ) {
329+ runtime_path = retail_directory. join ( project_path. replace ( "\\ " , "/" ) ) . join ( utils:: uppercase_first_letter ( relative_runtime_path) ) ;
330+ }
331+
332+ runtime_path = runtime_path. canonicalize ( ) . map_err ( |_| InvalidRuntimePath ) ?;
316333 let package_definition_path = runtime_path. join ( "packagedefinition.txt" ) ;
317334
318335 Ok ( Self {
0 commit comments