diff --git a/apps/opencs/model/world/idcollection.cpp b/apps/opencs/model/world/idcollection.cpp index ca56eceb69..7890dc47b8 100644 --- a/apps/opencs/model/world/idcollection.cpp +++ b/apps/opencs/model/world/idcollection.cpp @@ -59,14 +59,13 @@ namespace CSMWorld const Record* IdCollection::searchRecord(std::uint16_t index, int plugin) const { - auto found = mIndices.find({ plugin, index }); - if (found != mIndices.end()) - { - int index = searchId(found->second); - if (index != -1) - return &getRecord(index); - } - return nullptr; + const auto it = mIndices.find({ plugin, index }); + if (it == mIndices.end()) + return nullptr; + const int recordIndex = searchId(it->second); + if (recordIndex == -1) + return nullptr; + return &getRecord(recordIndex); } const std::string* IdCollection::getLandTexture(std::uint16_t index, int plugin) const diff --git a/apps/openmw/mwscript/miscextensions.cpp b/apps/openmw/mwscript/miscextensions.cpp index fd2064463e..1511909332 100644 --- a/apps/openmw/mwscript/miscextensions.cpp +++ b/apps/openmw/mwscript/miscextensions.cpp @@ -604,7 +604,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - std::string_view effect = runtime.getStringLiteral(runtime[0].mInteger); + const std::string_view effectName = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); if (!ptr.getClass().isActor()) @@ -615,11 +615,11 @@ namespace MWScript long key; - if (const auto k = ::Misc::StringUtils::toNumeric(effect); + if (const auto k = ::Misc::StringUtils::toNumeric(effectName); k.has_value() && *k >= 0 && *k <= 32767) key = *k; else - key = ESM::MagicEffect::effectGmstIdToIndex(effect); + key = ESM::MagicEffect::effectGmstIdToIndex(effectName); const MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); for (const auto& spell : stats.getActiveSpells())