Fix for CoroutineManager IndexOutOfRangeException (maybe)
This commit is contained in:
@@ -65,41 +65,43 @@ namespace Barotrauma
|
|||||||
|
|
||||||
for (int i = Coroutines.Count-1; i>=0; i--)
|
for (int i = Coroutines.Count-1; i>=0; i--)
|
||||||
{
|
{
|
||||||
|
CoroutineHandle handle = Coroutines[i];
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Coroutines[i].Coroutine.Current != null)
|
if (handle.Coroutine.Current != null)
|
||||||
{
|
{
|
||||||
WaitForSeconds wfs = Coroutines[i].Coroutine.Current as WaitForSeconds;
|
WaitForSeconds wfs = handle.Coroutine.Current as WaitForSeconds;
|
||||||
if (wfs != null)
|
if (wfs != null)
|
||||||
{
|
{
|
||||||
if (!wfs.CheckFinished(unscaledDeltaTime)) continue;
|
if (!wfs.CheckFinished(unscaledDeltaTime)) continue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch ((CoroutineStatus)Coroutines[i].Coroutine.Current)
|
switch ((CoroutineStatus)handle.Coroutine.Current)
|
||||||
{
|
{
|
||||||
case CoroutineStatus.Success:
|
case CoroutineStatus.Success:
|
||||||
Coroutines.RemoveAt(i);
|
Coroutines.RemoveAt(i);
|
||||||
continue;
|
continue;
|
||||||
case CoroutineStatus.Failure:
|
case CoroutineStatus.Failure:
|
||||||
DebugConsole.ThrowError("Coroutine ''" + Coroutines[i]+ "'' has failed");
|
DebugConsole.ThrowError("Coroutine ''" + handle.Name + "'' has failed");
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Coroutines[i].Coroutine.MoveNext();
|
handle.Coroutine.MoveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
DebugConsole.ThrowError("Coroutine " + Coroutines[i].Name + " threw an exception: " + e.Message);
|
DebugConsole.ThrowError("Coroutine " + handle.Name + " threw an exception: " + e.Message);
|
||||||
|
|
||||||
//#if DEBUG
|
//#if DEBUG
|
||||||
// throw e;
|
// throw e;
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
Coroutines.RemoveAt(i);
|
Coroutines.Remove(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user