From 625c18a8899c64182e3f9df60c51547c13867d9d Mon Sep 17 00:00:00 2001 From: nordsoft Date: Fri, 18 Nov 2022 04:05:35 +0400 Subject: [PATCH] Fix #3234 --- client/lobby/RandomMapTab.cpp | 4 ++++ lib/rmg/CMapGenOptions.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/client/lobby/RandomMapTab.cpp b/client/lobby/RandomMapTab.cpp index 730ce0397..d945388cf 100644 --- a/client/lobby/RandomMapTab.cpp +++ b/client/lobby/RandomMapTab.cpp @@ -107,6 +107,10 @@ RandomMapTab::RandomMapTab() groupCompOnlyPlayers->addCallback([&](int btnId) { mapGenOptions->setCompOnlyPlayerCount(btnId); + + // deactive some MaxPlayers buttons to prevent total number of players exceeds PlayerColor::PLAYER_LIMIT_I + deactivateButtonsFrom(groupMaxPlayers.get(), PlayerColor::PLAYER_LIMIT_I - btnId + 1); + deactivateButtonsFrom(groupCompOnlyTeams.get(), (btnId == 0 ? 1 : btnId)); validateCompOnlyPlayersCnt(btnId); updateMapInfoByHost(); diff --git a/lib/rmg/CMapGenOptions.cpp b/lib/rmg/CMapGenOptions.cpp index 774f374d5..141e61782 100644 --- a/lib/rmg/CMapGenOptions.cpp +++ b/lib/rmg/CMapGenOptions.cpp @@ -70,7 +70,7 @@ void CMapGenOptions::setPlayerCount(si8 value) assert((value >= 1 && value <= PlayerColor::PLAYER_LIMIT_I) || value == RANDOM_SIZE); playerCount = value; - auto possibleCompPlayersCount = value; + auto possibleCompPlayersCount = PlayerColor::PLAYER_LIMIT_I - value; if (compOnlyPlayerCount > possibleCompPlayersCount) setCompOnlyPlayerCount(possibleCompPlayersCount);