1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

Fix regression

This commit is contained in:
Tomasz Zieliński
2023-08-11 20:13:25 +02:00
parent b002c015cf
commit 4741bd546f
3 changed files with 13 additions and 4 deletions

View File

@@ -89,14 +89,15 @@ void QuestArtifactPlacer::placeQuestArtifacts(CRandomGenerator & rand)
artifactToReplace->getObjectName(), artifactToReplace->getObjectName(),
artifactToReplace->getPosition().toString(), artifactToReplace->getPosition().toString(),
VLC->artifacts()->getById(artifactToPlace)->getNameTranslated()); VLC->artifacts()->getById(artifactToPlace)->getNameTranslated());
artifactToReplace->ID = Obj::ARTIFACT;
artifactToReplace->subID = artifactToPlace;
//Update appearance. Terrain is irrelevant. //Update appearance. Terrain is irrelevant.
auto handler = VLC->objtypeh->getHandlerFor(Obj::ARTIFACT, artifactToPlace); auto handler = VLC->objtypeh->getHandlerFor(Obj::ARTIFACT, artifactToPlace);
auto newObj = handler->create();
auto templates = handler->getTemplates(); auto templates = handler->getTemplates();
artifactToReplace->appearance = templates.front(); //artifactToReplace->appearance = templates.front();
//FIXME: Instance name is still "randomArtifact" newObj->appearance = templates.front();
newObj->pos = artifactToReplace->pos;
mapProxy->insertObject(newObj);
for (auto z : map.getZones()) for (auto z : map.getZones())
{ {
@@ -107,6 +108,7 @@ void QuestArtifactPlacer::placeQuestArtifacts(CRandomGenerator & rand)
localQap->dropReplacedArtifact(artifactToReplace); localQap->dropReplacedArtifact(artifactToReplace);
} }
} }
mapProxy->removeObject(artifactToReplace);
break; break;
} }
} }

View File

@@ -30,6 +30,12 @@ void MapProxy::insertObjects(std::set<CGObjectInstance*>& objects)
map.getEditManager()->insertObjects(objects); map.getEditManager()->insertObjects(objects);
} }
void MapProxy::removeObject(CGObjectInstance * obj)
{
Lock lock(mx);
map.getEditManager()->removeObject(obj);
}
void MapProxy::drawTerrain(CRandomGenerator & generator, std::vector<int3> & tiles, TerrainId terrain) void MapProxy::drawTerrain(CRandomGenerator & generator, std::vector<int3> & tiles, TerrainId terrain)
{ {
Lock lock(mx); Lock lock(mx);

View File

@@ -26,6 +26,7 @@ public:
void insertObject(CGObjectInstance * obj); void insertObject(CGObjectInstance * obj);
void insertObjects(std::set<CGObjectInstance*>& objects); void insertObjects(std::set<CGObjectInstance*>& objects);
void removeObject(CGObjectInstance* obj);
void drawTerrain(CRandomGenerator & generator, std::vector<int3> & tiles, TerrainId terrain); void drawTerrain(CRandomGenerator & generator, std::vector<int3> & tiles, TerrainId terrain);
void drawRivers(CRandomGenerator & generator, std::vector<int3> & tiles, TerrainId terrain); void drawRivers(CRandomGenerator & generator, std::vector<int3> & tiles, TerrainId terrain);