|
|
@@ -10,6 +10,7 @@
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
#include "RoadPlacer.h"
|
|
|
+#include "ObjectManager.h"
|
|
|
#include "Functions.h"
|
|
|
#include "CMapGenerator.h"
|
|
|
#include "RmgMap.h"
|
|
|
@@ -63,12 +64,13 @@ bool RoadPlacer::createRoad(const int3 & dst)
|
|
|
|
|
|
}
|
|
|
|
|
|
-void RoadPlacer::drawRoads()
|
|
|
+void RoadPlacer::drawRoads(bool secondary)
|
|
|
{
|
|
|
zone.areaPossible().subtract(roads);
|
|
|
zone.freePaths().unite(roads);
|
|
|
map.getEditManager()->getTerrainSelection().setSelection(roads.getTilesVector());
|
|
|
- map.getEditManager()->drawRoad(generator.getConfig().defaultRoadType, &generator.rand);
|
|
|
+ std::string roadType = (secondary ? generator.getConfig().secondaryRoadType : generator.getConfig().defaultRoadType);
|
|
|
+ map.getEditManager()->drawRoad(roadType, &generator.rand);
|
|
|
}
|
|
|
|
|
|
void RoadPlacer::addRoadNode(const int3& node)
|
|
|
@@ -78,7 +80,22 @@ void RoadPlacer::addRoadNode(const int3& node)
|
|
|
|
|
|
void RoadPlacer::connectRoads()
|
|
|
{
|
|
|
- if(roadNodes.empty())
|
|
|
+ bool noRoadNodes = false;
|
|
|
+ //Assumes objects are already placed
|
|
|
+ if (roadNodes.size() < 2)
|
|
|
+ {
|
|
|
+ //If there are no nodes, draw roads to mines
|
|
|
+ noRoadNodes = true;
|
|
|
+ if (auto* m = zone.getModificator<ObjectManager>())
|
|
|
+ {
|
|
|
+ for (auto object : m->getMines())
|
|
|
+ {
|
|
|
+ addRoadNode(object->visitablePos());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(roadNodes.size() < 2)
|
|
|
return;
|
|
|
|
|
|
//take any tile from road nodes as destination zone for all other road nodes
|
|
|
@@ -90,7 +107,8 @@ void RoadPlacer::connectRoads()
|
|
|
createRoad(node);
|
|
|
}
|
|
|
|
|
|
- drawRoads();
|
|
|
+ //Draw dirt roads if there are only mines
|
|
|
+ drawRoads(noRoadNodes);
|
|
|
}
|
|
|
|
|
|
char RoadPlacer::dump(const int3 & t)
|