diff --git a/.clang-tidy b/.clang-tidy index 1f37003f8e..656c10fb99 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -18,3 +18,5 @@ CheckOptions: value: CamelCase - key: readability-identifier-naming.NamespaceIgnoredRegexp value: 'bpo|osg(DB|FX|Particle|Shadow|Viewer|Util)?' +- key: readability-identifier-naming.LocalVariableCase + value: camelBack diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cdda455dac..cdcecac4f7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -425,6 +425,7 @@ Ubuntu_Clang: - mkdir -pv "${CCACHE_DIR}" - ccache -z -M "${CCACHE_SIZE}" - CI/before_script.linux.sh + - cp extern/.clang-tidy build/.clang-tidy - cd build - find . -name *.o -exec touch {} \; - cmake --build . -- -j $(nproc) ${BUILD_TARGETS} diff --git a/apps/bsatool/bsatool.cpp b/apps/bsatool/bsatool.cpp index 171e5606c4..b62a438294 100644 --- a/apps/bsatool/bsatool.cpp +++ b/apps/bsatool/bsatool.cpp @@ -75,8 +75,8 @@ Allowed options)"); bpo::variables_map variables; try { - bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(all).positional(p).run(); - bpo::store(valid_opts, variables); + bpo::parsed_options validOpts = bpo::command_line_parser(argc, argv).options(all).positional(p).run(); + bpo::store(validOpts, variables); } catch (std::exception& e) { diff --git a/apps/components_tests/lua/testscriptscontainer.cpp b/apps/components_tests/lua/testscriptscontainer.cpp index 9c4c656b32..19c148da2f 100644 --- a/apps/components_tests/lua/testscriptscontainer.cpp +++ b/apps/components_tests/lua/testscriptscontainer.cpp @@ -285,17 +285,17 @@ CUSTOM: customdata.lua EXPECT_TRUE(scripts.addCustomScript(getId(test2Path))); sol::state_view sol = mLua.unsafeState(); - std::string X0 = LuaUtil::serialize(sol.create_table_with("x", 0.5)); - std::string X1 = LuaUtil::serialize(sol.create_table_with("x", 1.5)); + std::string x0 = LuaUtil::serialize(sol.create_table_with("x", 0.5)); + std::string x1 = LuaUtil::serialize(sol.create_table_with("x", 1.5)); { testing::internal::CaptureStdout(); - scripts.receiveEvent("SomeEvent", X1); + scripts.receiveEvent("SomeEvent", x1); EXPECT_EQ(internal::GetCapturedStdout(), ""); } { testing::internal::CaptureStdout(); - scripts.receiveEvent("Event1", X1); + scripts.receiveEvent("Event1", x1); EXPECT_EQ(internal::GetCapturedStdout(), "Test[test2.lua]:\t event1 1.5\n" "Test[stopevent.lua]:\t event1 1.5\n" @@ -303,21 +303,21 @@ CUSTOM: customdata.lua } { testing::internal::CaptureStdout(); - scripts.receiveEvent("Event2", X1); + scripts.receiveEvent("Event2", x1); EXPECT_EQ(internal::GetCapturedStdout(), "Test[test2.lua]:\t event2 1.5\n" "Test[test1.lua]:\t event2 1.5\n"); } { testing::internal::CaptureStdout(); - scripts.receiveEvent("Event1", X0); + scripts.receiveEvent("Event1", x0); EXPECT_EQ(internal::GetCapturedStdout(), "Test[test2.lua]:\t event1 0.5\n" "Test[stopevent.lua]:\t event1 0.5\n"); } { testing::internal::CaptureStdout(); - scripts.receiveEvent("Event2", X0); + scripts.receiveEvent("Event2", x0); EXPECT_EQ(internal::GetCapturedStdout(), "Test[test2.lua]:\t event2 0.5\n" "Test[test1.lua]:\t event2 0.5\n"); @@ -333,12 +333,12 @@ CUSTOM: customdata.lua EXPECT_TRUE(scripts.addCustomScript(getId(test2Path))); sol::state_view sol = mLua.unsafeState(); - std::string X = LuaUtil::serialize(sol.create_table_with("x", 0.5)); + std::string x = LuaUtil::serialize(sol.create_table_with("x", 0.5)); { testing::internal::CaptureStdout(); scripts.update(1.5f); - scripts.receiveEvent("Event1", X); + scripts.receiveEvent("Event1", x); EXPECT_EQ(internal::GetCapturedStdout(), "Test[test1.lua]:\t update 1.5\n" "Test[test2.lua]:\t update 1.5\n" @@ -352,7 +352,7 @@ CUSTOM: customdata.lua scripts.removeScript(stopEventScriptId); EXPECT_FALSE(scripts.hasScript(stopEventScriptId)); scripts.update(1.5f); - scripts.receiveEvent("Event1", X); + scripts.receiveEvent("Event1", x); EXPECT_EQ(internal::GetCapturedStdout(), "Test[test1.lua]:\t update 1.5\n" "Test[test2.lua]:\t update 1.5\n" @@ -363,7 +363,7 @@ CUSTOM: customdata.lua testing::internal::CaptureStdout(); scripts.removeScript(getId(test1Path)); scripts.update(1.5f); - scripts.receiveEvent("Event1", X); + scripts.receiveEvent("Event1", x); EXPECT_EQ(internal::GetCapturedStdout(), "Test[test2.lua]:\t update 1.5\n" "Test[test2.lua]:\t event1 0.5\n"); diff --git a/apps/components_tests/lua/testserialization.cpp b/apps/components_tests/lua/testserialization.cpp index cff41dde9a..a7d9d8343f 100644 --- a/apps/components_tests/lua/testserialization.cpp +++ b/apps/components_tests/lua/testserialization.cpp @@ -171,10 +171,10 @@ namespace std::string serialized = LuaUtil::serialize(table); EXPECT_EQ(serialized.size(), 139); - sol::table res_table = LuaUtil::deserialize(lua, serialized); - sol::table res_readonly_table = LuaUtil::deserialize(lua, serialized, nullptr, true); + sol::table resTable = LuaUtil::deserialize(lua, serialized); + sol::table resReadonlyTable = LuaUtil::deserialize(lua, serialized, nullptr, true); - for (auto t : { res_table, res_readonly_table }) + for (auto t : { resTable, resReadonlyTable }) { EXPECT_EQ(t.get("aa"), 1); EXPECT_EQ(t.get("ab"), true); @@ -185,8 +185,8 @@ namespace EXPECT_EQ(t.get(2), osg::Vec2f(2, 1)); } - lua["t"] = res_table; - lua["ro_t"] = res_readonly_table; + lua["t"] = resTable; + lua["ro_t"] = resReadonlyTable; EXPECT_NO_THROW(lua.safe_script("t.x = 5")); EXPECT_NO_THROW(lua.safe_script("t.nested.x = 5")); EXPECT_ERROR(lua.safe_script("ro_t.x = 5"), "userdata value"); diff --git a/apps/esmtool/esmtool.cpp b/apps/esmtool/esmtool.cpp index 7cdc2bcd98..181dd5360f 100644 --- a/apps/esmtool/esmtool.cpp +++ b/apps/esmtool/esmtool.cpp @@ -101,9 +101,9 @@ Allowed options)"); try { - bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(all).positional(p).run(); + bpo::parsed_options validOpts = bpo::command_line_parser(argc, argv).options(all).positional(p).run(); - bpo::store(valid_opts, variables); + bpo::store(validOpts, variables); } catch (std::exception& e) { diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index b9c64d964a..8bb9a138b1 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -60,81 +60,81 @@ namespace std::string ruleString(const ESM::DialogueCondition& ss) { - std::string_view type_str = "INVALID"; - std::string_view func_str; + std::string_view typeStr = "INVALID"; + std::string_view funcStr; switch (ss.mFunction) { case ESM::DialogueCondition::Function_Global: - type_str = "Global"; - func_str = ss.mVariable; + typeStr = "Global"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_Local: - type_str = "Local"; - func_str = ss.mVariable; + typeStr = "Local"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_Journal: - type_str = "Journal"; - func_str = ss.mVariable; + typeStr = "Journal"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_Item: - type_str = "Item count"; - func_str = ss.mVariable; + typeStr = "Item count"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_Dead: - type_str = "Dead"; - func_str = ss.mVariable; + typeStr = "Dead"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_NotId: - type_str = "Not ID"; - func_str = ss.mVariable; + typeStr = "Not ID"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_NotFaction: - type_str = "Not Faction"; - func_str = ss.mVariable; + typeStr = "Not Faction"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_NotClass: - type_str = "Not Class"; - func_str = ss.mVariable; + typeStr = "Not Class"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_NotRace: - type_str = "Not Race"; - func_str = ss.mVariable; + typeStr = "Not Race"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_NotCell: - type_str = "Not Cell"; - func_str = ss.mVariable; + typeStr = "Not Cell"; + funcStr = ss.mVariable; break; case ESM::DialogueCondition::Function_NotLocal: - type_str = "Not Local"; - func_str = ss.mVariable; + typeStr = "Not Local"; + funcStr = ss.mVariable; break; default: - type_str = "Function"; - func_str = ruleFunction(ss.mFunction); + typeStr = "Function"; + funcStr = ruleFunction(ss.mFunction); break; } - std::string_view oper_str = "??"; + std::string_view operStr = "??"; switch (ss.mComparison) { case ESM::DialogueCondition::Comp_Eq: - oper_str = "=="; + operStr = "=="; break; case ESM::DialogueCondition::Comp_Ne: - oper_str = "!="; + operStr = "!="; break; case ESM::DialogueCondition::Comp_Gt: - oper_str = "> "; + operStr = "> "; break; case ESM::DialogueCondition::Comp_Ge: - oper_str = ">="; + operStr = ">="; break; case ESM::DialogueCondition::Comp_Ls: - oper_str = "< "; + operStr = "< "; break; case ESM::DialogueCondition::Comp_Le: - oper_str = "<="; + operStr = "<="; break; default: break; @@ -143,8 +143,7 @@ namespace std::ostringstream stream; std::visit([&](auto value) { stream << value; }, ss.mValue); - std::string result - = Misc::StringUtils::format("%-12s %-32s %2s %s", type_str, func_str, oper_str, stream.str()); + std::string result = Misc::StringUtils::format("%-12s %-32s %2s %s", typeStr, funcStr, operStr, stream.str()); return result; } diff --git a/apps/essimporter/converter.hpp b/apps/essimporter/converter.hpp index 520dd27f2a..db801f4e92 100644 --- a/apps/essimporter/converter.hpp +++ b/apps/essimporter/converter.hpp @@ -181,14 +181,14 @@ namespace ESSImport public: void read(ESM::ESMReader& esm) override { - ESM::Class class_; + ESM::Class classRecord; bool isDeleted = false; - class_.load(esm, isDeleted); - if (class_.mId == "NEWCLASSID_CHARGEN") - mContext->mCustomPlayerClassName = class_.mName; + classRecord.load(esm, isDeleted); + if (classRecord.mId == "NEWCLASSID_CHARGEN") + mContext->mCustomPlayerClassName = classRecord.mName; - mRecords[class_.mId] = class_; + mRecords[classRecord.mId] = classRecord; } }; diff --git a/apps/essimporter/main.cpp b/apps/essimporter/main.cpp index 50e11e2c5a..da3fac54f6 100644 --- a/apps/essimporter/main.cpp +++ b/apps/essimporter/main.cpp @@ -15,7 +15,7 @@ int main(int argc, char** argv) { bpo::options_description desc(R"(Syntax: openmw-essimporter infile.ess outfile.omwsave Allowed options)"); - bpo::positional_options_description p_desc; + bpo::positional_options_description positionalDesc; auto addOption = desc.add_options(); addOption("help,h", "produce help message"); addOption("mwsave,m", bpo::value(), "morrowind .ess save file"); @@ -23,12 +23,13 @@ Allowed options)"); addOption("compare,c", "compare two .ess files"); addOption("encoding", boost::program_options::value()->default_value("win1252"), "encoding of the save file"); - p_desc.add("mwsave", 1).add("output", 1); + positionalDesc.add("mwsave", 1).add("output", 1); Files::ConfigurationManager::addCommonOptions(desc); bpo::variables_map variables; - bpo::parsed_options parsed = bpo::command_line_parser(argc, argv).options(desc).positional(p_desc).run(); + bpo::parsed_options parsed + = bpo::command_line_parser(argc, argv).options(desc).positional(positionalDesc).run(); bpo::store(parsed, variables); if (variables.count("help") || !variables.count("mwsave") || !variables.count("output")) diff --git a/apps/launcher/utils/openalutil.cpp b/apps/launcher/utils/openalutil.cpp index 9a9ae9981b..e4de9ad5c2 100644 --- a/apps/launcher/utils/openalutil.cpp +++ b/apps/launcher/utils/openalutil.cpp @@ -43,10 +43,10 @@ std::vector Launcher::enumerateOpenALDevicesHrtf() LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr; void* funcPtr = alcGetProcAddress(device, "alcGetStringiSOFT"); memcpy(&alcGetStringiSOFT, &funcPtr, sizeof(funcPtr)); - ALCint num_hrtf; - alcGetIntegerv(device, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf); - ret.reserve(num_hrtf); - for (ALCint i = 0; i < num_hrtf; ++i) + ALCint numHrtf; + alcGetIntegerv(device, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &numHrtf); + ret.reserve(numHrtf); + for (ALCint i = 0; i < numHrtf; ++i) { const ALCchar* entry = alcGetStringiSOFT(device, ALC_HRTF_SPECIFIER_SOFT, i); if (strcmp(entry, "") == 0) diff --git a/apps/mwiniimporter/importer.cpp b/apps/mwiniimporter/importer.cpp index 4b8e7acd61..88afc09707 100644 --- a/apps/mwiniimporter/importer.cpp +++ b/apps/mwiniimporter/importer.cpp @@ -326,10 +326,10 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::filesystem::pat continue; } - int comment_pos = static_cast(utf8.find(';')); - if (comment_pos > 0) + const std::string::size_type commentPos = utf8.find(';'); + if (commentPos != std::string::npos) { - utf8 = utf8.substr(0, comment_pos); + utf8 = utf8.substr(0, commentPos); } int pos = static_cast(utf8.find('=')); diff --git a/apps/mwiniimporter/main.cpp b/apps/mwiniimporter/main.cpp index c5f21ac67f..cb1fb95628 100644 --- a/apps/mwiniimporter/main.cpp +++ b/apps/mwiniimporter/main.cpp @@ -62,7 +62,7 @@ int wmain(int argc, wchar_t* wargv[]) try { bpo::options_description desc("Syntax: openmw-iniimporter inifile configfile\nAllowed options"); - bpo::positional_options_description p_desc; + bpo::positional_options_description positionalDesc; auto addOption = desc.add_options(); addOption("help,h", "produce help message"); addOption("verbose,v", "verbose output"); @@ -79,11 +79,12 @@ int wmain(int argc, wchar_t* wargv[]) "\n\twin1251 - Cyrillic alphabet such as Russian, Bulgarian, Serbian Cyrillic and other languages\n" "\n\twin1252 - Western European (Latin) alphabet, used by default"); ; - p_desc.add("ini", 1).add("cfg", 1); + positionalDesc.add("ini", 1).add("cfg", 1); bpo::variables_map vm; - bpo::parsed_options parsed = bpo::command_line_parser(argc, argv).options(desc).positional(p_desc).run(); + bpo::parsed_options parsed + = bpo::command_line_parser(argc, argv).options(desc).positional(positionalDesc).run(); bpo::store(parsed, vm); if (vm.count("help") || !vm.count("ini") || !vm.count("cfg")) diff --git a/apps/niftest/niftest.cpp b/apps/niftest/niftest.cpp index 7f19008bd1..4afa0a04f4 100644 --- a/apps/niftest/niftest.cpp +++ b/apps/niftest/niftest.cpp @@ -235,8 +235,8 @@ Allowed options)"); bpo::variables_map variables; try { - bpo::parsed_options valid_opts = bpo::command_line_parser(argc, argv).options(desc).positional(p).run(); - bpo::store(valid_opts, variables); + bpo::parsed_options validOpts = bpo::command_line_parser(argc, argv).options(desc).positional(p).run(); + bpo::store(validOpts, variables); bpo::notify(variables); if (variables.count("help")) { diff --git a/apps/opencs/model/prefs/modifiersetting.cpp b/apps/opencs/model/prefs/modifiersetting.cpp index 4bb7d64e60..f93aa82467 100644 --- a/apps/opencs/model/prefs/modifiersetting.cpp +++ b/apps/opencs/model/prefs/modifiersetting.cpp @@ -95,9 +95,9 @@ namespace CSMPrefs bool ModifierSetting::handleEvent(QObject* target, int mod, int value) { // For potential future exceptions - const int Blacklist[] = { 0 }; + const int blacklist[] = { 0 }; - const size_t BlacklistSize = sizeof(Blacklist) / sizeof(int); + const size_t blacklistSize = std::size(blacklist); if (!mEditorActive) { @@ -114,9 +114,9 @@ namespace CSMPrefs } // Handle blacklist - for (size_t i = 0; i < BlacklistSize; ++i) + for (size_t i = 0; i < blacklistSize; ++i) { - if (value == Blacklist[i]) + if (value == blacklist[i]) return true; } diff --git a/apps/opencs/model/prefs/shortcutmanager.cpp b/apps/opencs/model/prefs/shortcutmanager.cpp index 2ffa042641..6e48eebb6a 100644 --- a/apps/opencs/model/prefs/shortcutmanager.cpp +++ b/apps/opencs/model/prefs/shortcutmanager.cpp @@ -174,7 +174,7 @@ namespace CSMPrefs void ShortcutManager::convertFromString(std::string_view data, QKeySequence& sequence) const { - const int MaxKeys = 4; // A limitation of QKeySequence + const int maxKeys = 4; // A limitation of QKeySequence size_t end = data.find(';'); size_t size = std::min(end, data.size()); @@ -185,7 +185,7 @@ namespace CSMPrefs int keyPos = 0; int mods = 0; - int keys[MaxKeys] = {}; + int keys[maxKeys] = {}; while (start < value.size()) { @@ -228,7 +228,7 @@ namespace CSMPrefs mods = 0; keyPos += 1; - if (keyPos >= MaxKeys) + if (keyPos >= maxKeys) break; } } @@ -286,14 +286,14 @@ namespace CSMPrefs QString ShortcutManager::processToolTip(const QString& toolTip) const { - const QChar SequenceStart = '{'; - const QChar SequenceEnd = '}'; + const QChar sequenceStart = '{'; + const QChar sequenceEnd = '}'; QStringList substrings; int prevIndex = 0; - int startIndex = toolTip.indexOf(SequenceStart); - int endIndex = (startIndex != -1) ? toolTip.indexOf(SequenceEnd, startIndex) : -1; + int startIndex = toolTip.indexOf(sequenceStart); + int endIndex = (startIndex != -1) ? toolTip.indexOf(sequenceEnd, startIndex) : -1; // Process every valid shortcut escape sequence while (startIndex != -1 && endIndex != -1) @@ -328,8 +328,8 @@ namespace CSMPrefs prevIndex = endIndex + 1; // '}' character } - startIndex = toolTip.indexOf(SequenceStart, endIndex); - endIndex = (startIndex != -1) ? toolTip.indexOf(SequenceEnd, startIndex) : -1; + startIndex = toolTip.indexOf(sequenceStart, endIndex); + endIndex = (startIndex != -1) ? toolTip.indexOf(sequenceEnd, startIndex) : -1; } if (prevIndex < toolTip.size()) diff --git a/apps/opencs/model/prefs/shortcutsetting.cpp b/apps/opencs/model/prefs/shortcutsetting.cpp index bdaf3a0fda..9011cc7cdb 100644 --- a/apps/opencs/model/prefs/shortcutsetting.cpp +++ b/apps/opencs/model/prefs/shortcutsetting.cpp @@ -118,9 +118,9 @@ namespace CSMPrefs bool ShortcutSetting::handleEvent(QObject* target, int mod, int value, bool active) { // Modifiers are handled differently - const int Blacklist[] = { Qt::Key_Shift, Qt::Key_Control, Qt::Key_Meta, Qt::Key_Alt, Qt::Key_AltGr }; + const int blacklist[] = { Qt::Key_Shift, Qt::Key_Control, Qt::Key_Meta, Qt::Key_Alt, Qt::Key_AltGr }; - const size_t BlacklistSize = sizeof(Blacklist) / sizeof(int); + const size_t blacklistSize = std::size(blacklist); if (!mEditorActive) { @@ -137,9 +137,9 @@ namespace CSMPrefs } // Handle blacklist - for (size_t i = 0; i < BlacklistSize; ++i) + for (size_t i = 0; i < blacklistSize; ++i) { - if (value == Blacklist[i]) + if (value == blacklist[i]) return true; } diff --git a/apps/opencs/model/tools/classcheck.cpp b/apps/opencs/model/tools/classcheck.cpp index 0cbf5562fc..dd3635a0c5 100644 --- a/apps/opencs/model/tools/classcheck.cpp +++ b/apps/opencs/model/tools/classcheck.cpp @@ -37,23 +37,23 @@ void CSMTools::ClassCheckStage::perform(int stage, CSMDoc::Messages& messages) if ((mIgnoreBaseRecords && record.mState == CSMWorld::RecordBase::State_BaseOnly) || record.isDeleted()) return; - const ESM::Class& class_ = record.get(); + const ESM::Class& classRecord = record.get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Class, class_.mId); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_Class, classRecord.mId); // A class should have a name - if (class_.mName.empty()) + if (classRecord.mName.empty()) messages.add(id, "Name is missing", "", CSMDoc::Message::Severity_Error); // A playable class should have a description - if (class_.mData.mIsPlayable != 0 && class_.mDescription.empty()) + if (classRecord.mData.mIsPlayable != 0 && classRecord.mDescription.empty()) messages.add(id, "Description of a playable class is missing", "", CSMDoc::Message::Severity_Warning); // test for invalid attributes std::map attributeCount; - for (size_t i = 0; i < class_.mData.mAttribute.size(); ++i) + for (size_t i = 0; i < classRecord.mData.mAttribute.size(); ++i) { - int attribute = class_.mData.mAttribute[i]; + int attribute = classRecord.mData.mAttribute[i]; if (attribute == -1) messages.add(id, "Attribute #" + std::to_string(i) + " is not set", {}, CSMDoc::Message::Severity_Error); else @@ -73,7 +73,7 @@ void CSMTools::ClassCheckStage::perform(int stage, CSMDoc::Messages& messages) // test for non-unique skill std::map skills; // ID, number of occurrences - for (const auto& s : class_.mData.mSkills) + for (const auto& s : classRecord.mData.mSkills) for (int skill : s) ++skills[skill]; diff --git a/apps/opencs/model/tools/referenceablecheck.cpp b/apps/opencs/model/tools/referenceablecheck.cpp index a00c3acd1c..b9ed2cec0d 100644 --- a/apps/opencs/model/tools/referenceablecheck.cpp +++ b/apps/opencs/model/tools/referenceablecheck.cpp @@ -581,12 +581,12 @@ void CSMTools::ReferenceableCheckStage::creaturesLevListCheck( if ((mIgnoreBaseRecords && baseRecord.mState == CSMWorld::RecordBase::State_BaseOnly) || baseRecord.isDeleted()) return; - const ESM::CreatureLevList& CreatureLevList + const ESM::CreatureLevList& creatureLevList = (dynamic_cast&>(baseRecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, - CreatureLevList.mId); // CreatureLevList but Type_CreatureLevelledList :/ + // CreatureLevList but Type_CreatureLevelledList :/ + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_CreatureLevelledList, creatureLevList.mId); - listCheck(CreatureLevList, messages, id.toString()); + listCheck(creatureLevList, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::itemLevelledListCheck( @@ -598,10 +598,10 @@ void CSMTools::ReferenceableCheckStage::itemLevelledListCheck( if ((mIgnoreBaseRecords && baseRecord.mState == CSMWorld::RecordBase::State_BaseOnly) || baseRecord.isDeleted()) return; - const ESM::ItemLevList& ItemLevList = (dynamic_cast&>(baseRecord)).get(); - CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId); + const ESM::ItemLevList& itemLevList = (dynamic_cast&>(baseRecord)).get(); + CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, itemLevList.mId); - listCheck(ItemLevList, messages, id.toString()); + listCheck(itemLevList, messages, id.toString()); } void CSMTools::ReferenceableCheckStage::lightCheck( diff --git a/apps/opencs/model/world/actoradapter.cpp b/apps/opencs/model/world/actoradapter.cpp index acbe6b5d38..f7796acd76 100644 --- a/apps/opencs/model/world/actoradapter.cpp +++ b/apps/opencs/model/world/actoradapter.cpp @@ -474,8 +474,8 @@ namespace CSMWorld return; } - const int TypeColumn = mReferenceables.findColumnIndex(Columns::ColumnId_RecordType); - int type = mReferenceables.getData(index, TypeColumn).toInt(); + const int typeColumn = mReferenceables.findColumnIndex(Columns::ColumnId_RecordType); + int type = mReferenceables.getData(index, typeColumn).toInt(); if (type == UniversalId::Type_Creature) { // Valid creature record @@ -606,8 +606,8 @@ namespace CSMWorld } }; - int TypeColumn = mReferenceables.findColumnIndex(Columns::ColumnId_RecordType); - int type = mReferenceables.getData(index, TypeColumn).toInt(); + const int typeColumn = mReferenceables.findColumnIndex(Columns::ColumnId_RecordType); + int type = mReferenceables.getData(index, typeColumn).toInt(); if (type == UniversalId::Type_Armor) { auto& armor = dynamic_cast&>(record).get(); diff --git a/apps/opencs/model/world/columnimp.cpp b/apps/opencs/model/world/columnimp.cpp index c31f9c01d0..baf2e5d8e3 100644 --- a/apps/opencs/model/world/columnimp.cpp +++ b/apps/opencs/model/world/columnimp.cpp @@ -86,14 +86,14 @@ namespace CSMWorld QVariant LandNormalsColumn::get(const Record& record) const { - const int Size = Land::LAND_NUM_VERTS * 3; + const int size = Land::LAND_NUM_VERTS * 3; const Land& land = record.get(); - DataType values(Size, 0); + DataType values(size, 0); if (land.isDataLoaded(Land::DATA_VNML)) { - for (int i = 0; i < Size; ++i) + for (int i = 0; i < size; ++i) values[i] = land.getLandData()->mNormals[i]; } @@ -133,14 +133,14 @@ namespace CSMWorld QVariant LandHeightsColumn::get(const Record& record) const { - const int Size = Land::LAND_NUM_VERTS; + const int size = Land::LAND_NUM_VERTS; const Land& land = record.get(); - DataType values(Size, 0); + DataType values(size, 0); if (land.isDataLoaded(Land::DATA_VHGT)) { - for (int i = 0; i < Size; ++i) + for (int i = 0; i < size; ++i) values[i] = land.getLandData()->mHeights[i]; } @@ -182,14 +182,14 @@ namespace CSMWorld QVariant LandColoursColumn::get(const Record& record) const { - const int Size = Land::LAND_NUM_VERTS * 3; + const int size = Land::LAND_NUM_VERTS * 3; const Land& land = record.get(); - DataType values(Size, 0); + DataType values(size, 0); if (land.isDataLoaded(Land::DATA_VCLR)) { - for (int i = 0; i < Size; ++i) + for (int i = 0; i < size; ++i) values[i] = land.getLandData()->mColours[i]; } @@ -231,14 +231,14 @@ namespace CSMWorld QVariant LandTexturesColumn::get(const Record& record) const { - const int Size = Land::LAND_NUM_TEXTURES; + const int size = Land::LAND_NUM_TEXTURES; const Land& land = record.get(); - DataType values(Size, 0); + DataType values(size, 0); if (land.isDataLoaded(Land::DATA_VTEX)) { - for (int i = 0; i < Size; ++i) + for (int i = 0; i < size; ++i) values[i] = land.getLandData()->mTextures[i]; } diff --git a/apps/opencs/model/world/infoselectwrapper.cpp b/apps/opencs/model/world/infoselectwrapper.cpp index 1ce126e0ee..c22ae19d94 100644 --- a/apps/opencs/model/world/infoselectwrapper.cpp +++ b/apps/opencs/model/world/infoselectwrapper.cpp @@ -345,9 +345,9 @@ void CSMWorld::ConstInfoSelectWrapper::updateComparisonType() std::pair CSMWorld::ConstInfoSelectWrapper::getConditionIntRange() const { - const int IntMax = std::numeric_limits::max(); - const int IntMin = std::numeric_limits::min(); - const std::pair InvalidRange(IntMax, IntMin); + const int intMax = std::numeric_limits::max(); + const int intMin = std::numeric_limits::min(); + const std::pair invalidRange(intMax, intMin); int value = std::get(mConstSelect.mValue); @@ -358,31 +358,31 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getConditionIntRange() con return std::pair(value, value); case ESM::DialogueCondition::Comp_Gt: - if (value == IntMax) + if (value == intMax) { - return InvalidRange; + return invalidRange; } else { - return std::pair(value + 1, IntMax); + return std::pair(value + 1, intMax); } break; case ESM::DialogueCondition::Comp_Ge: - return std::pair(value, IntMax); + return std::pair(value, intMax); case ESM::DialogueCondition::Comp_Ls: - if (value == IntMin) + if (value == intMin) { - return InvalidRange; + return invalidRange; } else { - return std::pair(IntMin, value - 1); + return std::pair(intMin, value - 1); } case ESM::DialogueCondition::Comp_Le: - return std::pair(IntMin, value); + return std::pair(intMin, value); default: throw std::logic_error("InfoSelectWrapper: relation does not have a range"); @@ -391,9 +391,9 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getConditionIntRange() con std::pair CSMWorld::ConstInfoSelectWrapper::getConditionFloatRange() const { - const float FloatMax = std::numeric_limits::infinity(); - const float FloatMin = -std::numeric_limits::infinity(); - const float Epsilon = std::numeric_limits::epsilon(); + const float floatMax = std::numeric_limits::infinity(); + const float floatMin = -std::numeric_limits::infinity(); + const float epsilon = std::numeric_limits::epsilon(); float value = std::get(mConstSelect.mValue); @@ -404,16 +404,16 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getConditionFloatRange return std::pair(value, value); case ESM::DialogueCondition::Comp_Gt: - return std::pair(value + Epsilon, FloatMax); + return std::pair(value + epsilon, floatMax); case ESM::DialogueCondition::Comp_Ge: - return std::pair(value, FloatMax); + return std::pair(value, floatMax); case ESM::DialogueCondition::Comp_Ls: - return std::pair(FloatMin, value - Epsilon); + return std::pair(floatMin, value - epsilon); case ESM::DialogueCondition::Comp_Le: - return std::pair(FloatMin, value); + return std::pair(floatMin, value); default: throw std::logic_error("InfoSelectWrapper: given relation does not have a range"); @@ -422,8 +422,8 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getConditionFloatRange std::pair CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const { - const int IntMax = std::numeric_limits::max(); - const int IntMin = std::numeric_limits::min(); + const int intMax = std::numeric_limits::max(); + const int intMin = std::numeric_limits::min(); switch (getFunctionName()) { @@ -455,7 +455,7 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const case ESM::DialogueCondition::Function_Reputation: case ESM::DialogueCondition::Function_PcReputation: case ESM::DialogueCondition::Function_Journal: - return std::pair(IntMin, IntMax); + return std::pair(intMin, intMax); case ESM::DialogueCondition::Function_Item: case ESM::DialogueCondition::Function_Dead: @@ -500,7 +500,7 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const case ESM::DialogueCondition::Function_PcLuck: case ESM::DialogueCondition::Function_Level: case ESM::DialogueCondition::Function_PcWerewolfKills: - return std::pair(0, IntMax); + return std::pair(0, intMax); case ESM::DialogueCondition::Function_Fight: case ESM::DialogueCondition::Function_Hello: @@ -530,12 +530,12 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const case ESM::DialogueCondition::Function_Global: case ESM::DialogueCondition::Function_Local: case ESM::DialogueCondition::Function_NotLocal: - return std::pair(IntMin, IntMax); + return std::pair(intMin, intMax); case ESM::DialogueCondition::Function_PcMagicka: case ESM::DialogueCondition::Function_PcFatigue: case ESM::DialogueCondition::Function_PcHealth: - return std::pair(0, IntMax); + return std::pair(0, intMax); case ESM::DialogueCondition::Function_Health_Percent: case ESM::DialogueCondition::Function_PcHealthPercent: @@ -548,8 +548,8 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const std::pair CSMWorld::ConstInfoSelectWrapper::getValidFloatRange() const { - const float FloatMax = std::numeric_limits::infinity(); - const float FloatMin = -std::numeric_limits::infinity(); + const float floatMax = std::numeric_limits::infinity(); + const float floatMin = -std::numeric_limits::infinity(); switch (getFunctionName()) { @@ -557,12 +557,12 @@ std::pair CSMWorld::ConstInfoSelectWrapper::getValidFloatRange() c case ESM::DialogueCondition::Function_Global: case ESM::DialogueCondition::Function_Local: case ESM::DialogueCondition::Function_NotLocal: - return std::pair(FloatMin, FloatMax); + return std::pair(floatMin, floatMax); case ESM::DialogueCondition::Function_PcMagicka: case ESM::DialogueCondition::Function_PcFatigue: case ESM::DialogueCondition::Function_PcHealth: - return std::pair(0, FloatMax); + return std::pair(0, floatMax); case ESM::DialogueCondition::Function_Health_Percent: case ESM::DialogueCondition::Function_PcHealthPercent: diff --git a/apps/opencs/model/world/nestedcoladapterimp.cpp b/apps/opencs/model/world/nestedcoladapterimp.cpp index 26c52ce50a..181c7d80e8 100644 --- a/apps/opencs/model/world/nestedcoladapterimp.cpp +++ b/apps/opencs/model/world/nestedcoladapterimp.cpp @@ -1054,14 +1054,14 @@ namespace CSMWorld QVariant RegionWeatherAdapter::getData(const Record& record, int subRowIndex, int subColIndex) const { - const char* WeatherNames[] + const char* weatherNames[] = { "Clear", "Cloudy", "Fog", "Overcast", "Rain", "Thunder", "Ash", "Blight", "Snow", "Blizzard" }; const ESM::Region& region = record.get(); if (subColIndex == 0 && subRowIndex >= 0 && subRowIndex < 10) { - return WeatherNames[subRowIndex]; + return weatherNames[subRowIndex]; } else if (subColIndex == 1) { diff --git a/apps/opencs/model/world/scope.cpp b/apps/opencs/model/world/scope.cpp index 175074e49a..cf6c311b89 100644 --- a/apps/opencs/model/world/scope.cpp +++ b/apps/opencs/model/world/scope.cpp @@ -13,17 +13,17 @@ namespace CSMWorld { Scope operator()(ESM::StringRefId v) const { - std::string_view namespace_; + std::string_view namespaceValue; const std::string::size_type i = v.getValue().find("::"); if (i != std::string::npos) - namespace_ = std::string_view(v.getValue()).substr(0, i); + namespaceValue = std::string_view(v.getValue()).substr(0, i); - if (Misc::StringUtils::ciEqual(namespace_, "project")) + if (Misc::StringUtils::ciEqual(namespaceValue, "project")) return Scope_Project; - if (Misc::StringUtils::ciEqual(namespace_, "session")) + if (Misc::StringUtils::ciEqual(namespaceValue, "session")) return Scope_Session; return Scope_Content; diff --git a/apps/opencs/view/render/cameracontroller.cpp b/apps/opencs/view/render/cameracontroller.cpp index 10033cb51f..229bb6e74f 100644 --- a/apps/opencs/view/render/cameracontroller.cpp +++ b/apps/opencs/view/render/cameracontroller.cpp @@ -355,7 +355,7 @@ namespace CSVRender void FreeCameraController::pitch(double value) { - const double Constraint = osg::PI / 2 - 0.1; + const double constraint = osg::PI / 2 - 0.1; if (mLockUpright) { @@ -369,8 +369,8 @@ namespace CSVRender if ((mUp ^ up) * left < 0) pitchAngle *= -1; - if (std::abs(pitchAngle + value) > Constraint) - value = (pitchAngle > 0 ? 1 : -1) * Constraint - pitchAngle; + if (std::abs(pitchAngle + value) > constraint) + value = (pitchAngle > 0 ? 1 : -1) * constraint - pitchAngle; } getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalLeft); @@ -651,7 +651,7 @@ namespace CSVRender void OrbitCameraController::initialize() { - static const int DefaultStartDistance = 10000.f; + const int defaultStartDistance = 10000.f; // Try to intelligently pick focus object osg::ref_ptr intersector( @@ -665,7 +665,7 @@ namespace CSVRender getCamera()->accept(visitor); osg::Vec3d eye, center, up; - getCamera()->getViewMatrixAsLookAt(eye, center, up, DefaultStartDistance); + getCamera()->getViewMatrixAsLookAt(eye, center, up, defaultStartDistance); if (intersector->getIntersections().begin() != intersector->getIntersections().end()) { @@ -675,7 +675,7 @@ namespace CSVRender else { mCenter = center; - mDistance = DefaultStartDistance; + mDistance = defaultStartDistance; } mInitialized = true; diff --git a/apps/opencs/view/render/cellwater.cpp b/apps/opencs/view/render/cellwater.cpp index 5ad860b435..de38e4ab0f 100644 --- a/apps/opencs/view/render/cellwater.cpp +++ b/apps/opencs/view/render/cellwater.cpp @@ -138,13 +138,13 @@ namespace CSVRender void CellWater::recreate() { - const int InteriorScalar = 20; - const int SegmentsPerCell = 1; - const int TextureRepeatsPerCell = 6; + const int interiorScalar = 20; + const int segmentsPerCell = 1; + const int textureRepeatsPerCell = 6; - const float Alpha = 0.5f; + const float alpha = 0.5f; - const int RenderBin = osg::StateSet::TRANSPARENT_BIN - 1; + const int renderBin = osg::StateSet::TRANSPARENT_BIN - 1; if (mWaterGeometry) { @@ -162,18 +162,18 @@ namespace CSVRender if (mExterior) { size = CellSize; - segments = SegmentsPerCell; - textureRepeats = TextureRepeatsPerCell; + segments = segmentsPerCell; + textureRepeats = textureRepeatsPerCell; } else { - size = CellSize * InteriorScalar; - segments = SegmentsPerCell * InteriorScalar; - textureRepeats = TextureRepeatsPerCell * InteriorScalar; + size = CellSize * interiorScalar; + segments = segmentsPerCell * interiorScalar; + textureRepeats = textureRepeatsPerCell * interiorScalar; } mWaterGeometry = SceneUtil::createWaterGeometry(size, segments, textureRepeats); - mWaterGeometry->setStateSet(SceneUtil::createSimpleWaterStateSet(Alpha, RenderBin)); + mWaterGeometry->setStateSet(SceneUtil::createSimpleWaterStateSet(alpha, renderBin)); // Add water texture constexpr VFS::Path::NormalizedView prefix("textures/water"); diff --git a/apps/opencs/view/render/lighting.cpp b/apps/opencs/view/render/lighting.cpp index 94b3f02ea7..3c5bbb4fb0 100644 --- a/apps/opencs/view/render/lighting.cpp +++ b/apps/opencs/view/render/lighting.cpp @@ -27,9 +27,9 @@ public: void apply(osg::Switch& switchNode) override { - constexpr int NoIndex = -1; + constexpr int noIndex = -1; - int initialIndex = NoIndex; + int initialIndex = noIndex; if (!switchNode.getUserValue("initialIndex", initialIndex)) { for (size_t i = 0; i < switchNode.getValueList().size(); ++i) @@ -41,7 +41,7 @@ public: } } - if (initialIndex != NoIndex) + if (initialIndex != noIndex) switchNode.setUserValue("initialIndex", initialIndex); } @@ -50,7 +50,7 @@ public: if (switchNode.getName() == Constants::NightDayLabel) switchNode.setSingleChildOn(mIndex); } - else if (initialIndex != NoIndex) + else if (initialIndex != noIndex) { switchNode.setSingleChildOn(initialIndex); } diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 30eac77eb9..ec13c803f4 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -83,8 +83,8 @@ void CSVRender::Object::update() clear(); const CSMWorld::RefIdCollection& referenceables = mData.getReferenceables(); - const int TypeIndex = referenceables.findColumnIndex(CSMWorld::Columns::ColumnId_RecordType); - const int ModelIndex = referenceables.findColumnIndex(CSMWorld::Columns::ColumnId_Model); + const int typeIndex = referenceables.findColumnIndex(CSMWorld::Columns::ColumnId_RecordType); + const int modelIndex = referenceables.findColumnIndex(CSMWorld::Columns::ColumnId_Model); int index = referenceables.searchId(mReferenceableId); const ESM::Light* light = nullptr; @@ -99,8 +99,8 @@ void CSVRender::Object::update() /// \todo check for Deleted state (error 1) - int recordType = referenceables.getData(index, TypeIndex).toInt(); - std::string model = referenceables.getData(index, ModelIndex).toString().toUtf8().constData(); + int recordType = referenceables.getData(index, typeIndex).toInt(); + std::string model = referenceables.getData(index, modelIndex).toString().toUtf8().constData(); if (recordType == CSMWorld::UniversalId::Type_Light) { diff --git a/apps/opencs/view/render/pathgrid.cpp b/apps/opencs/view/render/pathgrid.cpp index 7f35956901..a8b2c81659 100644 --- a/apps/opencs/view/render/pathgrid.cpp +++ b/apps/opencs/view/render/pathgrid.cpp @@ -97,10 +97,10 @@ namespace CSVRender , mDragGeometry(nullptr) , mTag(new PathgridTag(this)) { - const float CoordScalar = ESM::Land::REAL_SIZE; + const float coordScalar = ESM::Land::REAL_SIZE; mBaseNode = new osg::PositionAttitudeTransform(); - mBaseNode->setPosition(osg::Vec3f(mCoords.getX() * CoordScalar, mCoords.getY() * CoordScalar, 0.f)); + mBaseNode->setPosition(osg::Vec3f(mCoords.getX() * coordScalar, mCoords.getY() * coordScalar, 0.f)); mBaseNode->setUserData(mTag); mBaseNode->setUpdateCallback(new PathgridNodeCallback()); mBaseNode->setNodeMask(Mask_Pathgrid); @@ -698,12 +698,12 @@ namespace CSVRender int Pathgrid::clampToCell(int v) { - const int CellExtent = ESM::Land::REAL_SIZE; + const int cellExtent = ESM::Land::REAL_SIZE; if (mInterior) return v; - else if (v > CellExtent) - return CellExtent; + else if (v > cellExtent) + return cellExtent; else if (v < 0) return 0; else diff --git a/apps/opencs/view/render/terraintexturemode.cpp b/apps/opencs/view/render/terraintexturemode.cpp index b3fd64705d..fede11f07c 100644 --- a/apps/opencs/view/render/terraintexturemode.cpp +++ b/apps/opencs/view/render/terraintexturemode.cpp @@ -318,10 +318,10 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe { } - std::pair cellCoordinates_pair = CSMWorld::CellCoordinates::fromId(mCellId); + std::pair cellCoordinatesPair = CSMWorld::CellCoordinates::fromId(mCellId); - int cellX = cellCoordinates_pair.first.getX(); - int cellY = cellCoordinates_pair.first.getY(); + int cellX = cellCoordinatesPair.first.getX(); + int cellY = cellCoordinatesPair.first.getY(); // The coordinates of hit in mCellId int xHitInCell(float(((hit.worldPos.x() - (cellX * cellSize)) * landTextureSize / cellSize) - 0.25)); @@ -380,11 +380,11 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe if (yHitInCell + (r % landTextureSize) > landTextureSize - 1) lowerrightCellY++; - for (int i_cell = upperLeftCellX; i_cell <= lowerrightCellX; i_cell++) + for (int iCell = upperLeftCellX; iCell <= lowerrightCellX; iCell++) { - for (int j_cell = upperLeftCellY; j_cell <= lowerrightCellY; j_cell++) + for (int jCell = upperLeftCellY; jCell <= lowerrightCellY; jCell++) { - iteratedCellId = CSMWorld::CellCoordinates::generateId(i_cell, j_cell); + iteratedCellId = CSMWorld::CellCoordinates::generateId(iCell, jCell); if (allowLandTextureEditing(iteratedCellId)) { CSMWorld::LandTexturesColumn::DataType newTerrain @@ -395,8 +395,7 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe for (int j = 0; j < landTextureSize; j++) { - if (i_cell == cellX && j_cell == cellY && abs(i - xHitInCell) < r - && abs(j - yHitInCell) < r) + if (iCell == cellX && jCell == cellY && abs(i - xHitInCell) < r && abs(j - yHitInCell) < r) { newTerrain[j * landTextureSize + i] = brushInt; } @@ -404,17 +403,17 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe { int distanceX(0); int distanceY(0); - if (i_cell < cellX) - distanceX = xHitInCell + landTextureSize * abs(i_cell - cellX) - i; - if (j_cell < cellY) - distanceY = yHitInCell + landTextureSize * abs(j_cell - cellY) - j; - if (i_cell > cellX) - distanceX = -xHitInCell + landTextureSize * abs(i_cell - cellX) + i; - if (j_cell > cellY) - distanceY = -yHitInCell + landTextureSize * abs(j_cell - cellY) + j; - if (i_cell == cellX) + if (iCell < cellX) + distanceX = xHitInCell + landTextureSize * abs(iCell - cellX) - i; + if (jCell < cellY) + distanceY = yHitInCell + landTextureSize * abs(jCell - cellY) - j; + if (iCell > cellX) + distanceX = -xHitInCell + landTextureSize * abs(iCell - cellX) + i; + if (jCell > cellY) + distanceY = -yHitInCell + landTextureSize * abs(jCell - cellY) + j; + if (iCell == cellX) distanceX = abs(i - xHitInCell); - if (j_cell == cellY) + if (jCell == cellY) distanceY = abs(j - yHitInCell); if (distanceX < r && distanceY < r) newTerrain[j * landTextureSize + i] = brushInt; @@ -443,11 +442,11 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe if (yHitInCell + (r % landTextureSize) > landTextureSize - 1) lowerrightCellY++; - for (int i_cell = upperLeftCellX; i_cell <= lowerrightCellX; i_cell++) + for (int iCell = upperLeftCellX; iCell <= lowerrightCellX; iCell++) { - for (int j_cell = upperLeftCellY; j_cell <= lowerrightCellY; j_cell++) + for (int jCell = upperLeftCellY; jCell <= lowerrightCellY; jCell++) { - iteratedCellId = CSMWorld::CellCoordinates::generateId(i_cell, j_cell); + iteratedCellId = CSMWorld::CellCoordinates::generateId(iCell, jCell); if (allowLandTextureEditing(iteratedCellId)) { CSMWorld::LandTexturesColumn::DataType newTerrain @@ -457,8 +456,7 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe { for (int j = 0; j < landTextureSize; j++) { - if (i_cell == cellX && j_cell == cellY && abs(i - xHitInCell) < r - && abs(j - yHitInCell) < r) + if (iCell == cellX && jCell == cellY && abs(i - xHitInCell) < r && abs(j - yHitInCell) < r) { int distanceX = abs(i - xHitInCell); int distanceY = abs(j - yHitInCell); @@ -471,17 +469,17 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe { int distanceX(0); int distanceY(0); - if (i_cell < cellX) - distanceX = xHitInCell + landTextureSize * abs(i_cell - cellX) - i; - if (j_cell < cellY) - distanceY = yHitInCell + landTextureSize * abs(j_cell - cellY) - j; - if (i_cell > cellX) - distanceX = -xHitInCell + landTextureSize * abs(i_cell - cellX) + i; - if (j_cell > cellY) - distanceY = -yHitInCell + landTextureSize * abs(j_cell - cellY) + j; - if (i_cell == cellX) + if (iCell < cellX) + distanceX = xHitInCell + landTextureSize * abs(iCell - cellX) - i; + if (jCell < cellY) + distanceY = yHitInCell + landTextureSize * abs(jCell - cellY) - j; + if (iCell > cellX) + distanceX = -xHitInCell + landTextureSize * abs(iCell - cellX) + i; + if (jCell > cellY) + distanceY = -yHitInCell + landTextureSize * abs(jCell - cellY) + j; + if (iCell == cellX) distanceX = abs(i - xHitInCell); - if (j_cell == cellY) + if (jCell == cellY) distanceY = abs(j - yHitInCell); float distance = std::round(sqrt(pow(distanceX, 2) + pow(distanceY, 2))); float rf = static_cast(mBrushSize) / 2; diff --git a/apps/opencs/view/render/worldspacewidget.cpp b/apps/opencs/view/render/worldspacewidget.cpp index 836f5ff0ea..32b8311725 100644 --- a/apps/opencs/view/render/worldspacewidget.cpp +++ b/apps/opencs/view/render/worldspacewidget.cpp @@ -270,9 +270,9 @@ CSVWidget::SceneToolRun* CSVRender::WorldspaceWidget::makeRunTool(CSVWidget::Sce { int state = debugProfiles.data(debugProfiles.index(i, stateColumn)).toInt(); - bool default_ = debugProfiles.data(debugProfiles.index(i, defaultColumn)).toInt(); + const bool defaultValue = debugProfiles.data(debugProfiles.index(i, defaultColumn)).toInt(); - if (state != CSMWorld::RecordBase::State_Deleted && default_) + if (state != CSMWorld::RecordBase::State_Deleted && defaultValue) profiles.emplace_back(debugProfiles.data(debugProfiles.index(i, idColumn)).toString().toUtf8().constData()); } diff --git a/apps/opencs/view/world/genericcreator.cpp b/apps/opencs/view/world/genericcreator.cpp index e4c084e46b..0e87ab727f 100644 --- a/apps/opencs/view/world/genericcreator.cpp +++ b/apps/opencs/view/world/genericcreator.cpp @@ -122,23 +122,23 @@ std::string CSVWorld::GenericCreator::getNamespace() const void CSVWorld::GenericCreator::updateNamespace() { - std::string namespace_ = getNamespace(); + std::string namespaceName = getNamespace(); - mValidator->setNamespace(namespace_); + mValidator->setNamespace(namespaceName); int index = mId->text().indexOf("::"); if (index == -1) { // no namespace in old text - mId->setText(QString::fromUtf8(namespace_.c_str()) + mId->text()); + mId->setText(QString::fromUtf8(namespaceName.c_str()) + mId->text()); } else { std::string oldNamespace = Misc::StringUtils::lowerCase(mId->text().left(index).toUtf8().constData()); if (oldNamespace == "project" || oldNamespace == "session") - mId->setText(QString::fromUtf8(namespace_.c_str()) + mId->text().mid(index + 2)); + mId->setText(QString::fromUtf8(namespaceName.c_str()) + mId->text().mid(index + 2)); } } diff --git a/apps/opencs/view/world/idvalidator.cpp b/apps/opencs/view/world/idvalidator.cpp index 078bd6bce5..776fa79a75 100644 --- a/apps/opencs/view/world/idvalidator.cpp +++ b/apps/opencs/view/world/idvalidator.cpp @@ -33,12 +33,12 @@ QValidator::State CSVWorld::IdValidator::validate(QString& input, int& pos) cons if (!mNamespace.empty()) { - std::string namespace_ = input.left(static_cast(mNamespace.size())).toUtf8().constData(); + const std::string namespaceName = input.left(static_cast(mNamespace.size())).toUtf8().constData(); - if (Misc::StringUtils::lowerCase(namespace_) != mNamespace) + if (Misc::StringUtils::lowerCase(namespaceName) != mNamespace) return QValidator::Invalid; // incorrect namespace - iter += namespace_.size(); + iter += namespaceName.size(); first = false; prevScope = true; } @@ -48,9 +48,9 @@ QValidator::State CSVWorld::IdValidator::validate(QString& input, int& pos) cons if (index != -1) { - QString namespace_ = input.left(index); + const QString namespaceName = input.left(index); - if (namespace_ == "project" || namespace_ == "session") + if (namespaceName == "project" || namespaceName == "session") return QValidator::Invalid; // reserved namespace } } @@ -102,9 +102,9 @@ QValidator::State CSVWorld::IdValidator::validate(QString& input, int& pos) cons return QValidator::Acceptable; } -void CSVWorld::IdValidator::setNamespace(const std::string& namespace_) +void CSVWorld::IdValidator::setNamespace(const std::string& value) { - mNamespace = Misc::StringUtils::lowerCase(namespace_); + mNamespace = Misc::StringUtils::lowerCase(value); } std::string CSVWorld::IdValidator::getError() const diff --git a/apps/opencs/view/world/idvalidator.hpp b/apps/opencs/view/world/idvalidator.hpp index 6b98d35672..ec3050d69c 100644 --- a/apps/opencs/view/world/idvalidator.hpp +++ b/apps/opencs/view/world/idvalidator.hpp @@ -19,7 +19,7 @@ namespace CSVWorld State validate(QString& input, int& pos) const override; - void setNamespace(const std::string& namespace_); + void setNamespace(const std::string& value); /// Return a description of the error that resulted in the last call of validate /// returning QValidator::Intermediate. If the last call to validate returned diff --git a/apps/opencs/view/world/landcreator.cpp b/apps/opencs/view/world/landcreator.cpp index 5ba2de603e..5f1d3ffa1d 100644 --- a/apps/opencs/view/world/landcreator.cpp +++ b/apps/opencs/view/world/landcreator.cpp @@ -22,22 +22,22 @@ namespace CSVWorld , mX(nullptr) , mY(nullptr) { - const int MaxInt = std::numeric_limits::max(); - const int MinInt = std::numeric_limits::min(); + const int maxInt = std::numeric_limits::max(); + const int minInt = std::numeric_limits::min(); setManualEditing(false); mXLabel = new QLabel("X: "); mX = new QSpinBox(); - mX->setMinimum(MinInt); - mX->setMaximum(MaxInt); + mX->setMinimum(minInt); + mX->setMaximum(maxInt); insertBeforeButtons(mXLabel, false); insertBeforeButtons(mX, true); mYLabel = new QLabel("Y: "); mY = new QSpinBox(); - mY->setMinimum(MinInt); - mY->setMaximum(MaxInt); + mY->setMinimum(minInt); + mY->setMaximum(maxInt); insertBeforeButtons(mYLabel, false); insertBeforeButtons(mY, true); diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 2a66878a04..2ebfdeb8ae 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -493,12 +493,13 @@ void OMW::Engine::createWindow() const SDLUtil::VSyncMode vsync = Settings::video().mVsyncMode; unsigned antialiasing = static_cast(Settings::video().mAntialiasing); - int pos_x = SDL_WINDOWPOS_CENTERED_DISPLAY(screen), pos_y = SDL_WINDOWPOS_CENTERED_DISPLAY(screen); + int posX = SDL_WINDOWPOS_CENTERED_DISPLAY(screen); + int posY = SDL_WINDOWPOS_CENTERED_DISPLAY(screen); if (windowMode == Settings::WindowMode::Fullscreen || windowMode == Settings::WindowMode::WindowedFullscreen) { - pos_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); - pos_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); + posX = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); + posY = SDL_WINDOWPOS_UNDEFINED_DISPLAY(screen); } Uint32 flags = SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI; @@ -535,7 +536,7 @@ void OMW::Engine::createWindow() { while (!mWindow) { - mWindow = SDL_CreateWindow("OpenMW", pos_x, pos_y, width, height, flags); + mWindow = SDL_CreateWindow("OpenMW", posX, posY, width, height, flags); if (!mWindow) { // Try with a lower AA @@ -961,14 +962,14 @@ void OMW::Engine::go() prepareEngine(); #ifdef _WIN32 - const auto* stats_file = _wgetenv(L"OPENMW_OSG_STATS_FILE"); + const auto* statsFile = _wgetenv(L"OPENMW_OSG_STATS_FILE"); #else - const auto* stats_file = std::getenv("OPENMW_OSG_STATS_FILE"); + const auto* statsFile = std::getenv("OPENMW_OSG_STATS_FILE"); #endif std::filesystem::path path; - if (stats_file != nullptr) - path = stats_file; + if (statsFile != nullptr) + path = statsFile; std::ofstream stats; if (!path.empty()) diff --git a/apps/openmw/mwbase/mechanicsmanager.hpp b/apps/openmw/mwbase/mechanicsmanager.hpp index 551d86a041..f56f68b780 100644 --- a/apps/openmw/mwbase/mechanicsmanager.hpp +++ b/apps/openmw/mwbase/mechanicsmanager.hpp @@ -81,7 +81,7 @@ namespace MWBase virtual void setPlayerClass(const ESM::RefId& id) = 0; ///< Set player class to stock class. - virtual void setPlayerClass(const ESM::Class& class_) = 0; + virtual void setPlayerClass(const ESM::Class& value) = 0; ///< Set player class to custom class. virtual void restoreDynamicStats(const MWWorld::Ptr& actor, double hours, bool sleep) = 0; diff --git a/apps/openmw/mwclass/armor.cpp b/apps/openmw/mwclass/armor.cpp index 37b0b85d45..b45e0b25b9 100644 --- a/apps/openmw/mwclass/armor.cpp +++ b/apps/openmw/mwclass/armor.cpp @@ -85,7 +85,7 @@ namespace MWClass { const MWWorld::LiveCellRef* ref = ptr.get(); - std::vector slots_; + std::vector slots; const int size = 11; @@ -104,11 +104,11 @@ namespace MWClass for (int i = 0; i < size; ++i) if (sMapping[i][0] == ref->mBase->mData.mType) { - slots_.push_back(int(sMapping[i][1])); + slots.push_back(int(sMapping[i][1])); break; } - return std::make_pair(slots_, false); + return std::make_pair(slots, false); } ESM::RefId Armor::getEquipmentSkill(const MWWorld::ConstPtr& ptr, bool useLuaInterfaceIfAvailable) const @@ -352,9 +352,9 @@ namespace MWClass return { 0, "#{sInventoryMessage1}" }; // slots that this item can be equipped in - std::pair, bool> slots_ = getEquipmentSlots(ptr); + std::pair, bool> slots = getEquipmentSlots(ptr); - if (slots_.first.empty()) + if (slots.first.empty()) return { 0, {} }; if (npc.getClass().isNpc()) @@ -377,7 +377,7 @@ namespace MWClass } } - for (std::vector::const_iterator slot = slots_.first.begin(); slot != slots_.first.end(); ++slot) + for (std::vector::const_iterator slot = slots.first.begin(); slot != slots.first.end(); ++slot) { // If equipping a shield, check if there's a twohanded weapon conflicting with it if (*slot == MWWorld::InventoryStore::Slot_CarriedLeft) diff --git a/apps/openmw/mwclass/clothing.cpp b/apps/openmw/mwclass/clothing.cpp index e303635309..32f00b4110 100644 --- a/apps/openmw/mwclass/clothing.cpp +++ b/apps/openmw/mwclass/clothing.cpp @@ -66,12 +66,12 @@ namespace MWClass { const MWWorld::LiveCellRef* ref = ptr.get(); - std::vector slots_; + std::vector slots; if (ref->mBase->mData.mType == ESM::Clothing::Ring) { - slots_.push_back(int(MWWorld::InventoryStore::Slot_LeftRing)); - slots_.push_back(int(MWWorld::InventoryStore::Slot_RightRing)); + slots.push_back(int(MWWorld::InventoryStore::Slot_LeftRing)); + slots.push_back(int(MWWorld::InventoryStore::Slot_RightRing)); } else { @@ -90,12 +90,12 @@ namespace MWClass for (int i = 0; i < size; ++i) if (sMapping[i][0] == ref->mBase->mData.mType) { - slots_.push_back(int(sMapping[i][1])); + slots.push_back(int(sMapping[i][1])); break; } } - return std::make_pair(slots_, false); + return std::make_pair(slots, false); } ESM::RefId Clothing::getEquipmentSkill(const MWWorld::ConstPtr& ptr, bool useLuaInterfaceIfAvailable) const @@ -200,9 +200,9 @@ namespace MWClass const MWWorld::ConstPtr& ptr, const MWWorld::Ptr& npc) const { // slots that this item can be equipped in - std::pair, bool> slots_ = getEquipmentSlots(ptr); + std::pair, bool> slots = getEquipmentSlots(ptr); - if (slots_.first.empty()) + if (slots.first.empty()) return { 0, {} }; if (npc.getClass().isNpc()) diff --git a/apps/openmw/mwclass/light.cpp b/apps/openmw/mwclass/light.cpp index 9aa5e2c67d..11867daa4d 100644 --- a/apps/openmw/mwclass/light.cpp +++ b/apps/openmw/mwclass/light.cpp @@ -113,12 +113,12 @@ namespace MWClass { const MWWorld::LiveCellRef* ref = ptr.get(); - std::vector slots_; + std::vector slots; if (ref->mBase->mData.mFlags & ESM::Light::Carry) - slots_.push_back(int(MWWorld::InventoryStore::Slot_CarriedLeft)); + slots.push_back(int(MWWorld::InventoryStore::Slot_CarriedLeft)); - return std::make_pair(slots_, false); + return std::make_pair(slots, false); } int Light::getValue(const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/lockpick.cpp b/apps/openmw/mwclass/lockpick.cpp index 7955d5af20..1c78b3dfef 100644 --- a/apps/openmw/mwclass/lockpick.cpp +++ b/apps/openmw/mwclass/lockpick.cpp @@ -63,11 +63,11 @@ namespace MWClass std::pair, bool> Lockpick::getEquipmentSlots(const MWWorld::ConstPtr& ptr) const { - std::vector slots_; + std::vector slots; - slots_.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight)); + slots.push_back(static_cast(MWWorld::InventoryStore::Slot_CarriedRight)); - return std::make_pair(slots_, false); + return std::make_pair(slots, false); } int Lockpick::getValue(const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/npc.cpp b/apps/openmw/mwclass/npc.cpp index da0e78bcd3..f56ce35b26 100644 --- a/apps/openmw/mwclass/npc.cpp +++ b/apps/openmw/mwclass/npc.cpp @@ -87,9 +87,9 @@ namespace int is_even(double d) { - double int_part; - modf(d / 2.0, &int_part); - return 2.0 * int_part == d; + double intPart; + modf(d / 2.0, &intPart); + return 2.0 * intPart == d; } int round_ieee_754(double d) @@ -118,9 +118,9 @@ namespace creatureStats.setAttribute(attribute.mId, race->mData.getAttribute(attribute.mId, male)); // class bonus - const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); + const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); - for (int attribute : class_->mData.mAttribute) + for (int attribute : npcClass->mData.mAttribute) { if (attribute >= 0 && attribute < ESM::Attribute::Length) { @@ -143,7 +143,7 @@ namespace // is this a minor or major skill? float add = 0.2f; int index = ESM::Skill::refIdToIndex(skill.mId); - for (const auto& skills : class_->mData.mSkills) + for (const auto& skills : npcClass->mData.mSkills) { if (skills[0] == index) add = 0.5; @@ -164,14 +164,14 @@ namespace int multiplier = 3; - if (class_->mData.mSpecialization == ESM::Class::Combat) + if (npcClass->mData.mSpecialization == ESM::Class::Combat) multiplier += 2; - else if (class_->mData.mSpecialization == ESM::Class::Stealth) + else if (npcClass->mData.mSpecialization == ESM::Class::Stealth) multiplier += 1; - if (std::find(class_->mData.mAttribute.begin(), class_->mData.mAttribute.end(), + if (std::find(npcClass->mData.mAttribute.begin(), npcClass->mData.mAttribute.end(), ESM::Attribute::refIdToIndex(ESM::Attribute::Endurance)) - != class_->mData.mAttribute.end()) + != npcClass->mData.mAttribute.end()) multiplier += 1; creatureStats.setHealth(floor(0.5f * (strength + endurance)) + multiplier * (creatureStats.getLevel() - 1)); @@ -194,7 +194,7 @@ namespace void autoCalculateSkills( const ESM::NPC* npc, MWMechanics::NpcStats& npcStats, const MWWorld::Ptr& ptr, bool spellsInitialised) { - const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); + const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); unsigned int level = npcStats.getLevel(); @@ -204,7 +204,7 @@ namespace { int bonus = (i == 0) ? 10 : 25; - for (const auto& skills : class_->mData.mSkills) + for (const auto& skills : npcClass->mData.mSkills) { ESM::RefId id = ESM::Skill::indexToRefId(skills[i]); if (!id.empty()) @@ -228,7 +228,7 @@ namespace if (bonusIt != race->mData.mBonus.end()) raceBonus = bonusIt->mBonus; - for (const auto& skills : class_->mData.mSkills) + for (const auto& skills : npcClass->mData.mSkills) { // is this a minor or major skill? if (std::find(skills.begin(), skills.end(), index) != skills.end()) @@ -239,7 +239,7 @@ namespace } // is this skill in the same Specialization as the class? - if (skill.mData.mSpecialization == class_->mData.mSpecialization) + if (skill.mData.mSpecialization == npcClass->mData.mSpecialization) { specMultiplier = 0.5f; specBonus = 5; @@ -1166,8 +1166,8 @@ namespace MWClass const ESM::NPC* npc = actor.get()->mBase; if (npc->mFlags & ESM::NPC::Autocalc) { - const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); - return class_->mData.mServices; + const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); + return npcClass->mData.mServices; } return npc->mAiData.mServices; } diff --git a/apps/openmw/mwclass/probe.cpp b/apps/openmw/mwclass/probe.cpp index 4039f72cc5..110614bffd 100644 --- a/apps/openmw/mwclass/probe.cpp +++ b/apps/openmw/mwclass/probe.cpp @@ -62,11 +62,11 @@ namespace MWClass std::pair, bool> Probe::getEquipmentSlots(const MWWorld::ConstPtr& ptr) const { - std::vector slots_; + std::vector slots; - slots_.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight)); + slots.push_back(static_cast(MWWorld::InventoryStore::Slot_CarriedRight)); - return std::make_pair(slots_, false); + return std::make_pair(slots, false); } int Probe::getValue(const MWWorld::ConstPtr& ptr) const diff --git a/apps/openmw/mwclass/weapon.cpp b/apps/openmw/mwclass/weapon.cpp index bee68a52e5..863083ee94 100644 --- a/apps/openmw/mwclass/weapon.cpp +++ b/apps/openmw/mwclass/weapon.cpp @@ -86,23 +86,23 @@ namespace MWClass const MWWorld::LiveCellRef* ref = ptr.get(); ESM::WeaponType::Class weapClass = MWMechanics::getWeaponType(ref->mBase->mData.mType)->mWeaponClass; - std::vector slots_; + std::vector slots; bool stack = false; if (weapClass == ESM::WeaponType::Ammo) { - slots_.push_back(int(MWWorld::InventoryStore::Slot_Ammunition)); + slots.push_back(int(MWWorld::InventoryStore::Slot_Ammunition)); stack = true; } else if (weapClass == ESM::WeaponType::Thrown) { - slots_.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight)); + slots.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight)); stack = true; } else - slots_.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight)); + slots.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight)); - return std::make_pair(slots_, stack); + return std::make_pair(slots, stack); } ESM::RefId Weapon::getEquipmentSkill(const MWWorld::ConstPtr& ptr, bool useLuaInterfaceIfAvailable) const @@ -278,9 +278,9 @@ namespace MWClass if (hasItemHealth(ptr) && getItemHealth(ptr) == 0) return { 0, "#{sInventoryMessage1}" }; - std::pair, bool> slots_ = getEquipmentSlots(ptr); + std::pair, bool> slots = getEquipmentSlots(ptr); - if (slots_.first.empty()) + if (slots.first.empty()) return { 0, {} }; int type = ptr.get()->mBase->mData.mType; diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index ab92300804..dc3887435e 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -96,8 +96,8 @@ namespace MWDialogue if (tok->isExplicitLink()) { // calculation of standard form for all hyperlinks - size_t asterisk_count = HyperTextParser::removePseudoAsterisks(topicId); - for (; asterisk_count > 0; --asterisk_count) + size_t asteriskCount = HyperTextParser::removePseudoAsterisks(topicId); + for (; asteriskCount > 0; --asteriskCount) topicId.append("*"); topicId = mTranslationDataStorage.topicStandardForm(topicId); diff --git a/apps/openmw/mwdialogue/hypertextparser.cpp b/apps/openmw/mwdialogue/hypertextparser.cpp index de82aff7aa..60bfbca46a 100644 --- a/apps/openmw/mwdialogue/hypertextparser.cpp +++ b/apps/openmw/mwdialogue/hypertextparser.cpp @@ -16,27 +16,28 @@ namespace MWDialogue std::vector parseHyperText(const std::string& text) { std::vector result; - size_t pos_end = std::string::npos, iteration_pos = 0; + size_t posEnd = std::string::npos; + size_t iterationPos = 0; for (;;) { - size_t pos_begin = text.find('@', iteration_pos); - if (pos_begin != std::string::npos) - pos_end = text.find('#', pos_begin); + const size_t posBegin = text.find('@', iterationPos); + if (posBegin != std::string::npos) + posEnd = text.find('#', posBegin); - if (pos_begin != std::string::npos && pos_end != std::string::npos) + if (posBegin != std::string::npos && posEnd != std::string::npos) { - if (pos_begin != iteration_pos) - tokenizeKeywords(text.substr(iteration_pos, pos_begin - iteration_pos), result); + if (posBegin != iterationPos) + tokenizeKeywords(text.substr(iterationPos, posBegin - iterationPos), result); - std::string link = text.substr(pos_begin + 1, pos_end - pos_begin - 1); + std::string link = text.substr(posBegin + 1, posEnd - posBegin - 1); result.emplace_back(link, Token::ExplicitLink); - iteration_pos = pos_end + 1; + iterationPos = posEnd + 1; } else { - if (iteration_pos != text.size()) - tokenizeKeywords(text.substr(iteration_pos), result); + if (iterationPos != text.size()) + tokenizeKeywords(text.substr(iterationPos), result); break; } } diff --git a/apps/openmw/mwgui/bookpage.cpp b/apps/openmw/mwgui/bookpage.cpp index ef296534c4..24133dd34e 100644 --- a/apps/openmw/mwgui/bookpage.cpp +++ b/apps/openmw/mwgui/bookpage.cpp @@ -313,16 +313,16 @@ namespace MWGui Style* createHotStyle(Style* baseStyle, const Colour& normalColour, const Colour& hoverColour, const Colour& activeColour, InteractiveId id, bool unique) override { - StyleImpl* BaseStyle = static_cast(baseStyle); + StyleImpl* const baseStyleImpl = static_cast(baseStyle); if (!unique) for (Styles::iterator i = mBook->mStyles.begin(); i != mBook->mStyles.end(); ++i) - if (i->match(BaseStyle->mFont, hoverColour, activeColour, normalColour, id)) + if (i->match(baseStyleImpl->mFont, hoverColour, activeColour, normalColour, id)) return &*i; StyleImpl& style = *mBook->mStyles.insert(mBook->mStyles.end(), StyleImpl()); - style.mFont = BaseStyle->mFont; + style.mFont = baseStyleImpl->mFont; style.mHotColour = hoverColour; style.mActiveColour = activeColour; style.mNormalColour = normalColour; @@ -363,10 +363,10 @@ namespace MWGui assert(end <= mCurrentContent->size()); assert(begin <= mCurrentContent->size()); - Utf8Point begin_ = mCurrentContent->data() + begin; - Utf8Point end_ = mCurrentContent->data() + end; + const Utf8Point contentBegin = mCurrentContent->data() + begin; + const Utf8Point contentEnd = mCurrentContent->data() + end; - writeImpl(static_cast(style), begin_, end_); + writeImpl(static_cast(style), contentBegin, contentEnd); } void lineBreak(float margin) override @@ -524,8 +524,8 @@ namespace MWGui if (ucsBreakingSpace(stream.peek()) && !mPartialWord.empty()) add_partial_text(); - int word_width = 0; - int space_width = 0; + int wordWidth = 0; + int spaceWidth = 0; Utf8Stream::Point lead = stream.current(); @@ -533,7 +533,7 @@ namespace MWGui { MWGui::GlyphInfo info = GlyphInfo(style->mFont, stream.peek()); if (info.charFound) - space_width += static_cast(info.advance + info.bearingX); + spaceWidth += static_cast(info.advance + info.bearingX); stream.consume(); } @@ -543,7 +543,7 @@ namespace MWGui { MWGui::GlyphInfo info = GlyphInfo(style->mFont, stream.peek()); if (info.charFound) - word_width += static_cast(info.advance + info.bearingX); + wordWidth += static_cast(info.advance + info.bearingX); stream.consume(); } @@ -553,9 +553,9 @@ namespace MWGui break; if (lead != origin) - mPartialWhitespace.emplace_back(style, lead, origin, space_width); + mPartialWhitespace.emplace_back(style, lead, origin, spaceWidth); if (origin != extent) - mPartialWord.emplace_back(style, origin, extent, word_width); + mPartialWord.emplace_back(style, origin, extent, wordWidth); } } @@ -565,17 +565,17 @@ namespace MWGui return; const int fontHeight = Settings::gui().mFontSize; - int space_width = 0; - int word_width = 0; + int spaceWidth = 0; + int wordWidth = 0; for (PartialTextConstIterator i = mPartialWhitespace.begin(); i != mPartialWhitespace.end(); ++i) - space_width += i->mWidth; + spaceWidth += i->mWidth; for (PartialTextConstIterator i = mPartialWord.begin(); i != mPartialWord.end(); ++i) - word_width += i->mWidth; + wordWidth += i->mWidth; int left = mLine ? mLine->mRect.right : 0; - if (left + space_width + word_width > mPageWidth) + if (left + spaceWidth + wordWidth > mPageWidth) { mLine = nullptr; mRun = nullptr; @@ -964,9 +964,9 @@ namespace MWGui { if (mFocusItem != nullptr) { - MyGUI::IFont* Font = mBook->affectedFont(mFocusItem); + MyGUI::IFont* const font = mBook->affectedFont(mFocusItem); - ActiveTextFormats::iterator i = mActiveTextFormats.find(Font); + ActiveTextFormats::iterator i = mActiveTextFormats.find(font); if (mNode && i != mActiveTextFormats.end()) mNode->outOfDate(i->second->mRenderItem); @@ -1131,17 +1131,17 @@ namespace MWGui void operator()(Section const& section, Line const& line, Run const& run) const { - MyGUI::IFont* Font = run.mStyle->mFont; + MyGUI::IFont* const font = run.mStyle->mFont; - ActiveTextFormats::iterator j = this_->mActiveTextFormats.find(Font); + ActiveTextFormats::iterator j = this_->mActiveTextFormats.find(font); if (j == this_->mActiveTextFormats.end()) { - auto textFormat = std::make_unique(Font, this_); + auto textFormat = std::make_unique(font, this_); - textFormat->mTexture = Font->getTextureFont(); + textFormat->mTexture = font->getTextureFont(); - j = this_->mActiveTextFormats.insert(std::make_pair(Font, std::move(textFormat))).first; + j = this_->mActiveTextFormats.insert(std::make_pair(font, std::move(textFormat))).first; } j->second->mCountVertex += run.mPrintableChars * 6; @@ -1213,15 +1213,15 @@ namespace MWGui while (!stream.eof()) { - Utf8Stream::UnicodeChar code_point = stream.consume(); + const Utf8Stream::UnicodeChar codePoint = stream.consume(); - if (ucsCarriageReturn(code_point)) + if (ucsCarriageReturn(codePoint)) continue; - if (!ucsSpace(code_point)) - glyphStream.emitGlyph(code_point); + if (!ucsSpace(codePoint)) + glyphStream.emitGlyph(codePoint); else - glyphStream.emitSpace(code_point); + glyphStream.emitSpace(codePoint); } } }; @@ -1243,10 +1243,10 @@ namespace MWGui GlyphStream glyphStream(textFormat.mFont, static_cast(mCoord.left), static_cast(mCoord.top - mViewTop), z /*mNode->getNodeDepth()*/, vertices, renderXform); - int visit_top = (std::max)(mViewTop, mViewTop + int(renderXform.clipTop)); - int visit_bottom = (std::min)(mViewBottom, mViewTop + int(renderXform.clipBottom)); + const int visitTop = std::max(mViewTop, mViewTop + static_cast(renderXform.clipTop)); + const int visitBottom = std::min(mViewBottom, mViewTop + static_cast(renderXform.clipBottom)); - mBook->visitRuns(visit_top, visit_bottom, textFormat.mFont, RenderRun(this, glyphStream)); + mBook->visitRuns(visitTop, visitBottom, textFormat.mFont, RenderRun(this, glyphStream)); textFormat.mRenderItem->setLastVertexCount(glyphStream.end() - vertices); } diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index a94736baee..a4463a1133 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -634,7 +634,7 @@ namespace MWGui { std::string output = input; std::string tmp = input; - bool has_front_quote = false; + bool hasFrontQuote = false; /* Does the input string contain things that don't have to be completed? If yes erase them. */ @@ -659,7 +659,7 @@ namespace MWGui if (numquotes % 2) { tmp.erase(0, tmp.rfind('"') + 1); - has_front_quote = true; + hasFrontQuote = true; } else { @@ -672,7 +672,7 @@ namespace MWGui { tmp.clear(); } - has_front_quote = false; + hasFrontQuote = false; } } /* No quotation marks. Are there spaces?*/ @@ -706,7 +706,7 @@ namespace MWGui /* Iterate through the vector. */ for (std::string& name : mNames) { - bool string_different = false; + bool stringDifferent = false; /* Is the string shorter than the input string? If yes skip it. */ if (name.length() < tmp.length()) @@ -717,12 +717,12 @@ namespace MWGui { if (Misc::StringUtils::toLower(*iter) != Misc::StringUtils::toLower(*iter2)) { - string_different = true; + stringDifferent = true; break; } } - if (string_different) + if (stringDifferent) continue; /* The beginning of the string matches the input string, save it for the next test. */ @@ -741,11 +741,11 @@ namespace MWGui /* Adding quotation marks when the input string started with a quotation mark or has spaces in it*/ if ((matches.front().find(' ') != std::string::npos)) { - if (!has_front_quote) + if (!hasFrontQuote) output += '"'; return output.append(matches.front() + std::string("\" ")); } - else if (has_front_quote) + else if (hasFrontQuote) { return output.append(matches.front() + std::string("\" ")); } diff --git a/apps/openmw/mwgui/dialogue.cpp b/apps/openmw/mwgui/dialogue.cpp index ec7d726570..48f7d18ff8 100644 --- a/apps/openmw/mwgui/dialogue.cpp +++ b/apps/openmw/mwgui/dialogue.cpp @@ -228,16 +228,16 @@ namespace MWGui // We need this copy for when @# hyperlinks are replaced std::string text = mText; - size_t pos_end = std::string::npos; + size_t posEnd = std::string::npos; for (;;) { - size_t pos_begin = text.find('@'); - if (pos_begin != std::string::npos) - pos_end = text.find('#', pos_begin); + const size_t posBegin = text.find('@'); + if (posBegin != std::string::npos) + posEnd = text.find('#', posBegin); - if (pos_begin != std::string::npos && pos_end != std::string::npos) + if (posBegin != std::string::npos && posEnd != std::string::npos) { - std::string link = text.substr(pos_begin + 1, pos_end - pos_begin - 1); + std::string link = text.substr(posBegin + 1, posEnd - posBegin - 1); const char specialPseudoAsteriskCharacter = 127; std::replace(link.begin(), link.end(), specialPseudoAsteriskCharacter, '*'); std::string topicName @@ -247,10 +247,10 @@ namespace MWGui while (displayName[displayName.size() - 1] == '*') displayName.erase(displayName.size() - 1, 1); - text.replace(pos_begin, pos_end + 1 - pos_begin, displayName); + text.replace(posBegin, posEnd + 1 - posBegin, displayName); if (topicLinks.find(topicName) != topicLinks.end()) - hyperLinks[std::make_pair(pos_begin, pos_begin + displayName.size())] + hyperLinks[std::make_pair(posBegin, posBegin + displayName.size())] = intptr_t(topicLinks[topicName].get()); } else diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index 97dbe64e76..4a621831f4 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -731,8 +731,8 @@ namespace MWGui MWWorld::Ptr InventoryWindow::getAvatarSelectedItem(int x, int y) { - const osg::Vec2f viewport_coords = mapPreviewWindowToViewport(x, y); - int slot = mPreview->getSlotSelected(viewport_coords.x(), viewport_coords.y()); + const osg::Vec2f viewportCoords = mapPreviewWindowToViewport(x, y); + int slot = mPreview->getSlotSelected(viewportCoords.x(), viewportCoords.y()); if (slot == -1) return MWWorld::Ptr(); diff --git a/apps/openmw/mwgui/journalviewmodel.cpp b/apps/openmw/mwgui/journalviewmodel.cpp index 46f77f6dc4..2bb93cf0db 100644 --- a/apps/openmw/mwgui/journalviewmodel.cpp +++ b/apps/openmw/mwgui/journalviewmodel.cpp @@ -105,16 +105,16 @@ namespace MWGui utf8text = getText(); - size_t pos_end = 0; + size_t posEnd = 0; for (;;) { - size_t pos_begin = utf8text.find('@'); - if (pos_begin != std::string::npos) - pos_end = utf8text.find('#', pos_begin); + const size_t posBegin = utf8text.find('@'); + if (posBegin != std::string::npos) + posEnd = utf8text.find('#', posBegin); - if (pos_begin != std::string::npos && pos_end != std::string::npos) + if (posBegin != std::string::npos && posEnd != std::string::npos) { - std::string link = utf8text.substr(pos_begin + 1, pos_end - pos_begin - 1); + std::string link = utf8text.substr(posBegin + 1, posEnd - posBegin - 1); const char specialPseudoAsteriskCharacter = 127; std::replace(link.begin(), link.end(), specialPseudoAsteriskCharacter, '*'); std::string_view topicName = MWBase::Environment::get() @@ -126,11 +126,11 @@ namespace MWGui while (displayName[displayName.size() - 1] == '*') displayName.erase(displayName.size() - 1, 1); - utf8text.replace(pos_begin, pos_end + 1 - pos_begin, displayName); + utf8text.replace(posBegin, posEnd + 1 - posBegin, displayName); intptr_t value = 0; if (mModel->mKeywordSearch.containsKeyword(topicName, value)) - mHyperLinks[std::make_pair(pos_begin, pos_begin + displayName.size())] = value; + mHyperLinks[std::make_pair(posBegin, posBegin + displayName.size())] = value; } else break; diff --git a/apps/openmw/mwgui/layout.cpp b/apps/openmw/mwgui/layout.cpp index 8d70bc956b..c1d2e474c2 100644 --- a/apps/openmw/mwgui/layout.cpp +++ b/apps/openmw/mwgui/layout.cpp @@ -11,23 +11,23 @@ namespace MWGui { void Layout::initialise(std::string_view _layout) { - const auto MAIN_WINDOW = "_Main"; + constexpr char mainWindow[] = "_Main"; mLayoutName = _layout; mPrefix = MyGUI::utility::toString(this, "_"); mListWindowRoot = MyGUI::LayoutManager::getInstance().loadLayout(mLayoutName, mPrefix); - const std::string main_name = mPrefix + MAIN_WINDOW; + const std::string mainName = mPrefix + mainWindow; for (MyGUI::Widget* widget : mListWindowRoot) { - if (widget->getName() == main_name) + if (widget->getName() == mainName) mMainWidget = widget; // Force the alignment to update immediately widget->_setAlign(widget->getSize(), widget->getParentSize()); } MYGUI_ASSERT( - mMainWidget, "root widget name '" << MAIN_WINDOW << "' in layout '" << mLayoutName << "' not found."); + mMainWidget, "root widget name '" << mainWindow << "' in layout '" << mLayoutName << "' not found."); } void Layout::shutdown() diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index 8322ae9073..cae195e9aa 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -59,11 +59,10 @@ namespace MWGui void LoadingScreen::findSplashScreens() { auto isSupportedExtension = [](const std::string_view& ext) { - static const std::array supported_extensions{ { "tga", "dds", "ktx", "png", "bmp", "jpeg", + static const std::array supportedExtensions{ { "tga", "dds", "ktx", "png", "bmp", "jpeg", "jpg" } }; return !ext.empty() - && std::find(supported_extensions.begin(), supported_extensions.end(), ext) - != supported_extensions.end(); + && std::find(supportedExtensions.begin(), supportedExtensions.end(), ext) != supportedExtensions.end(); }; constexpr VFS::Path::NormalizedView splash("splash/"); diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 5543caf09f..90a690242f 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -1100,13 +1100,13 @@ namespace MWGui MapMarkerType mapMarkerWidget = { osg::Vec2f(x, y), createMarker(name, x, y, 0) }; mGlobalMapMarkers.emplace(mapMarkerWidget, std::vector()); - std::string name_ = name.substr(0, name.find(',')); - auto& entry = mGlobalMapMarkersByName[name_]; + const std::string markerName = name.substr(0, name.find(',')); + auto& entry = mGlobalMapMarkersByName[markerName]; if (!entry.widget) { entry = { osg::Vec2f(x, y), entry.widget }; // update the coords - entry.widget = createMarker(name_, entry.position.x(), entry.position.y(), 1); + entry.widget = createMarker(markerName, entry.position.x(), entry.position.y(), 1); mGlobalMapMarkers.emplace(entry, std::vector{ entry }); } else diff --git a/apps/openmw/mwgui/postprocessorhud.cpp b/apps/openmw/mwgui/postprocessorhud.cpp index 4513bea9da..eaa42162af 100644 --- a/apps/openmw/mwgui/postprocessorhud.cpp +++ b/apps/openmw/mwgui/postprocessorhud.cpp @@ -323,21 +323,21 @@ namespace MWGui std::ostringstream ss; - const std::string_view NA = "#{Interface:NotAvailableShort}"; + const std::string_view notAvailable = "#{Interface:NotAvailableShort}"; const char endl = '\n'; - std::string_view author = technique->getAuthor().empty() ? NA : technique->getAuthor(); - std::string_view version = technique->getVersion().empty() ? NA : technique->getVersion(); - std::string_view description = technique->getDescription().empty() ? NA : technique->getDescription(); + std::string_view author = technique->getAuthor().empty() ? notAvailable : technique->getAuthor(); + std::string_view version = technique->getVersion().empty() ? notAvailable : technique->getVersion(); + std::string_view description = technique->getDescription().empty() ? notAvailable : technique->getDescription(); auto serializeBool = [](bool value) { return value ? "#{Interface:Yes}" : "#{Interface:No}"; }; const auto flags = technique->getFlags(); - const auto flag_interior = serializeBool(!(flags & Fx::Technique::Flag_Disable_Interiors)); - const auto flag_exterior = serializeBool(!(flags & Fx::Technique::Flag_Disable_Exteriors)); - const auto flag_underwater = serializeBool(!(flags & Fx::Technique::Flag_Disable_Underwater)); - const auto flag_abovewater = serializeBool(!(flags & Fx::Technique::Flag_Disable_Abovewater)); + const auto flagInterior = serializeBool(!(flags & Fx::Technique::Flag_Disable_Interiors)); + const auto flagExterior = serializeBool(!(flags & Fx::Technique::Flag_Disable_Exteriors)); + const auto flagUnderwater = serializeBool(!(flags & Fx::Technique::Flag_Disable_Underwater)); + const auto flagAbovewater = serializeBool(!(flags & Fx::Technique::Flag_Disable_Abovewater)); switch (technique->getStatus()) { @@ -356,12 +356,11 @@ namespace MWGui << "#{fontcolourhtml=header}#{OMWShaders:Description}: #{fontcolourhtml=normal} " << description << endl << endl - << "#{fontcolourhtml=header}#{OMWShaders:InInteriors}: #{fontcolourhtml=normal} " << flag_interior - << "#{fontcolourhtml=header} #{OMWShaders:InExteriors}: #{fontcolourhtml=normal} " << flag_exterior - << "#{fontcolourhtml=header} #{OMWShaders:Underwater}: #{fontcolourhtml=normal} " - << flag_underwater + << "#{fontcolourhtml=header}#{OMWShaders:InInteriors}: #{fontcolourhtml=normal} " << flagInterior + << "#{fontcolourhtml=header} #{OMWShaders:InExteriors}: #{fontcolourhtml=normal} " << flagExterior + << "#{fontcolourhtml=header} #{OMWShaders:Underwater}: #{fontcolourhtml=normal} " << flagUnderwater << "#{fontcolourhtml=header} #{OMWShaders:Abovewater}: #{fontcolourhtml=normal} " - << flag_abovewater; + << flagAbovewater; break; } case Fx::Technique::Status::Parse_Error: diff --git a/apps/openmw/mwgui/savegamedialog.cpp b/apps/openmw/mwgui/savegamedialog.cpp index 28c1b17cda..eb83d82444 100644 --- a/apps/openmw/mwgui/savegamedialog.cpp +++ b/apps/openmw/mwgui/savegamedialog.cpp @@ -220,10 +220,10 @@ namespace MWGui else { // Find the localised name for this class from the store - const ESM::Class* class_ + const ESM::Class* playerClass = MWBase::Environment::get().getESMStore()->get().search(signature.mPlayerClassId); - if (class_) - className = class_->mName; + if (playerClass) + className = playerClass->mName; else className = "?"; // From an older savegame format that did not support custom classes properly. } diff --git a/apps/openmw/mwgui/statswindow.cpp b/apps/openmw/mwgui/statswindow.cpp index 9ae598052a..1af158aa76 100644 --- a/apps/openmw/mwgui/statswindow.cpp +++ b/apps/openmw/mwgui/statswindow.cpp @@ -334,15 +334,15 @@ namespace MWGui NoDrop::onFrame(dt); MWWorld::Ptr player = MWMechanics::getPlayer(); - const MWMechanics::NpcStats& PCstats = player.getClass().getNpcStats(player); + const MWMechanics::NpcStats& playerStats = player.getClass().getNpcStats(player); const auto& store = MWBase::Environment::get().getESMStore(); std::stringstream detail; bool first = true; for (const auto& attribute : store->get()) { - float mult = PCstats.getLevelupAttributeMultiplier(attribute.mId); - mult = std::min(mult, 100 - PCstats.getAttribute(attribute.mId).getBase()); + float mult = playerStats.getLevelupAttributeMultiplier(attribute.mId); + mult = std::min(mult, 100 - playerStats.getAttribute(attribute.mId).getBase()); if (mult > 1) { if (!first) @@ -361,21 +361,21 @@ namespace MWGui getWidget(levelWidget, i == 0 ? "Level_str" : "LevelText"); levelWidget->setUserString( - "RangePosition_LevelProgress", MyGUI::utility::toString(PCstats.getLevelProgress())); + "RangePosition_LevelProgress", MyGUI::utility::toString(playerStats.getLevelProgress())); levelWidget->setUserString("Range_LevelProgress", MyGUI::utility::toString(max)); levelWidget->setUserString("Caption_LevelProgressText", - MyGUI::utility::toString(PCstats.getLevelProgress()) + "/" + MyGUI::utility::toString(max)); + MyGUI::utility::toString(playerStats.getLevelProgress()) + "/" + MyGUI::utility::toString(max)); levelWidget->setUserString("Caption_LevelDetailText", detailText); } - setFactions(PCstats.getFactionRanks()); - setExpelled(PCstats.getExpelled()); + setFactions(playerStats.getFactionRanks()); + setExpelled(playerStats.getExpelled()); const auto& signId = MWBase::Environment::get().getWorld()->getPlayer().getBirthSign(); setBirthSign(signId); - setReputation(PCstats.getReputation()); - setBounty(PCstats.getBounty()); + setReputation(playerStats.getReputation()); + setBounty(playerStats.getBounty()); if (mChanged) updateSkillArea(); @@ -587,8 +587,8 @@ namespace MWGui if (!mFactions.empty()) { MWWorld::Ptr playerPtr = MWMechanics::getPlayer(); - const MWMechanics::NpcStats& PCstats = playerPtr.getClass().getNpcStats(playerPtr); - const std::set& expelled = PCstats.getExpelled(); + const MWMechanics::NpcStats& playerStats = playerPtr.getClass().getNpcStats(playerPtr); + const std::set& expelled = playerStats.getExpelled(); bool firstFaction = true; for (const auto& [factionId, factionRank] : mFactions) diff --git a/apps/openmw/mwgui/tooltips.cpp b/apps/openmw/mwgui/tooltips.cpp index b705fda64b..76bfa18d5e 100644 --- a/apps/openmw/mwgui/tooltips.cpp +++ b/apps/openmw/mwgui/tooltips.cpp @@ -604,17 +604,17 @@ namespace MWGui { mHorizontalScrollIndex = -totalSize.width; } - int horizontal_scroll = mHorizontalScrollIndex; - if (horizontal_scroll < 40) + int horizontalScroll = mHorizontalScrollIndex; + if (horizontalScroll < 40) { - horizontal_scroll = 40; + horizontalScroll = 40; } else { - horizontal_scroll = 80 - mHorizontalScrollIndex; + horizontalScroll = 80 - mHorizontalScrollIndex; } captionWidget->setPosition( - MyGUI::IntPoint(horizontal_scroll, captionWidget->getPosition().top + padding.top)); + MyGUI::IntPoint(horizontalScroll, captionWidget->getPosition().top + padding.top)); } else { diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 9836887c2b..347eef6cbd 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -62,9 +62,9 @@ namespace MWGui } else { - ESM::Position PlayerPos = player.getRefData().getPosition(); - float d = sqrt(pow(pos.pos[0] - PlayerPos.pos[0], 2) + pow(pos.pos[1] - PlayerPos.pos[1], 2) - + pow(pos.pos[2] - PlayerPos.pos[2], 2)); + const ESM::Position playerPos = player.getRefData().getPosition(); + float d = sqrt(pow(pos.pos[0] - playerPos.pos[0], 2) + pow(pos.pos[1] - playerPos.pos[1], 2) + + pow(pos.pos[2] - playerPos.pos[2], 2)); float fTravelMult = gmst.find("fTravelMult")->mValue.getFloat(); if (fTravelMult != 0) price = static_cast(d / fTravelMult); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index bcc67e42c1..261a5e6e16 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -1223,19 +1223,19 @@ namespace MWGui { std::string_view tag = _tag; - std::string_view MyGuiPrefix = "setting="; + constexpr std::string_view myGuiPrefix = "setting="; - std::string_view tokenToFind = "sCell="; + constexpr std::string_view tokenToFind = "sCell="; - if (tag.starts_with(MyGuiPrefix)) + if (tag.starts_with(myGuiPrefix)) { - tag = tag.substr(MyGuiPrefix.length()); - size_t comma_pos = tag.find(','); - if (comma_pos == std::string_view::npos) + tag = tag.substr(myGuiPrefix.length()); + const size_t commaPos = tag.find(','); + if (commaPos == std::string_view::npos) throw std::runtime_error("Invalid setting tag (expected comma): " + std::string(tag)); - std::string_view settingSection = tag.substr(0, comma_pos); - std::string_view settingTag = tag.substr(comma_pos + 1, tag.length()); + std::string_view settingSection = tag.substr(0, commaPos); + std::string_view settingTag = tag.substr(commaPos + 1, tag.length()); _result = Settings::get(settingSection, settingTag).get().print(); } @@ -2419,12 +2419,12 @@ namespace MWGui if (image.valid()) { // everything looks good, send it to the cursor manager - Uint8 hotspot_x = imgSetPointer->getHotSpot().left; - Uint8 hotspot_y = imgSetPointer->getHotSpot().top; + const Uint8 hotspotX = imgSetPointer->getHotSpot().left; + const Uint8 hotspotY = imgSetPointer->getHotSpot().top; int rotation = imgSetPointer->getRotation(); MyGUI::IntSize pointerSize = imgSetPointer->getSize(); - mCursorManager->createCursor(imgSetPointer->getResourceName(), rotation, image, hotspot_x, hotspot_y, + mCursorManager->createCursor(imgSetPointer->getResourceName(), rotation, image, hotspotX, hotspotY, pointerSize.width, pointerSize.height); } } diff --git a/apps/openmw/mwinput/controllermanager.cpp b/apps/openmw/mwinput/controllermanager.cpp index f32bf741db..a3a98200d9 100644 --- a/apps/openmw/mwinput/controllermanager.cpp +++ b/apps/openmw/mwinput/controllermanager.cpp @@ -428,11 +428,10 @@ namespace MWInput float ControllerManager::getAxisValue(SDL_GameControllerAxis axis) const { SDL_GameController* cntrl = mBindingsManager->getControllerOrNull(); - constexpr int AXIS_MAX_ABSOLUTE_VALUE = 32768; - if (cntrl) - return SDL_GameControllerGetAxis(cntrl, axis) / static_cast(AXIS_MAX_ABSOLUTE_VALUE); - else - return 0; + constexpr float axisMaxAbsoluteValue = 32768; + if (cntrl != nullptr) + return SDL_GameControllerGetAxis(cntrl, axis) / axisMaxAbsoluteValue; + return 0; } bool ControllerManager::isButtonPressed(SDL_GameControllerButton button) const diff --git a/apps/openmw/mwlua/menuscripts.cpp b/apps/openmw/mwlua/menuscripts.cpp index a7ff80e63e..cf747c1ecb 100644 --- a/apps/openmw/mwlua/menuscripts.cpp +++ b/apps/openmw/mwlua/menuscripts.cpp @@ -95,9 +95,9 @@ namespace MWLua contentFiles[LuaUtil::toLuaIndex(i)] = Misc::StringUtils::lowerCase(slot.mProfile.mContentFiles[i]); { - auto system_time = std::chrono::system_clock::now() + const auto systemTime = std::chrono::system_clock::now() - (std::filesystem::file_time_type::clock::now() - slot.mTimeStamp); - slotInfo["creationTime"] = std::chrono::duration(system_time.time_since_epoch()).count(); + slotInfo["creationTime"] = std::chrono::duration(systemTime.time_since_epoch()).count(); } slotInfo["contentFiles"] = contentFiles; diff --git a/apps/openmw/mwlua/types/actor.cpp b/apps/openmw/mwlua/types/actor.cpp index 1629235fdd..2d7db8ec77 100644 --- a/apps/openmw/mwlua/types/actor.cpp +++ b/apps/openmw/mwlua/types/actor.cpp @@ -31,14 +31,14 @@ namespace MWLua static std::pair findInInventory( MWWorld::InventoryStore& store, const EquipmentItem& item, int slot = sAnySlot) { - auto old_it = slot != sAnySlot ? store.getSlot(slot) : store.end(); + auto oldIt = slot != sAnySlot ? store.getSlot(slot) : store.end(); MWWorld::Ptr itemPtr; if (std::holds_alternative(item)) { itemPtr = MWBase::Environment::get().getWorldModel()->getPtr(std::get(item)); - if (old_it != store.end() && *old_it == itemPtr) - return { old_it, true }; // already equipped + if (oldIt != store.end() && *oldIt == itemPtr) + return { oldIt, true }; // already equipped if (itemPtr.isEmpty() || itemPtr.getCellRef().getCount() == 0 || itemPtr.getContainerStore() != static_cast(&store)) { @@ -50,8 +50,8 @@ namespace MWLua { const auto& stringId = std::get(item); ESM::RefId recordId = ESM::RefId::deserializeText(stringId); - if (old_it != store.end() && old_it->getCellRef().getRefId() == recordId) - return { old_it, true }; // already equipped + if (oldIt != store.end() && oldIt->getCellRef().getRefId() == recordId) + return { oldIt, true }; // already equipped itemPtr = store.search(recordId); if (itemPtr.isEmpty() || itemPtr.getCellRef().getCount() == 0) { @@ -119,15 +119,15 @@ namespace MWLua for (int slot = 0; slot < MWWorld::InventoryStore::Slots; ++slot) { - auto old_it = store.getSlot(slot); - auto new_it = equipment.find(slot); - if (new_it == equipment.end()) + auto oldIt = store.getSlot(slot); + auto newIt = equipment.find(slot); + if (newIt == equipment.end()) { - if (old_it != store.end()) + if (oldIt != store.end()) store.unequipSlot(slot); continue; } - if (tryEquipToSlot(slot, new_it->second)) + if (tryEquipToSlot(slot, newIt->second)) usedSlots[slot] = true; } for (const auto& [slot, item] : equipment) diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 4766afb55a..fd70671e85 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -762,9 +762,9 @@ namespace MWMechanics // start combat with actor2. if (aggressive) { - bool LOS = world->getLOS(actor1, actor2) && mechanicsManager->awarenessCheck(actor2, actor1); + const bool los = world->getLOS(actor1, actor2) && mechanicsManager->awarenessCheck(actor2, actor1); - if (LOS) + if (los) mechanicsManager->startCombat(actor1, actor2, &cachedAllies.getActorsSidingWith(actor2)); } } @@ -1441,10 +1441,10 @@ namespace MWMechanics // Find the earliest `t` when |relPos + relSpeed * t| == collisionDist. const float vr = relPos.x() * relSpeed.x() + relPos.y() * relSpeed.y(); const float v2 = relSpeed.length2(); - const float Dh = vr * vr - v2 * (relPos.length2() - collisionDist * collisionDist); - if (Dh <= 0 || v2 == 0) + const float dh = vr * vr - v2 * (relPos.length2() - collisionDist * collisionDist); + if (dh <= 0 || v2 == 0) continue; // No solution; distance is always >= collisionDist. - const float t = (-vr - std::sqrt(Dh)) / v2; + const float t = (-vr - std::sqrt(dh)) / v2; if (t < 0 || t > timeToCollision) continue; diff --git a/apps/openmw/mwmechanics/aicombat.cpp b/apps/openmw/mwmechanics/aicombat.cpp index cae4d57b39..4eb0c762eb 100644 --- a/apps/openmw/mwmechanics/aicombat.cpp +++ b/apps/openmw/mwmechanics/aicombat.cpp @@ -140,9 +140,9 @@ namespace MWMechanics const osg::Vec3f destination = storage.mUseCustomDestination ? storage.mCustomDestination : target.getRefData().getPosition().asVec3(); - const bool is_target_reached = pathTo(actor, destination, duration, + const bool isTargetReached = pathTo(actor, destination, duration, characterController.getSupportedMovementDirections(), targetReachedTolerance); - if (is_target_reached) + if (isTargetReached) storage.mReadyToAttack = true; } @@ -348,11 +348,11 @@ namespace MWMechanics void MWMechanics::AiCombat::updateLOS( const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, MWMechanics::AiCombatStorage& storage) { - static const float LOS_UPDATE_DURATION = 0.5f; + const float losUpdateDuration = 0.5f; if (storage.mUpdateLOSTimer <= 0.f) { storage.mLOS = MWBase::Environment::get().getWorld()->getLOS(actor, target); - storage.mUpdateLOSTimer = LOS_UPDATE_DURATION; + storage.mUpdateLOSTimer = losUpdateDuration; } else storage.mUpdateLOSTimer -= duration; @@ -361,7 +361,7 @@ namespace MWMechanics void MWMechanics::AiCombat::updateFleeing(const MWWorld::Ptr& actor, const MWWorld::Ptr& target, float duration, MWWorld::MovementDirectionFlags supportedMovementDirections, AiCombatStorage& storage) { - static const float BLIND_RUN_DURATION = 1.0f; + const float blindRunDuration = 1.0f; updateLOS(actor, target, duration, storage); @@ -427,7 +427,7 @@ namespace MWMechanics case AiCombatStorage::FleeState_RunBlindly: { // timer to prevent twitchy movement that can be observed in vanilla MW - if (storage.mFleeBlindRunTimer < BLIND_RUN_DURATION) + if (storage.mFleeBlindRunTimer < blindRunDuration) { storage.mFleeBlindRunTimer += duration; @@ -803,7 +803,7 @@ namespace float velDir = vTargetMoveDir * vDirToTargetNormalized; // time to collision between target and projectile - float t_collision; + float tCollision; float projVelDirSquared = projSpeed * projSpeed - velPerp * velPerp; if (projVelDirSquared > 0) @@ -814,12 +814,12 @@ namespace float projDistDiff = vDirToTarget * vTargetMoveDirNormalized; // dot product projDistDiff = std::sqrt(distToTarget * distToTarget - projDistDiff * projDistDiff); - t_collision = projDistDiff / (std::sqrt(projVelDirSquared) - velDir); + tCollision = projDistDiff / (std::sqrt(projVelDirSquared) - velDir); } else - t_collision = 0; // speed of projectile is not enough to reach moving target + tCollision = 0; // speed of projectile is not enough to reach moving target - return vDirToTarget + vTargetMoveDir * t_collision; + return vDirToTarget + vTargetMoveDir * tCollision; } } diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp index a3e260a4a7..4cfe1027c5 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.cpp @@ -186,9 +186,9 @@ namespace MWMechanics // class if (mClassSelected) { - const ESM::Class* class_ = esmStore.get().find(player->mClass); + const ESM::Class* playerClass = esmStore.get().find(player->mClass); - for (int attribute : class_->mData.mAttribute) + for (int attribute : playerClass->mData.mAttribute) { ESM::RefId id = ESM::Attribute::indexToRefId(attribute); if (!id.empty()) @@ -199,7 +199,7 @@ namespace MWMechanics { int bonus = i == 0 ? 10 : 25; - for (const auto& skills : class_->mData.mSkills) + for (const auto& skills : playerClass->mData.mSkills) { ESM::RefId id = ESM::Skill::indexToRefId(skills[i]); if (!id.empty()) @@ -209,7 +209,7 @@ namespace MWMechanics for (const ESM::Skill& skill : esmStore.get()) { - if (skill.mData.mSpecialization == class_->mData.mSpecialization) + if (skill.mData.mSpecialization == playerClass->mData.mSpecialization) npcStats.getSkill(skill.mId).setBase(npcStats.getSkill(skill.mId).getBase() + 5); } } @@ -466,11 +466,11 @@ namespace MWMechanics mUpdatePlayer = true; } - void MechanicsManager::setPlayerClass(const ESM::Class& cls) + void MechanicsManager::setPlayerClass(const ESM::Class& value) { MWBase::World* world = MWBase::Environment::get().getWorld(); - const ESM::Class* ptr = world->getStore().insert(cls); + const ESM::Class* ptr = world->getStore().insert(value); ESM::NPC player = *world->getPlayerPtr().get()->mBase; player.mClass = ptr->mId; diff --git a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp index 93af89863b..247bae1a5b 100644 --- a/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp +++ b/apps/openmw/mwmechanics/mechanicsmanagerimp.hpp @@ -75,7 +75,7 @@ namespace MWMechanics void setPlayerClass(const ESM::RefId& id) override; ///< Set player class to stock class. - void setPlayerClass(const ESM::Class& class_) override; + void setPlayerClass(const ESM::Class& value) override; ///< Set player class to custom class. void restoreDynamicStats(const MWWorld::Ptr& actor, double hours, bool sleep) override; diff --git a/apps/openmw/mwmechanics/npcstats.cpp b/apps/openmw/mwmechanics/npcstats.cpp index eceaf8b482..a55374411a 100644 --- a/apps/openmw/mwmechanics/npcstats.cpp +++ b/apps/openmw/mwmechanics/npcstats.cpp @@ -167,7 +167,7 @@ void MWMechanics::NpcStats::setFactionReputation(const ESM::RefId& faction, int mFactionReputation[faction] = value; } -float MWMechanics::NpcStats::getSkillProgressRequirement(ESM::RefId id, const ESM::Class& class_) const +float MWMechanics::NpcStats::getSkillProgressRequirement(ESM::RefId id, const ESM::Class& npcClass) const { float progressRequirement = 1.f + getSkill(id).getBase(); @@ -176,7 +176,7 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(ESM::RefId id, const ES float typeFactor = gmst.find("fMiscSkillBonus")->mValue.getFloat(); int index = ESM::Skill::refIdToIndex(skill->mId); - for (const auto& skills : class_.mData.mSkills) + for (const auto& skills : npcClass.mData.mSkills) { if (skills[0] == index) { @@ -197,7 +197,7 @@ float MWMechanics::NpcStats::getSkillProgressRequirement(ESM::RefId id, const ES float specialisationFactor = 1; - if (skill->mData.mSpecialization == class_.mData.mSpecialization) + if (skill->mData.mSpecialization == npcClass.mData.mSpecialization) { specialisationFactor = gmst.find("fSpecialSkillBonus")->mValue.getFloat(); diff --git a/apps/openmw/mwmechanics/npcstats.hpp b/apps/openmw/mwmechanics/npcstats.hpp index f94744cb71..879ccc2fd2 100644 --- a/apps/openmw/mwmechanics/npcstats.hpp +++ b/apps/openmw/mwmechanics/npcstats.hpp @@ -85,7 +85,7 @@ namespace MWMechanics bool isInFaction(const ESM::RefId& faction) const; - float getSkillProgressRequirement(ESM::RefId id, const ESM::Class& class_) const; + float getSkillProgressRequirement(ESM::RefId id, const ESM::Class& npcClass) const; int getLevelProgress() const; void setLevelProgress(int progress); diff --git a/apps/openmw/mwmechanics/pathfinding.cpp b/apps/openmw/mwmechanics/pathfinding.cpp index 165250c5c8..6c30f43cef 100644 --- a/apps/openmw/mwmechanics/pathfinding.cpp +++ b/apps/openmw/mwmechanics/pathfinding.cpp @@ -132,12 +132,12 @@ namespace MWMechanics dir.z() = 0; dir.normalize(); float verticalOffset = 200; // instead of '200' here we want the height of the actor - osg::Vec3f _from = from + dir * offsetXY + osg::Z_AXIS * verticalOffset; + const osg::Vec3f adjustedFrom = from + dir * offsetXY + osg::Z_AXIS * verticalOffset; // cast up-down ray and find height of hit in world space - float h = _from.z() + float h = adjustedFrom.z() - MWBase::Environment::get().getWorld()->getDistToNearestRayHit( - _from, -osg::Z_AXIS, verticalOffset + PATHFIND_Z_REACH + 1); + adjustedFrom, -osg::Z_AXIS, verticalOffset + PATHFIND_Z_REACH + 1); return (std::abs(from.z() - h) <= PATHFIND_Z_REACH); } diff --git a/apps/openmw/mwmechanics/pathgrid.cpp b/apps/openmw/mwmechanics/pathgrid.cpp index 980c0c660f..d2be688bc2 100644 --- a/apps/openmw/mwmechanics/pathgrid.cpp +++ b/apps/openmw/mwmechanics/pathgrid.cpp @@ -273,13 +273,13 @@ namespace MWMechanics { // not in closedset - i.e. have not traversed this edge destination size_t dest = edge.index; - float tentative_g = gScore[current] + edge.cost; + float tentativeG = gScore[current] + edge.cost; bool isInOpenSet = std::find(openset.begin(), openset.end(), dest) != openset.end(); - if (!isInOpenSet || tentative_g < gScore[dest]) + if (!isInOpenSet || tentativeG < gScore[dest]) { graphParent[dest] = current; - gScore[dest] = tentative_g; - fScore[dest] = tentative_g + costAStar(mPathgrid->mPoints[dest], mPathgrid->mPoints[goal]); + gScore[dest] = tentativeG; + fScore[dest] = tentativeG + costAStar(mPathgrid->mPoints[dest], mPathgrid->mPoints[goal]); if (!isInOpenSet) { // add this edge to openset, lowest cost goes to the front diff --git a/apps/openmw/mwphysics/movementsolver.cpp b/apps/openmw/mwphysics/movementsolver.cpp index 554cd7586a..93473c467c 100644 --- a/apps/openmw/mwphysics/movementsolver.cpp +++ b/apps/openmw/mwphysics/movementsolver.cpp @@ -462,12 +462,11 @@ namespace MWPhysics resultCallback.m_collisionFilterGroup = CollisionType_Projectile; const btQuaternion btrot = btQuaternion::getIdentity(); - btTransform from_(btrot, btFrom); - btTransform to_(btrot, btTo); const btCollisionShape* shape = projectile.mCollisionObject->getCollisionShape(); assert(shape->isConvex()); - collisionWorld->convexSweepTest(static_cast(shape), from_, to_, resultCallback); + collisionWorld->convexSweepTest(static_cast(shape), btTransform(btrot, btFrom), + btTransform(btrot, btTo), resultCallback); projectile.mPosition = Misc::Convert::toOsg(projectile.mProjectile->isActive() ? btTo : resultCallback.m_hitPointWorld); diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index adc107f7cc..9620befe6e 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -262,10 +262,8 @@ namespace MWPhysics btSphereShape shape(radius); const btQuaternion btrot = btQuaternion::getIdentity(); - btTransform from_(btrot, Misc::Convert::toBullet(from)); - btTransform to_(btrot, Misc::Convert::toBullet(to)); - - mTaskScheduler->convexSweepTest(&shape, from_, to_, callback); + mTaskScheduler->convexSweepTest(&shape, btTransform(btrot, Misc::Convert::toBullet(from)), + btTransform(btrot, Misc::Convert::toBullet(to)), callback); RayCastingResult result; result.mHit = callback.hasHit(); diff --git a/apps/openmw/mwphysics/trace.cpp b/apps/openmw/mwphysics/trace.cpp index 9e60a7c626..3927580624 100644 --- a/apps/openmw/mwphysics/trace.cpp +++ b/apps/openmw/mwphysics/trace.cpp @@ -50,16 +50,16 @@ namespace MWPhysics // This trace needs to be at least a couple units long, but there's no one particular ideal length. // The length of 2.1 chosen here is a "works well in practice after testing a few random lengths" value. // (Also, we only do this short test if the intended collision trace is long enough for it to make sense.) - const float fallback_length = 2.1f; - bool doing_short_trace = false; + const float fallbackLength = 2.1f; + bool doingShortTrace = false; // For some reason, typical scenes perform a little better if we increase the threshold length for the length // test. (Multiplying by 2 in 'square distance' units gives us about 1.4x the threshold length. In benchmarks // this was // slightly better for the performance of normal scenes than 4.0, and just plain better than 1.0.) - if (attempt_short_trace && (btend - btstart).length2() > fallback_length * fallback_length * 2.0) + if (attempt_short_trace && (btend - btstart).length2() > fallbackLength * fallbackLength * 2.0) { - btend = btstart + (btend - btstart).normalized() * fallback_length; - doing_short_trace = true; + btend = btstart + (btend - btstart).normalized() * fallbackLength; + doingShortTrace = true; } const auto traceCallback = sweepHelper(actor, btstart, btend, world, false); @@ -69,7 +69,7 @@ namespace MWPhysics { mFraction = traceCallback.m_closestHitFraction; // ensure fraction is correct (covers intended distance traveled instead of actual distance traveled) - if (doing_short_trace && (end - start).length2() > 0.0) + if (doingShortTrace && (end - start).length2() > 0.0) mFraction *= (btend - btstart).length() / (end - start).length(); mPlaneNormal = Misc::Convert::toOsg(traceCallback.m_hitNormalWorld); mEndPos = (end - start) * mFraction + start; @@ -78,7 +78,7 @@ namespace MWPhysics } else { - if (doing_short_trace) + if (doingShortTrace) { btend = Misc::Convert::toBullet(end); const auto newTraceCallback = sweepHelper(actor, btstart, btend, world, false); diff --git a/apps/openmw/mwrender/npcanimation.cpp b/apps/openmw/mwrender/npcanimation.cpp index 4aface83d6..9181996a4e 100644 --- a/apps/openmw/mwrender/npcanimation.cpp +++ b/apps/openmw/mwrender/npcanimation.cpp @@ -616,8 +616,8 @@ namespace MWRender ESM::PartReferenceType parts[] = { ESM::PRT_Groin, ESM::PRT_Skirt, ESM::PRT_RLeg, ESM::PRT_LLeg, ESM::PRT_RUpperarm, ESM::PRT_LUpperarm, ESM::PRT_RKnee, ESM::PRT_LKnee, ESM::PRT_RForearm, ESM::PRT_LForearm, ESM::PRT_Cuirass }; - size_t parts_size = sizeof(parts) / sizeof(parts[0]); - for (size_t p = 0; p < parts_size; ++p) + const size_t partsSize = sizeof(parts) / sizeof(parts[0]); + for (size_t p = 0; p < partsSize; ++p) reserveIndividualPart(parts[p], slotlist[i].mSlot, prio); } else if (slotlist[i].mSlot == MWWorld::InventoryStore::Slot_Skirt) @@ -1149,14 +1149,14 @@ namespace MWRender const std::vector& NpcAnimation::getBodyParts( const ESM::RefId& race, bool female, bool firstPerson, bool werewolf) { - static const int Flag_FirstPerson = 1 << 1; - static const int Flag_Female = 1 << 0; + constexpr int flagFirstPerson = 1 << 1; + constexpr int flagFemale = 1 << 0; int flags = (werewolf ? -1 : 0); if (female) - flags |= Flag_Female; + flags |= flagFemale; if (firstPerson) - flags |= Flag_FirstPerson; + flags |= flagFirstPerson; RaceMapping::iterator found = sRaceMapping.find(std::make_pair(race, flags)); if (found != sRaceMapping.end()) diff --git a/apps/openmw/mwrender/sky.cpp b/apps/openmw/mwrender/sky.cpp index b601c0dd61..244e1035ed 100644 --- a/apps/openmw/mwrender/sky.cpp +++ b/apps/openmw/mwrender/sky.cpp @@ -56,7 +56,7 @@ namespace osg::Object* clone(const osg::CopyOp& op) const override { return nullptr; } - void operate(osgParticle::Particle* P, double dt) override {} + void operate(osgParticle::Particle* particle, double dt) override {} void operateParticles(osgParticle::ParticleSystem* ps, double dt) override { diff --git a/apps/openmw/mwscript/interpretercontext.cpp b/apps/openmw/mwscript/interpretercontext.cpp index f6c20c9c10..a177e97b37 100644 --- a/apps/openmw/mwscript/interpretercontext.cpp +++ b/apps/openmw/mwscript/interpretercontext.cpp @@ -295,8 +295,8 @@ namespace MWScript std::string_view InterpreterContext::getNPCClass() const { const ESM::NPC* npc = getReferenceImp().get()->mBase; - const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); - return class_->mName; + const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get().find(npc->mClass); + return npcClass->mName; } std::string_view InterpreterContext::getNPCFaction() const @@ -356,8 +356,8 @@ namespace MWScript std::string_view InterpreterContext::getPCClass() const { MWBase::World* world = MWBase::Environment::get().getWorld(); - const ESM::RefId& class_ = world->getPlayerPtr().get()->mBase->mClass; - return world->getStore().get().find(class_)->mName; + const ESM::RefId& playerClass = world->getPlayerPtr().get()->mBase->mClass; + return world->getStore().get().find(playerClass)->mName; } std::string_view InterpreterContext::getPCRank() const diff --git a/apps/openmw/mwscript/scriptmanagerimp.cpp b/apps/openmw/mwscript/scriptmanagerimp.cpp index e8d57b4c74..32f85a4a2a 100644 --- a/apps/openmw/mwscript/scriptmanagerimp.cpp +++ b/apps/openmw/mwscript/scriptmanagerimp.cpp @@ -45,7 +45,7 @@ namespace MWScript { mErrorHandler.setContext(script->mId.getRefIdString()); - bool Success = true; + bool success = true; try { std::istringstream input(script->mScriptText); @@ -55,25 +55,25 @@ namespace MWScript scanner.scan(mParser); if (!mErrorHandler.isGood()) - Success = false; + success = false; } catch (const Compiler::SourceException&) { // error has already been reported via error handler - Success = false; + success = false; } catch (const std::exception& error) { Log(Debug::Error) << "Error: An exception has been thrown: " << error.what(); - Success = false; + success = false; } - if (!Success) + if (!success) { Log(Debug::Error) << "Error: script compiling failed: " << name; } - if (Success) + if (success) { mScripts.emplace(name, CompiledScript(mParser.getProgram(), mParser.getLocals())); diff --git a/apps/openmw/mwsound/ffmpegdecoder.cpp b/apps/openmw/mwsound/ffmpegdecoder.cpp index f8b40ddabb..051f16c27e 100644 --- a/apps/openmw/mwsound/ffmpegdecoder.cpp +++ b/apps/openmw/mwsound/ffmpegdecoder.cpp @@ -111,11 +111,11 @@ namespace MWSound if (!mStream) return false; - std::ptrdiff_t stream_idx = mStream - mFormatCtx->streams; + std::ptrdiff_t streamIdx = mStream - mFormatCtx->streams; while (av_read_frame(mFormatCtx.get(), &mPacket) >= 0) { /* Check if the packet belongs to this stream */ - if (stream_idx == mPacket.stream_index) + if (streamIdx == mPacket.stream_index) { if (mPacket.pts != (int64_t)AV_NOPTS_VALUE) mNextPts = av_q2d((*mStream)->time_base) * mPacket.pts; @@ -131,7 +131,7 @@ namespace MWSound bool FFmpegDecoder::getAVAudioData() { - bool got_frame = false; + bool gotFrame = false; if (mCodecCtx->codec_type != AVMEDIA_TYPE_AUDIO) return false; @@ -156,7 +156,7 @@ namespace MWSound if (mFrame->nb_samples == 0) continue; - got_frame = true; + gotFrame = true; if (mSwr) { @@ -186,7 +186,7 @@ namespace MWSound else mFrameData = &mFrame->data[0]; - } while (!got_frame); + } while (!gotFrame); mNextPts += (double)mFrame->nb_samples / mCodecCtx->sample_rate; return true; @@ -416,11 +416,11 @@ namespace MWSound *samplerate = mCodecCtx->sample_rate; #if OPENMW_FFMPEG_5_OR_GREATER - AVChannelLayout ch_layout = mCodecCtx->ch_layout; - if (ch_layout.u.mask == 0) - av_channel_layout_default(&ch_layout, mCodecCtx->ch_layout.nb_channels); + AVChannelLayout chLayout = mCodecCtx->ch_layout; + if (chLayout.u.mask == 0) + av_channel_layout_default(&chLayout, mCodecCtx->ch_layout.nb_channels); - if (mOutputSampleFormat != mCodecCtx->sample_fmt || mOutputChannelLayout.u.mask != ch_layout.u.mask) + if (mOutputSampleFormat != mCodecCtx->sample_fmt || mOutputChannelLayout.u.mask != chLayout.u.mask) #else int64_t ch_layout = mCodecCtx->channel_layout; if (ch_layout == 0) @@ -435,7 +435,7 @@ namespace MWSound &mOutputChannelLayout, // output ch layout mOutputSampleFormat, // output sample format mCodecCtx->sample_rate, // output sample rate - &ch_layout, // input ch layout + &chLayout, // input ch layout mCodecCtx->sample_fmt, // input sample format mCodecCtx->sample_rate, // input sample rate 0, // logging level offset diff --git a/apps/openmw/mwsound/movieaudiofactory.cpp b/apps/openmw/mwsound/movieaudiofactory.cpp index 61992bc0d5..6e479f5af2 100644 --- a/apps/openmw/mwsound/movieaudiofactory.cpp +++ b/apps/openmw/mwsound/movieaudiofactory.cpp @@ -48,12 +48,13 @@ namespace MWSound size_t getSampleOffset() { #if OPENMW_FFMPEG_5_OR_GREATER - ssize_t clock_delay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels + const ssize_t clockDelay = (mFrameSize - mFramePos) / mOutputChannelLayout.nb_channels #else - ssize_t clock_delay = (mFrameSize - mFramePos) / av_get_channel_layout_nb_channels(mOutputChannelLayout) + const ssize_t clockDelay = (mFrameSize - mFramePos) + / av_get_channel_layout_nb_channels(mOutputChannelLayout) #endif / av_get_bytes_per_sample(mOutputSampleFormat); - return (size_t)(mAudioClock * mAudioContext->sample_rate) - clock_delay; + return static_cast(static_cast(mAudioClock * mAudioContext->sample_rate) - clockDelay); } std::string getStreamName() diff --git a/apps/openmw/mwsound/openaloutput.cpp b/apps/openmw/mwsound/openaloutput.cpp index ecce476685..4b0e6ff72b 100644 --- a/apps/openmw/mwsound/openaloutput.cpp +++ b/apps/openmw/mwsound/openaloutput.cpp @@ -751,9 +751,9 @@ namespace MWSound if (!hrtfname.empty()) { ALCint index = -1; - ALCint num_hrtf; - alcGetIntegerv(mDevice, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf); - for (ALCint i = 0; i < num_hrtf; ++i) + ALCint numHrtf; + alcGetIntegerv(mDevice, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &numHrtf); + for (ALCint i = 0; i < numHrtf; ++i) { const ALCchar* entry = alcGetStringiSOFT(mDevice, ALC_HRTF_SPECIFIER_SOFT, i); if (hrtfname == entry) @@ -819,9 +819,9 @@ namespace MWSound Log(Debug::Warning) << "HRTF status unavailable"; else { - ALCint hrtf_state; - alcGetIntegerv(mDevice, ALC_HRTF_SOFT, 1, &hrtf_state); - if (!hrtf_state) + ALCint hrtfState; + alcGetIntegerv(mDevice, ALC_HRTF_SOFT, 1, &hrtfState); + if (!hrtfState) Log(Debug::Info) << "HRTF disabled"; else { @@ -1017,10 +1017,10 @@ namespace MWSound LPALCGETSTRINGISOFT alcGetStringiSOFT = nullptr; getALCFunc(alcGetStringiSOFT, mDevice, "alcGetStringiSOFT"); - ALCint num_hrtf; - alcGetIntegerv(mDevice, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &num_hrtf); - ret.reserve(num_hrtf); - for (ALCint i = 0; i < num_hrtf; ++i) + ALCint numHrtf; + alcGetIntegerv(mDevice, ALC_NUM_HRTF_SPECIFIERS_SOFT, 1, &numHrtf); + ret.reserve(numHrtf); + for (ALCint i = 0; i < numHrtf; ++i) { const ALCchar* entry = alcGetStringiSOFT(mDevice, ALC_HRTF_SPECIFIER_SOFT, i); ret.emplace_back(entry); diff --git a/apps/openmw/mwworld/actionequip.cpp b/apps/openmw/mwworld/actionequip.cpp index dbc548f585..5144ba92e8 100644 --- a/apps/openmw/mwworld/actionequip.cpp +++ b/apps/openmw/mwworld/actionequip.cpp @@ -46,8 +46,8 @@ namespace MWWorld } // slots that this item can be equipped in - std::pair, bool> slots_ = getTarget().getClass().getEquipmentSlots(getTarget()); - if (slots_.first.empty()) + std::pair, bool> slots = getTarget().getClass().getEquipmentSlots(getTarget()); + if (slots.first.empty()) return; // retrieve ContainerStoreIterator to the item @@ -64,8 +64,8 @@ namespace MWWorld throw std::runtime_error("ActionEquip can't find item " + object.getCellRef().getRefId().toDebugString()); // equip the item in the first free slot - std::vector::const_iterator slot = slots_.first.begin(); - for (; slot != slots_.first.end(); ++slot) + std::vector::const_iterator slot = slots.first.begin(); + for (; slot != slots.first.end(); ++slot) { // if the item is equipped already, nothing to do if (invStore.getSlot(*slot) == it) @@ -81,14 +81,14 @@ namespace MWWorld // all slots are occupied -> cycle // move all slots one towards begin(), then equip the item in the slot that is now free - if (slot == slots_.first.end()) + if (slot == slots.first.end()) { ContainerStoreIterator enchItem = invStore.getSelectedEnchantItem(); bool reEquip = false; - for (slot = slots_.first.begin(); slot != slots_.first.end(); ++slot) + for (slot = slots.first.begin(); slot != slots.first.end(); ++slot) { invStore.unequipSlot(*slot, false); - if (slot + 1 != slots_.first.end()) + if (slot + 1 != slots.first.end()) { invStore.equip(*slot, invStore.getSlot(*(slot + 1))); } diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index ec3355b09e..d7fd58c6c1 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -39,10 +39,10 @@ void MWWorld::InventoryStore::copySlots(const InventoryStore& store) mSelectedEnchantItem = slot; } -void MWWorld::InventoryStore::initSlots(TSlots& slots_) +void MWWorld::InventoryStore::initSlots(TSlots& slots) { for (int i = 0; i < Slots; ++i) - slots_.push_back(end()); + slots.push_back(end()); } void MWWorld::InventoryStore::storeEquipmentState( @@ -159,18 +159,18 @@ void MWWorld::InventoryStore::equip(int slot, const ContainerStoreIterator& iter if (iterator.getContainerStore() != this) throw std::runtime_error("attempt to equip an item that is not in the inventory"); - std::pair, bool> slots_; + std::pair, bool> slots; - slots_ = iterator->getClass().getEquipmentSlots(*iterator); + slots = iterator->getClass().getEquipmentSlots(*iterator); - if (std::find(slots_.first.begin(), slots_.first.end(), slot) == slots_.first.end()) + if (std::find(slots.first.begin(), slots.first.end(), slot) == slots.first.end()) throw std::runtime_error("invalid slot"); if (mSlots[slot] != end()) unequipSlot(slot); // unstack item pointed to by iterator if required - if (iterator != end() && !slots_.second + if (iterator != end() && !slots.second && iterator->getCellRef().getCount() > 1) // if slots.second is true, item can stay stacked when equipped { unstack(*iterator); @@ -219,7 +219,7 @@ MWWorld::ContainerStoreIterator MWWorld::InventoryStore::findSlot(int slot) cons return mSlots[slot]; } -void MWWorld::InventoryStore::autoEquipWeapon(TSlots& slots_) +void MWWorld::InventoryStore::autoEquipWeapon(TSlots& slots) { const Ptr& actor = getPtr(); if (!actor.getClass().isNpc()) @@ -337,14 +337,14 @@ void MWWorld::InventoryStore::autoEquipWeapon(TSlots& slots_) if (arrow == end()) hasAmmo = false; else - slots_[Slot_Ammunition] = arrow; + slots[Slot_Ammunition] = arrow; } else if (ammotype == ESM::Weapon::Bolt) { if (bolt == end()) hasAmmo = false; else - slots_[Slot_Ammunition] = bolt; + slots[Slot_Ammunition] = bolt; } if (hasAmmo) @@ -362,10 +362,10 @@ void MWWorld::InventoryStore::autoEquipWeapon(TSlots& slots_) } int slot = itemsSlots.first.front(); - slots_[slot] = weapon; + slots[slot] = weapon; if (ammotype == ESM::Weapon::None) - slots_[Slot_Ammunition] = end(); + slots[Slot_Ammunition] = end(); } break; @@ -376,7 +376,7 @@ void MWWorld::InventoryStore::autoEquipWeapon(TSlots& slots_) } } -void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots_) +void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots) { const Ptr& actor = getPtr(); @@ -428,9 +428,9 @@ void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots_) for (const int slot : itemSlots) { // check if slot may require swapping if current item is more valuable - if (slots_.at(slot) != end()) + if (slots.at(slot) != end()) { - Ptr old = *slots_.at(slot); + Ptr old = *slots.at(slot); const MWWorld::Class& oldCls = old.getClass(); unsigned int oldType = old.getType(); @@ -443,10 +443,10 @@ void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots_) // If the left ring slot is filled, don't swap if the right ring is cheaper if (slot == Slot_LeftRing) { - if (slots_.at(Slot_RightRing) == end()) + if (slots.at(Slot_RightRing) == end()) continue; - Ptr rightRing = *slots_.at(Slot_RightRing); + Ptr rightRing = *slots.at(Slot_RightRing); if (rightRing.getClass().getValue(rightRing) <= oldCls.getValue(old)) continue; } @@ -486,7 +486,7 @@ void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots_) } // if we are here it means item can be equipped or swapped - slots_[slot] = iter; + slots[slot] = iter; break; } } @@ -494,22 +494,22 @@ void MWWorld::InventoryStore::autoEquipArmor(TSlots& slots_) void MWWorld::InventoryStore::autoEquip() { - TSlots slots_; - initSlots(slots_); + TSlots slots; + initSlots(slots); // Disable model update during auto-equip mUpdatesEnabled = false; // Autoequip clothing, armor and weapons. // Equipping lights is handled in Actors::updateEquippedLight based on environment light. - autoEquipWeapon(slots_); - autoEquipArmor(slots_); + autoEquipWeapon(slots); + autoEquipArmor(slots); bool changed = false; - for (std::size_t i = 0; i < slots_.size(); ++i) + for (std::size_t i = 0; i < slots.size(); ++i) { - if (slots_[i] != mSlots[i]) + if (slots[i] != mSlots[i]) { changed = true; break; @@ -519,7 +519,7 @@ void MWWorld::InventoryStore::autoEquip() if (changed) { - mSlots.swap(slots_); + mSlots.swap(slots); fireEquipmentChangedEvent(); flagAsModified(); } diff --git a/apps/openmw/mwworld/inventorystore.hpp b/apps/openmw/mwworld/inventorystore.hpp index 33de6f66d3..850e0860aa 100644 --- a/apps/openmw/mwworld/inventorystore.hpp +++ b/apps/openmw/mwworld/inventorystore.hpp @@ -67,15 +67,15 @@ namespace MWWorld TSlots mSlots; - void autoEquipWeapon(TSlots& slots_); - void autoEquipArmor(TSlots& slots_); + void autoEquipWeapon(TSlots& slots); + void autoEquipArmor(TSlots& slots); // selected magic item (for using enchantments of type "Cast once" or "Cast when used") ContainerStoreIterator mSelectedEnchantItem; void copySlots(const InventoryStore& store); - void initSlots(TSlots& slots_); + void initSlots(TSlots& slots); void fireEquipmentChangedEvent(); diff --git a/apps/openmw/mwworld/projectilemanager.cpp b/apps/openmw/mwworld/projectilemanager.cpp index c436f86df5..667a9d608b 100644 --- a/apps/openmw/mwworld/projectilemanager.cpp +++ b/apps/openmw/mwworld/projectilemanager.cpp @@ -123,14 +123,14 @@ namespace texture = magicEffect->mParticle; } - if (projectileEffects.mList.size() - > 1) // insert a VFX_Multiple projectile if there are multiple projectile effects + // insert a VFX_Multiple projectile if there are multiple projectile effects + if (projectileEffects.mList.size() > 1) { - const ESM::RefId ID = ESM::RefId::stringRefId("VFX_Multiple" + std::to_string(effects->mList.size())); - std::vector::iterator it; - it = projectileIDs.begin(); - it = projectileIDs.insert(it, ID); + const ESM::RefId projectileId + = ESM::RefId::stringRefId("VFX_Multiple" + std::to_string(effects->mList.size())); + projectileIDs.insert(projectileIDs.begin(), projectileId); } + return projectileEffects; } diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index f2cffb5611..adc2a175fd 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -858,12 +858,12 @@ namespace MWWorld if (mTimeSettings.mNightStart < mSunriseTime) adjustedNightStart += 24.f; - const bool is_night = adjustedHour >= adjustedNightStart; + const bool isNight = adjustedHour >= adjustedNightStart; const float dayDuration = adjustedNightStart - mSunriseTime; const float nightDuration = 24.f - dayDuration; float orbit; - if (!is_night) + if (!isNight) { float t = (adjustedHour - mSunriseTime) / dayDuration; orbit = 1.f - 2.f * t; @@ -877,7 +877,7 @@ namespace MWWorld // Hardcoded constant from Morrowind const osg::Vec3f sunDir(-400.f * orbit, 75.f, -100.f); mRendering.setSunDirection(sunDir); - mRendering.setNight(is_night); + mRendering.setNight(isNight); } float underwaterFog = mUnderwaterFog.getValue(time.getHour(), mTimeSettings, "Fog"); diff --git a/apps/wizard/unshield/unshieldworker.cpp b/apps/wizard/unshield/unshieldworker.cpp index 1d7d21b256..438c3c1fef 100644 --- a/apps/wizard/unshield/unshieldworker.cpp +++ b/apps/wizard/unshield/unshieldworker.cpp @@ -900,9 +900,9 @@ QString Wizard::UnshieldWorker::findFile(const QString& fileName, const QString& QStringList Wizard::UnshieldWorker::findFiles( const QString& fileName, const QString& path, int depth, bool recursive, bool directories, Qt::MatchFlags flags) { - static const int MAXIMUM_DEPTH = 10; + constexpr int maximumDepth = 10; - if (depth >= MAXIMUM_DEPTH) + if (depth >= maximumDepth) { qWarning("Maximum directory depth limit reached."); return QStringList(); diff --git a/components/compiler/scanner.hpp b/components/compiler/scanner.hpp index 34b122413e..7520903625 100644 --- a/components/compiler/scanner.hpp +++ b/components/compiler/scanner.hpp @@ -135,7 +135,7 @@ namespace Compiler bool peek(std::istream& in) { - std::streampos p_orig = in.tellg(); + std::streampos pOrig = in.tellg(); char ch = static_cast(in.peek()); @@ -158,7 +158,7 @@ namespace Compiler mLength = length; - in.seekg(p_orig); + in.seekg(pOrig); return true; } diff --git a/components/contentselector/model/contentmodel.cpp b/components/contentselector/model/contentmodel.cpp index 53d5476fb6..9b6e7b00c5 100644 --- a/components/contentselector/model/contentmodel.cpp +++ b/components/contentselector/model/contentmodel.cpp @@ -92,10 +92,10 @@ const ContentSelectorModel::EsmFile* ContentSelectorModel::ContentModel::item(co QModelIndex ContentSelectorModel::ContentModel::indexFromItem(const EsmFile* item) const { // workaround: non-const pointer cast for calls from outside contentmodel/contentselector - EsmFile* non_const_file_ptr = const_cast(item); + EsmFile* const nonConstFilePtr = const_cast(item); if (item) - return index(mFiles.indexOf(non_const_file_ptr), 0); + return index(mFiles.indexOf(nonConstFilePtr), 0); return QModelIndex(); } diff --git a/components/contentselector/view/contentselector.cpp b/components/contentselector/view/contentselector.cpp index 5fd54ee789..458913a8e2 100644 --- a/components/contentselector/view/contentselector.cpp +++ b/components/contentselector/view/contentselector.cpp @@ -58,12 +58,13 @@ public: bool filterAcceptsRow(int sourceRow, const QModelIndex& sourceParent) const override { - static const QString ContentTypeAddon = QString::number((int)ContentSelectorModel::ContentType_Addon); + static const QString contentTypeAddon + = QString::number(static_cast(ContentSelectorModel::ContentType_Addon)); QModelIndex nameIndex = sourceModel()->index(sourceRow, 0, sourceParent); const QString userRole = sourceModel()->data(nameIndex, Qt::UserRole).toString(); - return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent) && userRole == ContentTypeAddon; + return QSortFilterProxyModel::filterAcceptsRow(sourceRow, sourceParent) && userRole == contentTypeAddon; } }; diff --git a/components/crashcatcher/crashcatcher.cpp b/components/crashcatcher/crashcatcher.cpp index cf93a605bd..e460f04dcc 100644 --- a/components/crashcatcher/crashcatcher.cpp +++ b/components/crashcatcher/crashcatcher.cpp @@ -320,9 +320,9 @@ static void crash_catcher(int signum, siginfo_t* siginfo, void* /*context*/) else crash_info.siginfo = *siginfo; - const pid_t dbg_pid = fork(); + const pid_t dbgPid = fork(); /* Fork off to start a crash handler */ - switch (dbg_pid) + switch (dbgPid) { /* Error */ case -1: @@ -342,7 +342,7 @@ static void crash_catcher(int signum, siginfo_t* siginfo, void* /*context*/) default: #ifdef __linux__ - prctl(PR_SET_PTRACER, dbg_pid, 0, 0, 0); + prctl(PR_SET_PTRACER, dbgPid, 0, 0, 0); #endif safe_write(fd[1], &crash_info, sizeof(crash_info)); close(fd[0]); @@ -352,7 +352,7 @@ static void crash_catcher(int signum, siginfo_t* siginfo, void* /*context*/) do { int status; - if (waitpid(dbg_pid, &status, 0) == dbg_pid && (WIFEXITED(status) || WIFSIGNALED(status))) + if (waitpid(dbgPid, &status, 0) == dbgPid && (WIFEXITED(status) || WIFSIGNALED(status))) { /* The debug process died before it could kill us */ raise(signum); diff --git a/components/debug/debugdraw.cpp b/components/debug/debugdraw.cpp index cd98fe2b6d..e013af0e11 100644 --- a/components/debug/debugdraw.cpp +++ b/components/debug/debugdraw.cpp @@ -68,37 +68,37 @@ static void generateCube(osg::Geometry& geom, float dim) osg::ref_ptr normals = new osg::Vec3Array; osg::ref_ptr indices = new osg::DrawElementsUShort(osg::DrawElementsUShort::TRIANGLES, 0); - for (int i_face = 0; i_face < 6; i_face++) + for (int iFace = 0; iFace < 6; iFace++) { osg::Vec3f normale(0., 0., 0.); osg::Vec3f u(0., 0., 0.); osg::Vec3f v(0., 0., 0.); - int axis = i_face / 2; - int dir = i_face % 2 == 0 ? -1 : 1; - float float_dir = dir; - normale[axis] = float_dir; + int axis = iFace / 2; + int dir = iFace % 2 == 0 ? -1 : 1; + float floatDir = dir; + normale[axis] = floatDir; u[(axis + 1) % 3] = 1.0; v[(axis + 2) % 3] = 1.0; - for (int i_point = 0; i_point < 4; i_point++) + for (int iPoint = 0; iPoint < 4; iPoint++) { - float iu = i_point % 2 == 1 - ? float_dir - : -float_dir; // This is to get the right triangle orientation when the normal changes* - float iv = i_point / 2 == 1 ? 1.0 : -1.0; + float iu = iPoint % 2 == 1 + ? floatDir + : -floatDir; // This is to get the right triangle orientation when the normal changes* + float iv = iPoint / 2 == 1 ? 1.0 : -1.0; osg::Vec3f point = (u * iu) + (v * iv); point = (point + normale); point = point * (dim * 0.5f); vertices->push_back(point); normals->push_back(normale); } - int start_vertex(i_face * 4); - int newFace1[] = { start_vertex, start_vertex + 1, start_vertex + 2 }; + int startVertex(iFace * 4); + int newFace1[] = { startVertex, startVertex + 1, startVertex + 2 }; for (int i = 0; i < 3; i++) { indices->push_back(newFace1[i]); } - int newFace2[] = { start_vertex + 2, start_vertex + 1, start_vertex + 3 }; + int newFace2[] = { startVertex + 2, startVertex + 1, startVertex + 3 }; for (int i = 0; i < 3; i++) { indices->push_back(newFace2[i]); @@ -146,7 +146,7 @@ static void generateCylinder(osg::Geometry& geom, float radius, float height, in iVertex += 1; } // bottom disk - auto begin_bot = iVertex; + auto beginBot = iVertex; for (int i = 0; i < subdiv; i++) { float theta = float(i) / float(subdiv) * osg::PI * 2.; @@ -179,11 +179,11 @@ static void generateCylinder(osg::Geometry& geom, float radius, float height, in // create triangles sides for (int i = 0; i < subdiv; i++) { - auto next_vert = (i + 1) % subdiv; + auto nextVert = (i + 1) % subdiv; auto v1 = (beginSide + 2 * i); auto v2 = (beginSide + 2 * i + 1); - auto v3 = (beginSide + 2 * next_vert); - auto v4 = (beginSide + 2 * next_vert + 1); + auto v3 = (beginSide + 2 * nextVert); + auto v4 = (beginSide + 2 * nextVert + 1); indices->push_back(v1); indices->push_back(v2); indices->push_back(v4); @@ -194,12 +194,12 @@ static void generateCylinder(osg::Geometry& geom, float radius, float height, in } for (int i = 0; i < subdiv; i++) { - auto next_vert = (i + 1) % subdiv; + auto nextVert = (i + 1) % subdiv; auto top1 = (beginTop + i); - auto top2 = (beginTop + next_vert); + auto top2 = (beginTop + nextVert); - auto bot1 = (begin_bot + i); - auto bot2 = (begin_bot + next_vert); + auto bot1 = (beginBot + i); + auto bot2 = (beginBot + nextVert); indices->push_back(top2); indices->push_back(centerTop); diff --git a/components/debug/debugging.cpp b/components/debug/debugging.cpp index 4cb625c548..6a6f044eee 100644 --- a/components/debug/debugging.cpp +++ b/components/debug/debugging.cpp @@ -131,13 +131,13 @@ namespace Debug prefix[0] = '['; const auto now = std::chrono::system_clock::now(); const auto time = std::chrono::system_clock::to_time_t(now); - tm time_info{}; + tm timeInfo{}; #ifdef _WIN32 - (void)localtime_s(&time_info, &time); + (void)localtime_s(&timeInfo, &time); #else - (void)localtime_r(&time, &time_info); + (void)localtime_r(&time, &timeInfo); #endif - prefixSize = std::strftime(prefix + 1, sizeof(prefix) - 1, "%T", &time_info) + 1; + prefixSize = std::strftime(prefix + 1, sizeof(prefix) - 1, "%T", &timeInfo) + 1; char levelLetter = " EWIVD*"[int(level)]; const auto ms = std::chrono::duration_cast(now.time_since_epoch()).count(); diff --git a/components/esm3/player.cpp b/components/esm3/player.cpp index bf5864ce4c..c6db5215fb 100644 --- a/components/esm3/player.cpp +++ b/components/esm3/player.cpp @@ -64,8 +64,8 @@ namespace ESM mSaveSkills[i] = skill.mBase + skill.mMod - skill.mDamage; if (mObject.mNpcStats.mIsWerewolf) { - constexpr int Acrobatics = 20; - if (i == Acrobatics) + constexpr int acrobatics = 20; + if (i == acrobatics) mSetWerewolfAcrobatics = mObject.mNpcStats.mSkills[i].mBase != skill.mBase; mObject.mNpcStats.mSkills[i] = skill; } diff --git a/components/esm4/loadrace.cpp b/components/esm4/loadrace.cpp index 02f6f953b4..45fe876730 100644 --- a/components/esm4/loadrace.cpp +++ b/components/esm4/loadrace.cpp @@ -43,7 +43,7 @@ void ESM4::Race::load(ESM4::Reader& reader) bool isFO3 = false; bool isMale = false; - int curr_part = -1; // 0 = head, 1 = body, 2 = egt, 3 = hkx + int currPart = -1; // 0 = head, 1 = body, 2 = egt, 3 = hkx std::uint32_t currentIndex = 0xffffffff; while (reader.getSubRecordHeader()) @@ -278,7 +278,7 @@ void ESM4::Race::load(ESM4::Reader& reader) // case ESM::fourCC("NAM0"): // start marker head data /* 1 */ { - curr_part = 0; // head part + currPart = 0; // head part if (isFO3 || isFONV) { @@ -319,7 +319,7 @@ void ESM4::Race::load(ESM4::Reader& reader) { reader.skipSubRecordData(); } - else if (curr_part == 0) // head part + else if (currPart == 0) // head part { if (isMale || isTES4) reader.getZString(mHeadParts[currentIndex].mesh); @@ -328,7 +328,7 @@ void ESM4::Race::load(ESM4::Reader& reader) // TES5 keeps head part formid in mHeadPartIdsMale and mHeadPartIdsFemale } - else if (curr_part == 1) // body part + else if (currPart == 1) // body part { if (isMale) reader.getZString(mBodyPartsMale[currentIndex].mesh); @@ -359,14 +359,14 @@ void ESM4::Race::load(ESM4::Reader& reader) { reader.skipSubRecordData(); } - else if (curr_part == 0) // head part + else if (currPart == 0) // head part { if (isMale || isTES4) reader.getZString(mHeadParts[currentIndex].texture); else reader.getZString(mHeadPartsFemale[currentIndex].texture); // TODO: check TES4 } - else if (curr_part == 1) // body part + else if (currPart == 1) // body part { if (isMale) reader.getZString(mBodyPartsMale[currentIndex].texture); @@ -384,20 +384,20 @@ void ESM4::Race::load(ESM4::Reader& reader) if (isFO3 || isFONV) { - curr_part = 1; // body part + currPart = 1; // body part mBodyPartsMale.resize(4); mBodyPartsFemale.resize(4); } else if (isTES4) { - curr_part = 1; // body part + currPart = 1; // body part mBodyPartsMale.resize(5); // 0 = upper body, 1 = legs, 2 = hands, 3 = feet, 4 = tail mBodyPartsFemale.resize(5); // 0 = upper body, 1 = legs, 2 = hands, 3 = feet, 4 = tail } else // TES5 - curr_part = 2; // for TES5 NAM1 indicates the start of EGT model + currPart = 2; // for TES5 NAM1 indicates the start of EGT model if (isTES4) currentIndex = 4; // FIXME: argonian tail mesh without preceeding INDX @@ -613,7 +613,7 @@ void ESM4::Race::load(ESM4::Reader& reader) } case ESM::fourCC("NAM3"): // start of hkx model { - curr_part = 3; // for TES5 NAM3 indicates the start of hkx model + currPart = 3; // for TES5 NAM3 indicates the start of hkx model break; } diff --git a/components/esm4/loadrefr.cpp b/components/esm4/loadrefr.cpp index 5ac3a5f077..321427f782 100644 --- a/components/esm4/loadrefr.cpp +++ b/components/esm4/loadrefr.cpp @@ -54,9 +54,9 @@ void ESM4::Reference::load(ESM4::Reader& reader) break; case ESM::fourCC("NAME"): { - ESM::FormId BaseId; - reader.getFormId(BaseId); - mBaseObj = BaseId; + ESM::FormId baseId; + reader.getFormId(baseId); + mBaseObj = baseId; break; } case ESM::fourCC("DATA"): diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 1a07f6fe0a..73030ab96a 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -681,29 +681,29 @@ namespace ESMTerrain if (mAutoUseNormalMaps) { - std::string texture_ = texture; - Misc::StringUtils::replaceLast(texture_, ".", mNormalHeightMapPattern + "."); - if (mVFS->exists(texture_)) + std::string normalMapTexture = texture; + Misc::StringUtils::replaceLast(normalMapTexture, ".", mNormalHeightMapPattern + "."); + if (mVFS->exists(normalMapTexture)) { - info.mNormalMap = std::move(texture_); + info.mNormalMap = std::move(normalMapTexture); info.mParallax = true; } else { - texture_ = texture; - Misc::StringUtils::replaceLast(texture_, ".", mNormalMapPattern + "."); - if (mVFS->exists(texture_)) - info.mNormalMap = std::move(texture_); + normalMapTexture = texture; + Misc::StringUtils::replaceLast(normalMapTexture, ".", mNormalMapPattern + "."); + if (mVFS->exists(normalMapTexture)) + info.mNormalMap = std::move(normalMapTexture); } } if (mAutoUseSpecularMaps) { - std::string texture_ = texture; - Misc::StringUtils::replaceLast(texture_, ".", mSpecularMapPattern + "."); - if (mVFS->exists(texture_)) + std::string specularMapTexture = texture; + Misc::StringUtils::replaceLast(specularMapTexture, ".", mSpecularMapPattern + "."); + if (mVFS->exists(specularMapTexture)) { - info.mDiffuseMap = std::move(texture_); + info.mDiffuseMap = std::move(specularMapTexture); info.mSpecular = true; } } diff --git a/components/files/configfileparser.cpp b/components/files/configfileparser.cpp index 2f498ef736..9bf9eae066 100644 --- a/components/files/configfileparser.cpp +++ b/components/files/configfileparser.cpp @@ -11,6 +11,8 @@ #include #include +// NOLINTBEGIN(readability-identifier-naming) + namespace Files { namespace @@ -289,3 +291,5 @@ namespace Files template bpo::basic_parsed_options parse_config_file( std::basic_istream& is, const bpo::options_description& desc, bool allow_unregistered); } + +// NOLINTEND(readability-identifier-naming) diff --git a/components/files/configfileparser.hpp b/components/files/configfileparser.hpp index 72a4370d8b..de6effa64f 100644 --- a/components/files/configfileparser.hpp +++ b/components/files/configfileparser.hpp @@ -3,6 +3,8 @@ #include +// NOLINTBEGIN(readability-identifier-naming) + namespace Files { @@ -14,4 +16,6 @@ namespace Files } -#endif // COMPONENTS_FILES_CONFIGFILEPARSER_HPP \ No newline at end of file +// NOLINTEND(readability-identifier-naming) + +#endif // COMPONENTS_FILES_CONFIGFILEPARSER_HPP diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index f43c78bfd3..d2bc7359b9 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -395,8 +395,8 @@ namespace Gui if (one != 1) fail(*file, fileName, "Unexpected value"); - char name_[284]; - file->read(name_, sizeof(name_)); + char nameBuffer[284]; + file->read(nameBuffer, sizeof(nameBuffer)); if (!file->good()) fail(*file, fileName, "File too small to be a valid font"); @@ -408,7 +408,7 @@ namespace Gui file.reset(); // Create the font texture - const std::string name(name_); + const std::string name(nameBuffer); const std::string bitmapFilename = "fonts/" + name + ".tex"; Files::IStreamPtr bitmapFile = mVFS->get(bitmapFilename); diff --git a/components/lua/scriptscontainer.hpp b/components/lua/scriptscontainer.hpp index dd066d3414..8eaaf2955f 100644 --- a/components/lua/scriptscontainer.hpp +++ b/components/lua/scriptscontainer.hpp @@ -172,10 +172,10 @@ namespace LuaUtil std::optional res = std::nullopt; mLua.protectedCall([&](LuaUtil::LuaView& view) { LoadedData& data = ensureLoaded(); - auto I = data.mPublicInterfaces.get>(interfaceName); - if (I) + auto interface = data.mPublicInterfaces.get>(interfaceName); + if (interface) { - auto o = I->get_or(identifier, sol::nil); + auto o = interface->get_or(identifier, sol::nil); if (o.is()) { sol::object luaRes = o.as().call(args...); diff --git a/components/lua/utf8.cpp b/components/lua/utf8.cpp index e4188d6926..d8aa7cf295 100644 --- a/components/lua/utf8.cpp +++ b/components/lua/utf8.cpp @@ -137,13 +137,13 @@ namespace LuaUtf8 utf8["codes"] = [](std::string_view s) { return sol::as_function( - [s, pos_byte = std::vector{ 1 }]() mutable -> sol::optional> { - if (pos_byte.back() <= static_cast(s.size())) + [s, posByte = std::vector{ 1 }]() mutable -> sol::optional> { + if (posByte.back() <= static_cast(s.size())) { - const auto pair = decodeNextUTF8Character(s, pos_byte); + const auto pair = decodeNextUTF8Character(s, posByte); if (pair.second == -1) throw std::runtime_error( - "Invalid UTF-8 code at position " + std::to_string(pos_byte.size())); + "Invalid UTF-8 code at position " + std::to_string(posByte.size())); return pair; } @@ -168,14 +168,14 @@ namespace LuaUtf8 if (len == 0) return len; - std::vector pos_byte = { iv }; + std::vector posByte = { iv }; - while (pos_byte.back() <= fv) + while (posByte.back() <= fv) { - if (decodeNextUTF8Character(s, pos_byte).second == -1) - return std::pair(sol::lua_nil, pos_byte.back()); + if (decodeNextUTF8Character(s, posByte).second == -1) + return std::pair(sol::lua_nil, posByte.back()); } - return pos_byte.size() - 1; + return posByte.size() - 1; }; utf8["codepoint"] @@ -195,14 +195,14 @@ namespace LuaUtf8 if (iv > fv) return sol::as_returns(std::vector{}); /* empty interval; return nothing */ - std::vector pos_byte = { iv }; + std::vector posByte = { iv }; std::vector codepoints; - while (pos_byte.back() <= fv) + while (posByte.back() <= fv) { - codepoints.push_back(decodeNextUTF8Character(s, pos_byte).second); + codepoints.push_back(decodeNextUTF8Character(s, posByte).second); if (codepoints.back() == -1) - throw std::runtime_error("Invalid UTF-8 code at position " + std::to_string(pos_byte.size())); + throw std::runtime_error("Invalid UTF-8 code at position " + std::to_string(posByte.size())); } return sol::as_returns(std::move(codepoints)); @@ -223,23 +223,23 @@ namespace LuaUtf8 else iv = getInteger(args[0], 3, "offset"); - std::vector pos_byte = { 1 }; + std::vector posByte = { 1 }; relativePosition(iv, len); if (iv > static_cast(len) + 1) throw std::runtime_error("bad argument #3 to 'offset' (position out of bounds)"); - while (pos_byte.back() <= static_cast(len)) - decodeNextUTF8Character(s, pos_byte); + while (posByte.back() <= static_cast(len)) + decodeNextUTF8Character(s, posByte); - for (auto it = pos_byte.begin(); it != pos_byte.end(); ++it) + for (auto it = posByte.begin(); it != posByte.end(); ++it) { if (*it == iv) { - if (n <= 0 && it + n >= pos_byte.begin()) + if (n <= 0 && it + n >= posByte.begin()) return *(it + n); - if (n > 0 && it + n - 1 < pos_byte.end()) + if (n > 0 && it + n - 1 < posByte.end()) return *(it + n - 1); break; } diff --git a/components/lua/utilpackage.cpp b/components/lua/utilpackage.cpp index 2b706e1cb8..bf03789180 100644 --- a/components/lua/utilpackage.cpp +++ b/components/lua/utilpackage.cpp @@ -270,25 +270,29 @@ namespace LuaUtil return res; }); transMType[sol::meta_function::to_string] = [](const TransformM& m) { - osg::Vec3f trans, scale; - osg::Quat rotation, so; + osg::Vec3f trans; + osg::Vec3f scale; + osg::Quat rotation; + osg::Quat so; m.mM.decompose(trans, rotation, scale, so); - osg::Quat::value_type rot_angle, so_angle; - osg::Vec3f rot_axis, so_axis; - rotation.getRotate(rot_angle, rot_axis); - so.getRotate(so_angle, so_axis); + osg::Quat::value_type rotationAngle; + osg::Quat::value_type soAngle; + osg::Vec3f rotationAxis; + osg::Vec3f soAxis; + rotation.getRotate(rotationAngle, rotationAxis); + so.getRotate(soAngle, soAxis); std::stringstream ss; ss << "TransformM{ "; if (trans.length2() > 0) ss << "move(" << trans.x() << ", " << trans.y() << ", " << trans.z() << ") "; - if (rot_angle != 0) - ss << "rotation(angle=" << rot_angle << ", axis=(" << rot_axis.x() << ", " << rot_axis.y() << ", " - << rot_axis.z() << ")) "; + if (rotationAngle != 0) + ss << "rotation(angle=" << rotationAngle << ", axis=(" << rotationAxis.x() << ", " << rotationAxis.y() + << ", " << rotationAxis.z() << ")) "; if (scale.x() != 1 || scale.y() != 1 || scale.z() != 1) ss << "scale(" << scale.x() << ", " << scale.y() << ", " << scale.z() << ") "; - if (so_angle != 0) - ss << "rotation(angle=" << so_angle << ", axis=(" << so_axis.x() << ", " << so_axis.y() << ", " - << so_axis.z() << ")) "; + if (soAngle != 0) + ss << "rotation(angle=" << soAngle << ", axis=(" << soAxis.x() << ", " << soAxis.y() << ", " + << soAxis.z() << ")) "; ss << "}"; return ss.str(); }; diff --git a/components/misc/timeconvert.hpp b/components/misc/timeconvert.hpp index 6e4ad0ab2b..66d58bc7d1 100644 --- a/components/misc/timeconvert.hpp +++ b/components/misc/timeconvert.hpp @@ -24,16 +24,16 @@ namespace Misc inline std::string timeTToString(const std::time_t tp, const char* fmt) { - tm time_info{}; + tm timeInfo{}; #ifdef _WIN32 - if (const errno_t error = localtime_s(&time_info, &tp); error != 0) + if (const errno_t error = localtime_s(&timeInfo, &tp); error != 0) throw std::system_error(error, std::generic_category()); #else - if (localtime_r(&tp, &time_info) == nullptr) + if (localtime_r(&tp, &timeInfo) == nullptr) throw std::system_error(errno, std::generic_category()); #endif std::stringstream out; - out << std::put_time(&time_info, fmt); + out << std::put_time(&timeInfo, fmt); return out.str(); } diff --git a/components/myguiplatform/myguirendermanager.cpp b/components/myguiplatform/myguirendermanager.cpp index a17e387ed6..ce043c5665 100644 --- a/components/myguiplatform/myguirendermanager.cpp +++ b/components/myguiplatform/myguirendermanager.cpp @@ -473,13 +473,13 @@ namespace MyGUIPlatform void RenderManager::update() { static MyGUI::Timer timer; - static unsigned long last_time = timer.getMilliseconds(); - unsigned long now_time = timer.getMilliseconds(); - unsigned long time = now_time - last_time; + static unsigned long lastLime = timer.getMilliseconds(); + unsigned long nowTime = timer.getMilliseconds(); + unsigned long time = nowTime - lastLime; - onFrameEvent((float)((double)(time) / (double)1000)); + onFrameEvent(static_cast(static_cast(time) / 1000)); - last_time = now_time; + lastLime = nowTime; } void RenderManager::collectDrawCalls() diff --git a/components/nifosg/nifloader.cpp b/components/nifosg/nifloader.cpp index de5aa01b15..f3b85ec2fd 100644 --- a/components/nifosg/nifloader.cpp +++ b/components/nifosg/nifloader.cpp @@ -2687,8 +2687,8 @@ namespace NifOsg bool hasMatCtrl = false; bool hasSortAlpha = false; - auto setBin_BackToFront = [](osg::StateSet* ss) { ss->setRenderBinDetails(0, "SORT_BACK_TO_FRONT"); }; - auto setBin_Traversal = [](osg::StateSet* ss) { ss->setRenderBinDetails(2, "TraversalOrderBin"); }; + auto setBinBackToFront = [](osg::StateSet* ss) { ss->setRenderBinDetails(0, "SORT_BACK_TO_FRONT"); }; + auto setBinTraversal = [](osg::StateSet* ss) { ss->setRenderBinDetails(2, "TraversalOrderBin"); }; auto lightmode = Nif::NiVertexColorProperty::LightMode::LightMode_EmiAmbDif; float emissiveMult = 1.f; @@ -2888,7 +2888,7 @@ namespace NifOsg if (!mPushedSorter) { if (!hasSortAlpha && mHasStencilProperty) - setBin_Traversal(node->getOrCreateStateSet()); + setBinTraversal(node->getOrCreateStateSet()); return; } @@ -2896,19 +2896,19 @@ namespace NifOsg auto assignBin = [&](Nif::NiSortAdjustNode::SortingMode mode, int type) { if (mode == Nif::NiSortAdjustNode::SortingMode::Off) { - setBin_Traversal(stateset); + setBinTraversal(stateset); return; } if (type == Nif::RC_NiAlphaAccumulator) { if (hasSortAlpha) - setBin_BackToFront(stateset); + setBinBackToFront(stateset); else - setBin_Traversal(stateset); + setBinTraversal(stateset); } else if (type == Nif::RC_NiClusterAccumulator) - setBin_BackToFront(stateset); + setBinBackToFront(stateset); else Log(Debug::Error) << "Unrecognized NiAccumulator in " << mFilename; }; @@ -2925,7 +2925,7 @@ namespace NifOsg } case Nif::NiSortAdjustNode::SortingMode::Off: { - setBin_Traversal(stateset); + setBinTraversal(stateset); break; } case Nif::NiSortAdjustNode::SortingMode::Subsort: diff --git a/components/nifosg/particle.cpp b/components/nifosg/particle.cpp index f15678c879..53830388a5 100644 --- a/components/nifosg/particle.cpp +++ b/components/nifosg/particle.cpp @@ -550,17 +550,17 @@ namespace NifOsg for (int i = 0; i < n; ++i) { - osgParticle::Particle* P = getParticleSystem()->createParticle(nullptr); - if (P) + osgParticle::Particle* const particle = getParticleSystem()->createParticle(nullptr); + if (particle) { if (useGeometryEmitter) - P->setPosition((*geometryVertices)[Misc::Rng::rollDice(geometryVertices->getNumElements())]); + particle->setPosition((*geometryVertices)[Misc::Rng::rollDice(geometryVertices->getNumElements())]); else if (mPlacer) - mPlacer->place(P); + mPlacer->place(particle); - mShooter->shoot(P); + mShooter->shoot(particle); - P->transformPositionVelocity(emitterToPs); + particle->transformPositionVelocity(emitterToPs); } } } diff --git a/components/sceneutil/depth.cpp b/components/sceneutil/depth.cpp index 5232d321dc..93e76a89b4 100644 --- a/components/sceneutil/depth.cpp +++ b/components/sceneutil/depth.cpp @@ -16,15 +16,15 @@ namespace SceneUtil osg::Matrix getReversedZProjectionMatrixAsPerspectiveInf(double fov, double aspect, double near) { - double A = 1.0 / std::tan(osg::DegreesToRadians(fov) / 2.0); - return osg::Matrix(A / aspect, 0, 0, 0, 0, A, 0, 0, 0, 0, 0, -1, 0, 0, near, 0); + const double a = 1.0 / std::tan(osg::DegreesToRadians(fov) / 2.0); + return osg::Matrix(a / aspect, 0, 0, 0, 0, a, 0, 0, 0, 0, 0, -1, 0, 0, near, 0); } osg::Matrix getReversedZProjectionMatrixAsPerspective(double fov, double aspect, double near, double far) { - double A = 1.0 / std::tan(osg::DegreesToRadians(fov) / 2.0); + const double a = 1.0 / std::tan(osg::DegreesToRadians(fov) / 2.0); return osg::Matrix( - A / aspect, 0, 0, 0, 0, A, 0, 0, 0, 0, near / (far - near), -1, 0, 0, (far * near) / (far - near), 0); + a / aspect, 0, 0, 0, 0, a, 0, 0, 0, 0, near / (far - near), -1, 0, 0, (far * near) / (far - near), 0); } osg::Matrix getReversedZProjectionMatrixAsOrtho( diff --git a/components/sceneutil/mwshadowtechnique.cpp b/components/sceneutil/mwshadowtechnique.cpp index d456795781..5f033cb612 100644 --- a/components/sceneutil/mwshadowtechnique.cpp +++ b/components/sceneutil/mwshadowtechnique.cpp @@ -32,6 +32,8 @@ #include "glextensions.hpp" #include "shadowsbin.hpp" +// NOLINTBEGIN(readability-identifier-naming) + namespace { using namespace osgShadow; @@ -3380,4 +3382,7 @@ osg::ref_ptr SceneUtil::MWShadowTechnique::getOrCreateShadowsBinS } return _shadowsBinStateSet; } + +// NOLINTEND(readability-identifier-naming) + // clang-format on diff --git a/components/sceneutil/mwshadowtechnique.hpp b/components/sceneutil/mwshadowtechnique.hpp index 4b9de9364a..1b7307024a 100644 --- a/components/sceneutil/mwshadowtechnique.hpp +++ b/components/sceneutil/mwshadowtechnique.hpp @@ -34,6 +34,8 @@ #include +// NOLINTBEGIN(readability-identifier-naming) + namespace SceneUtil { /** ViewDependentShadowMap provides an base implementation of view dependent shadow mapping techniques.*/ @@ -339,5 +341,7 @@ namespace SceneUtil { } +// NOLINTEND(readability-identifier-naming) + #endif // clang-format on diff --git a/components/sceneutil/optimizer.cpp b/components/sceneutil/optimizer.cpp index 7822f17448..ec2f4af26f 100644 --- a/components/sceneutil/optimizer.cpp +++ b/components/sceneutil/optimizer.cpp @@ -42,6 +42,8 @@ #include +// NOLINTBEGIN(readability-identifier-naming) + using namespace osgUtil; namespace SceneUtil @@ -2057,4 +2059,7 @@ void Optimizer::MergeGroupsVisitor::apply(osg::Group &group) } } + +// NOLINTEND(readability-identifier-naming) + // clang-format on diff --git a/components/sceneutil/optimizer.hpp b/components/sceneutil/optimizer.hpp index 86a05d7549..81033fa8fd 100644 --- a/components/sceneutil/optimizer.hpp +++ b/components/sceneutil/optimizer.hpp @@ -28,6 +28,8 @@ #include #include +// NOLINTBEGIN(readability-identifier-naming) + namespace osgDB { class SharedStateManager; @@ -479,5 +481,7 @@ inline bool BaseOptimizerVisitor::isOperationPermissibleForObject(const osg::Nod } +// NOLINTEND(readability-identifier-naming) + #endif // clang-format on diff --git a/components/sceneutil/recastmesh.cpp b/components/sceneutil/recastmesh.cpp index 7491eb7c95..89712495f7 100644 --- a/components/sceneutil/recastmesh.cpp +++ b/components/sceneutil/recastmesh.cpp @@ -22,12 +22,12 @@ namespace std::vector result(indices.size()); for (std::size_t i = 0, n = indices.size(); i < n; i += 3) { - const float* v0_ptr = &vertices[indices[i] * 3]; - const float* v1_ptr = &vertices[indices[i + 1] * 3]; - const float* v2_ptr = &vertices[indices[i + 2] * 3]; - const osg::Vec3f v0(v0_ptr[0], v0_ptr[1], v0_ptr[2]); - const osg::Vec3f v1(v1_ptr[0], v1_ptr[1], v1_ptr[2]); - const osg::Vec3f v2(v2_ptr[0], v2_ptr[1], v2_ptr[2]); + const float* v0Ptr = &vertices[indices[i] * 3]; + const float* v1Ptr = &vertices[indices[i + 1] * 3]; + const float* v2Ptr = &vertices[indices[i + 2] * 3]; + const osg::Vec3f v0(v0Ptr[0], v0Ptr[1], v0Ptr[2]); + const osg::Vec3f v1(v1Ptr[0], v1Ptr[1], v1Ptr[2]); + const osg::Vec3f v2(v2Ptr[0], v2Ptr[1], v2Ptr[2]); const osg::Vec3f e0 = v1 - v0; const osg::Vec3f e1 = v2 - v0; osg::Vec3f normal = e0 ^ e1; diff --git a/components/sceneutil/shadowsbin.cpp b/components/sceneutil/shadowsbin.cpp index dd03879e8c..21179d65b2 100644 --- a/components/sceneutil/shadowsbin.cpp +++ b/components/sceneutil/shadowsbin.cpp @@ -66,18 +66,18 @@ namespace SceneUtil StateGraph* ShadowsBin::cullStateGraph( StateGraph* sg, StateGraph* root, std::unordered_set& uninterestingCache, bool cullFaceOverridden) { - std::vector return_path; + std::vector returnPath; State state; - StateGraph* sg_new = sg; + StateGraph* sgNew = sg; do { - if (uninterestingCache.find(sg_new) != uninterestingCache.end()) + if (uninterestingCache.find(sgNew) != uninterestingCache.end()) break; - return_path.push_back(sg_new); - sg_new = sg_new->_parent; - } while (sg_new && sg_new != root); + returnPath.push_back(sgNew); + sgNew = sgNew->_parent; + } while (sgNew && sgNew != root); - for (auto itr = return_path.rbegin(); itr != return_path.rend(); ++itr) + for (auto itr = returnPath.rbegin(); itr != returnPath.rend(); ++itr) { const osg::StateSet* ss = (*itr)->getStateSet(); if (!ss) @@ -134,21 +134,21 @@ namespace SceneUtil if (state.mAlphaBlend) { - sg_new = sg->find_or_insert(mShaderAlphaTestStateSet); - sg_new->_leaves = std::move(sg->_leaves); - for (RenderLeaf* leaf : sg_new->_leaves) - leaf->_parent = sg_new; - sg = sg_new; + sgNew = sg->find_or_insert(mShaderAlphaTestStateSet); + sgNew->_leaves = std::move(sg->_leaves); + for (RenderLeaf* leaf : sgNew->_leaves) + leaf->_parent = sgNew; + sg = sgNew; } // GL_ALWAYS is set by default by mwshadowtechnique if (state.mAlphaFunc && state.mAlphaFunc->getFunction() != GL_ALWAYS) { - sg_new = sg->find_or_insert(mAlphaFuncShaders[state.mAlphaFunc->getFunction() - GL_NEVER]); - sg_new->_leaves = std::move(sg->_leaves); - for (RenderLeaf* leaf : sg_new->_leaves) - leaf->_parent = sg_new; - sg = sg_new; + sgNew = sg->find_or_insert(mAlphaFuncShaders[state.mAlphaFunc->getFunction() - GL_NEVER]); + sgNew->_leaves = std::move(sg->_leaves); + for (RenderLeaf* leaf : sgNew->_leaves) + leaf->_parent = sgNew; + sg = sgNew; } return sg; diff --git a/components/sceneutil/shadowsbin.hpp b/components/sceneutil/shadowsbin.hpp index 4e5e19ee1f..81a75c8e84 100644 --- a/components/sceneutil/shadowsbin.hpp +++ b/components/sceneutil/shadowsbin.hpp @@ -1,5 +1,6 @@ #ifndef OPENMW_COMPONENTS_SCENEUTIL_SHADOWBIN_H #define OPENMW_COMPONENTS_SCENEUTIL_SHADOWBIN_H + #include #include #include diff --git a/components/sceneutil/util.hpp b/components/sceneutil/util.hpp index b320195eff..5a0280c661 100644 --- a/components/sceneutil/util.hpp +++ b/components/sceneutil/util.hpp @@ -68,19 +68,19 @@ namespace SceneUtil bsphere._center = bsphere._center * matrix; xdash -= bsphere._center; - typename VT::value_type sqrlen_xdash = xdash.length2(); + typename VT::value_type sqrlenXdash = xdash.length2(); ydash -= bsphere._center; - typename VT::value_type sqrlen_ydash = ydash.length2(); + typename VT::value_type sqrlenYdash = ydash.length2(); zdash -= bsphere._center; - typename VT::value_type sqrlen_zdash = zdash.length2(); + typename VT::value_type sqrlenZdash = zdash.length2(); - bsphere._radius = sqrlen_xdash; - if (bsphere._radius < sqrlen_ydash) - bsphere._radius = sqrlen_ydash; - if (bsphere._radius < sqrlen_zdash) - bsphere._radius = sqrlen_zdash; + bsphere._radius = sqrlenXdash; + if (bsphere._radius < sqrlenYdash) + bsphere._radius = sqrlenYdash; + if (bsphere._radius < sqrlenZdash) + bsphere._radius = sqrlenZdash; bsphere._radius = sqrtf(bsphere._radius); } diff --git a/components/sdlutil/sdlcursormanager.cpp b/components/sdlutil/sdlcursormanager.cpp index aae6c2350a..caeefcb1e3 100644 --- a/components/sdlutil/sdlcursormanager.cpp +++ b/components/sdlutil/sdlcursormanager.cpp @@ -35,12 +35,12 @@ namespace SDLUtil SDLCursorManager::~SDLCursorManager() { - CursorMap::const_iterator curs_iter = mCursorMap.begin(); + CursorMap::const_iterator cursIter = mCursorMap.begin(); - while (curs_iter != mCursorMap.end()) + while (cursIter != mCursorMap.end()) { - SDL_FreeCursor(curs_iter->second); - ++curs_iter; + SDL_FreeCursor(cursIter->second); + ++cursIter; } mCursorMap.clear(); diff --git a/components/sdlutil/sdlinputwrapper.cpp b/components/sdlutil/sdlinputwrapper.cpp index 104f83fc6d..5786517b88 100644 --- a/components/sdlutil/sdlinputwrapper.cpp +++ b/components/sdlutil/sdlinputwrapper.cpp @@ -403,12 +403,12 @@ namespace SDLUtil SDL_GetWindowSize(mSDLWindow, &width, &height); - const int FUDGE_FACTOR_X = width / 4; - const int FUDGE_FACTOR_Y = height / 4; + const int fudgeFactorX = width / 4; + const int fudgeFactorY = height / 4; // warp the mouse if it's about to go outside the window - if (evt.x - FUDGE_FACTOR_X < 0 || evt.x + FUDGE_FACTOR_X > width || evt.y - FUDGE_FACTOR_Y < 0 - || evt.y + FUDGE_FACTOR_Y > height) + if (evt.x - fudgeFactorX < 0 || evt.x + fudgeFactorX > width || evt.y - fudgeFactorY < 0 + || evt.y + fudgeFactorY > height) { warpMouse(width / 2, height / 2); } @@ -417,37 +417,37 @@ namespace SDLUtil /// \brief Package mouse and mousewheel motions into a single event MouseMotionEvent InputWrapper::_packageMouseMotion(const SDL_Event& evt) { - MouseMotionEvent pack_evt = {}; - pack_evt.x = mMouseX * mScaleX; - pack_evt.y = mMouseY * mScaleY; - pack_evt.z = mMouseZ; + MouseMotionEvent packEvt = {}; + packEvt.x = mMouseX * mScaleX; + packEvt.y = mMouseY * mScaleY; + packEvt.z = mMouseZ; if (evt.type == SDL_MOUSEMOTION) { - pack_evt.x = mMouseX = evt.motion.x * mScaleX; - pack_evt.y = mMouseY = evt.motion.y * mScaleY; - pack_evt.xrel = evt.motion.xrel * mScaleX; - pack_evt.yrel = evt.motion.yrel * mScaleY; - pack_evt.type = SDL_MOUSEMOTION; + packEvt.x = mMouseX = evt.motion.x * mScaleX; + packEvt.y = mMouseY = evt.motion.y * mScaleY; + packEvt.xrel = evt.motion.xrel * mScaleX; + packEvt.yrel = evt.motion.yrel * mScaleY; + packEvt.type = SDL_MOUSEMOTION; if (mFirstMouseMove) { // first event should be treated as non-relative, since there's no point of reference // SDL then (incorrectly) uses (0,0) as point of reference, on Linux at least... - pack_evt.xrel = pack_evt.yrel = 0; + packEvt.xrel = packEvt.yrel = 0; mFirstMouseMove = false; } } else if (evt.type == SDL_MOUSEWHEEL) { - mMouseZ += pack_evt.zrel = (evt.wheel.y * 120); - pack_evt.z = mMouseZ; - pack_evt.type = SDL_MOUSEWHEEL; + mMouseZ += packEvt.zrel = (evt.wheel.y * 120); + packEvt.z = mMouseZ; + packEvt.type = SDL_MOUSEWHEEL; } else { throw std::runtime_error("Tried to package non-motion event!"); } - return pack_evt; + return packEvt; } } diff --git a/components/shader/shadermanager.cpp b/components/shader/shadermanager.cpp index 96d6346149..acc6924f08 100644 --- a/components/shader/shadermanager.cpp +++ b/components/shader/shadermanager.cpp @@ -458,9 +458,8 @@ namespace Shader bool threadsRunningToStop = false; for (auto& [pathShaderToTest, shaderKeys] : mShaderFiles) { - - std::filesystem::file_time_type write_time = std::filesystem::last_write_time(pathShaderToTest); - if (write_time.time_since_epoch() > mLastAutoRecompileTime.time_since_epoch()) + const std::filesystem::file_time_type writeTime = std::filesystem::last_write_time(pathShaderToTest); + if (writeTime.time_since_epoch() > mLastAutoRecompileTime.time_since_epoch()) { if (!threadsRunningToStop) { diff --git a/components/terrain/terraindrawable.cpp b/components/terrain/terraindrawable.cpp index 785d56be2a..65f7aaf98b 100644 --- a/components/terrain/terraindrawable.cpp +++ b/components/terrain/terraindrawable.cpp @@ -45,20 +45,18 @@ namespace Terrain // !osgfixpotential! bool clusterCull(osg::ClusterCullingCallback* cb, const osg::Vec3f& eyePoint, bool shadowcam) { - float _deviation = cb->getDeviation(); - const osg::Vec3& _controlPoint = cb->getControlPoint(); - osg::Vec3 _normal = cb->getNormal(); + const float deviation = cb->getDeviation(); + const osg::Vec3& controlPoint = cb->getControlPoint(); + osg::Vec3 normal = cb->getNormal(); if (shadowcam) - _normal = _normal * -1; // inverting for shadowcam frontfaceculing - float _radius = cb->getRadius(); - if (_deviation <= -1.0f) + normal = normal * -1; // inverting for shadowcam frontfaceculing + if (deviation <= -1.0f) return false; - osg::Vec3 eye_cp = eyePoint - _controlPoint; - float radius = eye_cp.length(); - if (radius < _radius) + const osg::Vec3 eyeControlPoint = eyePoint - controlPoint; + const float radius = eyeControlPoint.length(); + if (radius < cb->getRadius()) return false; - float deviation = (eye_cp * _normal) / radius; - return deviation < _deviation; + return (eyeControlPoint * normal) / radius < deviation; } void TerrainDrawable::cull(osgUtil::CullVisitor* cv) diff --git a/components/translation/translation.cpp b/components/translation/translation.cpp index 517a60512f..36cca02fcc 100644 --- a/components/translation/translation.cpp +++ b/components/translation/translation.cpp @@ -51,11 +51,11 @@ namespace Translation { const std::string_view utf8 = mEncoder->getUtf8(line); - size_t tab_pos = utf8.find('\t'); - if (tab_pos != std::string::npos && tab_pos > 0 && tab_pos < utf8.size() - 1) + size_t tabPos = utf8.find('\t'); + if (tabPos != std::string::npos && tabPos > 0 && tabPos < utf8.size() - 1) { - const std::string_view key = utf8.substr(0, tab_pos); - const std::string_view value = utf8.substr(tab_pos + 1); + const std::string_view key = utf8.substr(0, tabPos); + const std::string_view value = utf8.substr(tabPos + 1); if (!key.empty() && !value.empty()) container.emplace(key, value); diff --git a/components/widgets/box.cpp b/components/widgets/box.cpp index d711925656..25965b7b1e 100644 --- a/components/widgets/box.cpp +++ b/components/widgets/box.cpp @@ -177,9 +177,9 @@ namespace Gui void HBox::align() { unsigned int count = getChildCount(); - size_t h_stretched_count = 0; - int total_width = 0; - int total_height = 0; + size_t hStretchedCount = 0; + int totalWidth = 0; + int totalHeight = 0; std::vector> sizes; sizes.resize(count); @@ -190,33 +190,33 @@ namespace Gui bool hidden = w->getUserString("Hidden") == "true"; if (hidden) continue; - h_stretched_count += hstretch; + hStretchedCount += hstretch; AutoSizedWidget* aw = dynamic_cast(w); if (aw) { sizes[i] = std::make_pair(aw->getRequestedSize(), hstretch); - total_width += aw->getRequestedSize().width; - total_height = std::max(total_height, aw->getRequestedSize().height); + totalWidth += aw->getRequestedSize().width; + totalHeight = std::max(totalHeight, aw->getRequestedSize().height); } else { sizes[i] = std::make_pair(w->getSize(), hstretch); - total_width += w->getSize().width; + totalWidth += w->getSize().width; if (!(w->getUserString("VStretch") == "true")) - total_height = std::max(total_height, w->getSize().height); + totalHeight = std::max(totalHeight, w->getSize().height); } if (i != count - 1) - total_width += mSpacing; + totalWidth += mSpacing; } if (mAutoResize - && (total_width + mPadding * 2 != getClientCoord().width - || total_height + mPadding * 2 != getClientCoord().height)) + && (totalWidth + mPadding * 2 != getClientCoord().width + || totalHeight + mPadding * 2 != getClientCoord().height)) { int xmargin = getSize().width - getClientCoord().width; int ymargin = getSize().height - getClientCoord().height; - setSize(MyGUI::IntSize(total_width + mPadding * 2 + xmargin, total_height + mPadding * 2 + ymargin)); + setSize(MyGUI::IntSize(totalWidth + mPadding * 2 + xmargin, totalHeight + mPadding * 2 + ymargin)); return; } @@ -233,8 +233,8 @@ namespace Gui continue; bool vstretch = w->getUserString("VStretch") == "true"; - int max_height = getClientCoord().height - mPadding * 2; - int height = vstretch ? max_height : sizes[i].first.height; + int maxHeight = getClientCoord().height - mPadding * 2; + int height = vstretch ? maxHeight : sizes[i].first.height; MyGUI::IntCoord widgetCoord; widgetCoord.left = curX; @@ -243,10 +243,9 @@ namespace Gui int width = 0; if (sizes[i].second) { - if (h_stretched_count == 0) + if (hStretchedCount == 0) throw std::logic_error("unexpected"); - width - = sizes[i].first.width + (getClientCoord().width - mPadding * 2 - total_width) / h_stretched_count; + width = sizes[i].first.width + (getClientCoord().width - mPadding * 2 - totalWidth) / hStretchedCount; } else width = sizes[i].first.width; @@ -330,9 +329,9 @@ namespace Gui void VBox::align() { unsigned int count = getChildCount(); - size_t v_stretched_count = 0; - int total_height = 0; - int total_width = 0; + size_t vStretchedCount = 0; + int totalHeight = 0; + int totalWidth = 0; std::vector> sizes; sizes.resize(count); for (unsigned int i = 0; i < count; ++i) @@ -344,34 +343,34 @@ namespace Gui continue; bool vstretch = w->getUserString("VStretch") == "true"; - v_stretched_count += vstretch; + vStretchedCount += vstretch; AutoSizedWidget* aw = dynamic_cast(w); if (aw) { sizes[i] = std::make_pair(aw->getRequestedSize(), vstretch); - total_height += aw->getRequestedSize().height; - total_width = std::max(total_width, aw->getRequestedSize().width); + totalHeight += aw->getRequestedSize().height; + totalWidth = std::max(totalWidth, aw->getRequestedSize().width); } else { sizes[i] = std::make_pair(w->getSize(), vstretch); - total_height += w->getSize().height; + totalHeight += w->getSize().height; if (!(w->getUserString("HStretch") == "true")) - total_width = std::max(total_width, w->getSize().width); + totalWidth = std::max(totalWidth, w->getSize().width); } if (i != count - 1) - total_height += mSpacing; + totalHeight += mSpacing; } if (mAutoResize - && (total_width + mPadding * 2 != getClientCoord().width - || total_height + mPadding * 2 != getClientCoord().height)) + && (totalWidth + mPadding * 2 != getClientCoord().width + || totalHeight + mPadding * 2 != getClientCoord().height)) { int xmargin = getSize().width - getClientCoord().width; int ymargin = getSize().height - getClientCoord().height; - setSize(MyGUI::IntSize(total_width + mPadding * 2 + xmargin, total_height + mPadding * 2 + ymargin)); + setSize(MyGUI::IntSize(totalWidth + mPadding * 2 + xmargin, totalHeight + mPadding * 2 + ymargin)); return; } @@ -398,10 +397,10 @@ namespace Gui int height = 0; if (sizes[i].second) { - if (v_stretched_count == 0) + if (vStretchedCount == 0) throw std::logic_error("unexpected"); - height = sizes[i].first.height - + (getClientCoord().height - mPadding * 2 - total_height) / v_stretched_count; + height + = sizes[i].first.height + (getClientCoord().height - mPadding * 2 - totalHeight) / vStretchedCount; } else height = sizes[i].first.height; diff --git a/components/widgets/list.cpp b/components/widgets/list.cpp index 739d50bff2..33d2948408 100644 --- a/components/widgets/list.cpp +++ b/components/widgets/list.cpp @@ -46,8 +46,8 @@ namespace Gui void MWList::redraw(bool scrollbarShown) { - constexpr int _scrollBarWidth = 20; // fetch this from skin? - const int scrollBarWidth = scrollbarShown ? _scrollBarWidth : 0; + constexpr int scrollbarShownScrollBarWidth = 20; // fetch this from skin? + const int scrollBarWidth = scrollbarShown ? scrollbarShownScrollBarWidth : 0; int viewPosition = -mScrollView->getViewOffset().top; while (mScrollView->getChildCount())