From e31ace2661a8a4a7258f7cf4bfe571c23a02cf0c Mon Sep 17 00:00:00 2001 From: Laserlicht <13953785+Laserlicht@users.noreply.github.com> Date: Sun, 1 Sep 2024 02:16:03 +0200 Subject: [PATCH] make sonar cloud (a little bit) happy --- launcher/modManager/chroniclesextractor.cpp | 12 +++--- launcher/modManager/chroniclesextractor.h | 4 +- launcher/modManager/cmodlistview_moc.cpp | 2 +- lib/campaign/CampaignState.cpp | 48 ++++++++++----------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/launcher/modManager/chroniclesextractor.cpp b/launcher/modManager/chroniclesextractor.cpp index 1e7d234d1..40ec76a3a 100644 --- a/launcher/modManager/chroniclesextractor.cpp +++ b/launcher/modManager/chroniclesextractor.cpp @@ -100,7 +100,7 @@ bool ChroniclesExtractor::extractGogInstaller(QString file) try { process_file(file.toStdString(), o, [this](float progress) { - float overallProgress = ((1.0 / float(fileCount)) * float(extractionFile)) + (progress / float(fileCount)); + float overallProgress = ((1.0 / static_cast(fileCount)) * static_cast(extractionFile)) + (progress / static_cast(fileCount)); if(cb) cb(overallProgress); }); @@ -133,7 +133,7 @@ bool ChroniclesExtractor::extractGogInstaller(QString file) #endif } -void ChroniclesExtractor::createBaseMod() +void ChroniclesExtractor::createBaseMod() const { QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods")); dir.mkdir("chronicles"); @@ -180,7 +180,7 @@ void ChroniclesExtractor::createChronicleMod(int no) extractFiles(no); } -void ChroniclesExtractor::extractFiles(int no) +void ChroniclesExtractor::extractFiles(int no) const { QByteArray tmpChronicles = chronicles.at(no); tmpChronicles.replace('\0', ""); @@ -202,14 +202,14 @@ void ChroniclesExtractor::extractFiles(int no) archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true); else { - for(auto & item : files) + for(const auto & item : files) if(!boost::algorithm::to_lower_copy(entry.second.name).find(boost::algorithm::to_lower_copy(item))) archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true); } }; auto rename = [no](QDir dest){ dest.refresh(); - for(auto & entry : dest.entryList()) + for(const auto & entry : dest.entryList()) { if(entry.toUpper().startsWith("HPS") || entry.toUpper().startsWith("HPL")) dest.rename(entry, "Hc_" + entry); @@ -229,7 +229,7 @@ void ChroniclesExtractor::extractFiles(int no) if(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).size()) { QDir tmpDirMaps = tmpDir.filePath(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).front()); - for(auto & entry : tmpDirMaps.entryList()) + for(const auto & entry : tmpDirMaps.entryList()) QFile(tmpDirMaps.filePath(entry)).copy(outDirData.filePath(entry)); } diff --git a/launcher/modManager/chroniclesextractor.h b/launcher/modManager/chroniclesextractor.h index ba35a47bc..a162d54d2 100644 --- a/launcher/modManager/chroniclesextractor.h +++ b/launcher/modManager/chroniclesextractor.h @@ -25,9 +25,9 @@ class ChroniclesExtractor : public QObject bool handleTempDir(bool create); int getChronicleNo(QFile & file); bool extractGogInstaller(QString filePath); - void createBaseMod(); + void createBaseMod() const; void createChronicleMod(int no); - void extractFiles(int no); + void extractFiles(int no) const; const std::map chronicles = { {1, QByteArray{reinterpret_cast(u"Warlords of the Wasteland"), 50}}, diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 7894892b0..e803a1311 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -854,7 +854,7 @@ void CModListView::installFiles(QStringList files) while(futureExtract.wait_for(std::chrono::milliseconds(10)) != std::future_status::ready) { - emit extractionProgress(int(prog * 1000.f), 1000); + emit extractionProgress(static_cast(prog * 1000.f), 1000); qApp->processEvents(); } diff --git a/lib/campaign/CampaignState.cpp b/lib/campaign/CampaignState.cpp index d142d89b6..45a7b6161 100644 --- a/lib/campaign/CampaignState.cpp +++ b/lib/campaign/CampaignState.cpp @@ -481,36 +481,36 @@ void Campaign::overrideCampaign(bool scenario) { JsonNode node = JsonUtils::assembleFromFiles("config/campaignOverrides.json"); for (auto & entry : node.Struct()) - if(filename == entry.first) - { - if(!scenario) + if(filename == entry.first) { - if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull()) - loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer()); - if(!entry.second["loadingBackground"].isNull()) - loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String()); - if(!entry.second["introVideoRim"].isNull()) - introVideoRim = ImagePath::builtin(entry.second["introVideoRim"].String()); - if(!entry.second["introVideo"].isNull()) - introVideo = VideoPath::builtin(entry.second["introVideo"].String()); - } - else - { - if(!entry.second["scenarios"].isNull()) + if(!scenario) { - auto sc = entry.second["scenarios"].Vector(); - for(int i = 0; i < sc.size(); i++) + if(!entry.second["regions"].isNull() && !entry.second["scenarioCount"].isNull()) + loadLegacyData(CampaignRegions::fromJson(entry.second["regions"]), entry.second["scenarioCount"].Integer()); + if(!entry.second["loadingBackground"].isNull()) + loadingBackground = ImagePath::builtin(entry.second["loadingBackground"].String()); + if(!entry.second["introVideoRim"].isNull()) + introVideoRim = ImagePath::builtin(entry.second["introVideoRim"].String()); + if(!entry.second["introVideo"].isNull()) + introVideo = VideoPath::builtin(entry.second["introVideo"].String()); + } + else + { + if(!entry.second["scenarios"].isNull()) { - auto it = scenarios.begin(); - std::advance(it, i); - if(!sc.at(i)["voiceProlog"].isNull()) - it->second.prolog.prologVoice = AudioPath::builtin(sc.at(i)["voiceProlog"].String()); - if(!sc.at(i)["voiceEpilog"].isNull()) - it->second.epilog.prologVoice = AudioPath::builtin(sc.at(i)["voiceEpilog"].String()); + auto sc = entry.second["scenarios"].Vector(); + for(int i = 0; i < sc.size(); i++) + { + auto it = scenarios.begin(); + std::advance(it, i); + if(!sc.at(i)["voiceProlog"].isNull()) + it->second.prolog.prologVoice = AudioPath::builtin(sc.at(i)["voiceProlog"].String()); + if(!sc.at(i)["voiceEpilog"].isNull()) + it->second.epilog.prologVoice = AudioPath::builtin(sc.at(i)["voiceEpilog"].String()); + } } } } - } } int Campaign::scenariosCount() const