@@ -300,15 +300,21 @@ public void UpdateTType(bool stateChange)
300300 {
301301 _activeInSource . Uninitialize ( ) ;
302302 //_activeInSource.Car = null;
303- _activeInSource = _inSources [ _curTType ] ;
303+ if ( 0 <= _curTType && _curTType < _inSources . Count )
304+ _activeInSource = _inSources [ _curTType ] ;
305+ else
306+ Trace . TraceWarning ( "Could not change inside sound region to {0}" , _curTType ) ;
304307 //_activeInSource.Car = Car;
305308 }
306309
307310 if ( _activeOutSource != null )
308311 {
309312 _activeOutSource . Uninitialize ( ) ;
310313 //_activeOutSource.Car = null;
311- _activeOutSource = _outSources [ _curTType ] ;
314+ if ( 0 <= _curTType && _curTType < _outSources . Count )
315+ _activeOutSource = _outSources [ _curTType ] ;
316+ else
317+ Trace . TraceWarning ( "Could not change outside sound region to {0}" , _curTType ) ;
312318 //_activeOutSource.Car = Car;
313319 }
314320#if DEBUGSCR
@@ -457,15 +463,21 @@ public bool UpdateCarOnSwitchAndCurve()
457463 {
458464 _activeInSource . Uninitialize ( ) ;
459465 //_activeInSource.Car = null;
460- _activeInSource = _inSources [ _curTType ] ;
466+ if ( 0 <= _curTType && _curTType < _inSources . Count )
467+ _activeInSource = _inSources [ _curTType ] ;
468+ else
469+ Trace . TraceWarning ( "Could not change inside sound region to {0}" , _curTType ) ;
461470 //_activeInSource.Car = Car;
462471 }
463472
464473 if ( _activeOutSource != null )
465474 {
466475 _activeOutSource . Uninitialize ( ) ;
467476 //_activeOutSource.Car = null;
468- _activeOutSource = _outSources [ _curTType ] ;
477+ if ( 0 <= _curTType && _curTType < _outSources . Count )
478+ _activeOutSource = _outSources [ _curTType ] ;
479+ else
480+ Trace . TraceWarning ( "Could not change outside sound region to {0}" , _curTType ) ;
469481 //_activeOutSource.Car = Car;
470482 }
471483#if DEBUGSCR
0 commit comments