mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Add option for single-thread generation. Still doesn't guarantee excactly identical maps :?
This commit is contained in:
parent
edf47f5769
commit
cd9bd491e0
@ -83,6 +83,7 @@ void CMapGenerator::loadConfig()
|
||||
config.secondaryRoadType = "";
|
||||
if(!mapGenOptions.isRoadEnabled(config.defaultRoadType))
|
||||
config.defaultRoadType = config.secondaryRoadType;
|
||||
config.singleThread = randomMapJson["singleThread"].Bool();
|
||||
}
|
||||
|
||||
const CMapGenerator::Config & CMapGenerator::getConfig() const
|
||||
@ -310,12 +311,6 @@ void CMapGenerator::fillZones()
|
||||
|
||||
std::vector<std::shared_ptr<Zone>> treasureZones;
|
||||
|
||||
ThreadPool pool;
|
||||
|
||||
std::vector<boost::future<void>> futures;
|
||||
//At most one Modificator can run for every zone
|
||||
pool.init(std::min<int>(boost::thread::hardware_concurrency(), numZones));
|
||||
|
||||
TModificators allJobs;
|
||||
for (auto& it : map->getZones())
|
||||
{
|
||||
@ -324,6 +319,34 @@ void CMapGenerator::fillZones()
|
||||
|
||||
Load::Progress::setupStepsTill(allJobs.size(), 240);
|
||||
|
||||
if (config.singleThread) //No thread pool, just queue with deterministic order
|
||||
{
|
||||
while (!allJobs.empty())
|
||||
{
|
||||
for (auto it = allJobs.begin(); it != allJobs.end();)
|
||||
{
|
||||
if ((*it)->isReady())
|
||||
{
|
||||
auto jobCopy = *it;
|
||||
jobCopy->run();
|
||||
Progress::Progress::step(); //Update progress bar
|
||||
allJobs.erase(it);
|
||||
break; //Restart from the first job
|
||||
}
|
||||
else
|
||||
{
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ThreadPool pool;
|
||||
std::vector<boost::future<void>> futures;
|
||||
//At most one Modificator can run for every zone
|
||||
pool.init(std::min<int>(boost::thread::hardware_concurrency(), numZones));
|
||||
|
||||
while (!allJobs.empty())
|
||||
{
|
||||
for (auto it = allJobs.begin(); it != allJobs.end();)
|
||||
@ -356,6 +379,7 @@ void CMapGenerator::fillZones()
|
||||
{
|
||||
fut.get();
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& it : map->getZones())
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
int pandoraMultiplierGold, pandoraMultiplierExperience, pandoraMultiplierSpells, pandoraSpellSchool, pandoraSpell60;
|
||||
std::vector<int> pandoraCreatureValues;
|
||||
std::vector<int> questValues, questRewardValues;
|
||||
bool singleThread;
|
||||
};
|
||||
|
||||
explicit CMapGenerator(CMapGenOptions& mapGenOptions, int RandomSeed = std::time(nullptr));
|
||||
|
@ -42,7 +42,6 @@ void ObstaclePlacer::process()
|
||||
blockedArea.subtract(zone.areaUsed());
|
||||
zone.areaPossible().subtract(blockedArea);
|
||||
|
||||
//TODO: Set prohibited area in ObstacleProxy :?
|
||||
prohibitedArea = zone.freePaths() + zone.areaUsed() + manager->getVisitableArea();
|
||||
|
||||
auto objs = createObstacles(zone.getRand());
|
||||
|
Loading…
Reference in New Issue
Block a user