Fix roundstart being called multiple times.

...By adding a guard against it. Look, it's not pretty but it works.
This commit is contained in:
Vera Aguilera Puerto
2021-12-21 22:20:17 +01:00
parent b1f86f0d2c
commit 07a3b3a798

View File

@@ -41,6 +41,9 @@ namespace Content.Server.GameTicking
[ViewVariables]
private TimeSpan _roundStartTimeSpan;
[ViewVariables]
private bool _startingRound;
[ViewVariables]
private GameRunLevel _runLevel;
@@ -66,6 +69,7 @@ namespace Content.Server.GameTicking
{
DefaultMap = _mapManager.CreateMap();
_pauseManager.AddUninitializedMap(DefaultMap);
_startingRound = false;
var startTime = _gameTiming.RealTime;
var map = _gameMapManager.GetSelectedMapChecked(true);
var grid = _mapLoader.LoadBlueprint(DefaultMap, map.MapPath);
@@ -105,10 +109,12 @@ namespace Content.Server.GameTicking
try
{
#endif
// If this game ticker is a dummy, do nothing!
if (DummyTicker)
// If this game ticker is a dummy or the round is already being started, do nothing!
if (DummyTicker || _startingRound)
return;
_startingRound = true;
DebugTools.Assert(RunLevel == GameRunLevel.PreRoundLobby);
Logger.InfoS("ticker", "Starting round!");
@@ -253,6 +259,8 @@ namespace Content.Server.GameTicking
_roundStartDateTime = DateTime.UtcNow;
RunLevel = GameRunLevel.InRound;
_startingRound = false;
_roundStartTimeSpan = _gameTiming.RealTime;
SendStatusToAll();
ReqWindowAttentionAll();
@@ -424,6 +432,8 @@ namespace Content.Server.GameTicking
EntityManager.DeleteEntity(entity);
}
_startingRound = false;
_mapManager.Restart();
// Clear up any game rules.