@@ -463,10 +463,10 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
463463 if ( Program . Simulator . CarSpawnerLists != null && ( ( CarSpawnerObj ) worldObject ) . ListName != null )
464464 {
465465 ( ( CarSpawnerObj ) worldObject ) . CarSpawnerListIdx = Program . Simulator . CarSpawnerLists . FindIndex ( x => x . ListName == ( ( CarSpawnerObj ) worldObject ) . ListName ) ;
466- if ( ( ( CarSpawnerObj ) worldObject ) . CarSpawnerListIdx < 0 || ( ( CarSpawnerObj ) worldObject ) . CarSpawnerListIdx > Program . Simulator . CarSpawnerLists . Count - 1 )
466+ if ( ( ( CarSpawnerObj ) worldObject ) . CarSpawnerListIdx < 0 || ( ( CarSpawnerObj ) worldObject ) . CarSpawnerListIdx > Program . Simulator . CarSpawnerLists . Count - 1 )
467467 ( ( CarSpawnerObj ) worldObject ) . CarSpawnerListIdx = 0 ;
468468 }
469- else
469+ else
470470 ( ( CarSpawnerObj ) worldObject ) . CarSpawnerListIdx = 0 ;
471471 carSpawners . Add ( new RoadCarSpawner ( viewer , worldMatrix , ( CarSpawnerObj ) worldObject ) ) ;
472472 }
@@ -480,10 +480,16 @@ public WorldFile(Viewer viewer, int tileX, int tileZ, bool visible)
480480 }
481481 else if ( worldObject . GetType ( ) == typeof ( StaticObj ) )
482482 {
483- // preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
483+ // preTestShape for lookup if it is an animated clock shape with subobjects named as clock hands
484484 StaticShape preTestShape = ( new StaticShape ( viewer , shapeFilePath , worldMatrix , shadowCaster ? ShapeFlags . ShadowCaster : ShapeFlags . None ) ) ;
485- var animNodes = preTestShape . SharedShape . Animations ? [ 0 ] ? . anim_nodes ?? new List < anim_node > ( ) ;
486- var isAnimatedClock = animNodes . Exists ( node => Regex . IsMatch ( node . Name , @"^orts_[hmsc]hand_clock" , RegexOptions . IgnoreCase ) ) ;
485+ var isAnimatedClock = false ;
486+ if ( preTestShape . SharedShape . Animations != null
487+ && preTestShape . SharedShape . Animations . Count > 0 ) // Since animations( 0 ) is a valid entry in *.s files
488+ // and is included by MSTSexporter for Blender 2.8+ Release V4.0 or older
489+ {
490+ var animNodes = preTestShape . SharedShape . Animations [ 0 ] ? . anim_nodes ?? new List < anim_node > ( ) ;
491+ isAnimatedClock = animNodes . Exists ( node => Regex . IsMatch ( node . Name , @"^orts_[hmsc]hand_clock" , RegexOptions . IgnoreCase ) ) ;
492+ }
487493 if ( isAnimatedClock )
488494 {
489495 sceneryObjects . Add ( new AnalogClockShape ( viewer , shapeFilePath , worldMatrix , shadowCaster ? ShapeFlags . ShadowCaster : ShapeFlags . None ) ) ;
0 commit comments