1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Optimization for random treasures.

This commit is contained in:
DjWarmonger 2015-03-11 16:19:03 +01:00
parent 17f3f94ca6
commit 01390e0c2c

View File

@ -1304,6 +1304,12 @@ void CRmgTemplateZone::createTreasures(CMapGenerator* gen)
int totalDensity = 0;
for (auto t : treasureInfo)
{
//discard objects with too high value to be ever placed
vstd::erase_if(possibleObjects, [t](const ObjectInfo& oi) -> bool
{
return oi.value > t.max;
});
totalDensity += t.density;
//treasure density is inversely proportional to zone size but must be scaled back to map size