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

Parallel RMG works fine for maps without water.

This commit is contained in:
Tomasz Zieliński
2023-05-19 20:30:15 +02:00
parent 19010dd834
commit 73d9f5bd0a
36 changed files with 521 additions and 411 deletions

View File

@ -27,18 +27,28 @@ VCMI_LIB_NAMESPACE_BEGIN
void ObjectDistributor::process()
{
//Firts call will add objects to ALL zones, once they were added skip it
if (zone.getModificator<TreasurePlacer>()->getPossibleObjectsSize() == 0)
//Do that only once
auto lockVec = tryLockAll<ObjectDistributor>();
if (!lockVec.empty())
{
for(auto & z : map.getZones())
{
if(auto * m = z.second->getModificator<ObjectDistributor>())
{
if(m->isFinished())
return;
}
}
distributeLimitedObjects();
distributeSeerHuts();
finished = true;
}
}
void ObjectDistributor::init()
{
DEPENDENCY(TownPlacer);
DEPENDENCY(TerrainPainter);
//All of the terrain types need to be determined
DEPENDENCY_ALL(TerrainPainter);
POSTFUNCTION(TreasurePlacer);
}
@ -84,6 +94,8 @@ void ObjectDistributor::distributeLimitedObjects()
//We already know there are some templates
auto templates = handler->getTemplates(zone->getTerrainType());
//FIXME: Templates empty?! Maybe zone changed terrain type over time?
//Assume the template with fewest terrains is the most suitable
auto temp = *boost::min_element(templates, [](std::shared_ptr<const ObjectTemplate> lhs, std::shared_ptr<const ObjectTemplate> rhs) -> bool
{