1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-23 22:37:55 +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

@@ -1618,12 +1618,11 @@ void CGameState::attachArmedObjects()
bool CGameState::giveHeroArtifact(CGHeroInstance * h, const ArtifactID & aid)
{
CArtifactInstance * ai = ArtifactUtils::createArtifact(aid);
map->addNewArtifactInstance(ai);
CArtifactInstance * ai = createArtifact(aid);
auto slot = ArtifactUtils::getArtAnyPosition(h, aid);
if(ArtifactUtils::isSlotEquipment(slot) || ArtifactUtils::isSlotBackpack(slot))
{
map->putArtifactInstance(*h, ai, slot);
map->putArtifactInstance(*h, ai->getId(), slot);
return true;
}
else
@@ -1766,4 +1765,14 @@ ArtifactID CGameState::pickRandomArtifact(vstd::RNG & rand, int flags)
return pickRandomArtifact(rand, flags, [](const ArtifactID &) { return true; });
}
CArtifactInstance * CGameState::createScroll(const SpellID & spellId)
{
return map->createScroll(spellId);
}
CArtifactInstance * CGameState::createArtifact(const ArtifactID & artID, const SpellID & spellId)
{
return map->createArtifact(artID, spellId);
}
VCMI_LIB_NAMESPACE_END