1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Random Map Generator Option: Allow having more computer only players than human/computer players

Remove unused variable humanPlayersCount and function getHumanOnlyPlayerCount()
This commit is contained in:
laikh
2020-07-07 19:45:53 +08:00
parent 90e2ab58a8
commit edc1d06f4e
4 changed files with 21 additions and 28 deletions

View File

@@ -19,7 +19,7 @@
CMapGenOptions::CMapGenOptions()
: width(CMapHeader::MAP_SIZE_MIDDLE), height(CMapHeader::MAP_SIZE_MIDDLE), hasTwoLevels(true),
playerCount(RANDOM_SIZE), teamCount(RANDOM_SIZE), compOnlyPlayerCount(RANDOM_SIZE), compOnlyTeamCount(RANDOM_SIZE), humanPlayersCount(0),
playerCount(RANDOM_SIZE), teamCount(RANDOM_SIZE), compOnlyPlayerCount(RANDOM_SIZE), compOnlyTeamCount(RANDOM_SIZE),
waterContent(EWaterContent::RANDOM), monsterStrength(EMonsterStrength::RANDOM), mapTemplate(nullptr)
{
resetPlayersMap();
@@ -71,22 +71,9 @@ void CMapGenOptions::setPlayerCount(si8 value)
if (compOnlyPlayerCount > possibleCompPlayersCount)
setCompOnlyPlayerCount(possibleCompPlayersCount);
if (getPlayerCount() != RANDOM_SIZE)
{
if (getCompOnlyPlayerCount() != RANDOM_SIZE)
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
else
humanPlayersCount = getPlayerCount();
}
resetPlayersMap();
}
si8 CMapGenOptions::getHumanOnlyPlayerCount() const
{
return humanPlayersCount;
}
si8 CMapGenOptions::getTeamCount() const
{
return teamCount;
@@ -105,12 +92,9 @@ si8 CMapGenOptions::getCompOnlyPlayerCount() const
void CMapGenOptions::setCompOnlyPlayerCount(si8 value)
{
assert(value == RANDOM_SIZE || (getPlayerCount() == RANDOM_SIZE || (value >= 0 && value <= getPlayerCount())));
assert(value == RANDOM_SIZE || (getPlayerCount() == RANDOM_SIZE || (value >= 0 && value <= PlayerColor::PLAYER_LIMIT_I - getPlayerCount())));
compOnlyPlayerCount = value;
if (getPlayerCount() != RANDOM_SIZE && getCompOnlyPlayerCount() != RANDOM_SIZE)
humanPlayersCount = getPlayerCount() - getCompOnlyPlayerCount();
resetPlayersMap();
}
@@ -159,7 +143,7 @@ void CMapGenOptions::resetPlayersMap()
players.clear();
int realPlayersCnt = humanPlayersCount;
int realPlayersCnt = playerCount;
int realCompOnlyPlayersCnt = (compOnlyPlayerCount == RANDOM_SIZE) ? (PlayerColor::PLAYER_LIMIT_I - realPlayersCnt) : compOnlyPlayerCount;
int totalPlayersLimit = realPlayersCnt + realCompOnlyPlayersCnt;
if (getPlayerCount() == RANDOM_SIZE || compOnlyPlayerCount == RANDOM_SIZE)