Skip to content

Commit 723f722

Browse files
authored
Merge pull request #536 from pzgulyas/ttype
Gently handle a track sound crash. Fixes bug https://bugs.launchpad.net/or/+bug/1754805
2 parents 11692f3 + 5fdf9aa commit 723f722

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

Source/RunActivity/Viewer3D/Sound.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)