1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-28 23:06:24 +02:00

Place towns and monoliths first - preferably at the zone border.

This commit is contained in:
Tomasz Zieliński 2023-03-29 16:25:13 +02:00
parent 045942fd68
commit 5ed3c2d518
2 changed files with 11 additions and 3 deletions

View File

@ -237,7 +237,6 @@ bool ObjectManager::createRequiredObjects()
{
logGlobal->trace("Creating required objects");
RandomGeneratorUtil::randomShuffle(requiredObjects, generator.rand);
for(const auto & object : requiredObjects)
{
auto * obj = object.first;

View File

@ -158,6 +158,8 @@ bool TownPlacer::placeMines(ObjectManager & manager)
using namespace Res;
std::vector<CGMine*> createdMines;
std::vector<std::pair<CGObjectInstance*, ui32>> requiredObjects;
for(const auto & mineInfo : zone.getMinesInfo())
{
ERes res = static_cast<ERes>(mineInfo.first);
@ -175,10 +177,17 @@ bool TownPlacer::placeMines(ObjectManager & manager)
if(!i && (res == ERes::WOOD || res == ERes::ORE))
manager.addCloseObject(mine, rmginfo.value); //only first wood&ore mines are close
else
manager.addRequiredObject(mine, rmginfo.value);
requiredObjects.push_back(std::pair<CGObjectInstance*, ui32>(mine, rmginfo.value));
}
}
//Shuffle mines to avoid patterns, but don't shuffle key objects like towns
RandomGeneratorUtil::randomShuffle(requiredObjects, generator.rand);
for (const auto& obj : requiredObjects)
{
manager.addRequiredObject(obj.first, obj.second);
}
//create extra resources
if(int extraRes = generator.getConfig().mineExtraResources)
{