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

Unified identifiers to entity conversion code

This commit is contained in:
Ivan Savenko 2024-01-04 23:47:44 +02:00
parent 121ef77440
commit 55bd164f1c

View File

@ -292,7 +292,7 @@ const Skill * SecondarySkill::toEntity(const Services * services) const
const CCreature * CreatureIDBase::toCreature() const
{
return VLC->creh->objects.at(num);
return dynamic_cast<const CCreature *>(toEntity(VLC));
}
const Creature * CreatureIDBase::toEntity(const Services * services) const
@ -324,12 +324,7 @@ std::string CreatureID::entityType()
const CSpell * SpellIDBase::toSpell() const
{
if(num < 0 || num >= VLC->spellh->objects.size())
{
logGlobal->error("Unable to get spell of invalid ID %d", static_cast<int>(num));
return nullptr;
}
return VLC->spellh->objects[num];
return dynamic_cast<const CSpell*>(toEntity(VLC));
}
const spells::Spell * SpellIDBase::toEntity(const Services * services) const