File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -384,24 +384,26 @@ public static Color GetHouseTypeUITextColor(HouseType houseType)
384384
385385 public static void FindDefaultSideForNewHouseType ( HouseType houseType , Rules rules )
386386 {
387+ // Cut numbers from the end of the housetype's name (so, for example, GDI2 becomes GDI)
388+ string houseTypeIniName = houseType . ININame ;
389+ while ( houseTypeIniName . Length > 0 && char . IsDigit ( houseTypeIniName [ ^ 1 ] ) )
390+ houseTypeIniName = houseTypeIniName [ ..^ 1 ] ;
391+
392+ if ( string . IsNullOrWhiteSpace ( houseTypeIniName ) )
393+ {
394+ houseType . Side = rules . Sides [ 0 ] ;
395+ return ;
396+ }
397+
387398 for ( int sideIndex = 0 ; sideIndex < rules . Sides . Count ; sideIndex ++ )
388399 {
389400 string side = rules . Sides [ sideIndex ] ;
390401
391- if ( houseType . ININame . StartsWith ( side ) )
402+ if ( side . StartsWith ( houseTypeIniName ) )
392403 {
393404 houseType . Side = side ;
394405 break ;
395406 }
396-
397- if ( side . EndsWith ( "Side" ) && side . Length > 4 )
398- {
399- if ( houseType . ININame . StartsWith ( side [ ..4 ] ) )
400- {
401- houseType . Side = side ;
402- break ;
403- }
404- }
405407 }
406408
407409 if ( string . IsNullOrWhiteSpace ( houseType . Side ) )
You can’t perform that action at this time.
0 commit comments