1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-27 22:49:25 +02:00

+ Remove roads from wide connections BEFORE graph is generated

+ Explain all requirements in a commeny
This commit is contained in:
Tomasz Zieliński
2025-03-20 21:37:14 +01:00
parent 237f6ebb1c
commit 863e469b4d
3 changed files with 27 additions and 0 deletions

View File

@@ -1005,6 +1005,22 @@ void CZonePlacer::assignZones(vstd::RNG * rand)
logGlobal->info("Finished zone colouring");
}
void CZonePlacer::RemoveRoadsForWideConnections()
{
auto zones = map.getZones();
for(auto & zonePtr : zones)
{
for(auto & connection : zonePtr.second->getConnections())
{
if(connection.getConnectionType() == rmg::EConnectionType::WIDE)
{
zonePtr.second->setRoadOption(connection.getId(), rmg::ERoadOption::ROAD_FALSE);
}
}
}
}
TRmgTemplateZoneId findSet(std::map<TRmgTemplateZoneId, TRmgTemplateZoneId> & parent, TRmgTemplateZoneId x)
{
if(parent[x] != x)
@@ -1020,6 +1036,15 @@ void unionSets(std::map<TRmgTemplateZoneId, TRmgTemplateZoneId> & parent, TRmgTe
parent[rx] = ry;
}
/*
Random road generation requirements:
- Every town should be connected via road
- There should be exactly one road betwen any two towns (connected MST)
- This excludes cases when there are multiple road connetions betwween two zones
- Road cannot end in a zone without town
- Wide connections should have no road
*/
void CZonePlacer::dropRandomRoads(vstd::RNG * rand)
{
logGlobal->info("Starting road randomization");