Merge branch 'local_variable_naming' into 'master'

Fix and enforce local variable naming (#8424)

See merge request OpenMW/openmw!4832
This commit is contained in:
Evil Eye 2025-08-06 17:50:33 +00:00
commit 60d5e4d30b
122 changed files with 828 additions and 801 deletions

View File

@ -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

View File

@ -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}

View File

@ -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)
{

View File

@ -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");

View File

@ -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<int>("aa"), 1);
EXPECT_EQ(t.get<bool>("ab"), true);
@ -185,8 +185,8 @@ namespace
EXPECT_EQ(t.get<osg::Vec2f>(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");

View File

@ -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)
{

View File

@ -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;
}

View File

@ -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;
}
};

View File

@ -15,7 +15,7 @@ int main(int argc, char** argv)
{
bpo::options_description desc(R"(Syntax: openmw-essimporter <options> 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<Files::MaybeQuotedPath>(), "morrowind .ess save file");
@ -23,12 +23,13 @@ Allowed options)");
addOption("compare,c", "compare two .ess files");
addOption("encoding", boost::program_options::value<std::string>()->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"))

View File

@ -43,10 +43,10 @@ std::vector<std::string> 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)

View File

@ -326,10 +326,10 @@ MwIniImporter::multistrmap MwIniImporter::loadIniFile(const std::filesystem::pat
continue;
}
int comment_pos = static_cast<int>(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<int>(utf8.find('='));

View File

@ -62,7 +62,7 @@ int wmain(int argc, wchar_t* wargv[])
try
{
bpo::options_description desc("Syntax: openmw-iniimporter <options> 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"))

View File

@ -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"))
{

View File

@ -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;
}

View File

@ -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())

View File

@ -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;
}

View File

@ -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<int, int> 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<int, int> 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];

View File

