Prevent SecretRule from picking invalid presets (#27456)

* Prevent SecretRule from picking invalid presets

* remove lonely semicolon

---------

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
This commit is contained in:
Leon Friedrich
2024-04-29 16:00:41 +12:00
committed by GitHub
parent 2393ce1ceb
commit 8f1a44fe05
2 changed files with 150 additions and 22 deletions

View File

@@ -173,6 +173,26 @@ namespace Content.Server.GameTicking
return gridUids;
}
public int ReadyPlayerCount()
{
var total = 0;
foreach (var (userId, status) in _playerGameStatuses)
{
if (LobbyEnabled && status == PlayerGameStatus.NotReadyToPlay)
continue;
if (!_playerManager.TryGetSessionById(userId, out _))
continue;
if (_banManager.GetRoleBans(userId) == null)
continue;
total++;
}
return total;
}
public void StartRound(bool force = false)
{
#if EXCEPTION_TOLERANCE
@@ -228,6 +248,8 @@ namespace Content.Server.GameTicking
readyPlayerProfiles.Add(userId, profile);
}
DebugTools.AssertEqual(readyPlayers.Count, ReadyPlayerCount());
// Just in case it hasn't been loaded previously we'll try loading it.
LoadMaps();