Fix TOCTOU issues when calling Game.RunAfterDelay.

Since the action runs after a delay, the state of the game may no longer be the same and it may no longer be valid to run the action. Anything that references the world now calls IsCurrentWorld to ensure the world hasn't changed or been disposed.
This commit is contained in:
RoosterDragon
2015-10-24 19:27:05 +01:00
parent d10dd5c9d9
commit 7c889c5ef0
7 changed files with 36 additions and 22 deletions

View File

@@ -150,6 +150,9 @@ namespace OpenRA.Mods.Common.Traits
if (gameOver)
Game.RunAfterDelay(Info.GameOverDelay, () =>
{
if (!Game.IsCurrentWorld(player.World))
return;
player.World.EndGame();
player.World.SetPauseState(true);
player.World.PauseStateLocked = true;