Disable gamemode vote if only one available (#11915)

* disable vote on condition

* move to new method

* still allow vote if current mode is different from available
This commit is contained in:
corentt
2022-10-15 06:10:10 +02:00
committed by GitHub
parent 0b38589728
commit 4159638300
2 changed files with 31 additions and 15 deletions

View File

@@ -103,21 +103,7 @@ namespace Content.Server.Voting.Managers
private void CreatePresetVote(IPlayerSession? initiator)
{
var presets = new Dictionary<string, string>();
foreach (var preset in _prototypeManager.EnumeratePrototypes<GamePresetPrototype>())
{
if(!preset.ShowInVote)
continue;
if(_playerManager.PlayerCount < (preset.MinPlayers ?? int.MinValue))
continue;
if(_playerManager.PlayerCount > (preset.MaxPlayers ?? int.MaxValue))
continue;
presets[preset.ID] = preset.ModeTitle;
}
var presets = GetGamePresets();
var alone = _playerManager.PlayerCount == 1 && initiator != null;
var options = new VoteOptions
@@ -211,5 +197,25 @@ namespace Content.Server.Voting.Managers
_standardVoteTimeout[type] = _timing.RealTime + timeout;
DirtyCanCallVoteAll();
}
private Dictionary<string, string> GetGamePresets()
{
var presets = new Dictionary<string, string>();
foreach (var preset in _prototypeManager.EnumeratePrototypes<GamePresetPrototype>())
{
if(!preset.ShowInVote)
continue;
if(_playerManager.PlayerCount < (preset.MinPlayers ?? int.MinValue))
continue;
if(_playerManager.PlayerCount > (preset.MaxPlayers ?? int.MaxValue))
continue;
presets[preset.ID] = preset.ModeTitle;
}
return presets;
}
}
}