@ -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<const CSMWorld::Record<ESM::CreatureLevList>&>(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<ESM::CreatureLevList>(CreatureLevList, messages, id.toString());
listCheck<ESM::CreatureLevList>(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<const CSMWorld::Record<ESM::ItemLevList>&>(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, ItemLevList.mId);
const ESM::ItemLevList& itemLevList = (dynamic_cast<const CSMWorld::Record<ESM::ItemLevList>&>(baseRecord)).get();
CSMWorld::UniversalId id(CSMWorld::UniversalId::Type_ItemLevelledList, itemLevList.mId);
listCheck<ESM::ItemLevList>(ItemLevList, messages, id.toString());
listCheck<ESM::ItemLevList>(itemLevList, messages, id.toString());
}
void CSMTools::ReferenceableCheckStage::lightCheck(

View File

@ -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<const Record<ESM::Armor>&>(record).get();

View File

@ -86,14 +86,14 @@ namespace CSMWorld
QVariant LandNormalsColumn::get(const Record<Land>& 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<Land>& 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<Land>& 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<Land>& 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];
}

View File

@ -345,9 +345,9 @@ void CSMWorld::ConstInfoSelectWrapper::updateComparisonType()
std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getConditionIntRange() const
{
const int IntMax = std::numeric_limits<int>::max();
const int IntMin = std::numeric_limits<int>::min();
const std::pair<int, int> InvalidRange(IntMax, IntMin);
const int intMax = std::numeric_limits<int>::max();
const int intMin = std::numeric_limits<int>::min();
const std::pair<int, int> invalidRange(intMax, intMin);
int value = std::get<int>(mConstSelect.mValue);
@ -358,31 +358,31 @@ std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getConditionIntRange() con
return std::pair<int, int>(value, value);
case ESM::DialogueCondition::Comp_Gt:
if (value == IntMax)
if (value == intMax)
{
return InvalidRange;
return invalidRange;
}
else
{
return std::pair<int, int>(value + 1, IntMax);
return std::pair<int, int>(value + 1, intMax);
}
break;
case ESM::DialogueCondition::Comp_Ge:
return std::pair<int, int>(value, IntMax);
return std::pair<int, int>(value, intMax);
case ESM::DialogueCondition::Comp_Ls:
if (value == IntMin)
if (value == intMin)
{
return InvalidRange;
return invalidRange;
}
else
{
return std::pair<int, int>(IntMin, value - 1);
return std::pair<int, int>(intMin, value - 1);
}
case ESM::DialogueCondition::Comp_Le:
return std::pair<int, int>(IntMin, value);
return std::pair<int, int>(intMin, value);
default:
throw std::logic_error("InfoSelectWrapper: relation does not have a range");
@ -391,9 +391,9 @@ std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getConditionIntRange() con
std::pair<float, float> CSMWorld::ConstInfoSelectWrapper::getConditionFloatRange() const
{
const float FloatMax = std::numeric_limits<float>::infinity();
const float FloatMin = -std::numeric_limits<float>::infinity();
const float Epsilon = std::numeric_limits<float>::epsilon();
const float floatMax = std::numeric_limits<float>::infinity();
const float floatMin = -std::numeric_limits<float>::infinity();
const float epsilon = std::numeric_limits<float>::epsilon();
float value = std::get<float>(mConstSelect.mValue);
@ -404,16 +404,16 @@ std::pair<float, float> CSMWorld::ConstInfoSelectWrapper::getConditionFloatRange
return std::pair<float, float>(value, value);
case ESM::DialogueCondition::Comp_Gt:
return std::pair<float, float>(value + Epsilon, FloatMax);
return std::pair<float, float>(value + epsilon, floatMax);
case ESM::DialogueCondition::Comp_Ge:
return std::pair<float, float>(value, FloatMax);
return std::pair<float, float>(value, floatMax);
case ESM::DialogueCondition::Comp_Ls:
return std::pair<float, float>(FloatMin, value - Epsilon);
return std::pair<float, float>(floatMin, value - epsilon);
case ESM::DialogueCondition::Comp_Le:
return std::pair<float, float>(FloatMin, value);
return std::pair<float, float>(floatMin, value);
default:
throw std::logic_error("InfoSelectWrapper: given relation does not have a range");
@ -422,8 +422,8 @@ std::pair<float, float> CSMWorld::ConstInfoSelectWrapper::getConditionFloatRange
std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const
{
const int IntMax = std::numeric_limits<int>::max();
const int IntMin = std::numeric_limits<int>::min();
const int intMax = std::numeric_limits<int>::max();
const int intMin = std::numeric_limits<int>::min();
switch (getFunctionName())
{
@ -455,7 +455,7 @@ std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const
case ESM::DialogueCondition::Function_Reputation:
case ESM::DialogueCondition::Function_PcReputation:
case ESM::DialogueCondition::Function_Journal:
return std::pair<int, int>(IntMin, IntMax);
return std::pair<int, int>(intMin, intMax);
case ESM::DialogueCondition::Function_Item:
case ESM::DialogueCondition::Function_Dead:
@ -500,7 +500,7 @@ std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const
case ESM::DialogueCondition::Function_PcLuck:
case ESM::DialogueCondition::Function_Level:
case ESM::DialogueCondition::Function_PcWerewolfKills:
return std::pair<int, int>(0, IntMax);
return std::pair<int, int>(0, intMax);
case ESM::DialogueCondition::Function_Fight:
case ESM::DialogueCondition::Function_Hello:
@ -530,12 +530,12 @@ std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const
case ESM::DialogueCondition::Function_Global:
case ESM::DialogueCondition::Function_Local:
case ESM::DialogueCondition::Function_NotLocal:
return std::pair<int, int>(IntMin, IntMax);
return std::pair<int, int>(intMin, intMax);
case ESM::DialogueCondition::Function_PcMagicka:
case ESM::DialogueCondition::Function_PcFatigue:
case ESM::DialogueCondition::Function_PcHealth:
return std::pair<int, int>(0, IntMax);
return std::pair<int, int>(0, intMax);
case ESM::DialogueCondition::Function_Health_Percent:
case ESM::DialogueCondition::Function_PcHealthPercent:
@ -548,8 +548,8 @@ std::pair<int, int> CSMWorld::ConstInfoSelectWrapper::getValidIntRange() const
std::pair<float, float> CSMWorld::ConstInfoSelectWrapper::getValidFloatRange() const
{
const float FloatMax = std::numeric_limits<float>::infinity();
const float FloatMin = -std::numeric_limits<float>::infinity();
const float floatMax = std::numeric_limits<float>::infinity();
const float floatMin = -std::numeric_limits<float>::infinity();
switch (getFunctionName())
{
@ -557,12 +557,12 @@ std::pair<float, float> CSMWorld::ConstInfoSelectWrapper::getValidFloatRange() c
case ESM::DialogueCondition::Function_Global:
case ESM::DialogueCondition::Function_Local:
case ESM::DialogueCondition::Function_NotLocal:
return std::pair<float, float>(FloatMin, FloatMax);
return std::pair<float, float>(floatMin, floatMax);
case ESM::DialogueCondition::Function_PcMagicka:
case ESM::DialogueCondition::Function_PcFatigue:
case ESM::DialogueCondition::Function_PcHealth:
return std::pair<float, float>(0, FloatMax);
return std::pair<float, float>(0, floatMax);
case ESM::DialogueCondition::Function_Health_Percent:
case ESM::DialogueCondition::Function_PcHealthPercent:

View File

@ -1054,14 +1054,14 @@ namespace CSMWorld
QVariant RegionWeatherAdapter::getData(const Record<ESM::Region>& 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)
{

View File

@ -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;

View File

@ -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<osgUtil::LineSegmentIntersector> 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;

View File

@ -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");

View File

@ -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);
}

View File

@ -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)
{

View File

@ -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

View File

@ -318,10 +318,10 @@ void CSVRender::TerrainTextureMode::editTerrainTextureGrid(const WorldspaceHitRe
{
}
std::pair<CSMWorld::CellCoordinates, bool> cellCoordinates_pair = CSMWorld::CellCoordinates::fromId(mCellId);
std::pair<CSMWorld::CellCoordinates, bool> 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<float>(mBrushSize) / 2;

View File

@ -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());
}

View File

@ -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));
}
}

View File

@ -33,12 +33,12 @@ QValidator::State CSVWorld::IdValidator::validate(QString& input, int& pos) cons
if (!mNamespace.empty())
{
std::string namespace_ = input.left(static_cast<int>(mNamespace.size())).toUtf8().constData();
const std::string namespaceName = input.left(static_cast<int>(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

View File

@ -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

View File

@ -22,22 +22,22 @@ namespace CSVWorld
, mX(nullptr)
, mY(nullptr)
{
const int MaxInt = std::numeric_limits<int>::max();
const int MinInt = std::numeric_limits<int>::min();
const int maxInt = std::numeric_limits<int>::max();
const int minInt = std::numeric_limits<int>::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);

View File

@ -493,12 +493,13 @@ void OMW::Engine::createWindow()
const SDLUtil::VSyncMode vsync = Settings::video().mVsyncMode;
unsigned antialiasing = static_cast<unsigned>(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())

View File

@ -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;

View File

@ -85,7 +85,7 @@ namespace MWClass
{
const MWWorld::LiveCellRef<ESM::Armor>* ref = ptr.get<ESM::Armor>();
std::vector<int> slots_;
std::vector<int> 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<std::vector<int>, bool> slots_ = getEquipmentSlots(ptr);
std::pair<std::vector<int>, 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<int>::const_iterator slot = slots_.first.begin(); slot != slots_.first.end(); ++slot)
for (std::vector<int>::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)

View File

@ -66,12 +66,12 @@ namespace MWClass
{
const MWWorld::LiveCellRef<ESM::Clothing>* ref = ptr.get<ESM::Clothing>();
std::vector<int> slots_;
std::vector<int> 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<std::vector<int>, bool> slots_ = getEquipmentSlots(ptr);
std::pair<std::vector<int>, bool> slots = getEquipmentSlots(ptr);
if (slots_.first.empty())
if (slots.first.empty())
return { 0, {} };
if (npc.getClass().isNpc())

View File

@ -113,12 +113,12 @@ namespace MWClass
{
const MWWorld::LiveCellRef<ESM::Light>* ref = ptr.get<ESM::Light>();
std::vector<int> slots_;
std::vector<int> 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

View File

@ -63,11 +63,11 @@ namespace MWClass
std::pair<std::vector<int>, bool> Lockpick::getEquipmentSlots(const MWWorld::ConstPtr& ptr) const
{
std::vector<int> slots_;
std::vector<int> slots;
slots_.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight));
slots.push_back(static_cast<int>(MWWorld::InventoryStore::Slot_CarriedRight));
return std::make_pair(slots_, false);
return std::make_pair(slots, false);
}
int Lockpick::getValue(const MWWorld::ConstPtr& ptr) const

View File

@ -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<ESM::Class>().find(npc->mClass);
const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().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<ESM::Class>().find(npc->mClass);
const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().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<ESM::NPC>()->mBase;
if (npc->mFlags & ESM::NPC::Autocalc)
{
const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass);
return class_->mData.mServices;
const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass);
return npcClass->mData.mServices;
}
return npc->mAiData.mServices;
}

View File

@ -62,11 +62,11 @@ namespace MWClass
std::pair<std::vector<int>, bool> Probe::getEquipmentSlots(const MWWorld::ConstPtr& ptr) const
{
std::vector<int> slots_;
std::vector<int> slots;
slots_.push_back(int(MWWorld::InventoryStore::Slot_CarriedRight));
slots.push_back(static_cast<int>(MWWorld::InventoryStore::Slot_CarriedRight));
return std::make_pair(slots_, false);
return std::make_pair(slots, false);
}
int Probe::getValue(const MWWorld::ConstPtr& ptr) const

View File

@ -86,23 +86,23 @@ namespace MWClass
const MWWorld::LiveCellRef<ESM::Weapon>* ref = ptr.get<ESM::Weapon>();
ESM::WeaponType::Class weapClass = MWMechanics::getWeaponType(ref->mBase->mData.mType)->mWeaponClass;
std::vector<int> slots_;
std::vector<int> 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<std::vector<int>, bool> slots_ = getEquipmentSlots(ptr);
std::pair<std::vector<int>, bool> slots = getEquipmentSlots(ptr);
if (slots_.first.empty())
if (slots.first.empty())
return { 0, {} };
int type = ptr.get<ESM::Weapon>()->mBase->mData.mType;

View File

@ -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);

