1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-30 23:18:08 +02:00

Merge pull request #1149 from Nordsoft91/fix-crash-3234

Fix #3234
This commit is contained in:
Andrii Danylchenko 2022-11-19 12:40:43 +02:00 committed by GitHub
commit 7ae35b95a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -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();

View File

@ -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);