1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-29 23:07:48 +02:00

Respect GUI settings for roads. By default, all road types are enabled.

This commit is contained in:
Tomasz Zieliński
2023-07-08 08:44:10 +02:00
parent 27c4882237
commit 730b36612c
5 changed files with 47 additions and 17 deletions

View File

@@ -79,9 +79,7 @@ bool RoadPlacer::createRoad(const int3 & dst)
}
void RoadPlacer::drawRoads(bool secondary)
{
//TODO: Check road type set in lobby. If no road, return.
{
{
//Clean space under roads even if they won't be eventually generated
Zone::Lock lock(zone.areaMutex);
@@ -90,15 +88,32 @@ void RoadPlacer::drawRoads(bool secondary)
zone.freePaths().unite(roads);
}
if (!generator.getMapGenOptions().isRoadEnabled())
{
return;
}
if((secondary && generator.getConfig().secondaryRoadType.empty())
|| (!secondary && generator.getConfig().defaultRoadType.empty()))
return;
//TODO: Allow custom road type for object
//TODO: Remove these default types
auto tiles = roads.getTilesVector();
std::string roadName = (secondary ? generator.getConfig().secondaryRoadType : generator.getConfig().defaultRoadType);
RoadId roadType(*VLC->modh->identifiers.getIdentifier(CModHandler::scopeGame(), "road", roadName));
mapProxy->drawRoads(zone.getRand(), tiles, roadType);
//If our road type is not enabled, choose highest below it
for (int8_t bestRoad = roadType.getNum(); bestRoad > RoadId(Road::NO_ROAD).getNum(); bestRoad--)
{
if (generator.getMapGenOptions().isRoadEnabled(RoadId(bestRoad)))
{
mapProxy->drawRoads(zone.getRand(), tiles, RoadId(bestRoad));
return;
}
}
}
void RoadPlacer::addRoadNode(const int3& node)