Fixed timer crash once for all - yes it was a race condition
This commit is contained in:
@@ -60,6 +60,8 @@ namespace Barotrauma
|
|||||||
throw new ArgumentNullException(nameof(timedAction));
|
throw new ArgumentNullException(nameof(timedAction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock (timedActions)
|
||||||
|
{
|
||||||
int insertionPoint = timedActions.BinarySearch(timedAction, new TimerComparer());
|
int insertionPoint = timedActions.BinarySearch(timedAction, new TimerComparer());
|
||||||
|
|
||||||
if (insertionPoint < 0)
|
if (insertionPoint < 0)
|
||||||
@@ -69,8 +71,11 @@ namespace Barotrauma
|
|||||||
|
|
||||||
timedActions.Insert(insertionPoint, timedAction);
|
timedActions.Insert(insertionPoint, timedAction);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
|
{
|
||||||
|
lock (timedActions)
|
||||||
{
|
{
|
||||||
TimedAction[] timedCopy = timedActions.ToArray();
|
TimedAction[] timedCopy = timedActions.ToArray();
|
||||||
for (int i = 0; i < timedCopy.Length; i++)
|
for (int i = 0; i < timedCopy.Length; i++)
|
||||||
@@ -95,6 +100,7 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Clear()
|
public void Clear()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user