From f3d7c658f077110471c475e642da191a3cba3775 Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Mon, 22 Sep 2014 14:18:01 +0200 Subject: [PATCH] Ensure distance between treasure piles. --- lib/rmg/CRmgTemplateZone.cpp | 10 +++++----- lib/rmg/CRmgTemplateZone.h | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/rmg/CRmgTemplateZone.cpp b/lib/rmg/CRmgTemplateZone.cpp index 2423490e6..990e23198 100644 --- a/lib/rmg/CRmgTemplateZone.cpp +++ b/lib/rmg/CRmgTemplateZone.cpp @@ -643,7 +643,7 @@ bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength, return true; } -bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos) +bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos, float minDistance) { CTreasurePileInfo info; @@ -751,9 +751,9 @@ bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos) if (gen->isPossible(tile)) //we can place new treasure only on possible tile { bool here = true; - gen->foreach_neighbour (tile, [gen, &here](int3 pos) + gen->foreach_neighbour (tile, [gen, &here, minDistance](int3 pos) { - if (!(gen->isBlocked(pos) || gen->isPossible(pos))) + if (!(gen->isBlocked(pos) || gen->isPossible(pos)) || gen->getNearestObjectDistance(pos) < minDistance) here = false; }); if (here) @@ -1108,7 +1108,7 @@ void CRmgTemplateZone::createTreasures(CMapGenerator* gen) { break; } - createTreasurePile (gen, pos); + createTreasurePile (gen, pos, minDistance); } while(true); } @@ -1238,7 +1238,7 @@ bool CRmgTemplateZone::findPlaceForTreasurePile(CMapGenerator* gen, float min_di //logGlobal->infoStream() << boost::format("Min dist for density %f is %d") % density % min_dist; for(auto tile : possibleTiles) { - auto dist = gen->getTile(tile).getNearestObjectDistance(); + auto dist = gen->getNearestObjectDistance(tile); if ((dist >= min_dist) && (dist > best_distance)) { diff --git a/lib/rmg/CRmgTemplateZone.h b/lib/rmg/CRmgTemplateZone.h index 7b2312472..891ba9ab2 100644 --- a/lib/rmg/CRmgTemplateZone.h +++ b/lib/rmg/CRmgTemplateZone.h @@ -151,7 +151,7 @@ public: void addRequiredObject(CGObjectInstance * obj, si32 guardStrength=0); bool addMonster(CMapGenerator* gen, int3 &pos, si32 strength, bool clearSurroundingTiles = true, bool zoneGuard = false); - bool createTreasurePile (CMapGenerator* gen, int3 &pos); + bool createTreasurePile(CMapGenerator* gen, int3 &pos, float minDistance); bool fill (CMapGenerator* gen); bool placeMines (CMapGenerator* gen); void initTownType (CMapGenerator* gen);