mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Merge pull request #2498 from vcmi/fix_roads_in_rock
Fix placing road inside underground rock
This commit is contained in:
@@ -376,6 +376,12 @@ void Area::translate(const int3 & shift)
|
|||||||
//toAbsolute(dTiles, 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 operator- (const Area & l, const int3 & r)
|
||||||
{
|
{
|
||||||
Area result(l);
|
Area result(l);
|
||||||
|
@@ -64,6 +64,7 @@ namespace rmg
|
|||||||
void intersect(const Area & area);
|
void intersect(const Area & area);
|
||||||
void subtract(const Area & area);
|
void subtract(const Area & area);
|
||||||
void translate(const int3 & shift);
|
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
|
||||||
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 "../threadpool/MapProxy.h"
|
||||||
#include "../../CModHandler.h"
|
#include "../../CModHandler.h"
|
||||||
#include "../../mapping/CMapEditManager.h"
|
#include "../../mapping/CMapEditManager.h"
|
||||||
|
#include "../../TerrainHandler.h"
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_BEGIN
|
VCMI_LIB_NAMESPACE_BEGIN
|
||||||
|
|
||||||
|
class TerrainType;
|
||||||
|
|
||||||
void RoadPlacer::process()
|
void RoadPlacer::process()
|
||||||
{
|
{
|
||||||
if(generator.getConfig().defaultRoadType.empty() && generator.getConfig().secondaryRoadType.empty())
|
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
|
//Clean space under roads even if they won't be eventually generated
|
||||||
Zone::Lock lock(zone.areaMutex);
|
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.areaPossible().subtract(roads);
|
||||||
zone.freePaths().unite(roads);
|
zone.freePaths().unite(roads);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user