1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Optimization - don't add multiple copies of Modificators which only need one instance.

This commit is contained in:
Tomasz Zieliński 2023-05-20 09:58:08 +02:00
parent 71f882d5ba
commit 5f99facd8f

View File

@ -118,12 +118,19 @@ void RmgMap::initTiles(CMapGenerator & generator)
void RmgMap::addModificators()
{
bool hasObjectDistributor = false;
bool hasRockFiller = false;
for(auto & z : getZones())
{
auto zone = z.second;
zone->addModificator<ObjectManager>();
zone->addModificator<ObjectDistributor>(); //FIXME: Only one is needed for map
if (!hasObjectDistributor)
{
zone->addModificator<ObjectDistributor>();
hasObjectDistributor = true;
}
zone->addModificator<TreasurePlacer>();
zone->addModificator<ObstaclePlacer>();
zone->addModificator<TerrainPainter>();
@ -151,7 +158,11 @@ void RmgMap::addModificators()
if(zone->isUnderground())
{
zone->addModificator<RockPlacer>();
zone->addModificator<RockFiller>(); //FIXME: Only one is needed for map
if (!hasRockFiller)
{
zone->addModificator<RockFiller>();
hasRockFiller = true;
}
}
}