View File

@ -16,27 +16,28 @@ namespace MWDialogue
std::vector<Token> parseHyperText(const std::string& text)
{
std::vector<Token> 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;
}
}

View File

@ -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<StyleImpl*>(baseStyle);
StyleImpl* const baseStyleImpl = static_cast<StyleImpl*>(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<StyleImpl*>(style), begin_, end_);
writeImpl(static_cast<StyleImpl*>(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<int>(info.advance + info.bearingX);
spaceWidth += static_cast<int>(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<int>(info.advance + info.bearingX);
wordWidth += static_cast<int>(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<TextFormat>(Font, this_);
auto textFormat = std::make_unique<TextFormat>(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<float>(mCoord.left),
static_cast<float>(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<int>(renderXform.clipTop));
const int visitBottom = std::min(mViewBottom, mViewTop + static_cast<int>(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);
}

View File

@ -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("\" "));
}

View File

@ -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

View File

@ -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();

View File

@ -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;

View File

@ -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()

View File

@ -59,11 +59,10 @@ namespace MWGui
void LoadingScreen::findSplashScreens()
{
auto isSupportedExtension = [](const std::string_view& ext) {
static const std::array<std::string, 7> supported_extensions{ { "tga", "dds", "ktx", "png", "bmp", "jpeg",
static const std::array<std::string, 7> 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/");

View File

@ -1100,13 +1100,13 @@ namespace MWGui
MapMarkerType mapMarkerWidget = { osg::Vec2f(x, y), createMarker(name, x, y, 0) };
mGlobalMapMarkers.emplace(mapMarkerWidget, std::vector<MapMarkerType>());
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<MapMarkerType>{ entry });
}
else

View File

@ -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:

View File

@ -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<ESM::Class>().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.
}

View File

@ -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<ESM::Attribute>())
{
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<ESM::RefId>& expelled = PCstats.getExpelled();
const MWMechanics::NpcStats& playerStats = playerPtr.getClass().getNpcStats(playerPtr);
const std::set<ESM::RefId>& expelled = playerStats.getExpelled();
bool firstFaction = true;
for (const auto& [factionId, factionRank] : mFactions)

View File

@ -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
{

View File

@ -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<int>(d / fTravelMult);

View File

@ -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<MyGUI::Colour>(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);
}
}

View File

@ -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<float>(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

View File

@ -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<double>(system_time.time_since_epoch()).count();
slotInfo["creationTime"] = std::chrono::duration<double>(systemTime.time_since_epoch()).count();
}
slotInfo["contentFiles"] = contentFiles;

View File

@ -31,14 +31,14 @@ namespace MWLua
static std::pair<MWWorld::ContainerStoreIterator, bool> 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<ObjectId>(item))
{
itemPtr = MWBase::Environment::get().getWorldModel()->getPtr(std::get<ObjectId>(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<const MWWorld::ContainerStore*>(&store))
{
@ -50,8 +50,8 @@ namespace MWLua
{
const auto& stringId = std::get<std::string>(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)

View File

@ -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;

View File

@ -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;
}
}

View File

@ -186,9 +186,9 @@ namespace MWMechanics
// class
if (mClassSelected)
{
const ESM::Class* class_ = esmStore.get<ESM::Class>().find(player->mClass);
const ESM::Class* playerClass = esmStore.get<ESM::Class>().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<ESM::Skill>())
{
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<ESM::NPC>()->mBase;
player.mClass = ptr->mId;

View File

@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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);
}

View File

@ -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

View File

@ -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<const btConvexShape*>(shape), from_, to_, resultCallback);
collisionWorld->convexSweepTest(static_cast<const btConvexShape*>(shape), btTransform(btrot, btFrom),
btTransform(btrot, btTo), resultCallback);
projectile.mPosition
= Misc::Convert::toOsg(projectile.mProjectile->isActive() ? btTo : resultCallback.m_hitPointWorld);

View File

@ -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();

View File

@ -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);

View File

@ -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<const ESM::BodyPart*>& 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())

