1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-17 00:07:41 +02:00

Artifact instances are now owned solely by CMap

This commit is contained in:
Ivan Savenko
2025-03-10 16:20:40 +00:00
parent 797646cc05
commit 2ca1748e96
31 changed files with 203 additions and 194 deletions

View File

@ -663,10 +663,8 @@ void CGArtifact::initObj(vstd::RNG & rand)
if(ID == Obj::ARTIFACT)
{
if (!storedArtifact)
{
storedArtifact = ArtifactUtils::createArtifact(ArtifactID());
cb->gameState()->getMap().addNewArtifactInstance(storedArtifact);
}
storedArtifact = cb->gameState()->createArtifact(ArtifactID());
if(!storedArtifact->getType())
storedArtifact->setType(getArtifact().toArtifact());
}
@ -813,15 +811,6 @@ void CGArtifact::blockingDialogAnswered(const CGHeroInstance *hero, int32_t answ
cb->startBattle(hero, this);
}
void CGArtifact::afterAddToMap(CMap * map)
{
//Artifacts from map objects are never removed
//FIXME: This should be revertible in map editor
if(ID == Obj::SPELL_SCROLL && storedArtifact && storedArtifact->getId().getNum() < 0)
map->addNewArtifactInstance(storedArtifact);
}
void CGArtifact::serializeJsonOptions(JsonSerializeFormat& handler)
{
handler.serializeStruct("guardMessage", message);