From 22dd97ad18e6ef9c7d0514ba43ddfa80c68b1c61 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Mon, 27 Mar 2023 14:56:39 +0300 Subject: [PATCH] vcmi: use entilites when possible part 1 --- AI/Nullkiller/Goals/AbstractGoal.cpp | 2 +- lib/GameConstants.cpp | 2 +- lib/HeroBonus.cpp | 2 +- lib/mapObjects/JsonRandom.cpp | 2 +- lib/spells/CSpellHandler.cpp | 2 +- mapeditor/inspector/inspector.cpp | 2 +- mapeditor/inspector/rewardswidget.cpp | 6 +++--- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AI/Nullkiller/Goals/AbstractGoal.cpp b/AI/Nullkiller/Goals/AbstractGoal.cpp index d2e4f0d8c..0c42bae84 100644 --- a/AI/Nullkiller/Goals/AbstractGoal.cpp +++ b/AI/Nullkiller/Goals/AbstractGoal.cpp @@ -60,7 +60,7 @@ std::string AbstractGoal::toString() const //TODO: virtualize desc = "GATHER TROOPS"; break; case GET_ART_TYPE: - desc = "GET ARTIFACT OF TYPE " + VLC->arth->objects[aid]->getNameTranslated(); + desc = "GET ARTIFACT OF TYPE " + VLC->artifacts()->getByIndex(aid)->getNameTranslated(); break; case DIG_AT_TILE: desc = "DIG AT TILE " + tile.toString(); diff --git a/lib/GameConstants.cpp b/lib/GameConstants.cpp index e62ff54f1..62bf1f4b3 100644 --- a/lib/GameConstants.cpp +++ b/lib/GameConstants.cpp @@ -76,7 +76,7 @@ std::string HeroTypeID::encode(const si32 index) const CArtifact * ArtifactID::toArtifact() const { - return VLC->arth->objects.at(*this); + return dynamic_cast(toArtifact(VLC->artifacts())); } const Artifact * ArtifactID::toArtifact(const ArtifactService * service) const diff --git a/lib/HeroBonus.cpp b/lib/HeroBonus.cpp index fc5fc0f8e..41563dedc 100644 --- a/lib/HeroBonus.cpp +++ b/lib/HeroBonus.cpp @@ -1700,7 +1700,7 @@ std::string Bonus::nameForBonus() const case Bonus::SPECIAL_PECULIAR_ENCHANT: case Bonus::SPECIAL_ADD_VALUE_ENCHANT: case Bonus::SPECIAL_FIXED_VALUE_ENCHANT: - return (*VLC->spellh)[static_cast(subtype)]->identifier; + return VLC->spells()->getByIndex(subtype)->getJsonKey(); case Bonus::SPECIAL_UPGRADE: return CreatureID::encode(subtype) + "2" + CreatureID::encode(additionalInfo[0]); case Bonus::GENERATE_RESOURCE: diff --git a/lib/mapObjects/JsonRandom.cpp b/lib/mapObjects/JsonRandom.cpp index e002ebd74..9519c07c7 100644 --- a/lib/mapObjects/JsonRandom.cpp +++ b/lib/mapObjects/JsonRandom.cpp @@ -183,7 +183,7 @@ namespace JsonRandom vstd::erase_if(spells, [=](const SpellID & spell) { - return VLC->spellh->objects[spell]->level != si32(value["level"].Float()); + return VLC->spellh->getById(spell)->getLevel() != si32(value["level"].Float()); }); return SpellID(*RandomGeneratorUtil::nextItem(spells, rng)); diff --git a/lib/spells/CSpellHandler.cpp b/lib/spells/CSpellHandler.cpp index 2efb5cb5a..32cfcec0a 100644 --- a/lib/spells/CSpellHandler.cpp +++ b/lib/spells/CSpellHandler.cpp @@ -204,7 +204,7 @@ std::string CSpell::getDescriptionTranslated(int32_t level) const std::string CSpell::getJsonKey() const { - return modScope + ':' + identifier;; + return modScope + ':' + identifier; } int32_t CSpell::getIndex() const diff --git a/mapeditor/inspector/inspector.cpp b/mapeditor/inspector/inspector.cpp index 74a3aa836..2e96b3179 100644 --- a/mapeditor/inspector/inspector.cpp +++ b/mapeditor/inspector/inspector.cpp @@ -289,7 +289,7 @@ void Inspector::updateProperties(CGArtifact * o) //if(map->isAllowedSpell(spell->id)) delegate->options << QObject::tr(spell->getJsonKey().c_str()); } - addProperty("Spell", VLC->spellh->objects[spellId]->getJsonKey(), delegate, false); + addProperty("Spell", VLC->spellh->getById(spellId)->getJsonKey(), delegate, false); } } } diff --git a/mapeditor/inspector/rewardswidget.cpp b/mapeditor/inspector/rewardswidget.cpp index c3b8d1348..c0dd92fa2 100644 --- a/mapeditor/inspector/rewardswidget.cpp +++ b/mapeditor/inspector/rewardswidget.cpp @@ -74,7 +74,7 @@ QList RewardsWidget::getListForType(RewardType typeId) for(int i = 0; i < map.allowedAbilities.size(); ++i) { if(map.allowedAbilities[i]) - result.append(QString::fromStdString(VLC->skillh->objects.at(i)->getNameTranslated())); + result.append(QString::fromStdString(VLC->skills()->getByIndex(i)->getNameTranslated())); } break; @@ -82,7 +82,7 @@ QList RewardsWidget::getListForType(RewardType typeId) for(int i = 0; i < map.allowedArtifact.size(); ++i) { if(map.allowedArtifact[i]) - result.append(QString::fromStdString(VLC->arth->objects.at(i)->getNameTranslated())); + result.append(QString::fromStdString(VLC->artifacts()->getByIndex(i)->getNameTranslated())); } break; @@ -90,7 +90,7 @@ QList RewardsWidget::getListForType(RewardType typeId) for(int i = 0; i < map.allowedSpell.size(); ++i) { if(map.allowedSpell[i]) - result.append(QString::fromStdString(VLC->spellh->objects.at(i)->getNameTranslated())); + result.append(QString::fromStdString(VLC->spells()->getByIndex(i)->getNameTranslated())); } break;