View File

@ -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
{

View File

@ -295,8 +295,8 @@ namespace MWScript
std::string_view InterpreterContext::getNPCClass() const
{
const ESM::NPC* npc = getReferenceImp().get<ESM::NPC>()->mBase;
const ESM::Class* class_ = MWBase::Environment::get().getESMStore()->get<ESM::Class>().find(npc->mClass);
return class_->mName;
const ESM::Class* npcClass = MWBase::Environment::get().getESMStore()->get<ESM::Class>().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<ESM::NPC>()->mBase->mClass;
return world->getStore().get<ESM::Class>().find(class_)->mName;
const ESM::RefId& playerClass = world->getPlayerPtr().get<ESM::NPC>()->mBase->mClass;
return world->getStore().get<ESM::Class>().find(playerClass)->mName;
}
std::string_view InterpreterContext::getPCRank() const

View File

@ -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()));

View File

@ -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

View File

@ -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<size_t>(static_cast<ssize_t>(mAudioClock * mAudioContext->sample_rate) - clockDelay);
}
std::string getStreamName()

View File

@ -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);

View File

@ -46,8 +46,8 @@ namespace MWWorld
}
// slots that this item can be equipped in
std::pair<std::vector<int>, bool> slots_ = getTarget().getClass().getEquipmentSlots(getTarget());
if (slots_.first.empty())
std::pair<std::vector<int>, 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<int>::const_iterator slot = slots_.first.begin();
for (; slot != slots_.first.end(); ++slot)
std::vector<int>::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)));
}

