diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index db2f1fe338..e3bf06a10f 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -660,8 +660,7 @@ namespace MWBase virtual DetourNavigator::Navigator* getNavigator() const = 0; virtual void updateActorPath(const MWWorld::ConstPtr& actor, const std::deque& path, - const DetourNavigator::AgentBounds& agentBounds, const osg::Vec3f& start, const osg::Vec3f& end) const - = 0; + const DetourNavigator::AgentBounds& agentBounds, const osg::Vec3f& start, const osg::Vec3f& end) const = 0; virtual void removeActorPath(const MWWorld::ConstPtr& actor) const = 0; @@ -670,12 +669,10 @@ namespace MWBase virtual DetourNavigator::AgentBounds getPathfindingAgentBounds(const MWWorld::ConstPtr& actor) const = 0; virtual bool hasCollisionWithDoor( - const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const - = 0; + const MWWorld::ConstPtr& door, const osg::Vec3f& position, const osg::Vec3f& destination) const = 0; virtual bool isAreaOccupiedByOtherActor(const osg::Vec3f& position, const float radius, - std::span ignore, std::vector* occupyingActors = nullptr) const - = 0; + std::span ignore, std::vector* occupyingActors = nullptr) const = 0; virtual void reportStats(unsigned int frameNumber, osg::Stats& stats) const = 0; diff --git a/apps/openmw/mwgui/birth.cpp b/apps/openmw/mwgui/birth.cpp index ed82a80507..c60a3e1ca5 100644 --- a/apps/openmw/mwgui/birth.cpp +++ b/apps/openmw/mwgui/birth.cpp @@ -96,7 +96,7 @@ namespace MWGui size_t count = mBirthList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (ESM::RefId::stringRefId(*mBirthList->getItemDataAt(i)) == birthId) + if (*mBirthList->getItemDataAt(i) == birthId) { mBirthList->setIndexSelected(i); break; @@ -133,7 +133,7 @@ namespace MWGui if (_index == MyGUI::ITEM_NONE) return; - const ESM::RefId birthId = ESM::RefId::stringRefId(*mBirthList->getItemDataAt(_index)); + const ESM::RefId& birthId = *mBirthList->getItemDataAt(_index); if (mCurrentBirthId == birthId) return; diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index b90ff9a10a..54ab302f67 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -191,7 +191,7 @@ namespace MWGui size_t count = mRaceList->getItemCount(); for (size_t i = 0; i < count; ++i) { - if (ESM::RefId::stringRefId(*mRaceList->getItemDataAt(i)) == raceId) + if (*mRaceList->getItemDataAt(i) == raceId) { mRaceList->setIndexSelected(i); break; @@ -292,7 +292,7 @@ namespace MWGui if (_index == MyGUI::ITEM_NONE) return; - ESM::RefId raceId = ESM::RefId::stringRefId(*mRaceList->getItemDataAt(_index)); + ESM::RefId& raceId = *mRaceList->getItemDataAt(_index); if (mCurrentRaceId == raceId) return; diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 2a54152442..2ad1c91e28 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1029,7 +1029,7 @@ namespace MWMechanics } } - auto sound = charClass.getSoundIdFromSndGen(mPtr, soundgen); + const auto& sound = charClass.getSoundIdFromSndGen(mPtr, soundgen); if (!sound.empty()) { MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager(); @@ -2043,7 +2043,7 @@ namespace MWMechanics if (!godmode) { // reduce fatigue - float fatigueLoss = 0; + float fatigueLoss = 0.f; static const float fFatigueRunBase = gmst.find("fFatigueRunBase")->mValue.getFloat(); static const float fFatigueRunMult = gmst.find("fFatigueRunMult")->mValue.getFloat(); static const float fFatigueSwimWalkBase = gmst.find("fFatigueSwimWalkBase")->mValue.getFloat(); @@ -2159,7 +2159,6 @@ namespace MWMechanics if (mPtr.getClass().isNpc()) { std::string_view sound; - osg::Vec3f pos(mPtr.getRefData().getPosition().asVec3()); if (world->isUnderwater(mPtr.getCell(), pos) || world->isWalkingOnWater(mPtr)) sound = "DefaultLandWater"; diff --git a/apps/openmw/mwmechanics/levelledlist.hpp b/apps/openmw/mwmechanics/levelledlist.hpp index f9ad488607..d499649944 100644 --- a/apps/openmw/mwmechanics/levelledlist.hpp +++ b/apps/openmw/mwmechanics/levelledlist.hpp @@ -44,7 +44,7 @@ namespace MWMechanics if (creature) allLevels = levItem->mFlags & ESM::CreatureLevList::AllLevels; - std::pair highest = { -1, {} }; + std::pair highest = { -1, nullptr }; for (const auto& levelledItem : items) { if (playerLevel >= levelledItem.mLevel && (allLevels || levelledItem.mLevel == highestLevel)) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 92c6d1990f..2310e00920 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -524,7 +524,7 @@ namespace MWMechanics float reaction = 0; int rank = 0; - ESM::RefId npcFaction = ptr.getClass().getPrimaryFaction(ptr); + const ESM::RefId& npcFaction = ptr.getClass().getPrimaryFaction(ptr); if (playerStats.getFactionRanks().find(npcFaction) != playerStats.getFactionRanks().end()) { diff --git a/apps/openmw/mwrender/weaponanimation.cpp b/apps/openmw/mwrender/weaponanimation.cpp index a356545ce5..a6f069e932 100644 --- a/apps/openmw/mwrender/weaponanimation.cpp +++ b/apps/openmw/mwrender/weaponanimation.cpp @@ -69,7 +69,7 @@ namespace MWRender ESM::WeaponType::Class weapclass = MWMechanics::getWeaponType(type)->mWeaponClass; if (weapclass == ESM::WeaponType::Thrown) { - auto soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot); + const auto& soundid = weaponSlot->getClass().getUpSoundId(*weaponSlot); if (!soundid.empty()) { MWBase::SoundManager* sndMgr = MWBase::Environment::get().getSoundManager(); diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index 38847515ba..d31b7896ee 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -485,7 +485,7 @@ void MWWorld::ContainerStore::updateRechargingItems() mRechargingItems.clear(); for (ContainerStoreIterator it = begin(); it != end(); ++it) { - auto enchantmentId = it->getClass().getEnchantment(*it); + const auto& enchantmentId = it->getClass().getEnchantment(*it); if (!enchantmentId.empty()) { const ESM::Enchantment* enchantment diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index df26abe14a..99402c1e35 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -62,10 +62,11 @@ MWWorld::CellStore* MWWorld::WorldModel::getCellStore(const ESM::Cell* cell) { if (cell->mData.mFlags & ESM::Cell::Interior) { - auto result = mInteriors.find(cell->mName); + std::string lowerName(Misc::StringUtils::lowerCase(cell->mName)); + auto result = mInteriors.find(lowerName); if (result == mInteriors.end()) - result = mInteriors.emplace(std::move(cell->mName), CellStore(cell, mStore, mReaders)).first; + result = mInteriors.emplace(std::move(lowerName), CellStore(cell, mStore, mReaders)).first; return &result->second; } @@ -171,13 +172,14 @@ MWWorld::CellStore* MWWorld::WorldModel::getExterior(int x, int y) MWWorld::CellStore* MWWorld::WorldModel::getInterior(std::string_view name) { - auto result = mInteriors.find(std::string(name)); + std::string lowerName = Misc::StringUtils::lowerCase(name); + auto result = mInteriors.find(lowerName); if (result == mInteriors.end()) { const ESM::Cell* cell = mStore.get().find(ESM::RefId::stringRefId(name)); - result = mInteriors.emplace(std::move(name), CellStore(cell, mStore, mReaders)).first; + result = mInteriors.emplace(lowerName, CellStore(cell, mStore, mReaders)).first; } if (result->second.getState() != CellStore::State_Loaded) diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index 363d68c30d..bd4e722205 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -205,7 +205,7 @@ namespace Compiler mMemberOp = false; std::string name2 = Misc::StringUtils::lowerCase(name); - auto id = ESM::RefId::stringRefId(mExplicit); + auto id = ESM::RefId::stringRefId(Misc::StringUtils::lowerCase(mExplicit)); std::pair type = getContext().getMemberType(name2, id); @@ -303,29 +303,31 @@ namespace Compiler { start(); - char type = mLocals.getType(name); + std::string name2 = Misc::StringUtils::lowerCase(name); + + char type = mLocals.getType(name2); if (type != ' ') { - Generator::fetchLocal(mCode, type, mLocals.getIndex(name)); + Generator::fetchLocal(mCode, type, mLocals.getIndex(name2)); mNextOperand = false; mOperands.push_back(type == 'f' ? 'f' : 'l'); return true; } - type = getContext().getGlobalType(name); + type = getContext().getGlobalType(name2); if (type != ' ') { - Generator::fetchGlobal(mCode, mLiterals, type, name); + Generator::fetchGlobal(mCode, mLiterals, type, name2); mNextOperand = false; mOperands.push_back(type == 'f' ? 'f' : 'l'); return true; } - if (mExplicit.empty() && getContext().isId(ESM::RefId::stringRefId(name))) + if (mExplicit.empty() && getContext().isId(ESM::RefId::stringRefId(name2))) { - mExplicit = name; + mExplicit = name2; return true; } @@ -333,7 +335,7 @@ namespace Compiler // Convert the string to a number even if it's impossible and use it as a number literal. // Can't use stof/atof or to_string out of locale concerns. float number; - std::stringstream stream(name); + std::stringstream stream(name2); stream >> number; stream.str(std::string()); stream.clear(); diff --git a/components/compiler/streamerrorhandler.cpp b/components/compiler/streamerrorhandler.cpp index b198cf05d1..e72eb6fdb1 100644 --- a/components/compiler/streamerrorhandler.cpp +++ b/components/compiler/streamerrorhandler.cpp @@ -3,7 +3,6 @@ #include #include -#include #include "tokenloc.hpp" diff --git a/components/interpreter/defines.cpp b/components/interpreter/defines.cpp index 64090fb9b8..0fd0157425 100644 --- a/components/interpreter/defines.cpp +++ b/components/interpreter/defines.cpp @@ -214,7 +214,6 @@ namespace Interpreter if (globals.empty()) { globals = context.getGlobals(); - ; sort(globals.begin(), globals.end(), longerStr); }