mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix placing road inside underground rock
This commit is contained in:
parent
b9e804954d
commit
c089e55893
@ -376,6 +376,12 @@ void Area::translate(const int3 & shift)
|
||||
//toAbsolute(dTiles, shift);
|
||||
}
|
||||
|
||||
void Area::erase_if(std::function<bool(const int3&)> predicate)
|
||||
{
|
||||
invalidate();
|
||||
vstd::erase_if(dTiles, predicate);
|
||||
}
|
||||
|
||||
Area operator- (const Area & l, const int3 & r)
|
||||
{
|
||||
Area result(l);
|
||||
|
@ -64,6 +64,7 @@ namespace rmg
|
||||
void intersect(const Area & area);
|
||||
void subtract(const Area & area);
|
||||
void translate(const int3 & shift);
|
||||
void erase_if(std::function<bool(const int3&)> predicate);
|
||||
|
||||
friend Area operator+ (const Area & l, const int3 & r); //translation
|
||||
friend Area operator- (const Area & l, const int3 & r); //translation
|
||||
|
@ -18,9 +18,12 @@
|
||||
#include "../threadpool/MapProxy.h"
|
||||
#include "../../CModHandler.h"
|
||||
#include "../../mapping/CMapEditManager.h"
|
||||
#include "../../TerrainHandler.h"
|
||||
|
||||
VCMI_LIB_NAMESPACE_BEGIN
|
||||
|
||||
class TerrainType;
|
||||
|
||||
void RoadPlacer::process()
|
||||
{
|
||||
if(generator.getConfig().defaultRoadType.empty() && generator.getConfig().secondaryRoadType.empty())
|
||||
@ -114,6 +117,13 @@ void RoadPlacer::drawRoads(bool secondary)
|
||||
//Clean space under roads even if they won't be eventually generated
|
||||
Zone::Lock lock(zone.areaMutex);
|
||||
|
||||
//Do not draw roads on underground rock or water
|
||||
roads.erase_if([this](const int3& pos) -> bool
|
||||
{
|
||||
const auto* terrain = map.getTile(pos).terType;;
|
||||
return !terrain->isPassable() || !terrain->isLand();
|
||||
});
|
||||
|
||||
zone.areaPossible().subtract(roads);
|
||||
zone.freePaths().unite(roads);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user