From 01390e0c2c24bfbba6659ec548889cfb05829628 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Wed, 11 Mar 2015 16:19:03 +0100 Subject: [PATCH] Optimization for random treasures. --- lib/rmg/CRmgTemplateZone.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index e23e6df3d..cbe71e93d 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -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