1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Ensure distance between treasure piles.

This commit is contained in:
DjWarmonger 2014-09-22 14:18:01 +02:00
parent 0f4608ae01
commit f3d7c658f0
2 changed files with 6 additions and 6 deletions

View File

@ -643,7 +643,7 @@ bool CRmgTemplateZone::addMonster(CMapGenerator* gen, int3 &pos, si32 strength,
return true; return true;
} }
bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos) bool CRmgTemplateZone::createTreasurePile (CMapGenerator* gen, int3 &pos, float minDistance)
{ {
CTreasurePileInfo info; 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 if (gen->isPossible(tile)) //we can place new treasure only on possible tile
{ {
bool here = true; 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; here = false;
}); });
if (here) if (here)
@ -1108,7 +1108,7 @@ void CRmgTemplateZone::createTreasures(CMapGenerator* gen)
{ {
break; break;
} }
createTreasurePile (gen, pos); createTreasurePile (gen, pos, minDistance);
} while(true); } 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; //logGlobal->infoStream() << boost::format("Min dist for density %f is %d") % density % min_dist;
for(auto tile : possibleTiles) for(auto tile : possibleTiles)
{ {
auto dist = gen->getTile(tile).getNearestObjectDistance(); auto dist = gen->getNearestObjectDistance(tile);
if ((dist >= min_dist) && (dist > best_distance)) if ((dist >= min_dist) && (dist > best_distance))
{ {

View File

@ -151,7 +151,7 @@ public:
void addRequiredObject(CGObjectInstance * obj, si32 guardStrength=0); void addRequiredObject(CGObjectInstance * obj, si32 guardStrength=0);
bool addMonster(CMapGenerator* gen, int3 &pos, si32 strength, bool clearSurroundingTiles = true, bool zoneGuard = false); 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 fill (CMapGenerator* gen);
bool placeMines (CMapGenerator* gen); bool placeMines (CMapGenerator* gen);
void initTownType (CMapGenerator* gen); void initTownType (CMapGenerator* gen);