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:
commit
917f846a3a
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user