From 55bd164f1cd434a02f7352ef96150411e86468a1 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 4 Jan 2024 23:47:44 +0200 Subject: [PATCH] Unified identifiers to entity conversion code --- lib/constants/EntityIdentifiers.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/constants/EntityIdentifiers.cpp b/lib/constants/EntityIdentifiers.cpp index 60cf811c2..597343cc2 100644 --- a/lib/constants/EntityIdentifiers.cpp +++ b/lib/constants/EntityIdentifiers.cpp @@ -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(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(num)); - return nullptr; - } - return VLC->spellh->objects[num]; + return dynamic_cast(toEntity(VLC)); } const spells::Spell * SpellIDBase::toEntity(const Services * services) const