From 6528124c1e6c6ddc1cd17b32d479f007a9a52fdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Sun, 4 Feb 2024 08:55:51 +0100 Subject: [PATCH 1/4] Do not fill water zone with obstacles --- lib/rmg/Zone.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/rmg/Zone.cpp b/lib/rmg/Zone.cpp index e48e3e43b..09f563727 100644 --- a/lib/rmg/Zone.cpp +++ b/lib/rmg/Zone.cpp @@ -116,6 +116,7 @@ void Zone::initFreeTiles() if(dAreaFree.empty()) { + // Fixme: This might fail fot water zone, which doesn't need to have a tile in its center of the mass dAreaPossible.erase(pos); dAreaFree.add(pos); //zone must have at least one free tile where other paths go - for instance in the center } @@ -250,21 +251,30 @@ void Zone::fractalize() treasureDensity += t.density; } - if (treasureValue > 400) + if (getType() == ETemplateZoneType::WATER) { - // A quater at max density - marginFactor = (0.25f + ((std::max(0, (600 - treasureValue))) / (600.f - 400)) * 0.75f); + // Set very little obstacles on water + spanFactor = 0.2; } - else if (treasureValue < 125) + else //Scale with treasure density { - //Dense obstacles - spanFactor *= (treasureValue / 125.f); - vstd::amax(spanFactor, 0.15f); + if (treasureValue > 400) + { + // A quater at max density + marginFactor = (0.25f + ((std::max(0, (600 - treasureValue))) / (600.f - 400)) * 0.75f); + } + else if (treasureValue < 125) + { + //Dense obstacles + spanFactor *= (treasureValue / 125.f); + vstd::amax(spanFactor, 0.15f); + } + if (treasureDensity <= 10) + { + vstd::amin(spanFactor, 0.1f + 0.01f * treasureDensity); //Add extra obstacles to fill up space } - if (treasureDensity <= 10) - { - vstd::amin(spanFactor, 0.1f + 0.01f * treasureDensity); //Add extra obstacles to fill up space } + float blockDistance = minDistance * spanFactor; //More obstacles in the Underground freeDistance = freeDistance * marginFactor; vstd::amax(freeDistance, 4 * 4); From 7ce3553a6ddaa9d367620c356b3ba6c49dcc9345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Sun, 4 Feb 2024 08:56:21 +0100 Subject: [PATCH 2/4] Fix race condition when placing object at teh shore --- lib/rmg/modificators/ObjectManager.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/rmg/modificators/ObjectManager.cpp b/lib/rmg/modificators/ObjectManager.cpp index 6bc51579c..8dcc24c25 100644 --- a/lib/rmg/modificators/ObjectManager.cpp +++ b/lib/rmg/modificators/ObjectManager.cpp @@ -579,11 +579,15 @@ void ObjectManager::placeObject(rmg::Object & object, bool guarded, bool updateD for (auto id : adjacentZones) { - auto manager = map.getZones().at(id)->getModificator(); - if (manager) + auto otherZone = map.getZones().at(id); + if ((otherZone->getType() == ETemplateZoneType::WATER) == (zone.getType() == ETemplateZoneType::WATER)) { - // TODO: Update distances for perimeter of guarded object, not just treasures - manager->updateDistances(object); + // Do not update other zone if only one is water + auto manager = otherZone->getModificator(); + if (manager) + { + manager->updateDistances(object); + } } } } From af3c6450a7869a1e78c15237b5b48ec11179a6d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Sun, 4 Feb 2024 08:56:45 +0100 Subject: [PATCH 3/4] Update comments --- lib/rmg/CZonePlacer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rmg/CZonePlacer.cpp b/lib/rmg/CZonePlacer.cpp index 6bcc27d64..9765a7b4e 100644 --- a/lib/rmg/CZonePlacer.cpp +++ b/lib/rmg/CZonePlacer.cpp @@ -908,7 +908,7 @@ void CZonePlacer::assignZones(CRandomGenerator * rand) vertexMapping[closestZone].insert(int3(vertex.x() * width, vertex.y() * height, closestZone->getPos().z)); //Closest vertex belongs to zone } - //Assign actual tiles to each zone using nonlinear norm for fine edges + //Assign actual tiles to each zone for (pos.z = 0; pos.z < levels; pos.z++) { for (pos.x = 0; pos.x < width; pos.x++) @@ -918,7 +918,6 @@ void CZonePlacer::assignZones(CRandomGenerator * rand) distances.clear(); for(const auto & zoneVertex : vertexMapping) { - // FIXME: Find closest vertex, not closest zone auto zone = zoneVertex.first; for (const auto & vertex : zoneVertex.second) { @@ -929,7 +928,8 @@ void CZonePlacer::assignZones(CRandomGenerator * rand) } } - auto closestZone = boost::min_element(distances, simpleCompareByDistance)->first; //closest tile belongs to zone + //Tile closes to vertex belongs to zone + auto closestZone = boost::min_element(distances, simpleCompareByDistance)->first; closestZone->area().add(pos); map.setZoneID(pos, closestZone->getId()); } From 5c6a146952fdffe8408e9d000f14f09426f55753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Sun, 4 Feb 2024 08:57:02 +0100 Subject: [PATCH 4/4] Use HoTA values for water treasures --- config/randomMap.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/randomMap.json b/config/randomMap.json index 800a2f893..70a4d0dd6 100644 --- a/config/randomMap.json +++ b/config/randomMap.json @@ -3,8 +3,9 @@ { "treasure" : [ - { "min" : 2000, "max" : 6000, "density" : 1 }, - { "min" : 100, "max" : 1000, "density" : 5 } + { "min" : 4000, "max" : 12000, "density" : 1 }, + { "min" : 1000, "max" : 4000, "density" : 3 }, + { "min" : 100, "max" : 1000, "density" : 6 } ], "shipyard" : {