From d93e844609c227db50ba2b9f2273499f3ea05ff9 Mon Sep 17 00:00:00 2001 From: nordsoft Date: Sat, 17 Dec 2022 04:54:01 +0400 Subject: [PATCH] Use roads names instead of their filenames --- config/randomMap.json | 4 ++-- lib/Terrain.cpp | 6 ++++-- lib/Terrain.h | 11 ++++++++++- lib/rmg/RoadPlacer.cpp | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/config/randomMap.json b/config/randomMap.json index 926214ea2..fa54f121f 100644 --- a/config/randomMap.json +++ b/config/randomMap.json @@ -16,8 +16,8 @@ "extraResourcesLimit" : 3 }, "minGuardStrength" : 2000, - "defaultRoadType" : "pc", //pd - dirt, pg - gravel, pc - cobblestone - "secondaryRoadType": "pd", + "defaultRoadType" : "cobblestoneRoad", + "secondaryRoadType": "dirtRoad", "treasureValueLimit" : 20000, //generate pandora with gold for treasure above this limit "prisons" : { diff --git a/lib/Terrain.cpp b/lib/Terrain.cpp index fff98de34..7b6635080 100644 --- a/lib/Terrain.cpp +++ b/lib/Terrain.cpp @@ -220,6 +220,7 @@ void TerrainTypeHandler::initRivers(const std::vector & allConfigs) { RiverType info; + info.name = river.first; info.fileName = river.second["animation"].String(); info.code = river.second["code"].String(); info.deltaName = river.second["delta"].String(); @@ -255,6 +256,7 @@ void TerrainTypeHandler::initRoads(const std::vector & allConfigs) { RoadType info; + info.name = road.first; info.fileName = road.second["animation"].String(); info.code = road.second["code"].String(); info.movementCost = static_cast(road.second["moveCost"].Float()); @@ -295,7 +297,7 @@ void TerrainTypeHandler::recreateRiverMaps() { const auto * riverInfo = &riverTypes[i]; - riverInfoByName[riverInfo->fileName] = riverInfo; + riverInfoByName[riverInfo->name] = riverInfo; riverInfoByCode[riverInfo->code] = riverInfo; riverInfoById[riverInfo->id] = riverInfo; } @@ -307,7 +309,7 @@ void TerrainTypeHandler::recreateRoadMaps() { const auto * roadInfo = &roadTypes[i]; - roadInfoByName[roadInfo->fileName] = roadInfo; + roadInfoByName[roadInfo->name] = roadInfo; roadInfoByCode[roadInfo->code] = roadInfo; roadInfoById[roadInfo->id] = roadInfo; } diff --git a/lib/Terrain.h b/lib/Terrain.h index 6e23a9ca2..5d6fca1e7 100644 --- a/lib/Terrain.h +++ b/lib/Terrain.h @@ -89,7 +89,7 @@ public: class DLL_LINKAGE RiverType { public: - + std::string name; std::string fileName; std::string code; std::string deltaName; @@ -99,6 +99,10 @@ public: template void serialize(Handler& h, const int version) { + if(version >= 806) + { + h & name; + } h & fileName; h & code; h & deltaName; @@ -109,6 +113,7 @@ public: class DLL_LINKAGE RoadType { public: + std::string name; std::string fileName; std::string code; RoadId id; @@ -118,6 +123,10 @@ public: template void serialize(Handler& h, const int version) { + if(version >= 806) + { + h & name; + } h & fileName; h & code; h & id; diff --git a/lib/rmg/RoadPlacer.cpp b/lib/rmg/RoadPlacer.cpp index ff108375b..b8a037135 100644 --- a/lib/rmg/RoadPlacer.cpp +++ b/lib/rmg/RoadPlacer.cpp @@ -78,8 +78,8 @@ void RoadPlacer::drawRoads(bool secondary) zone.areaPossible().subtract(roads); zone.freePaths().unite(roads); map.getEditManager()->getTerrainSelection().setSelection(roads.getTilesVector()); - std::string roadCode = (secondary ? generator.getConfig().secondaryRoadType : generator.getConfig().defaultRoadType); - RoadId roadType = VLC->terrainTypeHandler->getRoadByCode(roadCode)->id; + std::string roadName = (secondary ? generator.getConfig().secondaryRoadType : generator.getConfig().defaultRoadType); + RoadId roadType = VLC->terrainTypeHandler->getRoadByName(roadName)->id; map.getEditManager()->drawRoad(roadType, &generator.rand); }