1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 03:29:55 +00:00

Override launcher file info with higher priority info

This commit is contained in:
Evil Eye 2024-01-07 12:06:01 +01:00
parent a0c0509e3f
commit 521394d67b
3 changed files with 21 additions and 12 deletions

View file

@ -121,6 +121,7 @@
Bug #7712: Casting doesn't support spells and enchantments with no effects
Bug #7723: Assaulting vampires and werewolves shouldn't be a crime
Bug #7724: Guards don't help vs werewolves
Bug #7733: Launcher shows incorrect data paths when there's two plugins with the same name
Bug #7742: Governing attribute training limit should use the modified attribute
Bug #7758: Water walking is not taken into account to compute path cost on the water
Bug #7761: Rain and ambient loop sounds are mutually exclusive

View file

@ -2,6 +2,7 @@
#include "esmfile.hpp"
#include <fstream>
#include <memory>
#include <stdexcept>
#include <unordered_set>
@ -447,26 +448,37 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf
{
QFileInfo info(dir.absoluteFilePath(path2));
if (item(info.fileName()))
continue;
// Enabled by default in system openmw.cfg; shouldn't be shown in content list.
if (info.fileName().compare("builtin.omwscripts", Qt::CaseInsensitive) == 0)
continue;
EsmFile* file = const_cast<EsmFile*>(item(info.fileName()));
bool add = file == nullptr;
std::unique_ptr<EsmFile> newFile;
if (add)
{
newFile = std::make_unique<EsmFile>(path2);
file = newFile.get();
}
else
{
// We've found the same file in a higher priority dir, update our existing entry
file->setFileName(path2);
file->setGameFiles({});
}
if (info.fileName().endsWith(".omwscripts", Qt::CaseInsensitive))
{
EsmFile* file = new EsmFile(path2);
file->setDate(info.lastModified());
file->setFilePath(info.absoluteFilePath());
addFile(file);
if (add)
addFile(newFile.release());
setNew(file->fileName(), newfiles);
continue;
}
try
{
EsmFile* file = new EsmFile(path2);
file->setDate(info.lastModified());
file->setFilePath(info.absoluteFilePath());
std::filesystem::path filepath = Files::pathFromQString(info.absoluteFilePath());
@ -522,14 +534,14 @@ void ContentSelectorModel::ContentModel::addFiles(const QString& path, bool newf
}
// Put the file in the table
addFile(file);
if (add)
addFile(newFile.release());
setNew(file->fileName(), newfiles);
}
catch (std::runtime_error& e)
{
// An error occurred while reading the .esp
qWarning() << "Error reading addon file: " << e.what();
continue;
}
}
}

View file

@ -30,15 +30,11 @@ namespace ContentSelectorModel
};
EsmFile(const QString& fileName = QString(), ModelItem* parent = nullptr);
// EsmFile(const EsmFile &);
~EsmFile() {}
void setFileProperty(const FileProperty prop, const QString& value);
void setFileName(const QString& fileName);
void setAuthor(const QString& author);
void setSize(const int size);
void setDate(const QDateTime& modified);
void setFormat(const QString& format);
void setFilePath(const QString& path);