mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-23 12:08:45 +02:00
Fixed issue when player starting towns were wiped.
This commit is contained in:
parent
f9781ffb47
commit
e9654ef487
@ -138,6 +138,17 @@ void CMapGenOptions::setMonsterStrength(EMonsterStrength::EMonsterStrength value
|
|||||||
|
|
||||||
void CMapGenOptions::resetPlayersMap()
|
void CMapGenOptions::resetPlayersMap()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
std::map<PlayerColor, TFaction> rememberTownTypes;
|
||||||
|
|
||||||
|
for (auto p : players)
|
||||||
|
{
|
||||||
|
auto town = p.second.getStartingTown();
|
||||||
|
if (town != RANDOM_SIZE)
|
||||||
|
rememberTownTypes[p.first] = town;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
players.clear();
|
players.clear();
|
||||||
int realPlayersCnt = humanPlayersCount;
|
int realPlayersCnt = humanPlayersCount;
|
||||||
int realCompOnlyPlayersCnt = (compOnlyPlayerCount == RANDOM_SIZE) ? (PlayerColor::PLAYER_LIMIT_I - realPlayersCnt) : compOnlyPlayerCount;
|
int realCompOnlyPlayersCnt = (compOnlyPlayerCount == RANDOM_SIZE) ? (PlayerColor::PLAYER_LIMIT_I - realPlayersCnt) : compOnlyPlayerCount;
|
||||||
@ -149,7 +160,8 @@ void CMapGenOptions::resetPlayersMap()
|
|||||||
for(int color = 0; color < totalPlayersLimit; ++color)
|
for(int color = 0; color < totalPlayersLimit; ++color)
|
||||||
{
|
{
|
||||||
CPlayerSettings player;
|
CPlayerSettings player;
|
||||||
player.setColor(PlayerColor(color));
|
auto pc = PlayerColor(color);
|
||||||
|
player.setColor(pc);
|
||||||
auto playerType = EPlayerType::AI;
|
auto playerType = EPlayerType::AI;
|
||||||
if ((getPlayerCount() != RANDOM_SIZE && color >= realPlayersCnt)
|
if ((getPlayerCount() != RANDOM_SIZE && color >= realPlayersCnt)
|
||||||
|| (compOnlyPlayerCount != RANDOM_SIZE && color >= (PlayerColor::PLAYER_LIMIT_I-compOnlyPlayerCount)))
|
|| (compOnlyPlayerCount != RANDOM_SIZE && color >= (PlayerColor::PLAYER_LIMIT_I-compOnlyPlayerCount)))
|
||||||
@ -157,7 +169,10 @@ void CMapGenOptions::resetPlayersMap()
|
|||||||
playerType = EPlayerType::COMP_ONLY;
|
playerType = EPlayerType::COMP_ONLY;
|
||||||
}
|
}
|
||||||
player.setPlayerType(playerType);
|
player.setPlayerType(playerType);
|
||||||
players[PlayerColor(color)] = player;
|
players[pc] = player;
|
||||||
|
|
||||||
|
if (vstd::contains(rememberTownTypes, pc))
|
||||||
|
players[pc].setStartingTown(rememberTownTypes[pc]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user