From cabffa23a9b1ec053a7a573ed71883c44d7a5b6a Mon Sep 17 00:00:00 2001 From: LePresidente Date: Sun, 29 Oct 2017 11:38:06 +0200 Subject: Use ScriptExtender PluginPath instead of appending "/plugin" to the old script extender name variable. --- src/loadmechanism.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/loadmechanism.cpp') diff --git a/src/loadmechanism.cpp b/src/loadmechanism.cpp index e476c56d..35aedfed 100644 --- a/src/loadmechanism.cpp +++ b/src/loadmechanism.cpp @@ -129,7 +129,7 @@ void LoadMechanism::deactivateScriptExtender() throw MyException(QObject::tr("game doesn't support a script extender")); } - QDir pluginsDir(game->gameDirectory().absolutePath() + "/data/" + extender->name() + "/plugins"); + QDir pluginsDir(game->gameDirectory().absolutePath() + "/data/" + extender->PluginPath()); #pragma message("implement this for usvfs") @@ -188,7 +188,7 @@ void LoadMechanism::activateScriptExtender() throw MyException(QObject::tr("game doesn't support a script extender")); } - QDir pluginsDir(game->gameDirectory().absolutePath() + "/data/" + extender->name() + "/plugins"); + QDir pluginsDir(game->gameDirectory().absolutePath() + "/data/" + extender->PluginPath()); if (!pluginsDir.exists()) { pluginsDir.mkpath("."); -- cgit v1.3.1 From 88452e5d76467fc687a9c4d6b6aaf7381d2463e1 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Sun, 29 Oct 2017 19:34:35 -0500 Subject: Reimplement ScriptExtender handling by detecting USVFS arch --- src/loadmechanism.cpp | 45 ++++++++++++++++++++++++++++++++------------- src/shared/appconfig.inc | 2 ++ 2 files changed, 34 insertions(+), 13 deletions(-) (limited to 'src/loadmechanism.cpp') diff --git a/src/loadmechanism.cpp b/src/loadmechanism.cpp index e476c56d..a9d444d1 100644 --- a/src/loadmechanism.cpp +++ b/src/loadmechanism.cpp @@ -133,17 +133,23 @@ void LoadMechanism::deactivateScriptExtender() #pragma message("implement this for usvfs") - /* - QString hookDLLName = ToQString(AppConfig::hookDLLName()); - if (QFile(pluginsDir.absoluteFilePath(hookDLLName)).exists()) { + QString vfsDLLName = ""; + if (extender->getArch() == IMAGE_FILE_MACHINE_I386) { + vfsDLLName = ToQString(AppConfig::vfs32DLLName()); + } + else if (extender->getArch() == IMAGE_FILE_MACHINE_AMD64) + { + vfsDLLName = ToQString(AppConfig::vfs64DLLName()); + } + qDebug("USVFS DLL Name: " + vfsDLLName.toLatin1()); + if (QFile(pluginsDir.absoluteFilePath(vfsDLLName)).exists()) { // remove dll from SE plugins directory - if (!pluginsDir.remove(hookDLLName)) { - throw MyException(QObject::tr("Failed to delete %1").arg(pluginsDir.absoluteFilePath(hookDLLName))); + if (!pluginsDir.remove(vfsDLLName)) { + throw MyException(QObject::tr("Failed to delete %1").arg(pluginsDir.absoluteFilePath(vfsDLLName))); } } removeHintFile(pluginsDir); - */ } catch (const std::exception &e) { QMessageBox::critical(nullptr, QObject::tr("Failed to deactivate script extender loading"), e.what()); } @@ -195,27 +201,37 @@ void LoadMechanism::activateScriptExtender() } #pragma message("implement this for usvfs") -/* - QString targetPath = pluginsDir.absoluteFilePath(ToQString(AppConfig::hookDLLName())); - QString hookDLLPath = qApp->applicationDirPath() + "/" + QString::fromStdWString(AppConfig::hookDLLName()); + QString targetPath; + QString vfsDLLPath; + if (extender->getArch() == IMAGE_FILE_MACHINE_I386) { + targetPath = pluginsDir.absoluteFilePath(ToQString(AppConfig::vfs32DLLName())); + vfsDLLPath = qApp->applicationDirPath() + "/" + QString::fromStdWString(AppConfig::vfs32DLLName()); + } + else if (extender->getArch() == IMAGE_FILE_MACHINE_AMD64) + { + targetPath = pluginsDir.absoluteFilePath(ToQString(AppConfig::vfs64DLLName())); + vfsDLLPath = qApp->applicationDirPath() + "/" + QString::fromStdWString(AppConfig::vfs64DLLName()); + } + + qDebug("DLL USVFS Target Path: " + targetPath.toLatin1()); + qDebug("DLL USVFS VFS DLL Path: " + vfsDLLPath.toLatin1()); QFile dllFile(targetPath); if (dllFile.exists()) { // may be outdated - if (!hashIdentical(targetPath, hookDLLPath)) { + if (!hashIdentical(targetPath, vfsDLLPath)) { dllFile.remove(); } } if (!dllFile.exists()) { // install dll to SE plugins - if (!QFile::copy(hookDLLPath, targetPath)) { - throw MyException(QObject::tr("Failed to copy %1 to %2").arg(hookDLLPath, targetPath)); + if (!QFile::copy(vfsDLLPath, targetPath)) { + throw MyException(QObject::tr("Failed to copy %1 to %2").arg(vfsDLLPath, targetPath)); } } writeHintFile(pluginsDir); -*/ } catch (const std::exception &e) { QMessageBox::critical(nullptr, QObject::tr("Failed to set up script extender loading"), e.what()); } @@ -278,14 +294,17 @@ void LoadMechanism::activate(EMechanism mechanism) { switch (mechanism) { case LOAD_MODORGANIZER: { + qDebug("Load Mechanism: Mod Organizer"); deactivateProxyDLL(); deactivateScriptExtender(); } break; case LOAD_SCRIPTEXTENDER: { + qDebug("Load Mechanism: ScriptExtender"); deactivateProxyDLL(); activateScriptExtender(); } break; case LOAD_PROXYDLL: { + qDebug("Load Mechanism: Proxy DLL"); deactivateScriptExtender(); activateProxyDLL(); } break; diff --git a/src/shared/appconfig.inc b/src/shared/appconfig.inc index ac6c210f..e98757d3 100644 --- a/src/shared/appconfig.inc +++ b/src/shared/appconfig.inc @@ -14,6 +14,8 @@ APPPARAM(std::wstring, iniFileName, L"ModOrganizer.ini") APPPARAM(std::wstring, proxyDLLTarget, L"steam_api.dll") APPPARAM(std::wstring, proxyDLLOrig, L"steam_api_orig.dll") // needs to be identical to the value used in proxydll-project APPPARAM(std::wstring, proxyDLLSource, L"proxy.dll") +APPPARAM(std::wstring, vfs32DLLName, L"usvfs_x86.dll") +APPPARAM(std::wstring, vfs64DLLName, L"usvfs_x64.dll") APPPARAM(const wchar_t*, localSavePlaceholder, L"__MOProfileSave__\\") APPPARAM(std::wstring, firstStepsTutorial, L"tutorial_firststeps_main.js") -- cgit v1.3.1 From 087f3841f3dbf92936ac30e935520c728fef1776 Mon Sep 17 00:00:00 2001 From: Jeremy Rimpo Date: Tue, 31 Oct 2017 21:29:12 -0500 Subject: If architecture is not detected, skip handling --- src/loadmechanism.cpp | 65 +++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 31 deletions(-) (limited to 'src/loadmechanism.cpp') diff --git a/src/loadmechanism.cpp b/src/loadmechanism.cpp index a2050512..7ad36ac7 100644 --- a/src/loadmechanism.cpp +++ b/src/loadmechanism.cpp @@ -142,12 +142,14 @@ void LoadMechanism::deactivateScriptExtender() vfsDLLName = ToQString(AppConfig::vfs64DLLName()); } qDebug("USVFS DLL Name: " + vfsDLLName.toLatin1()); - if (QFile(pluginsDir.absoluteFilePath(vfsDLLName)).exists()) { - // remove dll from SE plugins directory - if (!pluginsDir.remove(vfsDLLName)) { - throw MyException(QObject::tr("Failed to delete %1").arg(pluginsDir.absoluteFilePath(vfsDLLName))); - } - } + if (vfsDLLName != "") { + if (QFile(pluginsDir.absoluteFilePath(vfsDLLName)).exists()) { + // remove dll from SE plugins directory + if (!pluginsDir.remove(vfsDLLName)) { + throw MyException(QObject::tr("Failed to delete %1").arg(pluginsDir.absoluteFilePath(vfsDLLName))); + } + } + } removeHintFile(pluginsDir); } catch (const std::exception &e) { @@ -201,36 +203,37 @@ void LoadMechanism::activateScriptExtender() } #pragma message("implement this for usvfs") - QString targetPath; - QString vfsDLLPath; + std::wstring vfsDLL = L""; if (extender->getArch() == IMAGE_FILE_MACHINE_I386) { - targetPath = pluginsDir.absoluteFilePath(ToQString(AppConfig::vfs32DLLName())); - vfsDLLPath = qApp->applicationDirPath() + "/" + QString::fromStdWString(AppConfig::vfs32DLLName()); + vfsDLL = AppConfig::vfs32DLLName(); } else if (extender->getArch() == IMAGE_FILE_MACHINE_AMD64) { - targetPath = pluginsDir.absoluteFilePath(ToQString(AppConfig::vfs64DLLName())); - vfsDLLPath = qApp->applicationDirPath() + "/" + QString::fromStdWString(AppConfig::vfs64DLLName()); + vfsDLL = AppConfig::vfs64DLLName(); + } + if (vfsDLL != L"") { + QString targetPath = pluginsDir.absoluteFilePath(ToQString(vfsDLL)); + QString vfsDLLPath = qApp->applicationDirPath() + "/" + QString::fromStdWString(vfsDLL); + + qDebug("DLL USVFS Target Path: " + targetPath.toLatin1()); + qDebug("DLL USVFS VFS DLL Path: " + vfsDLLPath.toLatin1()); + + QFile dllFile(targetPath); + + if (dllFile.exists()) { + // may be outdated + if (!hashIdentical(targetPath, vfsDLLPath)) { + dllFile.remove(); + } + } + + if (!dllFile.exists()) { + // install dll to SE plugins + if (!QFile::copy(vfsDLLPath, targetPath)) { + throw MyException(QObject::tr("Failed to copy %1 to %2").arg(vfsDLLPath, targetPath)); + } + } } - - qDebug("DLL USVFS Target Path: " + targetPath.toLatin1()); - qDebug("DLL USVFS VFS DLL Path: " + vfsDLLPath.toLatin1()); - - QFile dllFile(targetPath); - - if (dllFile.exists()) { - // may be outdated - if (!hashIdentical(targetPath, vfsDLLPath)) { - dllFile.remove(); - } - } - - if (!dllFile.exists()) { - // install dll to SE plugins - if (!QFile::copy(vfsDLLPath, targetPath)) { - throw MyException(QObject::tr("Failed to copy %1 to %2").arg(vfsDLLPath, targetPath)); - } - } writeHintFile(pluginsDir); } catch (const std::exception &e) { QMessageBox::critical(nullptr, QObject::tr("Failed to set up script extender loading"), e.what()); -- cgit v1.3.1