From d4754f4d3ca7451d784e89ae1ddef240666dfdf8 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Thu, 15 Oct 2015 18:44:39 +0100 Subject: Fix for some nexus fomods having the old version of the mod link and not the new version. Also fixed a lot of const correctness things --- src/shared/gameinfo.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/shared/gameinfo.cpp') diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index 1f25cec1..5338c069 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -86,6 +86,19 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file) } } +bool GameInfo::isValidModURL(int modID, const std::wstring &url, const std::wstring &alt) const +{ + std::wostringstream os; + os << getNexusPage(false) << "/mods/" << modID; + if (url == os.str()) { + return true; + } + os.clear(); + os.str(L""); + os << alt << "/mods/" << modID; + return url == os.str(); +} + bool GameInfo::identifyGame(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &searchPath) { -- cgit v1.3.1 From 49de6e8d2555234c5da132c5fc35287083fe7ef7 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Fri, 20 Nov 2015 18:07:06 +0000 Subject: Get rid of `GameIfo::getOrganizerDirectory` and associated member variable qApp->getProperty("dataPath") can be used instead (and is pretty much everywhere else) so it's unnecessary --- src/main.cpp | 9 +++++---- src/organizercore.cpp | 1 + src/organizerproxy.cpp | 4 +++- src/selfupdater.cpp | 6 +++--- src/settingsdialog.cpp | 2 +- src/shared/fallout3info.cpp | 4 ++-- src/shared/fallout3info.h | 2 +- src/shared/falloutnvinfo.cpp | 4 ++-- src/shared/falloutnvinfo.h | 2 +- src/shared/gameinfo.cpp | 18 +++++++++--------- src/shared/gameinfo.h | 14 +++++++++----- src/shared/oblivioninfo.cpp | 4 ++-- src/shared/oblivioninfo.h | 2 +- src/shared/skyriminfo.cpp | 4 ++-- src/shared/skyriminfo.h | 2 +- 15 files changed, 43 insertions(+), 35 deletions(-) (limited to 'src/shared/gameinfo.cpp') diff --git a/src/main.cpp b/src/main.cpp index 773bfc16..ff34145d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -86,7 +86,8 @@ using namespace MOShared; bool createAndMakeWritable(const std::wstring &subPath) { - QString fullPath = qApp->property("dataPath").toString() + "/" + QString::fromStdWString(subPath); + QString const dataPath = qApp->property("dataPath").toString(); + QString fullPath = dataPath + "/" + QString::fromStdWString(subPath); if (!QDir(fullPath).exists()) { QDir().mkdir(fullPath); @@ -100,7 +101,7 @@ bool createAndMakeWritable(const std::wstring &subPath) "will be made writable for the current user account). You will be asked to run " "\"helper.exe\" with administrative rights."), QMessageBox::Yes | QMessageBox::Cancel) == QMessageBox::Yes) { - if (!Helper::init(GameInfo::instance().getOrganizerDirectory())) { + if (!Helper::init(dataPath.toStdWString())) { return false; } } else { @@ -341,7 +342,7 @@ int main(int argc, char *argv[]) instanceID = instanceFile.readAll().trimmed(); } - QString dataPath = + QString const dataPath = instanceID.isEmpty() ? application.applicationDirPath() : QDir::fromNativeSeparators( QStandardPaths::writableLocation(QStandardPaths::DataLocation) @@ -373,7 +374,7 @@ int main(int argc, char *argv[]) QSplashScreen splash(pixmap); try { - if (!bootstrap()) { // requires gameinfo to be initialised! + if (!bootstrap()) { return -1; } diff --git a/src/organizercore.cpp b/src/organizercore.cpp index a9284e97..c1f091d9 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -1,4 +1,5 @@ #include "organizercore.h" + #include "mainwindow.h" #include "gameinfoimpl.h" #include "messagedialog.h" diff --git a/src/organizerproxy.cpp b/src/organizerproxy.cpp index 095cb0bb..9e85929f 100644 --- a/src/organizerproxy.cpp +++ b/src/organizerproxy.cpp @@ -1,7 +1,9 @@ #include "organizerproxy.h" + #include #include +#include using namespace MOBase; using namespace MOShared; @@ -40,7 +42,7 @@ QString OrganizerProxy::downloadsPath() const QString OrganizerProxy::overwritePath() const { - return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory())) + return QDir::fromNativeSeparators(qApp->property("dataPath").toString()) + "/" + ToQString(AppConfig::overwritePath()); } diff --git a/src/selfupdater.cpp b/src/selfupdater.cpp index bcf81cfd..7e42f322 100644 --- a/src/selfupdater.cpp +++ b/src/selfupdater.cpp @@ -159,7 +159,7 @@ void SelfUpdater::download(const QString &downloadLink, const QString &fileName) QNetworkRequest request(dlUrl); m_Canceled = false; m_Reply = accessManager->get(request); - m_UpdateFile.setFileName(QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory()).append("\\").append(fileName))); + m_UpdateFile.setFileName(QDir::fromNativeSeparators(qApp->property("dataPath").toString()).append("/").append(fileName)); m_UpdateFile.open(QIODevice::WriteOnly); showProgress(); @@ -243,7 +243,7 @@ void SelfUpdater::downloadCancel() void SelfUpdater::installUpdate() { - const QString mopath = QDir::fromNativeSeparators(ToQString(GameInfo::instance().getOrganizerDirectory())); + const QString mopath = QDir::fromNativeSeparators(qApp->property("dataPath").toString()); QString backupPath = mopath + "/update_backup"; QDir().mkdir(backupPath); @@ -281,7 +281,7 @@ void SelfUpdater::installUpdate() } // now unpack the archive into the mo directory - if (!m_CurrentArchive->extract(GameInfo::instance().getOrganizerDirectory().c_str(), + if (!m_CurrentArchive->extract(QDir::toNativeSeparators(mopath).toStdWString().c_str(), new MethodCallback(this, &SelfUpdater::updateProgress), new MethodCallback(this, &SelfUpdater::updateProgressFile), new MethodCallback(this, &SelfUpdater::report7ZipError))) { diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index 765858f5..f2160719 100644 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -87,7 +87,7 @@ void SettingsDialog::on_categoriesBtn_clicked() void SettingsDialog::on_bsaDateBtn_clicked() { - Helper::backdateBSAs(GameInfo::instance().getOrganizerDirectory(), GameInfo::instance().getGameDirectory().append(L"\\data")); + Helper::backdateBSAs(qApp->property("dataPath").toString().toStdWString(), GameInfo::instance().getGameDirectory().append(L"\\data")); } void SettingsDialog::on_browseDownloadDirBtn_clicked() diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 0b369b50..055d3b38 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -30,8 +30,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -Fallout3Info::Fallout3Info(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +Fallout3Info::Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"fallout3"); } diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 0045581d..d019ee07 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -69,7 +69,7 @@ public: private: - Fallout3Info(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 1203bd25..2ddbf055 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -FalloutNVInfo::FalloutNVInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +FalloutNVInfo::FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"falloutnv"); } diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index e1a614d2..9a9004ec 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -102,7 +102,7 @@ public: private: - FalloutNVInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); }; diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index 1f25cec1..e5e47cdf 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -40,8 +40,8 @@ namespace MOShared { GameInfo* GameInfo::s_Instance = nullptr; -GameInfo::GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : m_GameDirectory(gameDirectory), m_OrganizerDirectory(moDirectory), m_OrganizerDataDirectory(moDataDirectory) +GameInfo::GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : m_GameDirectory(gameDirectory), m_OrganizerDataDirectory(moDataDirectory) { atexit(&cleanup); } @@ -87,16 +87,16 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file) } -bool GameInfo::identifyGame(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &searchPath) +bool GameInfo::identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath) { if (OblivionInfo::identifyGame(searchPath)) { - s_Instance = new OblivionInfo(moDirectory, moDataDirectory, searchPath); + s_Instance = new OblivionInfo(moDataDirectory, searchPath); } else if (Fallout3Info::identifyGame(searchPath)) { - s_Instance = new Fallout3Info(moDirectory, moDataDirectory, searchPath); + s_Instance = new Fallout3Info(moDataDirectory, searchPath); } else if (FalloutNVInfo::identifyGame(searchPath)) { - s_Instance = new FalloutNVInfo(moDirectory, moDataDirectory, searchPath); + s_Instance = new FalloutNVInfo(moDataDirectory, searchPath); } else if (SkyrimInfo::identifyGame(searchPath)) { - s_Instance = new SkyrimInfo(moDirectory, moDataDirectory, searchPath); + s_Instance = new SkyrimInfo(moDataDirectory, searchPath); } return s_Instance != nullptr; @@ -109,14 +109,14 @@ bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &moDataD if (gamePath.length() == 0) { // search upward in the directory until a recognized game-binary is found std::wstring searchPath(moDirectory); - while (!identifyGame(moDirectory, moDataDirectory, searchPath)) { + while (!identifyGame(moDataDirectory, searchPath)) { size_t lastSep = searchPath.find_last_of(L"/\\"); if (lastSep == std::string::npos) { return false; } searchPath.erase(lastSep); } - } else if (!identifyGame(moDirectory, moDataDirectory, gamePath)) { + } else if (!identifyGame(moDataDirectory, gamePath)) { return false; } } diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index a32b6b82..1d4b050b 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -56,8 +56,7 @@ public: virtual ~GameInfo() {} - std::wstring getOrganizerDirectory() { return m_OrganizerDirectory; } - + //**USED IN HOOKDLL virtual std::wstring getRegPath() = 0; virtual std::wstring getBinaryName() = 0; @@ -70,6 +69,7 @@ public: /// exception if the mechanism can't be determined virtual LoadOrderMechanism getLoadOrderMechanism() const { return TYPE_FILETIME; } + //**USED IN HOOKDLL virtual std::wstring getGameDirectory() const; virtual bool requiresSteam() const; @@ -80,9 +80,11 @@ public: // get a set of esp/esm files that are part of known dlcs virtual std::vector getDLCPlugins() = 0; + //**USED IN HOOKDLL // file name of this games ini file(s) virtual std::vector getIniFileNames() = 0; + //**USED IN HOOKDLL virtual std::wstring getReferenceDataFile() = 0; virtual std::wstring getNexusPage(bool nmmScheme = true) = 0; @@ -90,19 +92,22 @@ public: virtual int getNexusModID() = 0; virtual int getNexusGameID() = 0; + //**USED IN HOOKDLL virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0; public: + //**USED IN HOOKDLL // initialise with the path to the mo directory (needs to be where hook.dll is stored). This // needs to be called before the instance can be retrieved static bool init(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gamePath = L""); + //**USED IN HOOKDLL static GameInfo& instance(); protected: - GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); std::wstring getLocalAppFolder() const; const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; } @@ -110,7 +115,7 @@ protected: private: - static bool identifyGame(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &searchPath); + static bool identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath); std::wstring getSpecialPath(LPCWSTR name) const; static void cleanup(); @@ -122,7 +127,6 @@ private: std::wstring m_MyGamesDirectory; std::wstring m_GameDirectory; - std::wstring m_OrganizerDirectory; std::wstring m_OrganizerDataDirectory; }; diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 16748f58..a5760570 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -OblivionInfo::OblivionInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +OblivionInfo::OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"oblivion"); } diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 87ba26ff..0a6c416c 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -100,7 +100,7 @@ public: private: - OblivionInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index f66fcef4..e122390d 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -33,8 +33,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -SkyrimInfo::SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDirectory, moDataDirectory, gameDirectory) +SkyrimInfo::SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) + : GameInfo(moDataDirectory, gameDirectory) { identifyMyGamesDirectory(L"skyrim"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index 5951f910..f52be73a 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -68,7 +68,7 @@ public: private: - SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); -- cgit v1.3.1 From f339cc8431c0a7b6a4d514599e6fa57a75eb6495 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Fri, 20 Nov 2015 19:34:09 +0000 Subject: Member variable unused so removed it. Leaves one asking *why* the datapath can be inside the game directory. --- src/main.cpp | 2 +- src/shared/fallout3info.cpp | 4 ++-- src/shared/fallout3info.h | 2 +- src/shared/falloutnvinfo.cpp | 4 ++-- src/shared/falloutnvinfo.h | 2 +- src/shared/gameinfo.cpp | 20 ++++++++++---------- src/shared/gameinfo.h | 7 +++---- src/shared/oblivioninfo.cpp | 4 ++-- src/shared/oblivioninfo.h | 2 +- src/shared/skyriminfo.cpp | 4 ++-- src/shared/skyriminfo.h | 2 +- 11 files changed, 26 insertions(+), 27 deletions(-) (limited to 'src/shared/gameinfo.cpp') diff --git a/src/main.cpp b/src/main.cpp index ff34145d..4f79b0b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -446,7 +446,7 @@ int main(int argc, char *argv[]) QString gamePath = QString::fromUtf8(settings.value("gamePath", "").toByteArray()); bool done = false; while (!done) { - if (!GameInfo::init(ToWString(application.applicationDirPath()), ToWString(dataPath), ToWString(QDir::toNativeSeparators(gamePath)))) { + if (!GameInfo::init(ToWString(application.applicationDirPath()), ToWString(QDir::toNativeSeparators(gamePath)))) { if (!gamePath.isEmpty()) { reportError(QObject::tr("No game identified in \"%1\". The directory is required to contain " "the game binary and its launcher.").arg(gamePath)); diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 055d3b38..9c6ad5b9 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -30,8 +30,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -Fallout3Info::Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +Fallout3Info::Fallout3Info(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"fallout3"); } diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index d019ee07..51abe073 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -69,7 +69,7 @@ public: private: - Fallout3Info(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + Fallout3Info(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 2ddbf055..4601caf5 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -FalloutNVInfo::FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +FalloutNVInfo::FalloutNVInfo(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"falloutnv"); } diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 9a9004ec..59b52323 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -102,7 +102,7 @@ public: private: - FalloutNVInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + FalloutNVInfo(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); }; diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index e5e47cdf..703f4a40 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -40,8 +40,8 @@ namespace MOShared { GameInfo* GameInfo::s_Instance = nullptr; -GameInfo::GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : m_GameDirectory(gameDirectory), m_OrganizerDataDirectory(moDataDirectory) +GameInfo::GameInfo(const std::wstring &gameDirectory) + : m_GameDirectory(gameDirectory) { atexit(&cleanup); } @@ -87,36 +87,36 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file) } -bool GameInfo::identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath) +bool GameInfo::identifyGame(const std::wstring &searchPath) { if (OblivionInfo::identifyGame(searchPath)) { - s_Instance = new OblivionInfo(moDataDirectory, searchPath); + s_Instance = new OblivionInfo(searchPath); } else if (Fallout3Info::identifyGame(searchPath)) { - s_Instance = new Fallout3Info(moDataDirectory, searchPath); + s_Instance = new Fallout3Info(searchPath); } else if (FalloutNVInfo::identifyGame(searchPath)) { - s_Instance = new FalloutNVInfo(moDataDirectory, searchPath); + s_Instance = new FalloutNVInfo(searchPath); } else if (SkyrimInfo::identifyGame(searchPath)) { - s_Instance = new SkyrimInfo(moDataDirectory, searchPath); + s_Instance = new SkyrimInfo(searchPath); } return s_Instance != nullptr; } -bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gamePath) +bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &gamePath) { if (s_Instance == nullptr) { if (gamePath.length() == 0) { // search upward in the directory until a recognized game-binary is found std::wstring searchPath(moDirectory); - while (!identifyGame(moDataDirectory, searchPath)) { + while (!identifyGame(searchPath)) { size_t lastSep = searchPath.find_last_of(L"/\\"); if (lastSep == std::string::npos) { return false; } searchPath.erase(lastSep); } - } else if (!identifyGame(moDataDirectory, gamePath)) { + } else if (!identifyGame(gamePath)) { return false; } } diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 1d4b050b..47a5e767 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -100,14 +100,14 @@ public: //**USED IN HOOKDLL // initialise with the path to the mo directory (needs to be where hook.dll is stored). This // needs to be called before the instance can be retrieved - static bool init(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gamePath = L""); + static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); //**USED IN HOOKDLL static GameInfo& instance(); protected: - GameInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + GameInfo(const std::wstring &gameDirectory); std::wstring getLocalAppFolder() const; const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; } @@ -115,7 +115,7 @@ protected: private: - static bool identifyGame(const std::wstring &moDataDirectory, const std::wstring &searchPath); + static bool identifyGame(const std::wstring &searchPath); std::wstring getSpecialPath(LPCWSTR name) const; static void cleanup(); @@ -127,7 +127,6 @@ private: std::wstring m_MyGamesDirectory; std::wstring m_GameDirectory; - std::wstring m_OrganizerDataDirectory; }; diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index a5760570..4b0a8499 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -31,8 +31,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -OblivionInfo::OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +OblivionInfo::OblivionInfo(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"oblivion"); } diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index 0a6c416c..ac10b80a 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -100,7 +100,7 @@ public: private: - OblivionInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + OblivionInfo(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index e122390d..bd901357 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -33,8 +33,8 @@ along with Mod Organizer. If not, see . namespace MOShared { -SkyrimInfo::SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory) - : GameInfo(moDataDirectory, gameDirectory) +SkyrimInfo::SkyrimInfo(const std::wstring &gameDirectory) + : GameInfo(gameDirectory) { identifyMyGamesDirectory(L"skyrim"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index f52be73a..65977a69 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -68,7 +68,7 @@ public: private: - SkyrimInfo(const std::wstring &moDataDirectory, const std::wstring &gameDirectory); + SkyrimInfo(const std::wstring &gameDirectory); static bool identifyGame(const std::wstring &searchPath); -- cgit v1.3.1 From 2a50683133953edd80606aedbdd93a7f10d4a7d8 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Mon, 23 Nov 2015 13:35:48 +0000 Subject: Removed 'requiresSteam' which is only used in one place and might or might not be game related --- src/organizercore.cpp | 5 ++++- src/shared/gameinfo.cpp | 5 ----- src/shared/gameinfo.h | 2 -- 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'src/shared/gameinfo.cpp') diff --git a/src/organizercore.cpp b/src/organizercore.cpp index 826d5bea..ee69c46b 100644 --- a/src/organizercore.cpp +++ b/src/organizercore.cpp @@ -950,7 +950,10 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QString & ::SetEnvironmentVariableW(L"SteamAPPId", ToWString(m_Settings.getSteamAppID()).c_str()); } - if ((GameInfo::instance().requiresSteam()) + + //This could possibly be extracted somewhere else but it's probably for when + //we have more than one provider of game registration. + if (QFileInfo(managedGame()->gameDirectory().absoluteFilePath("steam_api.dll")).exists() && (m_Settings.getLoadMechanism() == LoadMechanism::LOAD_MODORGANIZER)) { if (!testForSteam()) { QWidget *window = qApp->activeWindow(); diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index 703f4a40..2890e9cc 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -135,11 +135,6 @@ std::wstring GameInfo::getGameDirectory() const return m_GameDirectory; } -bool GameInfo::requiresSteam() const -{ - return FileExists(getGameDirectory() + L"\\steam_api.dll"); -} - std::wstring GameInfo::getLocalAppFolder() const { wchar_t localAppFolder[MAX_PATH]; diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index 57613e5e..e1a70597 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -71,8 +71,6 @@ public: //**USED IN HOOKDLL virtual std::wstring getGameDirectory() const; - virtual bool requiresSteam() const; - // get a list of file extensions for additional files belonging to a save game virtual std::vector getSavegameAttachmentExtensions() = 0; -- cgit v1.3.1 From 235d893eb845c3c8c0edb9dcdb703ce3ec31bdb5 Mon Sep 17 00:00:00 2001 From: Thomas Tanner Date: Sat, 5 Dec 2015 19:13:05 +0000 Subject: Gets rid of last vestiges of GameInfo apart from startup and hookdll Working on sorting out savegame stuff --- src/mainwindow.cpp | 28 +++++++++++---- src/modinfoforeign.cpp | 8 +++-- src/savegame.cpp | 81 ++++++++++++-------------------------------- src/savegame.h | 20 +++-------- src/savegamegamebryo.cpp | 2 +- src/shared/fallout3info.cpp | 5 --- src/shared/fallout3info.h | 2 -- src/shared/falloutnvinfo.cpp | 5 --- src/shared/falloutnvinfo.h | 2 -- src/shared/gameinfo.cpp | 13 ------- src/shared/gameinfo.h | 20 ++++------- src/shared/oblivioninfo.cpp | 9 ----- src/shared/oblivioninfo.h | 2 -- src/shared/skyriminfo.cpp | 5 --- src/shared/skyriminfo.h | 2 -- 15 files changed, 61 insertions(+), 143 deletions(-) (limited to 'src/shared/gameinfo.cpp') diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 7dd5d71b..aa45a0bd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -835,15 +835,29 @@ SaveGameGamebryo *MainWindow::getSaveGame(const QString &name__) IPluginGame const *game = m_OrganizerCore.managedGame(); QString name(name__); + static int count = 0; //fudge with me -// game = m_PluginContainer.managedGame("Fallout 3"); -// name = "C:\\Users\\Dad\\Downloads\\Games\\Both good and evil saves -10416\\Save 106 - New Start Good, Vault 101 Entrance, 00.33.34.fos"; + switch (count) + { + case 0: + game = m_PluginContainer.managedGame("Fallout 3"); + name = "C:\\Users\\Dad\\Downloads\\Games\\Both good and evil saves -10416\\Save 106 - New Start Good, Vault 101 Entrance, 00.33.34.fos"; + break; + + case 1: + game = m_PluginContainer.managedGame("New Vegas"); + name = "C:\\Users\\Dad\\Downloads\\Games\\Crossroads - Clean Save-44883-1-0\\Crossroads.fos"; + break; -// game = m_PluginContainer.managedGame("New Vegas"); -// name = "C:\\Users\\Dad\\Downloads\\Games\\Crossroads - Clean Save-44883-1-0\\Crossroads.fos"; + case 2: + game = m_PluginContainer.managedGame("Oblivion"); + name = "C:\\Users\\Dad\\Saved Games\\Oblivion\\Saves\\Save 1537 - Hilary - Xirethard, Level 45, Playing Time 458.48.17.ess"; + break; -// game = m_PluginContainer.managedGame("Oblivion"); -// name = "C:\\Users\\Dad\\Saved Games\\Oblivion\\Saves\\Save 1537 - Hilary - Xirethard, Level 45, Playing Time 458.48.17.ess"; + case 3: + count = -1; + } + ++count; return new SaveGameGamebryo(this, name, game); } @@ -3210,7 +3224,7 @@ void MainWindow::deleteSavegame_clicked() foreach (const QModelIndex &idx, selectedIndexes) { QString name = idx.data().toString(); - SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString()); + SaveGame *save = new SaveGame(this, idx.data(Qt::UserRole).toString(), m_OrganizerCore.managedGame()); if (count < 10) { savesMsgLabel += "
  • " + QFileInfo(name).completeBaseName() + "
  • "; diff --git a/src/modinfoforeign.cpp b/src/modinfoforeign.cpp index c0e769c9..4dbe034b 100644 --- a/src/modinfoforeign.cpp +++ b/src/modinfoforeign.cpp @@ -1,8 +1,10 @@ #include "modinfoforeign.h" -#include "gameinfo.h" +#include "iplugingame.h" #include "utility.h" +#include + using namespace MOBase; using namespace MOShared; @@ -18,7 +20,9 @@ QDateTime ModInfoForeign::creationTime() const QString ModInfoForeign::absolutePath() const { - return QDir::fromNativeSeparators(ToQString(GameInfo::instance().getGameDirectory())) + "/data"; + //I ought to store this, it's used elsewhere + IPluginGame const *game = qApp->property("managed_game").value(); + return game->dataDirectory().absolutePath(); } std::vector ModInfoForeign::getFlags() const diff --git a/src/savegame.cpp b/src/savegame.cpp index 1cdabb2d..2b125575 100644 --- a/src/savegame.cpp +++ b/src/savegame.cpp @@ -18,50 +18,28 @@ along with Mod Organizer. If not, see . */ #include "savegame.h" -#include -#include -#include -#include -#include -#include -#include -#include "gameinfo.h" - - -SaveGame::SaveGame(QObject *parent) - : QObject(parent), m_FileName(), m_PCName(), m_PCLevel(0), m_PCLocation(), m_SaveNumber(0), m_Screenshot() -{ -} +#include "iplugingame.h" +#include "scriptextender.h" +#include "utility.h" -SaveGame::SaveGame(QObject *parent, const QString &filename) - : QObject(parent), m_FileName(filename), m_PCName(), m_PCLevel(0), m_PCLocation(), m_SaveNumber(0), m_Screenshot() -{ -} - +#include +#include +#include +#include -SaveGame::SaveGame(const SaveGame& reference) - : m_FileName(reference.m_FileName), m_PCName(reference.m_PCName), m_PCLevel(reference.m_PCLevel), - m_PCLocation(reference.m_PCLocation), m_SaveNumber(reference.m_SaveNumber), - m_Screenshot(reference.m_Screenshot) -{ -} +#include +#include +using namespace MOBase; -SaveGame& SaveGame::operator=(const SaveGame &reference) +SaveGame::SaveGame(QObject *parent, const QString &filename, const MOBase::IPluginGame *game) + : QObject(parent) + , m_FileName(filename) + , m_Game(game) { - if (&reference != this) { - m_FileName = reference.m_FileName; - m_PCName = reference.m_PCName; - m_PCLevel = reference.m_PCLevel; - m_PCLocation = reference.m_PCLocation; - m_SaveNumber = reference.m_SaveNumber; - m_Screenshot = reference.m_Screenshot; - } - return *this; } - SaveGame::~SaveGame() { } @@ -69,11 +47,14 @@ SaveGame::~SaveGame() QStringList SaveGame::attachedFiles() const { QStringList result; - foreach (const std::wstring &ext, MOShared::GameInfo::instance().getSavegameAttachmentExtensions()) { - QFileInfo fi(fileName()); - fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + MOBase::ToQString(ext)); - if (fi.exists()) { - result.append(fi.filePath()); + ScriptExtender const *extender = m_Game->feature(); + if (extender != nullptr) { + for (QString const &ext : extender->saveGameAttachmentExtensions()) { + QFileInfo fi(fileName()); + fi.setFile(fi.canonicalPath() + "/" + fi.completeBaseName() + "." + ext); + if (fi.exists()) { + result.append(fi.filePath()); + } } } @@ -86,21 +67,3 @@ QStringList SaveGame::saveFiles() const result.append(fileName()); return result; } - - -void SaveGame::setCreationTime(const QString &fileName) -{ - QFileInfo creationTime(fileName); - QDateTime modified = creationTime.lastModified(); - memset(&m_CreationTime, 0, sizeof(SYSTEMTIME)); - - m_CreationTime.wDay = static_cast(modified.date().day()); - m_CreationTime.wDayOfWeek = static_cast(modified.date().dayOfWeek()); - m_CreationTime.wMonth = static_cast(modified.date().month()); - m_CreationTime.wYear =static_cast( modified.date().year()); - - m_CreationTime.wHour = static_cast(modified.time().hour()); - m_CreationTime.wMinute = static_cast(modified.time().minute()); - m_CreationTime.wSecond = static_cast(modified.time().second()); - m_CreationTime.wMilliseconds = static_cast(modified.time().msec()); -} diff --git a/src/savegame.h b/src/savegame.h index 1fd2f7ab..d1bf4691 100644 --- a/src/savegame.h +++ b/src/savegame.h @@ -31,6 +31,7 @@ along with Mod Organizer. If not, see . #define WIN32_LEAN_AND_MEAN #include +namespace MOBase { class IPluginGame; } /** * @brief represents a single save game @@ -41,23 +42,14 @@ Q_OBJECT public: - /** - * @brief construct an empty object - **/ - SaveGame(QObject *parent = 0); - /** * @brief construct a save game and immediately read out information from the file * * @param filename absolute path of the save game file **/ - SaveGame(QObject *parent, const QString &filename); - - SaveGame(const SaveGame& reference); - - SaveGame& operator=(const SaveGame &reference); + SaveGame(QObject *parent, const QString &filename, MOBase::IPluginGame const *game); - ~SaveGame(); + virtual ~SaveGame(); /** * @brief read out information from a savegame @@ -111,10 +103,6 @@ public: **/ const QImage &screenshot() const { return m_Screenshot; } -private: - - void setCreationTime(const QString &fileName); - protected: QString m_FileName; @@ -125,6 +113,8 @@ protected: SYSTEMTIME m_CreationTime; QImage m_Screenshot; +private: + MOBase::IPluginGame const * const m_Game; }; diff --git a/src/savegamegamebryo.cpp b/src/savegamegamebryo.cpp index 457cbdf2..68ed30af 100644 --- a/src/savegamegamebryo.cpp +++ b/src/savegamegamebryo.cpp @@ -31,7 +31,7 @@ using namespace MOBase; SaveGameGamebryo::SaveGameGamebryo(QObject *parent, const QString &fileName, IPluginGame const *game) - : SaveGame(parent, fileName) + : SaveGame(parent, fileName, game) , m_Plugins() { SaveGameInfo const *info = game->feature(); diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp index 008a046c..797d68ec 100644 --- a/src/shared/fallout3info.cpp +++ b/src/shared/fallout3info.cpp @@ -63,11 +63,6 @@ std::wstring Fallout3Info::getRegPathStatic() } -std::vector Fallout3Info::getSavegameAttachmentExtensions() const -{ - return std::vector(); -} - std::vector Fallout3Info::getIniFileNames() const { return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h index 21356924..5cf98e3b 100644 --- a/src/shared/fallout3info.h +++ b/src/shared/fallout3info.h @@ -37,8 +37,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp index 80d2fba5..6347224d 100644 --- a/src/shared/falloutnvinfo.cpp +++ b/src/shared/falloutnvinfo.cpp @@ -63,11 +63,6 @@ std::wstring FalloutNVInfo::getRegPathStatic() } } -std::vector FalloutNVInfo::getSavegameAttachmentExtensions() const -{ - return std::vector(); -} - std::vector FalloutNVInfo::getIniFileNames() const { return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini"); diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h index 4bffff3f..04c13c7d 100644 --- a/src/shared/falloutnvinfo.h +++ b/src/shared/falloutnvinfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp index e77b9d17..5c13a520 100644 --- a/src/shared/gameinfo.cpp +++ b/src/shared/gameinfo.cpp @@ -134,19 +134,6 @@ std::wstring GameInfo::getGameDirectory() const return m_GameDirectory; } -std::wstring GameInfo::getLocalAppFolder() const -{ - wchar_t localAppFolder[MAX_PATH]; - memset(localAppFolder, '\0', MAX_PATH * sizeof(wchar_t)); - - if (::SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) { - return localAppFolder; - } else { - // fallback: try the registry - return getSpecialPath(L"Local AppData"); - } -} - std::wstring GameInfo::getSpecialPath(LPCWSTR name) const { HKEY key; diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h index a5c615cf..7bc86d3a 100644 --- a/src/shared/gameinfo.h +++ b/src/shared/gameinfo.h @@ -42,20 +42,16 @@ public: virtual ~GameInfo() {} - //**USED IN HOOKDLL and savegame code - static GameInfo& instance(); - - //**Used only in savegame which needs refactoring a lot. - // get a list of file extensions for additional files belonging to a save game - virtual std::vector getSavegameAttachmentExtensions() const = 0; + //**USED IN HOOKDLL and at startup to set up for hookdll to work + // initialise with the path to the mo directory (needs to be where hook.dll is stored). This + // needs to be called before the instance can be retrieved + static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); //**USED ONLY IN HOOKDLL - virtual std::wstring getGameDirectory() const; + static GameInfo& instance(); //**USED ONLY IN HOOKDLL - // initialise with the path to the mo directory (needs to be where hook.dll is stored). This - // needs to be called before the instance can be retrieved - static bool init(const std::wstring &moDirectory, const std::wstring &gamePath = L""); + virtual std::wstring getGameDirectory() const; //**USED ONLY IN HOOKDLL virtual std::wstring getRegPath() const = 0; @@ -74,12 +70,8 @@ protected: GameInfo(const std::wstring &gameDirectory); - std::wstring getLocalAppFolder() const; - const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; } void identifyMyGamesDirectory(const std::wstring &file); - bool isValidModURL(int modID, const std::wstring &url, const std::wstring &alt) const; - private: static bool identifyGame(const std::wstring &searchPath); diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp index 8f1f1843..b50f1daa 100644 --- a/src/shared/oblivioninfo.cpp +++ b/src/shared/oblivioninfo.cpp @@ -63,15 +63,6 @@ std::wstring OblivionInfo::getRegPathStatic() } } - - - -std::vector OblivionInfo::getSavegameAttachmentExtensions() const -{ - return boost::assign::list_of(L"obse"); -} - - std::vector OblivionInfo::getIniFileNames() const { return boost::assign::list_of(L"oblivion.ini")(L"oblivionprefs.ini"); diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h index fc949f4b..bf0b2707 100644 --- a/src/shared/oblivioninfo.h +++ b/src/shared/oblivioninfo.h @@ -36,8 +36,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp index d255e60f..9662e66d 100644 --- a/src/shared/skyriminfo.cpp +++ b/src/shared/skyriminfo.cpp @@ -73,11 +73,6 @@ std::wstring SkyrimInfo::getRegPathStatic() } } -std::vector SkyrimInfo::getSavegameAttachmentExtensions() const -{ - return boost::assign::list_of(L"skse"); -} - std::vector SkyrimInfo::getIniFileNames() const { return boost::assign::list_of(L"skyrim.ini")(L"skyrimprefs.ini"); diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h index ac979d20..bd329403 100644 --- a/src/shared/skyriminfo.h +++ b/src/shared/skyriminfo.h @@ -38,8 +38,6 @@ public: static std::wstring getRegPathStatic(); virtual std::wstring getRegPath() const { return getRegPathStatic(); } - virtual std::vector getSavegameAttachmentExtensions() const; - // file name of this games ini (no path) virtual std::vector getIniFileNames() const; -- cgit v1.3.1