mirror of
https://github.com/ModOrganizer2/modorganizer-diagnose_basic.git
synced 2026-07-27 14:03:10 -07:00
Compare commits
40
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d983c908ee | ||
|
|
0cc077b8c4 | ||
|
|
b245bc2ce3 | ||
|
|
0a1707fa9c | ||
|
|
b10b1f28ff | ||
|
|
59c10d78cd | ||
|
|
7dd29a68e2 | ||
|
|
ce0dc685ca | ||
|
|
e426d8efb4 | ||
|
|
bf00944706 | ||
|
|
97c8769334 | ||
|
|
05d1782cf1 | ||
|
|
f114b3ee60 | ||
|
|
0320bd719a | ||
|
|
943689d5c3 | ||
|
|
ecf0ff0d02 | ||
|
|
182ec5f85d | ||
|
|
2632e79de7 | ||
|
|
41eb0d50d4 | ||
|
|
863233e1ab | ||
|
|
9cb9c2cc56 | ||
|
|
8529da255f | ||
|
|
dd2203f647 | ||
|
|
123d291dc1 | ||
|
|
926cdedf8c | ||
|
|
0cc55698f7 | ||
|
|
7ea85f751e | ||
|
|
2cf83c7681 | ||
|
|
fb4eacabed | ||
|
|
366b3854b8 | ||
|
|
4bf94e9fda | ||
|
|
016a2efb88 | ||
|
|
6f73fe05a4 | ||
|
|
4531207250 | ||
|
|
266b597e4c | ||
|
|
41bd8cc0cd | ||
|
|
06487c2653 | ||
|
|
9b0637fa66 | ||
|
|
f0957919a5 | ||
|
|
4bce131613 |
@@ -0,0 +1,20 @@
|
||||
Import('qt_env')
|
||||
|
||||
env = qt_env.Clone()
|
||||
|
||||
env.AppendUnique(CPPDEFINES = [
|
||||
'DIAGNOSEBASIC_LIBRARY',
|
||||
'NOMINMAX',
|
||||
# suppress a few warnings caused by boost vs vc++ paranoia
|
||||
'_SCL_SECURE_NO_WARNINGS'
|
||||
])
|
||||
|
||||
env.AppendUnique(CPPPATH = [
|
||||
'${BOOSTPATH}'
|
||||
])
|
||||
|
||||
lib = env.SharedLibrary('diagnoseBasic', env.Glob('*.cpp'))
|
||||
env.InstallModule(lib)
|
||||
|
||||
res = env['QT_USED_MODULES']
|
||||
Return('res')
|
||||
@@ -10,9 +10,7 @@ TEMPLATE = lib
|
||||
CONFIG += plugins
|
||||
CONFIG += dll
|
||||
|
||||
contains(QT_VERSION, "^5.*") {
|
||||
QT += widgets
|
||||
}
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
|
||||
DEFINES += DIAGNOSEBASIC_LIBRARY
|
||||
DEFINES += NOMINMAX
|
||||
@@ -26,11 +24,12 @@ HEADERS += diagnosebasic.h
|
||||
|
||||
include(../plugin_template.pri)
|
||||
|
||||
INCLUDEPATH += "$(BOOSTPATH)"
|
||||
INCLUDEPATH += "$${BOOSTPATH}"
|
||||
|
||||
#CONFIG += dll
|
||||
|
||||
#DEFINES += INIEDITOR_LIBRARY
|
||||
|
||||
OTHER_FILES += \
|
||||
diagnosebasic.json
|
||||
diagnosebasic.json\
|
||||
SConscript
|
||||
|
||||
+122
-45
@@ -20,6 +20,9 @@
|
||||
#include "diagnosebasic.h"
|
||||
#include <report.h>
|
||||
#include <utility.h>
|
||||
#include <imodlist.h>
|
||||
#include <ipluginlist.h>
|
||||
#include <igameinfo.h>
|
||||
#include <QtPlugin>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
@@ -45,6 +48,7 @@ using namespace MOBase;
|
||||
|
||||
|
||||
DiagnoseBasic::DiagnoseBasic()
|
||||
: m_MOInfo(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -60,14 +64,20 @@ bool DiagnoseBasic::init(IOrganizer *moInfo)
|
||||
// checks
|
||||
invalidate();
|
||||
});
|
||||
m_MOInfo->pluginList()->onRefreshed([&] () { this->invalidate(); });
|
||||
m_MOInfo->pluginList()->onPluginMoved([&] (const QString&, int, int) {
|
||||
invalidate();
|
||||
});
|
||||
m_MOInfo->pluginList()->onRefreshed([&] () { invalidate(); });
|
||||
m_MOInfo->pluginList()->onPluginStateChanged([&] (const QString &, IPluginList::PluginStates) {
|
||||
invalidate();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QString DiagnoseBasic::name() const
|
||||
{
|
||||
return tr("Basic diagnosis plugin");
|
||||
return "Basic diagnosis plugin";
|
||||
}
|
||||
|
||||
QString DiagnoseBasic::author() const
|
||||
@@ -82,7 +92,7 @@ QString DiagnoseBasic::description() const
|
||||
|
||||
VersionInfo DiagnoseBasic::version() const
|
||||
{
|
||||
return VersionInfo(1, 1, 0, VersionInfo::RELEASE_FINAL);
|
||||
return VersionInfo(1, 1, 2, VersionInfo::RELEASE_FINAL);
|
||||
}
|
||||
|
||||
bool DiagnoseBasic::isActive() const
|
||||
@@ -92,13 +102,19 @@ bool DiagnoseBasic::isActive() const
|
||||
|
||||
QList<PluginSetting> DiagnoseBasic::settings() const
|
||||
{
|
||||
return QList<PluginSetting>();
|
||||
return QList<PluginSetting>()
|
||||
<< PluginSetting("check_errorlog", tr("Warn when an error occured last time an application was run"), true)
|
||||
<< PluginSetting("check_overwrite", tr("Warn when there are files in the overwrite directory"), true)
|
||||
<< PluginSetting("check_font", tr("Warn when the font configuration refers to files that aren't installed"), true)
|
||||
<< PluginSetting("check_conflict", tr("Warn when mods are installed that conflict with MO functionality"), true)
|
||||
<< PluginSetting("check_modorder", tr("Warn when MO determins the mod order may cause problems"), true)
|
||||
<< PluginSetting("check_missingmasters", tr("Warn when there are esps with missing masters"), true);
|
||||
}
|
||||
|
||||
|
||||
bool DiagnoseBasic::errorReported() const
|
||||
{
|
||||
QDir dir(QCoreApplication::applicationDirPath() + "/logs");
|
||||
QDir dir(qApp->property("dataPath").toString() + "/logs");
|
||||
QFileInfoList files = dir.entryInfoList(QStringList("ModOrganizer_??_??_??_??_??.log"),
|
||||
QDir::Files, QDir::Name | QDir::Reversed);
|
||||
|
||||
@@ -147,7 +163,7 @@ bool DiagnoseBasic::errorReported() const
|
||||
|
||||
bool DiagnoseBasic::overwriteFiles() const
|
||||
{
|
||||
QDir dir(QCoreApplication::applicationDirPath() + "/overwrite");
|
||||
QDir dir(qApp->property("dataPath").toString() + "/overwrite");
|
||||
|
||||
return dir.count() != 2; // account for . and ..
|
||||
}
|
||||
@@ -210,6 +226,9 @@ void DiagnoseBasic::topoSort(std::vector<DiagnoseBasic::ListElement> &list) cons
|
||||
|
||||
// figure out disconnected components of the graph
|
||||
std::vector<int> component(num_vertices(graph));
|
||||
if (component.size() == 0) {
|
||||
throw MyException(tr("failed to sort"));
|
||||
}
|
||||
connected_components(graph, &component[0]);
|
||||
for (int i = 0; i != component.size(); ++i) {
|
||||
list[i].sortGroup = component[i];
|
||||
@@ -239,7 +258,8 @@ void DiagnoseBasic::Sorter::sortGroup(std::vector<ListElement> modList)
|
||||
|
||||
auto iter = modList.begin() + 1;
|
||||
for (; iter != modList.end(); ++iter) {
|
||||
if (iter->modPriority < curSeqEnd->modPriority) {
|
||||
if ((iter->pluginPriority != curSeqEnd->pluginPriority)
|
||||
&& (iter->modPriority < curSeqEnd->modPriority)) {
|
||||
// sequence ends
|
||||
// use this sequence of correctly sorted mods if it is longer than the previously longest
|
||||
// sequence and doesn't have fewer mods that don't want to move. Thus the need for mods to
|
||||
@@ -281,7 +301,8 @@ void DiagnoseBasic::Sorter::sortGroup(std::vector<ListElement> modList)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (!found
|
||||
&& (iter->pluginPriority != (*sorted.rbegin()).pluginPriority)) {
|
||||
// add to end!
|
||||
moves.push_back(Move(*iter, *sorted.rbegin(), Move::AFTER));
|
||||
}
|
||||
@@ -320,12 +341,16 @@ bool DiagnoseBasic::assetOrder() const
|
||||
|
||||
// list of mods containing conflicted scripts. We care only for those
|
||||
std::map<QString, QSet<QString>> scriptMods;
|
||||
foreach (const IOrganizer::FileInfo & pex, m_MOInfo->findFileInfos("scripts",
|
||||
[] (const IOrganizer::FileInfo &file) -> bool { return file.filePath.endsWith(".pex", Qt::CaseInsensitive); })) {
|
||||
auto filter = [] (const IOrganizer::FileInfo &file) -> bool {
|
||||
return file.filePath.endsWith(".pex", Qt::CaseInsensitive); };
|
||||
|
||||
for (const IOrganizer::FileInfo &pex : m_MOInfo->findFileInfos("scripts", filter)) {
|
||||
QStringList origins = pex.origins;
|
||||
origins.removeAll("data"); // ignore files in base directory
|
||||
// ignore files in base directories
|
||||
origins.removeAll("data");
|
||||
origins.removeAll("Overwrite");
|
||||
if (origins.size() > 1) {
|
||||
foreach(const QString &origin, origins) {
|
||||
for(const QString &origin : origins) {
|
||||
scriptMods[origin].insert(pex.filePath);
|
||||
}
|
||||
}
|
||||
@@ -333,25 +358,28 @@ bool DiagnoseBasic::assetOrder() const
|
||||
|
||||
// produce a list with the information we need: plugin, mod and the priority for each
|
||||
QStringList esps = m_MOInfo->findFiles("",
|
||||
[] (const QString &fileName) -> bool { return fileName.endsWith(".esp", Qt::CaseInsensitive)
|
||||
|| fileName.endsWith(".esm", Qt::CaseInsensitive); });
|
||||
foreach (const QString &esp, esps) {
|
||||
ListElement ele;
|
||||
[] (const QString &fileName) -> bool {
|
||||
return fileName.endsWith(".esp", Qt::CaseInsensitive)
|
||||
|| fileName.endsWith(".esm", Qt::CaseInsensitive);
|
||||
});
|
||||
for (const QString &esp : esps) {
|
||||
for (const QString origin : m_MOInfo->getFileOrigins(esp)) {
|
||||
ListElement ele;
|
||||
|
||||
ele.espName = QFileInfo(esp).fileName();
|
||||
ele.modName = m_MOInfo->pluginList()->origin(ele.espName);
|
||||
ele.pluginPriority = m_MOInfo->pluginList()->priority(ele.espName);
|
||||
ele.modPriority = m_MOInfo->modList()->priority(ele.modName);
|
||||
IModList::ModStates state = m_MOInfo->modList()->state(ele.modName);
|
||||
ele.avoidMove = state.testFlag(IModList::STATE_ESSENTIAL);
|
||||
auto iter = scriptMods.find(ele.modName);
|
||||
if (state.testFlag(IModList::STATE_EXISTS)
|
||||
&& (iter != scriptMods.end())) {
|
||||
ele.relevantScripts = iter->second;
|
||||
modList.push_back(ele);
|
||||
ele.espName = QFileInfo(esp).fileName();
|
||||
ele.modName = origin;
|
||||
ele.pluginPriority = m_MOInfo->pluginList()->priority(ele.espName);
|
||||
ele.modPriority = m_MOInfo->modList()->priority(ele.modName);
|
||||
IModList::ModStates state = m_MOInfo->modList()->state(ele.modName);
|
||||
ele.avoidMove = state.testFlag(IModList::STATE_ESSENTIAL);
|
||||
auto iter = scriptMods.find(ele.modName);
|
||||
if (state.testFlag(IModList::STATE_EXISTS)
|
||||
&& (iter != scriptMods.end())) {
|
||||
ele.relevantScripts = iter->second;
|
||||
modList.push_back(ele);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// generate a copy of list that contains each mod only once, otherwise
|
||||
// strange things happen if a mod contains multiple esps that are mixed
|
||||
// with esps from other mods
|
||||
@@ -359,28 +387,66 @@ bool DiagnoseBasic::assetOrder() const
|
||||
{
|
||||
// sort the input list so we get predictable results
|
||||
std::sort(modList.begin(), modList.end(),
|
||||
[] (const ListElement &lhs, const ListElement &rhs) -> bool { return lhs.pluginPriority < rhs.pluginPriority; });
|
||||
[] (const ListElement &lhs, const ListElement &rhs) -> bool {
|
||||
return lhs.pluginPriority < rhs.pluginPriority;
|
||||
});
|
||||
|
||||
std::set<QString> includedMods;
|
||||
foreach(const ListElement &ele, modList) {
|
||||
for (const ListElement &ele : modList) {
|
||||
if (includedMods.find(ele.modName) == includedMods.end()) {
|
||||
distinctModList.push_back(ele);
|
||||
includedMods.insert(ele.modName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (distinctModList.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// sort the list by plugin priority. This step is probably unnecessary as the list was already sorted when we removed duplicates
|
||||
std::sort(distinctModList.begin(), distinctModList.end(),
|
||||
[] (const ListElement &lhs, const ListElement &rhs) -> bool { return lhs.pluginPriority < rhs.pluginPriority; });
|
||||
|
||||
topoSort(distinctModList);
|
||||
if (distinctModList.size() > 0) {
|
||||
topoSort(distinctModList);
|
||||
|
||||
// now determine the moves necessary to bring the mod list into this order
|
||||
minSorter(distinctModList);
|
||||
m_SuggestedMoves = minSorter.moves;
|
||||
// now determine the moves necessary to bring the mod list into this order
|
||||
minSorter(distinctModList);
|
||||
m_SuggestedMoves = minSorter.moves;
|
||||
return m_SuggestedMoves.size() > 0;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return m_SuggestedMoves.size() > 0;
|
||||
bool DiagnoseBasic::missingMasters() const
|
||||
{
|
||||
std::set<QString> enabledPlugins;
|
||||
|
||||
QStringList esps = m_MOInfo->findFiles("",
|
||||
[] (const QString &fileName) -> bool { return fileName.endsWith(".esp", Qt::CaseInsensitive)
|
||||
|| fileName.endsWith(".esm", Qt::CaseInsensitive); });
|
||||
// gather enabled masters first
|
||||
foreach (const QString &esp, esps) {
|
||||
QString baseName = QFileInfo(esp).fileName();
|
||||
if (m_MOInfo->pluginList()->state(baseName) == IPluginList::STATE_ACTIVE) {
|
||||
enabledPlugins.insert(baseName.toLower());
|
||||
}
|
||||
}
|
||||
|
||||
m_MissingMasters.clear();
|
||||
// for each required master in each esp, test if it's in the list of enabled masters.
|
||||
foreach (const QString &esp, esps) {
|
||||
QString baseName = QFileInfo(esp).fileName();
|
||||
if (m_MOInfo->pluginList()->state(baseName) == IPluginList::STATE_ACTIVE) {
|
||||
foreach (const QString master, m_MOInfo->pluginList()->masters(baseName)) {
|
||||
if (enabledPlugins.find(master.toLower()) == enabledPlugins.end()) {
|
||||
m_MissingMasters.insert(master);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return !m_MissingMasters.empty();
|
||||
}
|
||||
|
||||
bool DiagnoseBasic::invalidFontConfig() const
|
||||
@@ -427,26 +493,28 @@ bool DiagnoseBasic::invalidFontConfig() const
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::vector<unsigned int> DiagnoseBasic::activeProblems() const
|
||||
{
|
||||
std::vector<unsigned int> result;
|
||||
|
||||
if (errorReported()) {
|
||||
if (m_MOInfo->pluginSetting(name(), "check_errorlog").toBool() && errorReported()) {
|
||||
result.push_back(PROBLEM_ERRORLOG);
|
||||
}
|
||||
if (overwriteFiles()) {
|
||||
if (m_MOInfo->pluginSetting(name(), "check_overwrite").toBool() && overwriteFiles()) {
|
||||
result.push_back(PROBLEM_OVERWRITE);
|
||||
}
|
||||
if (invalidFontConfig()) {
|
||||
if (m_MOInfo->pluginSetting(name(), "check_font").toBool() && invalidFontConfig()) {
|
||||
result.push_back(PROBLEM_INVALIDFONT);
|
||||
}
|
||||
if (nitpickInstalled()) {
|
||||
if (m_MOInfo->pluginSetting(name(), "check_conflict").toBool() && nitpickInstalled()) {
|
||||
result.push_back(PROBLEM_NITPICKINSTALLED);
|
||||
}
|
||||
if (assetOrder()) {
|
||||
if (m_MOInfo->pluginSetting(name(), "check_modorder").toBool() && assetOrder()) {
|
||||
result.push_back(PROBLEM_ASSETORDER);
|
||||
}
|
||||
if (m_MOInfo->pluginSetting(name(), "check_missingmasters").toBool() && missingMasters()) {
|
||||
result.push_back(PROBLEM_MISSINGMASTERS);
|
||||
}
|
||||
if (QFile::exists(m_MOInfo->profilePath() + "/profile_tweaks.ini")) {
|
||||
result.push_back(PROBLEM_PROFILETWEAKS);
|
||||
}
|
||||
@@ -469,6 +537,8 @@ QString DiagnoseBasic::shortDescription(unsigned int key) const
|
||||
return tr("Potential Mod order problem");
|
||||
case PROBLEM_PROFILETWEAKS:
|
||||
return tr("Ini Tweaks overwritten");
|
||||
case PROBLEM_MISSINGMASTERS:
|
||||
return tr("Missing Masters");
|
||||
default:
|
||||
throw MyException(tr("invalid problem key %1").arg(key));
|
||||
}
|
||||
@@ -495,15 +565,17 @@ QString DiagnoseBasic::fullDescription(unsigned int key) const
|
||||
"Worse: The two solutions may conflict so it's strongly suggested you remove this plugin.");
|
||||
case PROBLEM_ASSETORDER: {
|
||||
QString res = tr("The conflict resolution order for some mods containing scripts differs from that of the corresponding esp.<br>"
|
||||
"This may lead to subtle, hard to locate bugs. You should re-order the affected mods (left list!).<br>"
|
||||
"This may lead to subtle, hard to locate bugs. <b>You should re-order the affected mods (<font color=\"red\">left list!</font>).</b><br>"
|
||||
"There is no way to reliably know if each of these changes is absolutely necessary but its definitively safer.<br>"
|
||||
"If someone suggested you ignore this message, please give them a proper slapping from me. <b>Do not ignore this warning</b><br>"
|
||||
"The following changes should prevent these kinds of errors:") + "<ul>";
|
||||
foreach(const Move &op, m_SuggestedMoves) {
|
||||
QString itemName = m_MOInfo->modList()->displayName(op.item.modName);
|
||||
QString referenceName = m_MOInfo->modList()->displayName(op.reference.modName);
|
||||
if (op.type == Move::BEFORE) {
|
||||
res += "<li>" + tr("Move %1 before %2").arg(op.item.modName).arg(op.reference.modName) + "</li>";
|
||||
res += "<li>" + tr("Move %1 before %2").arg(itemName).arg(referenceName) + "</li>";
|
||||
} else {
|
||||
res += "<li>" + tr("Move %1 after %2").arg(op.item.modName).arg(op.reference.modName) + "</li>";
|
||||
res += "<li>" + tr("Move %1 after %2").arg(itemName).arg(referenceName) + "</li>";
|
||||
}
|
||||
}
|
||||
res += "</ul>";
|
||||
@@ -519,6 +591,11 @@ QString DiagnoseBasic::fullDescription(unsigned int key) const
|
||||
"Hitting the <i>Fix</i> button will delete that file")
|
||||
+ "<hr><i>profile_tweaks.ini:</i><pre>" + fileContent + "</pre>";
|
||||
} break;
|
||||
case PROBLEM_MISSINGMASTERS: {
|
||||
return tr("The masters for some plugins (esp/esm) are not enabled.<br>"
|
||||
"The game will crash unless you install and enable the following plugins: ")
|
||||
+ "<ul><li>" + SetJoin(m_MissingMasters, "</li><li>") + "</li></ul>";
|
||||
} break;
|
||||
default:
|
||||
throw MyException(tr("invalid problem key %1").arg(key));
|
||||
}
|
||||
@@ -533,7 +610,7 @@ void DiagnoseBasic::startGuidedFix(unsigned int key) const
|
||||
{
|
||||
switch (key) {
|
||||
case PROBLEM_ASSETORDER: {
|
||||
if (QMessageBox::warning(NULL, tr("Continue?"), tr("This <b>BETA</b> feature will rearrange your mods to eliminate all "
|
||||
if (QMessageBox::warning(nullptr, tr("Continue?"), tr("This <b>BETA</b> feature will rearrange your mods to eliminate all "
|
||||
"possible ordering conflicts. Proceed?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
|
||||
foreach (const Move &op, m_SuggestedMoves) {
|
||||
int oldPriority = m_MOInfo->modList()->priority(op.item.modName);
|
||||
|
||||
+4
-1
@@ -29,7 +29,7 @@ along with this plugin. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include <QSet>
|
||||
|
||||
|
||||
class DiagnoseBasic : public QObject, MOBase::IPlugin, MOBase::IPluginDiagnose
|
||||
class DiagnoseBasic : public QObject, public MOBase::IPlugin, public MOBase::IPluginDiagnose
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(MOBase::IPlugin MOBase::IPluginDiagnose)
|
||||
@@ -66,6 +66,7 @@ private:
|
||||
bool invalidFontConfig() const;
|
||||
bool nitpickInstalled() const;
|
||||
bool assetOrder() const;
|
||||
bool missingMasters() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -75,6 +76,7 @@ private:
|
||||
static const unsigned int PROBLEM_NITPICKINSTALLED = 4;
|
||||
static const unsigned int PROBLEM_ASSETORDER = 5;
|
||||
static const unsigned int PROBLEM_PROFILETWEAKS = 7;
|
||||
static const unsigned int PROBLEM_MISSINGMASTERS = 8;
|
||||
|
||||
static const unsigned int NUM_CONTEXT_ROWS = 5;
|
||||
|
||||
@@ -129,6 +131,7 @@ private:
|
||||
mutable QString m_ErrorMessage;
|
||||
mutable std::vector <Move> m_SuggestedMoves;
|
||||
mutable QString m_NewestModlistBackup;
|
||||
mutable std::set<QString> m_MissingMasters;
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user