@@ -79,6 +79,7 @@ public Theater(string name)
7979 public TileSet RampTileSet { get ; set ; }
8080 public TileSet BridgeTileSet { get ; set ; }
8181 public TileSet TrainBridgeTileSet { get ; set ; }
82+ public TileSet WoodBridgeTileSet { get ; set ; }
8283
8384 private const string REQUIRED_SECTION = "General" ;
8485
@@ -131,21 +132,25 @@ public void ReadConfigINI(string baseDirectoryPath, CCFileManager ccFileManager)
131132 InitLATGround ( theaterIni , "CrystalTile" , "ClearToCrystalLat" , null , null , null , "Crystal" ) ;
132133 InitLATGround ( theaterIni , "BlueMoldTile" , "ClearToBlueMoldLat" , null , null , null , "Blue Mold" ) ;
133134
134- int rampTileSetIndex = theaterIni . GetIntValue ( "General" , "RampBase" , - 1 ) ;
135- if ( rampTileSetIndex < 0 || rampTileSetIndex >= TileSets . Count )
136- throw new INIConfigException ( "Invalid value specified for RampBase= in the theater configuration file!" ) ;
135+ RampTileSet = GetTileSetFromKey ( theaterIni , "RampBase" , false ) ;
136+ BridgeTileSet = GetTileSetFromKey ( theaterIni , "BridgeSet" , false ) ;
137+ TrainBridgeTileSet = GetTileSetFromKey ( theaterIni , "TrainBridgeSet" , false ) ;
138+ WoodBridgeTileSet = GetTileSetFromKey ( theaterIni , "WoodBridgeSet" , true ) ; // Wood bridges are optional as they do not exist in TS
139+ }
137140
138- int bridgeTileSetIndex = theaterIni . GetIntValue ( "General" , "BridgeSet" , - 1 ) ;
139- if ( bridgeTileSetIndex < 0 || bridgeTileSetIndex >= TileSets . Count )
140- throw new INIConfigException ( "Invalid value specified for BridgeSet= in the theater configuration file!" ) ;
141+ private TileSet GetTileSetFromKey ( IniFile theaterIni , string key , bool optional )
142+ {
143+ int index = theaterIni . GetIntValue ( "General" , key , - 1 ) ;
141144
142- int trainBridgeTileSetIndex = theaterIni . GetIntValue ( "General" , "TrainBridgeSet" , - 1 ) ;
143- if ( trainBridgeTileSetIndex < 0 || trainBridgeTileSetIndex >= TileSets . Count )
144- throw new INIConfigException ( "Invalid value specified for TrainBridgeSet= in the theater configuration file!" ) ;
145+ if ( index < 0 || index >= TileSets . Count )
146+ {
147+ if ( optional )
148+ return null ;
149+
150+ throw new INIConfigException ( $ "Invalid value specified for { key } = in the theater configuration file!") ;
151+ }
145152
146- RampTileSet = TileSets [ rampTileSetIndex ] ;
147- BridgeTileSet = TileSets [ bridgeTileSetIndex ] ;
148- TrainBridgeTileSet = TileSets [ trainBridgeTileSetIndex ] ;
153+ return TileSets [ index ] ;
149154 }
150155
151156 public TileSet TryGetTileSetById ( int id )
0 commit comments