1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-23 21:29:13 +02:00

Fixed some obvious bugs with random map options.

This commit is contained in:
DjWarmonger 2014-05-22 20:50:24 +02:00
parent 1e1dce20a8
commit aead8da54f

View File

@ -194,17 +194,17 @@ void CMapGenOptions::finalize(CRandomGenerator & rand)
auto possiblePlayers = mapTemplate->getPlayers().getNumbers(); auto possiblePlayers = mapTemplate->getPlayers().getNumbers();
possiblePlayers.erase(possiblePlayers.begin(), possiblePlayers.lower_bound(countHumanPlayers())); possiblePlayers.erase(possiblePlayers.begin(), possiblePlayers.lower_bound(countHumanPlayers()));
assert(!possiblePlayers.empty()); assert(!possiblePlayers.empty());
playerCount = *std::next(possiblePlayers.begin(), rand.nextInt(8)); playerCount = rand.nextInt(possiblePlayers.size());
updatePlayers(); updatePlayers();
} }
if(teamCount == RANDOM_SIZE) if(teamCount == RANDOM_SIZE)
{ {
teamCount = rand.nextInt(8); teamCount = rand.nextInt(playerCount - 1);
} }
if(compOnlyPlayerCount == RANDOM_SIZE) if(compOnlyPlayerCount == RANDOM_SIZE)
{ {
auto possiblePlayers = mapTemplate->getCpuPlayers().getNumbers(); auto possiblePlayers = mapTemplate->getCpuPlayers().getNumbers();
compOnlyPlayerCount = *std::next(possiblePlayers.begin(), rand.nextInt(8)); compOnlyPlayerCount = rand.nextInt(possiblePlayers.size());
updateCompOnlyPlayers(); updateCompOnlyPlayers();
} }
if(compOnlyTeamCount == RANDOM_SIZE) if(compOnlyTeamCount == RANDOM_SIZE)