From 4741bd546fd3c10255b4737a5729d1f2c874bad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Fri, 11 Aug 2023 20:13:25 +0200 Subject: [PATCH] Fix regression --- lib/rmg/modificators/QuestArtifactPlacer.cpp | 10 ++++++---- lib/rmg/threadpool/MapProxy.cpp | 6 ++++++ lib/rmg/threadpool/MapProxy.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/rmg/modificators/QuestArtifactPlacer.cpp b/lib/rmg/modificators/QuestArtifactPlacer.cpp index 7640474f3..fd9fe44d8 100644 --- a/lib/rmg/modificators/QuestArtifactPlacer.cpp +++ b/lib/rmg/modificators/QuestArtifactPlacer.cpp @@ -89,14 +89,15 @@ void QuestArtifactPlacer::placeQuestArtifacts(CRandomGenerator & rand) artifactToReplace->getObjectName(), artifactToReplace->getPosition().toString(), VLC->artifacts()->getById(artifactToPlace)->getNameTranslated()); - artifactToReplace->ID = Obj::ARTIFACT; - artifactToReplace->subID = artifactToPlace; //Update appearance. Terrain is irrelevant. auto handler = VLC->objtypeh->getHandlerFor(Obj::ARTIFACT, artifactToPlace); + auto newObj = handler->create(); auto templates = handler->getTemplates(); - artifactToReplace->appearance = templates.front(); - //FIXME: Instance name is still "randomArtifact" + //artifactToReplace->appearance = templates.front(); + newObj->appearance = templates.front(); + newObj->pos = artifactToReplace->pos; + mapProxy->insertObject(newObj); for (auto z : map.getZones()) { @@ -107,6 +108,7 @@ void QuestArtifactPlacer::placeQuestArtifacts(CRandomGenerator & rand) localQap->dropReplacedArtifact(artifactToReplace); } } + mapProxy->removeObject(artifactToReplace); break; } } diff --git a/lib/rmg/threadpool/MapProxy.cpp b/lib/rmg/threadpool/MapProxy.cpp index 7ae73fe9b..d1bf2f8ee 100644 --- a/lib/rmg/threadpool/MapProxy.cpp +++ b/lib/rmg/threadpool/MapProxy.cpp @@ -30,6 +30,12 @@ void MapProxy::insertObjects(std::set& objects) map.getEditManager()->insertObjects(objects); } +void MapProxy::removeObject(CGObjectInstance * obj) +{ + Lock lock(mx); + map.getEditManager()->removeObject(obj); +} + void MapProxy::drawTerrain(CRandomGenerator & generator, std::vector & tiles, TerrainId terrain) { Lock lock(mx); diff --git a/lib/rmg/threadpool/MapProxy.h b/lib/rmg/threadpool/MapProxy.h index c05530d50..a85d74fbf 100644 --- a/lib/rmg/threadpool/MapProxy.h +++ b/lib/rmg/threadpool/MapProxy.h @@ -26,6 +26,7 @@ public: void insertObject(CGObjectInstance * obj); void insertObjects(std::set& objects); + void removeObject(CGObjectInstance* obj); void drawTerrain(CRandomGenerator & generator, std::vector & tiles, TerrainId terrain); void drawRivers(CRandomGenerator & generator, std::vector & tiles, TerrainId terrain);