1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Merge pull request #2562 from vcmi/fix_artifact_replacement

Fix regression with replacing quest artifact
This commit is contained in:
DjWarmonger 2023-08-12 09:14:21 +02:00 committed by GitHub
commit 917f846a3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 4 deletions

View File

@ -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;
}
}

View File

@ -30,6 +30,12 @@ void MapProxy::insertObjects(std::set<CGObjectInstance*>& 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)
{
Lock lock(mx);

View File

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