mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-17 11:56:46 +02:00
make sonar cloud (a little bit) happy
This commit is contained in:
parent
9b3a5c7925
commit
e31ace2661
@ -100,7 +100,7 @@ bool ChroniclesExtractor::extractGogInstaller(QString file)
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
process_file(file.toStdString(), o, [this](float progress) {
|
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<float>(fileCount)) * static_cast<float>(extractionFile)) + (progress / static_cast<float>(fileCount));
|
||||||
if(cb)
|
if(cb)
|
||||||
cb(overallProgress);
|
cb(overallProgress);
|
||||||
});
|
});
|
||||||
@ -133,7 +133,7 @@ bool ChroniclesExtractor::extractGogInstaller(QString file)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChroniclesExtractor::createBaseMod()
|
void ChroniclesExtractor::createBaseMod() const
|
||||||
{
|
{
|
||||||
QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods"));
|
QDir dir(pathToQString(VCMIDirs::get().userDataPath() / "Mods"));
|
||||||
dir.mkdir("chronicles");
|
dir.mkdir("chronicles");
|
||||||
@ -180,7 +180,7 @@ void ChroniclesExtractor::createChronicleMod(int no)
|
|||||||
extractFiles(no);
|
extractFiles(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChroniclesExtractor::extractFiles(int no)
|
void ChroniclesExtractor::extractFiles(int no) const
|
||||||
{
|
{
|
||||||
QByteArray tmpChronicles = chronicles.at(no);
|
QByteArray tmpChronicles = chronicles.at(no);
|
||||||
tmpChronicles.replace('\0', "");
|
tmpChronicles.replace('\0', "");
|
||||||
@ -202,14 +202,14 @@ void ChroniclesExtractor::extractFiles(int no)
|
|||||||
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
||||||
else
|
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)))
|
if(!boost::algorithm::to_lower_copy(entry.second.name).find(boost::algorithm::to_lower_copy(item)))
|
||||||
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
archive.extractToFolder(dest.absolutePath().toStdString(), "", entry.second, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
auto rename = [no](QDir dest){
|
auto rename = [no](QDir dest){
|
||||||
dest.refresh();
|
dest.refresh();
|
||||||
for(auto & entry : dest.entryList())
|
for(const auto & entry : dest.entryList())
|
||||||
{
|
{
|
||||||
if(entry.toUpper().startsWith("HPS") || entry.toUpper().startsWith("HPL"))
|
if(entry.toUpper().startsWith("HPS") || entry.toUpper().startsWith("HPL"))
|
||||||
dest.rename(entry, "Hc_" + entry);
|
dest.rename(entry, "Hc_" + entry);
|
||||||
@ -229,7 +229,7 @@ void ChroniclesExtractor::extractFiles(int no)
|
|||||||
if(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).size())
|
if(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).size())
|
||||||
{
|
{
|
||||||
QDir tmpDirMaps = tmpDir.filePath(tmpDir.entryList({"maps"}, QDir::Filter::Dirs).front());
|
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));
|
QFile(tmpDirMaps.filePath(entry)).copy(outDirData.filePath(entry));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,9 +25,9 @@ class ChroniclesExtractor : public QObject
|
|||||||
bool handleTempDir(bool create);
|
bool handleTempDir(bool create);
|
||||||
int getChronicleNo(QFile & file);
|
int getChronicleNo(QFile & file);
|
||||||
bool extractGogInstaller(QString filePath);
|
bool extractGogInstaller(QString filePath);
|
||||||
void createBaseMod();
|
void createBaseMod() const;
|
||||||
void createChronicleMod(int no);
|
void createChronicleMod(int no);
|
||||||
void extractFiles(int no);
|
void extractFiles(int no) const;
|
||||||
|
|
||||||
const std::map<int, QByteArray> chronicles = {
|
const std::map<int, QByteArray> chronicles = {
|
||||||
{1, QByteArray{reinterpret_cast<const char*>(u"Warlords of the Wasteland"), 50}},
|
{1, QByteArray{reinterpret_cast<const char*>(u"Warlords of the Wasteland"), 50}},
|
||||||
|
@ -854,7 +854,7 @@ void CModListView::installFiles(QStringList files)
|
|||||||
|
|
||||||
while(futureExtract.wait_for(std::chrono::milliseconds(10)) != std::future_status::ready)
|
while(futureExtract.wait_for(std::chrono::milliseconds(10)) != std::future_status::ready)
|
||||||
{
|
{
|
||||||
emit extractionProgress(int(prog * 1000.f), 1000);
|
emit extractionProgress(static_cast<int>(prog * 1000.f), 1000);
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user