diff --git a/apps/opencs/model/doc/savingstages.cpp b/apps/opencs/model/doc/savingstages.cpp index 3ef465f39d..441e508c43 100644 --- a/apps/opencs/model/doc/savingstages.cpp +++ b/apps/opencs/model/doc/savingstages.cpp @@ -253,7 +253,8 @@ void CSMDoc::CollectionReferencesStage::perform(int stage, Messages& messages) if (record.isModified() || record.mState == CSMWorld::RecordBase::State_Deleted) { - const ESM::RefId& cellId = record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell; + const ESM::RefId& cellId + = record.get().mOriginalCell.empty() ? record.get().mCell : record.get().mOriginalCell; std::deque& indices = mState.getSubRecords()[cellId.getRefIdString()]; diff --git a/apps/opencs/model/tools/referencecheck.cpp b/apps/opencs/model/tools/referencecheck.cpp index 6d5535609b..562dbc9ba7 100644 --- a/apps/opencs/model/tools/referencecheck.cpp +++ b/apps/opencs/model/tools/referencecheck.cpp @@ -88,8 +88,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message } if (!cellRef.mDestCell.empty() && mCells.searchId(cellRef.mDestCell) == -1) - messages.add( - id, "Destination cell '" + cellRef.mDestCell.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Destination cell '" + cellRef.mDestCell.getRefIdString() + "' does not exist", "", + CSMDoc::Message::Severity_Error); if (cellRef.mScale < 0) messages.add(id, "Negative scale", "", CSMDoc::Message::Severity_Error); diff --git a/apps/opencs/model/tools/tools.cpp b/apps/opencs/model/tools/tools.cpp index 0c5852efd0..46462b9c99 100644 --- a/apps/opencs/model/tools/tools.cpp +++ b/apps/opencs/model/tools/tools.cpp @@ -77,7 +77,6 @@ CSMDoc::OperationHolder* CSMTools::Tools::getVerifier() connect(&mVerifier, &CSMDoc::OperationHolder::done, this, &Tools::done); connect(&mVerifier, &CSMDoc::OperationHolder::reportMessage, this, &Tools::verifierMessage); - std::vector mandatoryRefIds; { auto mandatoryIds = { "Day", "DaysPassed", "GameHour", "Month", "PCRace" }; @@ -85,7 +84,6 @@ CSMDoc::OperationHolder* CSMTools::Tools::getVerifier() mandatoryRefIds.push_back(ESM::RefId::stringRefId(id)); } - mVerifierOperation->appendStage(new MandatoryIdStage( mData.getGlobals(), CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Globals), mandatoryRefIds)); diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index 54b8c07afe..f85715a098 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -9,13 +9,13 @@ #include +#include #include #include #include #include #include #include -#include #include #include @@ -334,8 +334,8 @@ namespace CSMWorld bool isEditable() const override { return true; } }; - template<> - struct NameColumn : public Column < CSMWorld::Cell> + template <> + struct NameColumn : public Column { NameColumn(ColumnBase::Display display = ColumnBase::Display_String) : Column(Columns::ColumnId_Name, display) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 1528476794..545137f6ec 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -790,7 +790,7 @@ void OMW::Engine::prepareEngine() mScriptContext->setExtensions(&mExtensions); mScriptManager = std::make_unique(mWorld->getStore(), *mScriptContext, mWarningsMode, - mScriptBlacklistUse ? mScriptBlacklist : std::vector()); + mScriptBlacklistUse ? mScriptBlacklist : std::vector()); mEnvironment.setScriptManager(*mScriptManager); // Create game mechanics system @@ -1003,7 +1003,7 @@ void OMW::Engine::setWarningsMode(int mode) mWarningsMode = mode; } -void OMW::Engine::setScriptBlacklist(const std::vector& list) +void OMW::Engine::setScriptBlacklist(const std::vector& list) { mScriptBlacklist = list; } diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index d22c3c13f2..fe2aff174d 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -4,10 +4,10 @@ #include #include +#include #include #include #include -#include #include #include @@ -179,7 +179,7 @@ namespace OMW Files::Collections mFileCollections; bool mFSStrict; Translation::Storage mTranslationDataStorage; - std::vector mScriptBlacklist; + std::vector mScriptBlacklist; bool mScriptBlacklistUse; bool mNewGame; @@ -260,7 +260,7 @@ namespace OMW void setWarningsMode(int mode); - void setScriptBlacklist(const std::vector& list); + void setScriptBlacklist(const std::vector& list); void setScriptBlacklistUse(bool use); diff --git a/apps/openmw/main.cpp b/apps/openmw/main.cpp index a2c096e2a0..3eaa3f1980 100644 --- a/apps/openmw/main.cpp +++ b/apps/openmw/main.cpp @@ -161,7 +161,13 @@ bool parseOptions(int argc, char** argv, OMW::Engine& engine, Files::Configurati engine.setScriptConsoleMode(variables["script-console"].as()); engine.setStartupScript(variables["script-run"].as()); engine.setWarningsMode(variables["script-warn"].as()); - engine.setScriptBlacklist(variables["script-blacklist"].as()); + std::vector scriptBlacklist; + auto& scriptBlacklistString = variables["script-blacklist"].as(); + for (const auto& blacklistString : scriptBlacklistString) + { + scriptBlacklist.push_back(ESM::RefId::stringRefId(blacklistString)); + } + engine.setScriptBlacklist(scriptBlacklist); engine.setScriptBlacklistUse(variables["script-blacklist-use"].as()); engine.setSaveGameFile(variables["load-savegame"].as().u8string()); diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 9c52aa347e..3eb3ded7de 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -367,7 +367,7 @@ namespace MWDialogue if (dialog.mType == ESM::Dialogue::Topic) { const auto* answer = filter.search(dialog, true); - auto topicId = dialog.mId; + const auto& topicId = dialog.mId; if (answer != nullptr) { diff --git a/apps/openmw/mwdialogue/filter.cpp b/apps/openmw/mwdialogue/filter.cpp index 35b1f24b75..38a3e70ba7 100644 --- a/apps/openmw/mwdialogue/filter.cpp +++ b/apps/openmw/mwdialogue/filter.cpp @@ -196,7 +196,8 @@ bool MWDialogue::Filter::testPlayer(const ESM::DialInfo& info) const if (!info.mCell.empty()) { // supports partial matches, just like getPcCell - std::string_view playerCell = MWBase::Environment::get().getWorld()->getCellName(player.getCell()).getRefIdString(); + std::string_view playerCell + = MWBase::Environment::get().getWorld()->getCellName(player.getCell()).getRefIdString(); if (!Misc::StringUtils::ciStartsWith(playerCell, info.mCell.getRefIdString())) return false; } @@ -553,7 +554,8 @@ bool MWDialogue::Filter::getSelectStructBoolean(const SelectWrapper& select) con case SelectWrapper::Function_NotCell: { - std::string_view actorCell = MWBase::Environment::get().getWorld()->getCellName(mActor.getCell()).getRefIdString(); + std::string_view actorCell + = MWBase::Environment::get().getWorld()->getCellName(mActor.getCell()).getRefIdString(); return !Misc::StringUtils::ciStartsWith(actorCell, select.getName()); } case SelectWrapper::Function_SameGender: diff --git a/apps/openmw/mwgui/race.cpp b/apps/openmw/mwgui/race.cpp index 54ab302f67..30881ac730 100644 --- a/apps/openmw/mwgui/race.cpp +++ b/apps/openmw/mwgui/race.cpp @@ -330,8 +330,7 @@ namespace MWGui continue; if (mGenderIndex != (bodypart.mData.mFlags & ESM::BodyPart::BPF_Female)) continue; - bool firstPerson = (idString.size() >= 3) && idString[idString.size() - 3] == '1' - && idString[idString.size() - 2] == 's' && idString[idString.size() - 1] == 't'; + bool firstPerson = idString.ends_with("1st"); if (firstPerson) continue; if (bodypart.mRace == mCurrentRaceId) diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index bea74710b4..71db4c4a12 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -804,7 +804,7 @@ namespace MWGui return mMessageBoxManager->readPressedButton(); } - std::string_view WindowManager::getGameSettingString(const std::string_view id, std::string_view default_) + std::string_view WindowManager::getGameSettingString(std::string_view id, std::string_view default_) { const ESM::GameSetting* setting = mStore->get().search(id); diff --git a/apps/openmw/mwgui/windowmanagerimp.hpp b/apps/openmw/mwgui/windowmanagerimp.hpp index 85ce9f5035..3b31397dde 100644 --- a/apps/openmw/mwgui/windowmanagerimp.hpp +++ b/apps/openmw/mwgui/windowmanagerimp.hpp @@ -283,7 +283,7 @@ namespace MWGui * @param id Identifier for the GMST setting, e.g. "aName" * @param default Default value if the GMST setting cannot be used. */ - std::string_view getGameSettingString(const std::string_view id, std::string_view default_) override; + std::string_view getGameSettingString(std::string_view id, std::string_view default_) override; void processChangedSettings(const Settings::CategorySettingVector& changed) override; diff --git a/apps/openmw/mwlua/localscripts.cpp b/apps/openmw/mwlua/localscripts.cpp index 54f8b7e330..eb93037444 100644 --- a/apps/openmw/mwlua/localscripts.cpp +++ b/apps/openmw/mwlua/localscripts.cpp @@ -146,8 +146,8 @@ namespace MWLua if (esmCell->isExterior()) ai.stack(MWMechanics::AiEscort(refId, gameHoursDuration, dest.x(), dest.y(), dest.z(), false), ptr); else - ai.stack(MWMechanics::AiEscort(refId, esmCell->mName, gameHoursDuration, - dest.x(), dest.y(), dest.z(), false), + ai.stack(MWMechanics::AiEscort( + refId, esmCell->mName, gameHoursDuration, dest.x(), dest.y(), dest.z(), false), ptr); }; selfAPI["_startAiWander"] = [](SelfObject& self, int distance, float duration) { diff --git a/apps/openmw/mwlua/objectbindings.cpp b/apps/openmw/mwlua/objectbindings.cpp index 5f8fd62d74..ba6c53e3d4 100644 --- a/apps/openmw/mwlua/objectbindings.cpp +++ b/apps/openmw/mwlua/objectbindings.cpp @@ -246,8 +246,8 @@ namespace MWLua const sol::optional& optRot) { MWWorld::Ptr ptr = object.ptr(); osg::Vec3f rot = optRot ? *optRot : ptr.getRefData().getPosition().asRotationVec3(); - auto action - = std::make_unique(context.mLua, object.id(), ESM::RefId::stringRefId(cell), pos, rot); + auto action = std::make_unique( + context.mLua, object.id(), ESM::RefId::stringRefId(cell), pos, rot); if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) context.mLuaManager->addTeleportPlayerAction(std::move(action)); else diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 2ad1c91e28..c8d96d25f3 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1442,7 +1442,7 @@ namespace MWMechanics if (isWerewolf) { - const ESM::RefId wolfRun = ESM::RefId::stringRefId("WorldRun"); + const ESM::RefId wolfRun = ESM::RefId::stringRefId("WolfRun"); if (isRunning() && !world->isSwimming(mPtr) && mWeaponType == ESM::Weapon::None) { if (!sndMgr->getSoundPlaying(mPtr, wolfRun)) diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index 2310e00920..930e178f13 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -85,7 +85,6 @@ namespace const ESM::RefId& owner = cellref.getOwner(); bool isOwned = !owner.empty() && owner != ESM::RefId::stringRefId("Player"); - ; const ESM::RefId& faction = cellref.getFaction(); bool isFactionOwned = false; @@ -866,7 +865,7 @@ namespace MWMechanics } // Perform bound item check and assign the Flag_Bound bit if it passes - ESM::RefId tempItemID = item.getCellRef().getRefId(); + const ESM::RefId& tempItemID = item.getCellRef().getRefId(); if (boundItemIDCache.count(tempItemID) != 0) return true; @@ -893,7 +892,7 @@ namespace MWMechanics // TODO: implement a better check to check if target is owned bed if (target.getClass().isActivator() - && target.getClass().getScript(target).getRefIdString().compare(0, 3, "Bed") != 0) + && target.getClass().getScript(target).getRefIdString().starts_with("Bed") != 0) return true; if (target.getClass().isNpc()) diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index ce2b584344..d5582e7eb3 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -25,7 +25,7 @@ namespace MWScript { ScriptManager::ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, - const std::vector& scriptBlacklist) + const std::vector& scriptBlacklist) : mErrorHandler() , mStore(store) , mCompilerContext(compilerContext) @@ -37,8 +37,6 @@ namespace MWScript mScriptBlacklist.resize(scriptBlacklist.size()); - std::transform(scriptBlacklist.begin(), scriptBlacklist.end(), mScriptBlacklist.begin(), - [](const std::string& s) { return Misc::StringUtils::lowerCase(s); }); std::sort(mScriptBlacklist.begin(), mScriptBlacklist.end()); } @@ -112,7 +110,7 @@ namespace MWScript } // execute script - auto target = interpreterContext.getTarget(); + const auto& target = interpreterContext.getTarget(); if (!iter->second.mByteCode.empty() && iter->second.mInactive.find(target) == iter->second.mInactive.end()) try { @@ -155,8 +153,7 @@ namespace MWScript for (auto& script : mStore.get()) { - if (!std::binary_search(mScriptBlacklist.begin(), mScriptBlacklist.end(), - Misc::StringUtils::lowerCase(script.mId.getRefIdString()))) + if (!std::binary_search(mScriptBlacklist.begin(), mScriptBlacklist.end(), script.mId)) { ++count; @@ -188,8 +185,7 @@ namespace MWScript { Compiler::Locals locals; - const Compiler::ContextOverride override( - mErrorHandler, std::string{ name.getRefIdString() } + "[local variables]"); + const Compiler::ContextOverride override(mErrorHandler, name.getRefIdString() + "[local variables]"); std::istringstream stream(script->mScriptText); Compiler::QuickFileParser parser(mErrorHandler, mCompilerContext, locals); diff --git a/apps/openmw/mwscript/scriptmanagerimp.hpp b/apps/openmw/mwscript/scriptmanagerimp.hpp index f526ced447..74b20b222b 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.hpp +++ b/apps/openmw/mwscript/scriptmanagerimp.hpp @@ -60,11 +60,11 @@ namespace MWScript std::unordered_map mScripts; GlobalScripts mGlobalScripts; std::unordered_map mOtherLocals; - std::vector mScriptBlacklist; + std::vector mScriptBlacklist; public: ScriptManager(const MWWorld::ESMStore& store, Compiler::Context& compilerContext, int warningsMode, - const std::vector& scriptBlacklist); + const std::vector& scriptBlacklist); void clear() override; diff --git a/apps/openmw/mwscript/statsextensions.cpp b/apps/openmw/mwscript/statsextensions.cpp index 262f6727ba..6214a3b4fe 100644 --- a/apps/openmw/mwscript/statsextensions.cpp +++ b/apps/openmw/mwscript/statsextensions.cpp @@ -973,7 +973,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - ESM::RefId factionID = ptr.getClass().getPrimaryFaction(ptr); + const ESM::RefId& factionID = ptr.getClass().getPrimaryFaction(ptr); if (factionID.empty()) return; @@ -1007,7 +1007,7 @@ namespace MWScript { MWWorld::Ptr ptr = R()(runtime); - ESM::RefId factionID = ptr.getClass().getPrimaryFaction(ptr); + const ESM::RefId& factionID = ptr.getClass().getPrimaryFaction(ptr); if (factionID.empty()) return; diff --git a/apps/openmw/mwworld/containerstore.cpp b/apps/openmw/mwworld/containerstore.cpp index d31b7896ee..8587f10f25 100644 --- a/apps/openmw/mwworld/containerstore.cpp +++ b/apps/openmw/mwworld/containerstore.cpp @@ -628,7 +628,7 @@ void MWWorld::ContainerStore::addInitialItemImp( } else { - auto itemId = MWMechanics::getLevelledItem(ptr.get()->mBase, false, *prng); + const auto& itemId = MWMechanics::getLevelledItem(ptr.get()->mBase, false, *prng); if (itemId.empty()) return; addInitialItem(itemId, owner, count, prng, false); diff --git a/apps/openmw/mwworld/esmstore.cpp b/apps/openmw/mwworld/esmstore.cpp index db5b54ec57..03de9fda5d 100644 --- a/apps/openmw/mwworld/esmstore.cpp +++ b/apps/openmw/mwworld/esmstore.cpp @@ -429,7 +429,6 @@ namespace MWWorld if (value.mRefID != deletedRefID) { ESM::RefId& refId = refIDs[value.mRefID]; - // We manually lower case IDs here for the time being to improve performance. ++mRefCount[std::move(refId)]; } }; diff --git a/apps/openmw/mwworld/player.cpp b/apps/openmw/mwworld/player.cpp index b2922b56d3..1f4aca0cf0 100644 --- a/apps/openmw/mwworld/player.cpp +++ b/apps/openmw/mwworld/player.cpp @@ -50,7 +50,6 @@ namespace MWWorld ESM::CellRef cellRef; cellRef.blank(); cellRef.mRefID = ESM::RefId::stringRefId("Player"); - ; mPlayer = LiveCellRef(cellRef, player); ESM::Position playerPos = mPlayer.mData.getPosition(); diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index cdb47d0ef6..91cd49606d 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -572,7 +572,8 @@ namespace MWWorld if (cell) return cell; // treat "Wilderness" like an empty string - const ESM::RefId defaultName = ESM::RefId::stringRefId(mStore.get().find("sDefaultCellname")->mValue.getString()); + const ESM::RefId defaultName + = ESM::RefId::stringRefId(mStore.get().find("sDefaultCellname")->mValue.getString()); if (cellName == defaultName) { cell = mStore.get().searchExtByName(ESM::RefId::sEmpty); @@ -670,7 +671,7 @@ namespace MWWorld return cell->mName; if (const ESM::Region* region = mStore.get().search(cell->mRegion)) - return ESM::RefId::stringRefId( region->mName); + return ESM::RefId::stringRefId(region->mName); } return ESM::RefId::stringRefId(mStore.get().find("sDefaultCellname")->mValue.getString()); } diff --git a/components/detournavigator/navigatorimpl.cpp b/components/detournavigator/navigatorimpl.cpp index eb4871e865..9bcee95d1d 100644 --- a/components/detournavigator/navigatorimpl.cpp +++ b/components/detournavigator/navigatorimpl.cpp @@ -3,10 +3,9 @@ #include "stats.hpp" #include +#include #include #include -#include - namespace DetourNavigator { @@ -39,7 +38,8 @@ namespace DetourNavigator mNavMeshManager.setWorldspace(worldspace, getImpl(guard)); } - void NavigatorImpl::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) { + void NavigatorImpl::setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) + { setWorldspace(Misc::StringUtils::lowerCase(worldspace.getRefIdString()), guard); } diff --git a/components/detournavigator/navigatorimpl.hpp b/components/detournavigator/navigatorimpl.hpp index 43a6b1dae6..ddced1c3e9 100644 --- a/components/detournavigator/navigatorimpl.hpp +++ b/components/detournavigator/navigatorimpl.hpp @@ -31,7 +31,6 @@ namespace DetourNavigator void setWorldspace(const ESM::RefId& worldspace, const UpdateGuard* guard) override; - void updateBounds(const osg::Vec3f& playerPosition, const UpdateGuard* guard) override; void addObject(const ObjectId id, const ObjectShapes& shapes, const btTransform& transform, diff --git a/components/detournavigator/navigatorstub.hpp b/components/detournavigator/navigatorstub.hpp index 8ead5907ab..ad7f866797 100644 --- a/components/detournavigator/navigatorstub.hpp +++ b/components/detournavigator/navigatorstub.hpp @@ -26,7 +26,6 @@ namespace DetourNavigator void setWorldspace(std::string_view /*worldspace*/, const UpdateGuard* /*guard*/) override {} void setWorldspace(const ESM::RefId& /*worldspace*/, const UpdateGuard* /*guard*/) override {} - void addObject(const ObjectId /*id*/, const ObjectShapes& /*shapes*/, const btTransform& /*transform*/, const UpdateGuard* /*guard*/) override { diff --git a/components/esm3/cellid.hpp b/components/esm3/cellid.hpp index 2dbe9167d2..40acb63a2b 100644 --- a/components/esm3/cellid.hpp +++ b/components/esm3/cellid.hpp @@ -1,8 +1,8 @@ #ifndef OPENMW_ESM_CELLID_H #define OPENMW_ESM_CELLID_H -#include #include +#include namespace ESM {