mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Fix crash when generating random map with random number of players
This commit is contained in:
@@ -321,7 +321,7 @@ void CClient::initMapHandler()
|
|||||||
|
|
||||||
void CClient::initPlayerInterfaces()
|
void CClient::initPlayerInterfaces()
|
||||||
{
|
{
|
||||||
for(auto & elem : CSH->si->playerInfos)
|
for(auto & elem : gs->scenarioOps->playerInfos)
|
||||||
{
|
{
|
||||||
PlayerColor color = elem.first;
|
PlayerColor color = elem.first;
|
||||||
if(!vstd::contains(CSH->getAllClientPlayers(CSH->c->connectionID), color))
|
if(!vstd::contains(CSH->getAllClientPlayers(CSH->c->connectionID), color))
|
||||||
|
|||||||
@@ -71,8 +71,13 @@ void CMapGenOptions::setPlayerCount(si8 value)
|
|||||||
if (compOnlyPlayerCount > possibleCompPlayersCount)
|
if (compOnlyPlayerCount > possibleCompPlayersCount)
|
||||||
setCompOnlyPlayerCount(possibleCompPlayersCount);
|
setCompOnlyPlayerCount(possibleCompPlayersCount);
|
||||||
|
|
||||||
if (getPlayerCount() != RANDOM_SIZE && getCompOnlyPlayerCount() != RANDOM_SIZE)
|
if (getPlayerCount() != RANDOM_SIZE)
|
||||||
|
{
|
||||||
|
if (getCompOnlyPlayerCount() != RANDOM_SIZE)
|
||||||
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
|
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
|
||||||
|
else
|
||||||
|
humanPlayersCount = getPlayerCount();
|
||||||
|
}
|
||||||
|
|
||||||
resetPlayersMap();
|
resetPlayersMap();
|
||||||
}
|
}
|
||||||
@@ -167,7 +172,10 @@ void CMapGenOptions::resetPlayersMap()
|
|||||||
auto pc = PlayerColor(color);
|
auto pc = PlayerColor(color);
|
||||||
player.setColor(pc);
|
player.setColor(pc);
|
||||||
auto playerType = EPlayerType::AI;
|
auto playerType = EPlayerType::AI;
|
||||||
if ((getPlayerCount() != RANDOM_SIZE && color >= realPlayersCnt)
|
if (getPlayerCount() != RANDOM_SIZE && color < realPlayersCnt)
|
||||||
|
{
|
||||||
|
playerType = EPlayerType::HUMAN;
|
||||||
|
}else if ((getPlayerCount() != RANDOM_SIZE && color >= realPlayersCnt)
|
||||||
|| (compOnlyPlayerCount != RANDOM_SIZE && color >= (PlayerColor::PLAYER_LIMIT_I-compOnlyPlayerCount)))
|
|| (compOnlyPlayerCount != RANDOM_SIZE && color >= (PlayerColor::PLAYER_LIMIT_I-compOnlyPlayerCount)))
|
||||||
{
|
{
|
||||||
playerType = EPlayerType::COMP_ONLY;
|
playerType = EPlayerType::COMP_ONLY;
|
||||||
|
|||||||
Reference in New Issue
Block a user