Kaynağa Gözat

Unified identifiers to entity conversion code

Ivan Savenko 1 yıl önce
ebeveyn
işleme
55bd164f1c
1 değiştirilmiş dosya ile 2 ekleme ve 7 silme
  1. 2 7
      lib/constants/EntityIdentifiers.cpp

+ 2 - 7
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<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