1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Support roads and teams customization in engine

This commit is contained in:
nordsoft
2022-12-17 03:52:40 +04:00
parent bcf95c32e9
commit f27a40dd34
5 changed files with 79 additions and 12 deletions

View File

@@ -76,6 +76,11 @@ void CMapGenerator::loadConfig()
config.pandoraMultiplierSpells = randomMapJson["pandoras"]["valueMultiplierSpells"].Integer();
config.pandoraSpellSchool = randomMapJson["pandoras"]["valueSpellSchool"].Integer();
config.pandoraSpell60 = randomMapJson["pandoras"]["valueSpell60"].Integer();
//override config with game options
if(!mapGenOptions.isRoadEnabled(config.secondaryRoadType))
config.secondaryRoadType = "";
if(!mapGenOptions.isRoadEnabled(config.defaultRoadType))
config.defaultRoadType = config.secondaryRoadType;
}
const CMapGenerator::Config & CMapGenerator::getConfig() const
@@ -238,14 +243,21 @@ void CMapGenerator::addPlayerInfo()
player.canHumanPlay = true;
}
if (teamNumbers[j].empty())
if(pSettings.getTeam() != TeamID::NO_TEAM)
{
logGlobal->error("Not enough places in team for %s player", ((j == CPUONLY) ? "CPU" : "CPU or human"));
assert (teamNumbers[j].size());
player.team = pSettings.getTeam();
}
else
{
if (teamNumbers[j].empty())
{
logGlobal->error("Not enough places in team for %s player", ((j == CPUONLY) ? "CPU" : "CPU or human"));
assert (teamNumbers[j].size());
}
auto itTeam = RandomGeneratorUtil::nextItem(teamNumbers[j], rand);
player.team = TeamID(*itTeam);
teamNumbers[j].erase(itTeam);
}
auto itTeam = RandomGeneratorUtil::nextItem(teamNumbers[j], rand);
player.team = TeamID(*itTeam);
teamNumbers[j].erase(itTeam);
map->map().players[pSettings.getColor().getNum()] = player;
}