1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +02:00

Give every Zone its own RNG

This commit is contained in:
Tomasz Zieliński
2023-05-20 11:46:32 +02:00
parent 5da8c96214
commit 15b254fded
21 changed files with 76 additions and 67 deletions

View File

@@ -23,14 +23,14 @@ std::function<bool(const int3 &)> AREA_NO_FILTER = [](const int3 & t)
return true;
};
Zone::Zone(RmgMap & map, CMapGenerator & generator)
Zone::Zone(RmgMap & map, CMapGenerator & generator, CRandomGenerator & r)
: finished(false)
, townType(ETownType::NEUTRAL)
, terrainType(ETerrainId::GRASS)
, map(map)
, generator(generator)
{
rand.setSeed(r.nextInt());
}
bool Zone::isUnderground() const
@@ -214,7 +214,7 @@ void Zone::fractalize()
{
//link tiles in random order
std::vector<int3> tilesToMakePath = possibleTiles.getTilesVector();
RandomGeneratorUtil::randomShuffle(tilesToMakePath, generator.rand);
RandomGeneratorUtil::randomShuffle(tilesToMakePath, getRand());
int3 nodeFound(-1, -1, -1);
@@ -290,4 +290,9 @@ void Zone::initModificators()
logGlobal->info("Zone %d modificators initialized", getId());
}
CRandomGenerator& Zone::getRand()
{
return rand;
}
VCMI_LIB_NAMESPACE_END