View File

@ -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<std::vector<int>, bool> slots_;
std::pair<std::vector<int>, 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();
}

View File

@ -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();

View File

@ -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<ESM::RefId>::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;
}

View File

@ -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");

View File

@ -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();

View File

@ -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<char>(in.peek());
@ -158,7 +158,7 @@ namespace Compiler
mLength = length;
in.seekg(p_orig);
in.seekg(pOrig);
return true;
}

View File

@ -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<EsmFile*>(item);
EsmFile* const nonConstFilePtr = const_cast<EsmFile*>(item);
if (item)
return index(mFiles.indexOf(non_const_file_ptr), 0);
return index(mFiles.indexOf(nonConstFilePtr), 0);
return QModelIndex();
}

View File

@ -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<int>(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;
}
};

View File

@ -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);

View File

@ -68,37 +68,37 @@ static void generateCube(osg::Geometry& geom, float dim)
osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array;
osg::ref_ptr<osg::DrawElementsUShort> 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);

View File

@ -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<std::chrono::milliseconds>(now.time_since_epoch()).count();

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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"):

View File

@ -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;
}
}

View File

@ -11,6 +11,8 @@
#include <boost/program_options/detail/config_file.hpp>
#include <boost/program_options/detail/convert.hpp>
// NOLINTBEGIN(readability-identifier-naming)
namespace Files
{
namespace
@ -289,3 +291,5 @@ namespace Files
template bpo::basic_parsed_options<char> parse_config_file(
std::basic_istream<char>& is, const bpo::options_description& desc, bool allow_unregistered);
}
// NOLINTEND(readability-identifier-naming)

View File

@ -3,6 +3,8 @@
#include <boost/program_options/parsers.hpp>
// NOLINTBEGIN(readability-identifier-naming)
namespace Files
{
@ -14,4 +16,6 @@ namespace Files
}
#endif // COMPONENTS_FILES_CONFIGFILEPARSER_HPP
// NOLINTEND(readability-identifier-naming)
#endif // COMPONENTS_FILES_CONFIGFILEPARSER_HPP

View File

@ -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);

View File

@ -172,10 +172,10 @@ namespace LuaUtil
std::optional<T> res = std::nullopt;
mLua.protectedCall([&](LuaUtil::LuaView& view) {
LoadedData& data = ensureLoaded();
auto I = data.mPublicInterfaces.get<sol::optional<sol::table>>(interfaceName);
if (I)
auto interface = data.mPublicInterfaces.get<sol::optional<sol::table>>(interfaceName);
if (interface)
{
auto o = I->get_or<sol::object>(identifier, sol::nil);
auto o = interface->get_or<sol::object>(identifier, sol::nil);
if (o.is<sol::function>())
{
sol::object luaRes = o.as<sol::function>().call(args...);

Some files were not shown because too many files have changed in this diff Show More