summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorTannin <devnull@localhost>2015-03-09 12:34:34 +0100
committerTannin <devnull@localhost>2015-03-09 12:34:34 +0100
commit7a1ae9b0f1560c9eda32e032796fbb3fd56ff236 (patch)
treedea71435ac1042cb008fcd9f7b1ec57e6ea91227 /src/shared
parentd45ebf134819e1559718681becca9c4139fb7151 (diff)
parentdb2954e8eb41da715b9e7d79a72e225797401413 (diff)
Merge with branch1.2
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/appconfig.inc9
-rw-r--r--src/shared/directoryentry.cpp64
-rw-r--r--src/shared/directoryentry.h10
-rw-r--r--src/shared/error_report.cpp15
-rw-r--r--src/shared/fallout3info.cpp159
-rw-r--r--src/shared/fallout3info.h26
-rw-r--r--src/shared/falloutnvinfo.cpp154
-rw-r--r--src/shared/falloutnvinfo.h50
-rw-r--r--src/shared/gameinfo.cpp114
-rw-r--r--src/shared/gameinfo.h79
-rw-r--r--src/shared/inject.cpp16
-rw-r--r--src/shared/leaktrace.cpp2
-rw-r--r--src/shared/oblivioninfo.cpp155
-rw-r--r--src/shared/oblivioninfo.h52
-rw-r--r--src/shared/skyriminfo.cpp179
-rw-r--r--src/shared/skyriminfo.h34
-rw-r--r--src/shared/stackdata.cpp3
-rw-r--r--src/shared/util.cpp21
-rw-r--r--src/shared/windows_error.cpp4
19 files changed, 206 insertions, 940 deletions
diff --git a/src/shared/appconfig.inc b/src/shared/appconfig.inc
index 7ce2724f..e2dbfe20 100644
--- a/src/shared/appconfig.inc
+++ b/src/shared/appconfig.inc
@@ -1,9 +1,16 @@
APPPARAM(std::wstring, translationPrefix, L"organizer")
APPPARAM(std::wstring, pluginPath, L"plugins")
+APPPARAM(std::wstring, profilesPath, L"profiles")
+APPPARAM(std::wstring, modsPath, L"mods")
+APPPARAM(std::wstring, downloadPath, L"downloads")
APPPARAM(std::wstring, overwritePath, L"overwrite")
APPPARAM(std::wstring, stylesheetsPath, L"stylesheets")
+APPPARAM(std::wstring, cachePath, L"webcache")
+APPPARAM(std::wstring, tutorialsPath, L"tutorials")
+APPPARAM(std::wstring, logPath, L"logs")
APPPARAM(std::wstring, profileTweakIni, L"profile_tweaks.ini")
-APPPARAM(std::wstring, logFile, L"ModOrganizer.log")
+APPPARAM(std::wstring, logFileName, L"ModOrganizer.log")
+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")
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 8509e19b..9a864245 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -227,15 +227,16 @@ std::vector<FileEntry::Ptr> FilesOrigin::getFiles() const
void FileEntry::addOrigin(int origin, FILETIME fileTime, const std::wstring &archive)
{
- m_LastAccessed = time(NULL);
- if (m_Parent != NULL) {
+ m_LastAccessed = time(nullptr);
+ if (m_Parent != nullptr) {
m_Parent->propagateOrigin(origin);
}
if (m_Origin == -1) {
m_Origin = origin;
m_FileTime = fileTime;
m_Archive = archive;
- } else if (m_Parent->getOriginByID(origin).getPriority() > m_Parent->getOriginByID(m_Origin).getPriority()) {
+ } else if ((m_Parent != nullptr)
+ && (m_Parent->getOriginByID(origin).getPriority() > m_Parent->getOriginByID(m_Origin).getPriority())) {
if (std::find(m_Alternatives.begin(), m_Alternatives.end(), m_Origin) == m_Alternatives.end()) {
m_Alternatives.push_back(m_Origin);
}
@@ -253,7 +254,8 @@ void FileEntry::addOrigin(int origin, FILETIME fileTime, const std::wstring &arc
// already an origin
return;
}
- if (m_Parent->getOriginByID(*iter).getPriority() < m_Parent->getOriginByID(origin).getPriority()) {
+ if ((m_Parent != nullptr)
+ && (m_Parent->getOriginByID(*iter).getPriority() < m_Parent->getOriginByID(origin).getPriority())) {
m_Alternatives.insert(iter, origin);
found = true;
break;
@@ -285,8 +287,8 @@ bool FileEntry::removeOrigin(int origin)
// now we need to update the file time...
std::wstring filePath = getFullPath();
HANDLE file = ::CreateFile(filePath.c_str(), GENERIC_READ | GENERIC_WRITE,
- 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
- if (!::GetFileTime(file, NULL, NULL, &m_FileTime)) {
+ 0, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
+ if (!::GetFileTime(file, nullptr, nullptr, &m_FileTime)) {
// maybe this file is in a bsa, but there is no easy way to find out which. User should refresh
// the view to find out
m_Archive = L"bsa?";
@@ -319,13 +321,13 @@ static bool ByOriginPriority(DirectoryEntry *entry, int LHS, int RHS)
FileEntry::FileEntry()
- : m_Index(UINT_MAX), m_Name(), m_Origin(-1), m_Parent(NULL), m_LastAccessed(time(NULL))
+ : m_Index(UINT_MAX), m_Name(), m_Origin(-1), m_Parent(nullptr), m_LastAccessed(time(nullptr))
{
LEAK_TRACE;
}
FileEntry::FileEntry(Index index, const std::wstring &name, DirectoryEntry *parent)
- : m_Index(index), m_Name(name), m_Origin(-1), m_Parent(parent), m_Archive(L""), m_LastAccessed(time(NULL))
+ : m_Index(index), m_Name(name), m_Origin(-1), m_Parent(parent), m_Archive(L""), m_LastAccessed(time(nullptr))
{
LEAK_TRACE;
}
@@ -346,7 +348,7 @@ void FileEntry::sortOrigins()
bool FileEntry::recurseParents(std::wstring &path, const DirectoryEntry *parent) const
{
- if (parent == NULL) {
+ if (parent == nullptr) {
return false;
} else {
// don't append the topmost parent because it is the virtual data-root
@@ -475,7 +477,7 @@ void DirectoryEntry::addFromBSA(const std::wstring &originName, std::wstring &di
void DirectoryEntry::propagateOrigin(int origin)
{
m_Origins.insert(origin);
- if (m_Parent != NULL) {
+ if (m_Parent != nullptr) {
m_Parent->propagateOrigin(origin);
}
}
@@ -508,15 +510,15 @@ void DirectoryEntry::addFiles(FilesOrigin &origin, wchar_t *buffer, int bufferOf
{
WIN32_FIND_DATAW findData;
- _snwprintf(buffer + bufferOffset, MAXPATH_UNICODE - bufferOffset, L"\\*");
+ _snwprintf_s(buffer + bufferOffset, MAXPATH_UNICODE - bufferOffset, _TRUNCATE, L"\\*");
- HANDLE searchHandle = NULL;
+ HANDLE searchHandle = nullptr;
if (SupportOptimizedFind()) {
- searchHandle = ::FindFirstFileExW(buffer, FindExInfoBasic, &findData, FindExSearchNameMatch, NULL,
+ searchHandle = ::FindFirstFileExW(buffer, FindExInfoBasic, &findData, FindExSearchNameMatch, nullptr,
FIND_FIRST_EX_LARGE_FETCH);
} else {
- searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, NULL, 0);
+ searchHandle = ::FindFirstFileExW(buffer, FindExInfoStandard, &findData, FindExSearchNameMatch, nullptr, 0);
}
if (searchHandle != INVALID_HANDLE_VALUE) {
@@ -567,7 +569,7 @@ bool DirectoryEntry::removeFile(const std::wstring &filePath, int *origin)
std::wstring dirName = filePath.substr(0, pos);
std::wstring rest = filePath.substr(pos + 1);
DirectoryEntry *entry = getSubDirectoryRecursive(dirName, false);
- if (entry != NULL) {
+ if (entry != nullptr) {
return entry->removeFile(rest, origin);
} else {
return false;
@@ -605,7 +607,7 @@ void DirectoryEntry::removeDir(const std::wstring &path)
std::wstring dirName = path.substr(0, pos);
std::wstring rest = path.substr(pos + 1);
DirectoryEntry *entry = getSubDirectoryRecursive(dirName, false);
- if (entry != NULL) {
+ if (entry != nullptr) {
entry->removeDir(rest);
}
}
@@ -704,12 +706,12 @@ FilesOrigin &DirectoryEntry::getOriginByName(const std::wstring &name) const
int DirectoryEntry::getOrigin(const std::wstring &path, bool &archive)
{
- const DirectoryEntry *directory = NULL;
+ const DirectoryEntry *directory = nullptr;
const FileEntry::Ptr file = searchFile(path, &directory);
- if (file.get() != NULL) {
+ if (file.get() != nullptr) {
return file->getOrigin(archive);
} else {
- if (directory != NULL) {
+ if (directory != nullptr) {
return directory->anyOrigin();
} else {
return -1;
@@ -729,13 +731,13 @@ std::vector<FileEntry::Ptr> DirectoryEntry::getFiles() const
const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const DirectoryEntry **directory) const
{
- if (directory != NULL) {
- *directory = NULL;
+ if (directory != nullptr) {
+ *directory = nullptr;
}
if ((path.length() == 0) || (path == L"*")) {
// no file name -> the path ended on a (back-)slash
- if (directory != NULL) {
+ if (directory != nullptr) {
*directory = this;
}
return FileEntry::Ptr();
@@ -748,9 +750,9 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const
auto iter = m_Files.find(ToLower(path));
if (iter != m_Files.end()) {
return m_FileRegister->getFile(iter->second);
- } else if (directory != NULL) {
+ } else if (directory != nullptr) {
DirectoryEntry *temp = findSubDirectory(path);
- if (temp != NULL) {
+ if (temp != nullptr) {
*directory = temp;
}
}
@@ -758,7 +760,7 @@ const FileEntry::Ptr DirectoryEntry::searchFile(const std::wstring &path, const
// file is in in a subdirectory, recurse into the matching subdirectory
std::wstring pathComponent = path.substr(0, len);
DirectoryEntry *temp = findSubDirectory(pathComponent);
- if (temp != NULL) {
+ if (temp != nullptr) {
return temp->searchFile(path.substr(len + 1), directory);
}
}
@@ -773,7 +775,7 @@ DirectoryEntry *DirectoryEntry::findSubDirectory(const std::wstring &name) const
return *iter;
}
}
- return NULL;
+ return nullptr;
}
@@ -805,7 +807,7 @@ DirectoryEntry *DirectoryEntry::getSubDirectory(const std::wstring &name, bool c
new DirectoryEntry(name, this, originID, m_FileRegister, m_OriginConnection));
return *iter;
} else {
- return NULL;
+ return nullptr;
}
}
@@ -822,8 +824,8 @@ DirectoryEntry *DirectoryEntry::getSubDirectoryRecursive(const std::wstring &pat
return getSubDirectory(path, create);
} else {
DirectoryEntry *nextChild = getSubDirectory(path.substr(0, pos), create, originID);
- if (nextChild == NULL) {
- return NULL;
+ if (nextChild == nullptr) {
+ return nullptr;
} else {
return nextChild->getSubDirectoryRecursive(path.substr(pos + 1), create, originID);
}
@@ -885,7 +887,7 @@ void FileRegister::unregisterFile(FileEntry::Ptr file)
}
// unregister from directory
- if (file->getParent() != NULL) {
+ if (file->getParent() != nullptr) {
file->getParent()->removeFile(file->getIndex());
}
}
@@ -943,7 +945,7 @@ void FileRegister::removeOriginMulti(std::set<FileEntry::Index> indices, int ori
// only when disabling an origin that is probably frequently the case
std::set<DirectoryEntry*> parents;
BOOST_FOREACH (const FileEntry::Ptr &file, removedFiles) {
- if (file->getParent() != NULL) {
+ if (file->getParent() != nullptr) {
parents.insert(file->getParent());
}
}
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h
index 7a39b576..0075d5e5 100644
--- a/src/shared/directoryentry.h
+++ b/src/shared/directoryentry.h
@@ -245,12 +245,12 @@ public:
/** retrieve a file in this directory by name.
* @param name name of the file
- * @return fileentry object for the file or NULL if no file matches
+ * @return fileentry object for the file or nullptr if no file matches
*/
const FileEntry::Ptr findFile(const std::wstring &name) const;
/** search through this directory and all subdirectories for a file by the specified name (relative path).
- if directory is not NULL, the referenced variable will be set to the path containing the file */
+ if directory is not nullptr, the referenced variable will be set to the path containing the file */
const FileEntry::Ptr searchFile(const std::wstring &path, const DirectoryEntry **directory) const;
void insertFile(const std::wstring &filePath, FilesOrigin &origin, FILETIME fileTime);
@@ -258,7 +258,7 @@ public:
void removeFile(FileEntry::Index index);
// remove the specified file from the tree. This can be a path leading to a file in a subdirectory
- bool removeFile(const std::wstring &filePath, int *origin = NULL);
+ bool removeFile(const std::wstring &filePath, int *origin = nullptr);
/**
* @brief remove the specified directory
@@ -269,9 +269,9 @@ public:
bool remove(const std::wstring &fileName, int *origin) {
auto iter = m_Files.find(ToLower(fileName));
if (iter != m_Files.end()) {
- if (origin != NULL) {
+ if (origin != nullptr) {
FileEntry::Ptr entry = m_FileRegister->getFile(iter->second);
- if (entry.get() != NULL) {
+ if (entry.get() != nullptr) {
bool ignore;
*origin = entry->getOrigin(ignore);
}
diff --git a/src/shared/error_report.cpp b/src/shared/error_report.cpp
index 02ff2d56..6d091630 100644
--- a/src/shared/error_report.cpp
+++ b/src/shared/error_report.cpp
@@ -35,7 +35,7 @@ void reportError(LPCSTR format, ...)
vsnprintf(buffer, 1024, format, argList);
va_end(argList);
- MessageBoxA(NULL, buffer, "Error", MB_OK | MB_ICONERROR);
+ MessageBoxA(nullptr, buffer, "Error", MB_OK | MB_ICONERROR);
}
void reportError(LPCWSTR format, ...)
@@ -46,22 +46,21 @@ void reportError(LPCWSTR format, ...)
va_list argList;
va_start(argList, format);
-
- _vsnwprintf(buffer, 1024, format, argList);
+ _vsnwprintf_s(buffer, 1024, format, argList);
va_end(argList);
- MessageBoxW(NULL, buffer, L"Error", MB_OK | MB_ICONERROR);
+ MessageBoxW(nullptr, buffer, L"Error", MB_OK | MB_ICONERROR);
}
std::string getCurrentErrorStringA()
{
- LPSTR buffer = NULL;
+ LPSTR buffer = nullptr;
DWORD errorCode = ::GetLastError();
if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, NULL) == 0) {
+ nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, nullptr) == 0) {
::SetLastError(errorCode);
return std::string();
} else {
@@ -78,12 +77,12 @@ std::string getCurrentErrorStringA()
std::wstring getCurrentErrorStringW()
{
- LPWSTR buffer = NULL;
+ LPWSTR buffer = nullptr;
DWORD errorCode = ::GetLastError();
if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&buffer, 0, NULL) == 0) {
+ nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&buffer, 0, nullptr) == 0) {
::SetLastError(errorCode);
return std::wstring();
} else {
diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp
index 919764b4..37238a2a 100644
--- a/src/shared/fallout3info.cpp
+++ b/src/shared/fallout3info.cpp
@@ -30,8 +30,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-Fallout3Info::Fallout3Info(const std::wstring &omoDirectory, const std::wstring &gameDirectory)
- : GameInfo(omoDirectory, gameDirectory)
+Fallout3Info::Fallout3Info(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory)
+ : GameInfo(moDirectory, moDataDirectory, gameDirectory)
{
identifyMyGamesDirectory(L"fallout3");
}
@@ -42,11 +42,6 @@ bool Fallout3Info::identifyGame(const std::wstring &searchPath)
FileExists(searchPath, L"FalloutLauncher.exe");
}
-unsigned long Fallout3Info::getBSAVersion()
-{
- return 0x68;
-}
-
std::wstring Fallout3Info::getRegPathStatic()
{
HKEY key;
@@ -60,59 +55,13 @@ std::wstring Fallout3Info::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
}
}
-std::wstring Fallout3Info::getInvalidationBSA()
-{
- return L"Fallout - Invalidation.bsa";
-}
-
-bool Fallout3Info::isInvalidationBSA(const std::wstring &bsaName)
-{
- static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", NULL };
-
- for (int i = 0; invalidation[i] != NULL; ++i) {
- if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
- return true;
- }
- }
- return false;
-}
-
-std::wstring Fallout3Info::getDocumentsDir()
-{
- std::wostringstream temp;
- temp << getMyGamesDirectory() << L"\\Fallout3";
-
- return temp.str();
-}
-
-std::wstring Fallout3Info::getSaveGameDir()
-{
- std::wostringstream temp;
- temp << getDocumentsDir() << L"\\Saves";
- return temp.str();
-}
-
-std::vector<std::wstring> Fallout3Info::getPrimaryPlugins()
-{
- return boost::assign::list_of(L"fallout3.esm");
-}
-
-std::vector<std::wstring> Fallout3Info::getVanillaBSAs()
-{
- return boost::assign::list_of (L"Fallout - Textures.bsa")
- (L"Fallout - Meshes.bsa")
- (L"Fallout - Voices.bsa")
- (L"Fallout - Sound.bsa")
- (L"Fallout - MenuVoices.bsa")
- (L"Fallout - Misc.bsa");
-}
std::vector<std::wstring> Fallout3Info::getDLCPlugins()
{
@@ -134,40 +83,19 @@ std::vector<std::wstring> Fallout3Info::getIniFileNames()
return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini");
}
-std::wstring Fallout3Info::getSaveGameExtension()
-{
- return L"*.fos";
-}
-
std::wstring Fallout3Info::getReferenceDataFile()
{
return L"Fallout - Meshes.bsa";
}
-std::wstring Fallout3Info::getOMODExt()
-{
- return L"fomod";
-}
+
std::vector<std::wstring> Fallout3Info::getSteamVariants() const
{
return boost::assign::list_of(L"Regular")(L"Game Of The Year");
}
-std::wstring Fallout3Info::getSteamAPPId(int variant) const
-{
- switch (variant) {
- case 1: return L"22370";
- default: return L"22300";
- }
-}
-
-
-std::wstring Fallout3Info::getSEName()
-{
- return L"fose";
-}
std::wstring Fallout3Info::getNexusPage(bool nmmScheme)
@@ -192,73 +120,11 @@ int Fallout3Info::getNexusModIDStatic()
}
-void Fallout3Info::createProfile(const std::wstring &directory, bool useDefaults)
-{
- std::wostringstream target;
-
- // copy plugins.txt
- target << directory << "\\plugins.txt";
-
- if (!FileExists(target.str())) {
- std::wostringstream source;
- source << getLocalAppFolder() << "\\Fallout3\\plugins.txt";
- if (!::CopyFileW(source.str().c_str(), target.str().c_str(), true)) {
- HANDLE file = ::CreateFileW(target.str().c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- ::CloseHandle(file);
- }
- }
-
- // copy ini-file
- target.str(L""); target.clear();
- target << directory << L"\\fallout.ini";
-
- if (!FileExists(target.str())) {
- std::wostringstream source;
- if (useDefaults) {
- source << getGameDirectory() << L"\\fallout_default.ini";
- } else {
- source << getMyGamesDirectory() << L"\\Fallout3";
- if (FileExists(source.str(), L"fallout.ini")) {
- source << L"\\fallout.ini";
- } else {
- source.str(L"");
- source << getGameDirectory() << L"\\fallout_default.ini";
- }
- }
-
- if (!::CopyFileW(source.str().c_str(), target.str().c_str(), true)) {
- if (::GetLastError() != ERROR_FILE_EXISTS) {
- std::ostringstream stream;
- stream << "failed to copy ini file: " << ToString(source.str(), false);
- throw windows_error(stream.str());
- }
- }
- }
- { // copy falloutprefs.ini-file
- std::wstring target = directory + L"\\falloutprefs.ini";
- if (!FileExists(target)) {
- std::wstring source = getMyGamesDirectory() + L"\\Fallout3\\falloutprefs.ini";
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- if (::GetLastError() != ERROR_FILE_EXISTS) {
- throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
- }
- }
- }
- }
-}
-
-
-void Fallout3Info::repairProfile(const std::wstring &directory)
-{
- createProfile(directory, false);
-}
-
-
bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
- static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
@@ -266,17 +132,4 @@ bool Fallout3Info::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
return false;
}
-
-std::vector<ExecutableInfo> Fallout3Info::getExecutables()
-{
- std::vector<ExecutableInfo> result;
- result.push_back(ExecutableInfo(L"FOSE", L"fose_loader.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Fallout 3", L"fallout3.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Fallout Mod Manager", L"fomm/fomm.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Construction Kit", L"geck.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Fallout Launcher", L"FalloutLauncher.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"BOSS", L"BOSS/BOSS.exe", L"", L"", NEVER_CLOSE));
-
- return result;
-}
} // namespace MOShared
diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h
index 1e8d1e0c..6e6a7b85 100644
--- a/src/shared/fallout3info.h
+++ b/src/shared/fallout3info.h
@@ -35,8 +35,6 @@ public:
virtual ~Fallout3Info() {}
- virtual unsigned long getBSAVersion();
-
static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"Fallout3.exe"; }
@@ -46,32 +44,15 @@ public:
virtual std::wstring getGameName() const { return L"Fallout 3"; }
virtual std::wstring getGameShortName() const { return L"Fallout3"; }
- virtual std::wstring getInvalidationBSA();
-
- virtual bool isInvalidationBSA(const std::wstring &bsaName);
-
- // full path to this games "My Games"-directory
- virtual std::wstring getDocumentsDir();
-
- virtual std::wstring getSaveGameDir();
-
- virtual std::vector<std::wstring> getPrimaryPlugins();
-
- virtual std::vector<std::wstring> getVanillaBSAs();
virtual std::vector<std::wstring> getDLCPlugins();
virtual std::vector<std::wstring> getSavegameAttachmentExtensions();
// file name of this games ini (no path)
virtual std::vector<std::wstring> getIniFileNames();
- virtual std::wstring getSaveGameExtension();
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getOMODExt();
virtual std::vector<std::wstring> getSteamVariants() const;
- virtual std::wstring getSteamAPPId(int variant = 0) const;
-
- virtual std::wstring getSEName();
virtual std::wstring getNexusPage(bool nmmScheme = true);
static std::wstring getNexusInfoUrlStatic();
@@ -80,20 +61,17 @@ public:
virtual int getNexusModID() { return getNexusModIDStatic(); }
virtual int getNexusGameID() { return 120; }
- virtual void createProfile(const std::wstring &directory, bool useDefaults);
- virtual void repairProfile(const std::wstring &directory);
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
// get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
// the game directory
- virtual std::vector<ExecutableInfo> getExecutables();
+ //virtual std::vector<ExecutableInfo> getExecutables();
virtual std::wstring archiveListKey() { return L"SArchiveList"; }
private:
- Fallout3Info(const std::wstring &omoDirectory, const std::wstring &gameDirectory);
+ Fallout3Info(const std::wstring &moDirectory, 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 ff441f13..1203bd25 100644
--- a/src/shared/falloutnvinfo.cpp
+++ b/src/shared/falloutnvinfo.cpp
@@ -31,8 +31,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-FalloutNVInfo::FalloutNVInfo(const std::wstring &omoDirectory, const std::wstring &gameDirectory)
- : GameInfo(omoDirectory, gameDirectory)
+FalloutNVInfo::FalloutNVInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory)
+ : GameInfo(moDirectory, moDataDirectory, gameDirectory)
{
identifyMyGamesDirectory(L"falloutnv");
}
@@ -43,11 +43,6 @@ bool FalloutNVInfo::identifyGame(const std::wstring &searchPath)
FileExists(searchPath, L"FalloutNVLauncher.exe");
}
-unsigned long FalloutNVInfo::getBSAVersion()
-{
- return 0x68;
-}
-
std::wstring FalloutNVInfo::getRegPathStatic()
{
HKEY key;
@@ -61,60 +56,13 @@ std::wstring FalloutNVInfo::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
}
}
-std::wstring FalloutNVInfo::getInvalidationBSA()
-{
- return L"Fallout - Invalidation.bsa";
-}
-
-bool FalloutNVInfo::isInvalidationBSA(const std::wstring &bsaName)
-{
- static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", NULL };
-
- for (int i = 0; invalidation[i] != NULL; ++i) {
- if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
- return true;
- }
- }
- return false;
-}
-
-std::wstring FalloutNVInfo::getDocumentsDir()
-{
- std::wostringstream temp;
- temp << getMyGamesDirectory() << L"\\FalloutNV";
-
- return temp.str();
-}
-
-std::wstring FalloutNVInfo::getSaveGameDir()
-{
- std::wostringstream temp;
- temp << getDocumentsDir() << L"\\Saves";
- return temp.str();
-}
-
-std::vector<std::wstring> FalloutNVInfo::getPrimaryPlugins()
-{
- return boost::assign::list_of(L"falloutnv.esm");
-}
-
-std::vector<std::wstring> FalloutNVInfo::getVanillaBSAs()
-{
- return boost::assign::list_of (L"Fallout - Textures.bsa")
- (L"Fallout - Textures2.bsa")
- (L"Fallout - Meshes.bsa")
- (L"Fallout - Voices1.bsa")
- (L"Fallout - Sound.bsa")
- (L"Fallout - Misc.bsa");
-}
-
std::vector<std::wstring> FalloutNVInfo::getDLCPlugins()
{
return boost::assign::list_of (L"DeadMoney.esm")
@@ -139,84 +87,11 @@ std::vector<std::wstring> FalloutNVInfo::getIniFileNames()
return boost::assign::list_of(L"fallout.ini")(L"falloutprefs.ini");
}
-std::wstring FalloutNVInfo::getSaveGameExtension()
-{
- return L"*.fos";
-}
-
std::wstring FalloutNVInfo::getReferenceDataFile()
{
return L"Fallout - Meshes.bsa";
}
-
-std::wstring FalloutNVInfo::getOMODExt()
-{
- return L"fomod";
-}
-
-
-std::wstring FalloutNVInfo::getSteamAPPId(int) const
-{
- return L"22380";
-}
-
-
-void FalloutNVInfo::createProfile(const std::wstring &directory, bool useDefaults)
-{
- std::wstring target = directory + L"\\plugins.txt";
-
- // copy plugins.txt
- if (!FileExists(target)) {
- std::wstring source = getLocalAppFolder() + L"\\FalloutNV\\plugins.txt";
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- ::CloseHandle(file);
- }
- }
-
- // copy ini-file
- target = directory + L"\\fallout.ini";
-
- if (!FileExists(target)) {
- std::wstring source;
- if (useDefaults) {
- source = getGameDirectory() + L"\\fallout_default.ini";
- } else {
- source = getMyGamesDirectory() + L"\\FalloutNV";
- if (FileExists(source, L"fallout.ini")) {
- source += L"\\fallout.ini";
- } else {
- source = getGameDirectory() + L"\\fallout_default.ini";
- }
- }
-
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- if (::GetLastError() != ERROR_FILE_EXISTS) {
- throw windows_error("failed to copy ini file: " + ToString(source, false));
- }
- }
- }
- { // copy falloutprefs.ini-file
- std::wstring target = directory + L"\\falloutprefs.ini";
- if (!FileExists(target)) {
- std::wstring source = getMyGamesDirectory() + L"\\FalloutNV\\falloutprefs.ini";
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- if (::GetLastError() != ERROR_FILE_EXISTS) {
- throw windows_error("failed to copy ini file: " + ToString(source, false));
- }
- }
- }
- }
-}
-
-
-std::wstring FalloutNVInfo::getSEName()
-{
- return L"nvse";
-}
-
-
std::wstring FalloutNVInfo::getNexusPage(bool nmmScheme)
{
if (nmmScheme) {
@@ -239,17 +114,11 @@ int FalloutNVInfo::getNexusModIDStatic()
}
-void FalloutNVInfo::repairProfile(const std::wstring &directory)
-{
- createProfile(directory, false);
-}
-
-
bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
- static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"fallout.ini", L"falloutprefs.ini", L"plugins.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
@@ -257,17 +126,4 @@ bool FalloutNVInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
return false;
}
-
-std::vector<ExecutableInfo> FalloutNVInfo::getExecutables()
-{
- std::vector<ExecutableInfo> result;
- result.push_back(ExecutableInfo(L"NVSE", L"nvse_loader.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"New Vegas", L"falloutnv.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Fallout Mod Manager", L"fomm/fomm.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Construction Kit", L"geck.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Fallout Launcher", L"FalloutNVLauncher.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"BOSS", L"BOSS/BOSS.exe", L"", L"", NEVER_CLOSE));
-
- return result;
-}
} // namespace MOShared
diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h
index d862d313..e1a614d2 100644
--- a/src/shared/falloutnvinfo.h
+++ b/src/shared/falloutnvinfo.h
@@ -35,8 +35,6 @@ public:
virtual ~FalloutNVInfo() {}
- virtual unsigned long getBSAVersion();
-
static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"FalloutNV.exe"; }
@@ -48,31 +46,44 @@ public:
// virtual bool requiresSteam() const { return true; }
- virtual std::wstring getInvalidationBSA();
-
- virtual bool isInvalidationBSA(const std::wstring &bsaName);
+/* virtual std::wstring getInvalidationBSA()
+ {
+ return L"Fallout - Invalidation.bsa";
+ }
- // full path to this games "My Games"-directory
- virtual std::wstring getDocumentsDir();
+ virtual bool isInvalidationBSA(const std::wstring &bsaName)
+ {
+ static LPCWSTR invalidation[] = { L"Fallout - AI!.bsa", L"Fallout - Invalidation.bsa", nullptr };
- virtual std::wstring getSaveGameDir();
+ for (int i = 0; invalidation[i] != nullptr; ++i) {
+ if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
- virtual std::vector<std::wstring> getPrimaryPlugins();
+ virtual std::vector<std::wstring> getVanillaBSAs()
+ {
+ return boost::assign::list_of (L"Fallout - Textures.bsa")
+ (L"Fallout - Textures2.bsa")
+ (L"Fallout - Meshes.bsa")
+ (L"Fallout - Voices1.bsa")
+ (L"Fallout - Sound.bsa")
+ (L"Fallout - Misc.bsa");
+ }
- virtual std::vector<std::wstring> getVanillaBSAs();
+ virtual std::vector<std::wstring> getPrimaryPlugins()
+ {
+ return boost::assign::list_of(L"falloutnv.esm");
+ }*/
virtual std::vector<std::wstring> getDLCPlugins();
virtual std::vector<std::wstring> getSavegameAttachmentExtensions();
// file name of this games ini (no path)
virtual std::vector<std::wstring> getIniFileNames();
- virtual std::wstring getSaveGameExtension();
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getOMODExt();
-
- virtual std::wstring getSteamAPPId(int variant = 0) const;
-
- virtual std::wstring getSEName();
virtual std::wstring getNexusPage(bool nmmScheme = true);
static std::wstring getNexusInfoUrlStatic();
@@ -81,20 +92,17 @@ public:
virtual int getNexusModID() { return getNexusModIDStatic(); }
virtual int getNexusGameID() { return 130; }
- virtual void createProfile(const std::wstring &directory, bool useDefaults);
- virtual void repairProfile(const std::wstring &directory);
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
// get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
// the game directory
- virtual std::vector<ExecutableInfo> getExecutables();
+ //virtual std::vector<ExecutableInfo> getExecutables();
virtual std::wstring archiveListKey() { return L"SArchiveList"; }
private:
- FalloutNVInfo(const std::wstring &omoDirectory, const std::wstring &gameDirectory);
+ FalloutNVInfo(const std::wstring &moDirectory, 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 6a6e6c22..6d8957ad 100644
--- a/src/shared/gameinfo.cpp
+++ b/src/shared/gameinfo.cpp
@@ -27,19 +27,21 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "skyriminfo.h"
#include "util.h"
+#include <boost/assign.hpp>
+#include <boost/format.hpp>
+
#include <shlobj.h>
#include <sstream>
#include <cassert>
-#include <boost/assign.hpp>
namespace MOShared {
-GameInfo* GameInfo::s_Instance = NULL;
+GameInfo* GameInfo::s_Instance = nullptr;
-GameInfo::GameInfo(const std::wstring &omoDirectory, const std::wstring &gameDirectory)
- : m_GameDirectory(gameDirectory), m_OrganizerDirectory(omoDirectory)
+GameInfo::GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory)
+ : m_GameDirectory(gameDirectory), m_OrganizerDirectory(moDirectory), m_OrganizerDataDirectory(moDataDirectory)
{
atexit(&cleanup);
}
@@ -47,7 +49,7 @@ GameInfo::GameInfo(const std::wstring &omoDirectory, const std::wstring &gameDir
void GameInfo::cleanup() {
delete GameInfo::s_Instance;
- GameInfo::s_Instance = NULL;
+ GameInfo::s_Instance = nullptr;
}
@@ -60,56 +62,61 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file)
m_MyGamesDirectory.clear();
// a) this is the way it should work. get the configured My Documents\My Games directory
- if (::SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, myDocuments) == S_OK) {
+ if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_CURRENT, myDocuments) == S_OK) {
m_MyGamesDirectory = std::wstring(myDocuments) + L"\\My Games";
}
// b) if there is no <game> directory there, look in the default directory
if (m_MyGamesDirectory.empty()
|| !FileExists(m_MyGamesDirectory + L"\\" + file)) {
- if (::SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_DEFAULT, myDocuments) == S_OK) {
+ if (::SHGetFolderPathW(nullptr, CSIDL_PERSONAL, nullptr, SHGFP_TYPE_DEFAULT, myDocuments) == S_OK) {
std::wstring fromDefault = std::wstring(myDocuments) + L"\\My Games";
if (FileExists(fromDefault + L"\\" + file)) {
m_MyGamesDirectory = fromDefault;
}
}
}
- if (!FileExists(m_MyGamesDirectory.substr().append(L"/").append(file))) {
- m_MyGamesDirectory.assign(getSpecialPath(L"Personal")).append(L"\\My Games");
+ // c) finally, look in the registry. This is discouraged
+ if (m_MyGamesDirectory.empty()
+ || !FileExists(m_MyGamesDirectory + L"\\" + file)) {
+ std::wstring fromRegistry = getSpecialPath(L"Personal") + L"\\My Games";
+ if (FileExists(fromRegistry + L"\\" + file)) {
+ m_MyGamesDirectory = fromRegistry;
+ }
}
}
-bool GameInfo::identifyGame(const std::wstring &moDirectory, const std::wstring &searchPath)
+bool GameInfo::identifyGame(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &searchPath)
{
if (OblivionInfo::identifyGame(searchPath)) {
- s_Instance = new OblivionInfo(moDirectory, searchPath);
+ s_Instance = new OblivionInfo(moDirectory, moDataDirectory, searchPath);
} else if (Fallout3Info::identifyGame(searchPath)) {
- s_Instance = new Fallout3Info(moDirectory, searchPath);
+ s_Instance = new Fallout3Info(moDirectory, moDataDirectory, searchPath);
} else if (FalloutNVInfo::identifyGame(searchPath)) {
- s_Instance = new FalloutNVInfo(moDirectory, searchPath);
+ s_Instance = new FalloutNVInfo(moDirectory, moDataDirectory, searchPath);
} else if (SkyrimInfo::identifyGame(searchPath)) {
- s_Instance = new SkyrimInfo(moDirectory, searchPath);
+ s_Instance = new SkyrimInfo(moDirectory, moDataDirectory, searchPath);
}
- return s_Instance != NULL;
+ return s_Instance != nullptr;
}
-bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &gamePath)
+bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gamePath)
{
- if (s_Instance == NULL) {
+ 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(moDirectory, searchPath)) {
+ while (!identifyGame(moDirectory, moDataDirectory, searchPath)) {
size_t lastSep = searchPath.find_last_of(L"/\\");
if (lastSep == std::string::npos) {
return false;
}
searchPath.erase(lastSep);
}
- } else if (!identifyGame(moDirectory, gamePath)) {
+ } else if (!identifyGame(moDirectory, moDataDirectory, gamePath)) {
return false;
}
}
@@ -119,7 +126,7 @@ bool GameInfo::init(const std::wstring &moDirectory, const std::wstring &gamePat
GameInfo &GameInfo::instance()
{
- assert(s_Instance != NULL);
+ assert(s_Instance != nullptr && "gameinfo not yet initialized");
return *s_Instance;
}
@@ -128,61 +135,9 @@ std::wstring GameInfo::getGameDirectory() const
return m_GameDirectory;
}
-std::wstring GameInfo::getModsDir() const
-{
- return m_OrganizerDirectory + L"\\mods";
-}
-
-std::wstring GameInfo::getProfilesDir() const
-{
- return m_OrganizerDirectory + L"\\profiles";
-}
-
-std::wstring GameInfo::getIniFilename() const
-{
- return m_OrganizerDirectory + L"\\ModOrganizer.ini";
-}
-
-
-std::wstring GameInfo::getDownloadDir() const
-{
- return m_OrganizerDirectory + L"\\downloads";
-}
-
-
-std::wstring GameInfo::getCacheDir() const
-{
- return m_OrganizerDirectory + L"\\webcache";
-}
-
-
-std::wstring GameInfo::getOverwriteDir() const
-{
- return m_OrganizerDirectory + L"\\overwrite";
-}
-
-
-std::wstring GameInfo::getLogDir() const
-{
- return m_OrganizerDirectory + L"\\logs";
-}
-
-
-std::wstring GameInfo::getLootDir() const
-{
- return m_OrganizerDirectory + L"\\loot";
-}
-
-
-std::wstring GameInfo::getTutorialDir() const
-{
- return m_OrganizerDirectory + L"\\tutorials";
-}
-
-
bool GameInfo::requiresSteam() const
{
- return FileExists(getGameDirectory().append(L"\\steam_api.dll"));
+ return FileExists(getGameDirectory() + L"\\steam_api.dll");
}
std::vector<std::wstring> GameInfo::getSteamVariants() const
@@ -190,13 +145,12 @@ std::vector<std::wstring> GameInfo::getSteamVariants() const
return boost::assign::list_of(L"Regular");
}
-
std::wstring GameInfo::getLocalAppFolder() const
{
wchar_t localAppFolder[MAX_PATH];
memset(localAppFolder, '\0', MAX_PATH * sizeof(wchar_t));
- if (::SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) {
+ if (::SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) {
return localAppFolder;
} else {
// fallback: try the registry
@@ -207,19 +161,19 @@ std::wstring GameInfo::getLocalAppFolder() const
std::wstring GameInfo::getSpecialPath(LPCWSTR name) const
{
HKEY key;
- LONG errorcode = ::RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
- 0, KEY_QUERY_VALUE, &key);
+ LONG errorcode = ::RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\User Shell Folders",
+ 0, KEY_QUERY_VALUE, &key);
if (errorcode != ERROR_SUCCESS) {
- throw windows_error("failed to look up special folder", errorcode);
+ throw windows_error("failed to look up special folder (path)", errorcode);
}
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- errorcode = ::RegQueryValueExW(key, name, NULL, NULL, (LPBYTE)temp, &bufferSize);
+ errorcode = ::RegQueryValueExW(key, name, nullptr, nullptr, (LPBYTE)temp, &bufferSize);
if (errorcode != ERROR_SUCCESS) {
- throw windows_error("failed to look up special folder", errorcode);
+ throw windows_error((boost::format("failed to look up special folder (%1%)") % ToString(name, true)).str(), errorcode);
}
WCHAR temp2[MAX_PATH];
diff --git a/src/shared/gameinfo.h b/src/shared/gameinfo.h
index 33467cb9..77ed4d3c 100644
--- a/src/shared/gameinfo.h
+++ b/src/shared/gameinfo.h
@@ -29,31 +29,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-enum CloseMOStyle {
- DEFAULT_CLOSE,
- DEFAULT_STAY,
- NEVER_CLOSE
-};
-
-struct ExecutableInfo {
-
- ExecutableInfo(const std::wstring &aTitle, const std::wstring &aBinary,
- const std::wstring &aArguments, const std::wstring &aWorkingDirectory, CloseMOStyle aCloseMO)
- : title(aTitle), binary(aBinary), arguments(aArguments), workingDirectory(aWorkingDirectory),
- closeMO(aCloseMO), steamAppID(L"") {}
- ExecutableInfo(const std::wstring &aTitle, const std::wstring &aBinary,
- const std::wstring &aArguments, const std::wstring &aWorkingDirectory,
- CloseMOStyle aCloseMO, const std::wstring &aSteamAppID)
- : title(aTitle), binary(aBinary), arguments(aArguments), workingDirectory(aWorkingDirectory),
- closeMO(aCloseMO), steamAppID(aSteamAppID) {}
- std::wstring title;
- std::wstring binary;
- std::wstring arguments;
- std::wstring workingDirectory;
- CloseMOStyle closeMO;
- std::wstring steamAppID;
-};
-
/**
Class to manage information that depends on the used game type. The intention is to keep
@@ -86,50 +61,19 @@ public:
virtual std::wstring getRegPath() = 0;
virtual std::wstring getBinaryName() = 0;
- virtual unsigned long getBSAVersion() = 0;
-
virtual GameInfo::Type getType() = 0;
virtual std::wstring getGameName() const = 0;
virtual std::wstring getGameShortName() const = 0;
- // full path to this games "My Games"-directory
- virtual std::wstring getDocumentsDir() = 0;
-
- virtual std::wstring getSaveGameDir() = 0;
-
/// determine the load order mechanism used by this game. this may throw an
/// exception if the mechanism can't be determined
virtual LoadOrderMechanism getLoadOrderMechanism() const { return TYPE_FILETIME; }
virtual std::wstring getGameDirectory() const;
- // get absolute path to the directory where omo stores its mods
- virtual std::wstring getModsDir() const;
- // get absolute path to the directory where omo stores its profiles
- virtual std::wstring getProfilesDir() const;
-
- virtual std::wstring getIniFilename() const;
- virtual std::wstring getDownloadDir() const;
- virtual std::wstring getCacheDir() const;
- virtual std::wstring getOverwriteDir() const;
- virtual std::wstring getLogDir() const;
- virtual std::wstring getLootDir() const;
- virtual std::wstring getTutorialDir() const;
- virtual bool requiresBSAInvalidation() const { return true; }
virtual bool requiresSteam() const;
- virtual std::wstring getInvalidationBSA() = 0;
-
- virtual bool isInvalidationBSA(const std::wstring &bsaName) = 0;
-
- // the key in the game's ini-file that defines the list of bsas to load
- virtual std::wstring archiveListKey() = 0;
-
- virtual std::vector<std::wstring> getPrimaryPlugins() = 0;
-
- virtual std::vector<std::wstring> getVanillaBSAs() = 0;
-
// get a list of file extensions for additional files belonging to a save game
virtual std::vector<std::wstring> getSavegameAttachmentExtensions() = 0;
@@ -139,42 +83,28 @@ public:
// file name of this games ini file(s)
virtual std::vector<std::wstring> getIniFileNames() = 0;
- virtual std::wstring getSaveGameExtension() = 0;
virtual std::wstring getReferenceDataFile() = 0;
- virtual std::wstring getOMODExt() = 0;
-
virtual std::vector<std::wstring> getSteamVariants() const;
- virtual std::wstring getSteamAPPId(int variant = 0) const = 0;
-
- virtual std::wstring getSEName() = 0;
virtual std::wstring getNexusPage(bool nmmScheme = true) = 0;
virtual std::wstring getNexusInfoUrl() = 0;
virtual int getNexusModID() = 0;
virtual int getNexusGameID() = 0;
- // clone relevant files to the specified directory
- virtual void createProfile(const std::wstring &directory, bool useDefaults) = 0;
- virtual void repairProfile(const std::wstring &directory) = 0;
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath) = 0;
- // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
- // the game directory. the boolean says whether omo should be closed when the executable is started
- virtual std::vector<ExecutableInfo> getExecutables() = 0;
-
public:
- // initialise with the path to the omo directory (needs to be where hook.dll is stored). This
+ // 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 &omoDirectory, const std::wstring &gamePath = L"");
+ static bool init(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gamePath = L"");
static GameInfo& instance();
protected:
- GameInfo(const std::wstring &omoDirectory, const std::wstring &gameDirectory);
+ GameInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory);
std::wstring getLocalAppFolder() const;
const std::wstring &getMyGamesDirectory() const { return m_MyGamesDirectory; }
@@ -182,7 +112,7 @@ protected:
private:
- static bool identifyGame(const std::wstring &omoDirectory, const std::wstring &searchPath);
+ static bool identifyGame(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &searchPath);
std::wstring getSpecialPath(LPCWSTR name) const;
static void cleanup();
@@ -195,6 +125,7 @@ private:
std::wstring m_GameDirectory;
std::wstring m_OrganizerDirectory;
+ std::wstring m_OrganizerDataDirectory;
};
diff --git a/src/shared/inject.cpp b/src/shared/inject.cpp
index cf2a8972..36db7840 100644
--- a/src/shared/inject.cpp
+++ b/src/shared/inject.cpp
@@ -57,13 +57,13 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
_snprintf(parameters.initstr, 5, "Init"); //this is the name of thie initialisation function we want to call in the target process
HMODULE k32mod = ::LoadLibrary(__TEXT("kernel32.dll"));
- TLoadLibraryType loadLibraryFunc = NULL;
- TGetProcAddressType getProcAddressFunc = NULL;
+ TLoadLibraryType loadLibraryFunc = nullptr;
+ TGetProcAddressType getProcAddressFunc = nullptr;
// ansi binaries
- if (k32mod != NULL) {
+ if (k32mod != nullptr) {
loadLibraryFunc = reinterpret_cast<TLoadLibraryType>(::GetProcAddress(k32mod, "LoadLibraryA"));
getProcAddressFunc = reinterpret_cast<TGetProcAddressType>(::GetProcAddress(k32mod, "GetProcAddress"));
- if ((loadLibraryFunc == NULL) || (getProcAddressFunc == NULL)) {
+ if ((loadLibraryFunc == nullptr) || (getProcAddressFunc == nullptr)) {
throw windows_error("failed to determine address for required functions");
}
} else {
@@ -71,8 +71,8 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
}
// allocate memory in the target process and write the parameter-block there
- LPVOID remoteMem = ::VirtualAllocEx(processHandle, NULL, sizeof(TParameters), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
- if (remoteMem == NULL) {
+ LPVOID remoteMem = ::VirtualAllocEx(processHandle, nullptr, sizeof(TParameters), MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
+ if (remoteMem == nullptr) {
throw windows_error("failed to allocate memory in target process");
}
SIZE_T written;
@@ -104,8 +104,8 @@ void injectDLL(HANDLE processHandle, HANDLE threadHandle, const std::string &dll
};
// reserve memory for the stub
- PBYTE stubRemote = reinterpret_cast<PBYTE>(::VirtualAllocEx(processHandle, NULL, sizeof(stubLocal), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE));
- if (stubRemote == NULL) {
+ PBYTE stubRemote = reinterpret_cast<PBYTE>(::VirtualAllocEx(processHandle, nullptr, sizeof(stubLocal), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE));
+ if (stubRemote == nullptr) {
throw windows_error("failed to allocate memory for stub");
}
TParameters *remoteParams = reinterpret_cast<TParameters*>(remoteMem);
diff --git a/src/shared/leaktrace.cpp b/src/shared/leaktrace.cpp
index 0d99b82e..73786c6b 100644
--- a/src/shared/leaktrace.cpp
+++ b/src/shared/leaktrace.cpp
@@ -34,7 +34,7 @@ static struct __TraceData {
iter->second.size(), iter->first.toString().c_str());
printf("Addresses: ");
for (int i = 0; i < (std::min<int>)(5, iter->second.size()); ++i) {
- printf("%p, ", iter->second[i]);
+ printf("%p, ", reinterpret_cast<void*>(iter->second[i]));
}
printf("\n");
}
diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp
index 288ab17f..16748f58 100644
--- a/src/shared/oblivioninfo.cpp
+++ b/src/shared/oblivioninfo.cpp
@@ -31,8 +31,8 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-OblivionInfo::OblivionInfo(const std::wstring &omoDirectory, const std::wstring &gameDirectory)
- : GameInfo(omoDirectory, gameDirectory)
+OblivionInfo::OblivionInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory)
+ : GameInfo(moDirectory, moDataDirectory, gameDirectory)
{
identifyMyGamesDirectory(L"oblivion");
}
@@ -43,11 +43,6 @@ bool OblivionInfo::identifyGame(const std::wstring &searchPath)
FileExists(searchPath, L"OblivionLauncher.exe");
}
-unsigned long OblivionInfo::getBSAVersion()
-{
- return 0x67;
-}
-
std::wstring OblivionInfo::getRegPathStatic()
{
HKEY key;
@@ -61,63 +56,22 @@ std::wstring OblivionInfo::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
}
}
-std::wstring OblivionInfo::getInvalidationBSA()
-{
- return L"Oblivion - Invalidation.bsa";
-}
-bool OblivionInfo::isInvalidationBSA(const std::wstring &bsaName)
-{
- static LPCWSTR invalidation[] = { L"Oblivion - Invalidation.bsa", L"ArchiveInvalidationInvalidated!.bsa",
- L"BSARedirection.bsa", NULL };
- for (int i = 0; invalidation[i] != NULL; ++i) {
- if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
- return true;
- }
- }
- return false;
-}
-std::wstring OblivionInfo::getDocumentsDir()
-{
- std::wostringstream temp;
- temp << getMyGamesDirectory() << L"\\Oblivion";
- return temp.str();
-}
-std::wstring OblivionInfo::getSaveGameDir()
-{
- std::wostringstream temp;
- temp << getDocumentsDir() << L"\\Saves";
- return temp.str();
-}
-std::vector<std::wstring> OblivionInfo::getPrimaryPlugins()
-{
- return boost::assign::list_of(L"oblivion.esm");
-}
-std::vector<std::wstring> OblivionInfo::getVanillaBSAs()
-{
- return boost::assign::list_of(L"Oblivion - Meshes.bsa")
- (L"Oblivion - Textures - Compressed.bsa")
- (L"Oblivion - Sounds.bsa")
- (L"Oblivion - Voices1.bsa")
- (L"Oblivion - Voices2.bsa")
- (L"Oblivion - Misc.bsa");
-}
-
std::vector<std::wstring> OblivionInfo::getDLCPlugins()
{
@@ -147,67 +101,7 @@ std::vector<std::wstring> OblivionInfo::getIniFileNames()
}
-void OblivionInfo::createProfile(const std::wstring &directory, bool useDefaults)
-{
- std::wostringstream target;
-
- // copy plugins.txt
- target << directory << "\\plugins.txt";
-
- if (!FileExists(target.str())) {
- std::wostringstream source;
- source << getLocalAppFolder() << "\\Oblivion\\plugins.txt";
- if (!::CopyFileW(source.str().c_str(), target.str().c_str(), true)) {
- HANDLE file = ::CreateFileW(target.str().c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- ::CloseHandle(file);
- }
- }
-
- // copy ini-file
- target.str(L""); target.clear();
- target << directory << L"\\oblivion.ini";
-
- if (!FileExists(target.str())) {
- std::wostringstream source;
- if (useDefaults) {
- source << getGameDirectory() << L"\\oblivion_default.ini";
- } else {
- source << getMyGamesDirectory() << L"Oblivion";
- if (FileExists(source.str(), L"oblivion.ini")) {
- source << L"\\oblivion.ini";
- } else {
- source.str(L"");
- source << getGameDirectory() << L"\\oblivion_default.ini";
- }
- }
- if (!::CopyFileW(source.str().c_str(), target.str().c_str(), true)) {
- if (::GetLastError() != ERROR_FILE_EXISTS) {
- std::ostringstream stream;
- stream << "failed to copy ini file: " << ToString(source.str(), false);
- throw windows_error(stream.str());
- }
- }
- }
-
- { // copy oblivionprefs.ini-file
- std::wstring target = directory + L"\\oblivionprefs.ini";
- if (!FileExists(target)) {
- std::wstring source = getMyGamesDirectory() + L"\\Oblivion\\oblivionprefs.ini";
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- if ((::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL) == INVALID_HANDLE_VALUE) &&
- (::GetLastError() != ERROR_FILE_EXISTS)) {
- throw windows_error(std::string("failed to create ini file: ") + ToString(target, false));
- }
- }
- }
- }
-}
-
-std::wstring OblivionInfo::getSEName()
-{
- return L"obse";
-}
std::wstring OblivionInfo::getNexusPage(bool nmmScheme)
@@ -231,18 +125,11 @@ int OblivionInfo::getNexusModIDStatic()
return 38277;
}
-
-void OblivionInfo::repairProfile(const std::wstring &directory)
-{
- createProfile(directory, false);
-}
-
-
bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
{
- static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"oblivion.ini", L"oblivionprefs.ini", L"plugins.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
@@ -250,41 +137,9 @@ bool OblivionInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t*)
return false;
}
-
-std::wstring OblivionInfo::getSaveGameExtension()
-{
- return L"*.ess";
-}
-
std::wstring OblivionInfo::getReferenceDataFile()
{
return L"Oblivion - Meshes.bsa";
}
-
-std::wstring OblivionInfo::getOMODExt()
-{
- return L"omod";
-}
-
-
-std::wstring OblivionInfo::getSteamAPPId(int) const
-{
- return L"22330";
-}
-
-
-std::vector<ExecutableInfo> OblivionInfo::getExecutables()
-{
- std::vector<ExecutableInfo> result;
- result.push_back(ExecutableInfo(L"OBSE", L"obse_loader.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Oblivion", L"oblivion.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Oblivion Mod Manager", L"OblivionModManager.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Construction Set", L"TESConstructionSet.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Oblivion Launcher", L"OblivionLauncher.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"BOSS", L"BOSS/BOSS.exe", L"", L"", NEVER_CLOSE));
- result.push_back(ExecutableInfo(L"BOSS (old)", L"Data/BOSS.exe", L"", L"", NEVER_CLOSE));
-
- return result;
-}
} // namespace MOShared
diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h
index 7544e5ce..87ba26ff 100644
--- a/src/shared/oblivioninfo.h
+++ b/src/shared/oblivioninfo.h
@@ -33,8 +33,6 @@ public:
virtual ~OblivionInfo() {}
- virtual unsigned long getBSAVersion();
-
static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"Oblivion.exe"; }
@@ -43,32 +41,47 @@ public:
virtual std::wstring getGameName() const { return L"Oblivion"; }
virtual std::wstring getGameShortName() const { return L"Oblivion"; }
+/*
+ virtual std::wstring getInvalidationBSA()
+ {
+ return L"Oblivion - Invalidation.bsa";
+ }
- virtual std::wstring getInvalidationBSA();
-
- virtual bool isInvalidationBSA(const std::wstring &bsaName);
+ virtual bool isInvalidationBSA(const std::wstring &bsaName)
+ {
+ static LPCWSTR invalidation[] = { L"Oblivion - Invalidation.bsa", L"ArchiveInvalidationInvalidated!.bsa",
+ L"BSARedirection.bsa", nullptr };
- // full path to this games "My Games"-directory
- virtual std::wstring getDocumentsDir();
+ for (int i = 0; invalidation[i] != nullptr; ++i) {
+ if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
+ return true;
+ }
+ }
+ return false;
+ }
- virtual std::wstring getSaveGameDir();
+ virtual std::vector<std::wstring> getVanillaBSAs()
+ {
+ return boost::assign::list_of(L"Oblivion - Meshes.bsa")
+ (L"Oblivion - Textures - Compressed.bsa")
+ (L"Oblivion - Sounds.bsa")
+ (L"Oblivion - Voices1.bsa")
+ (L"Oblivion - Voices2.bsa")
+ (L"Oblivion - Misc.bsa");
+ }
- virtual std::vector<std::wstring> getPrimaryPlugins();
+ virtual std::vector<std::wstring> getPrimaryPlugins()
+ {
+ return boost::assign::list_of(L"oblivion.esm");
+ }*/
- virtual std::vector<std::wstring> getVanillaBSAs();
virtual std::vector<std::wstring> getDLCPlugins();
virtual std::vector<std::wstring> getSavegameAttachmentExtensions();
// file name of this games ini (no path)
virtual std::vector<std::wstring> getIniFileNames();
- virtual std::wstring getSaveGameExtension();
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getOMODExt();
-
- virtual std::wstring getSteamAPPId(int variant = 0) const;
-
- virtual std::wstring getSEName();
virtual std::wstring getNexusPage(bool nmmScheme = true);
static std::wstring getNexusInfoUrlStatic();
@@ -77,20 +90,17 @@ public:
virtual int getNexusModID() { return getNexusModIDStatic(); }
virtual int getNexusGameID() { return 101; }
- virtual void createProfile(const std::wstring &directory, bool useDefaults);
- virtual void repairProfile(const std::wstring &directory);
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
// get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
// the game directory
- virtual std::vector<ExecutableInfo> getExecutables();
+ //virtual std::vector<ExecutableInfo> getExecutables();
virtual std::wstring archiveListKey() { return L"SArchiveList"; }
private:
- OblivionInfo(const std::wstring &omoDirectory, const std::wstring &gameDirectory);
+ OblivionInfo(const std::wstring &moDirectory, 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 fc1401d8..f66fcef4 100644
--- a/src/shared/skyriminfo.cpp
+++ b/src/shared/skyriminfo.cpp
@@ -33,13 +33,13 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
namespace MOShared {
-SkyrimInfo::SkyrimInfo(const std::wstring &moDirectory, const std::wstring &gameDirectory)
- : GameInfo(moDirectory, gameDirectory)
+SkyrimInfo::SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory)
+ : GameInfo(moDirectory, moDataDirectory, gameDirectory)
{
identifyMyGamesDirectory(L"skyrim");
wchar_t appDataPath[MAX_PATH];
- if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, appDataPath))) {
+ if (SUCCEEDED(SHGetFolderPathW(nullptr, CSIDL_LOCAL_APPDATA, nullptr, SHGFP_TYPE_CURRENT, appDataPath))) {
m_AppData = appDataPath;
}
}
@@ -50,10 +50,7 @@ bool SkyrimInfo::identifyGame(const std::wstring &searchPath)
FileExists(searchPath, L"SkyrimLauncher.exe");
}
-unsigned long SkyrimInfo::getBSAVersion()
-{
- return 0x68;
-}
+
std::wstring SkyrimInfo::getRegPathStatic()
@@ -69,35 +66,16 @@ std::wstring SkyrimInfo::getRegPathStatic()
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ if (::RegQueryValueExW(key, L"Installed Path", nullptr, nullptr, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
return std::wstring(temp);
} else {
return std::wstring();
}
}
-
-std::wstring SkyrimInfo::getInvalidationBSA()
-{
- return L"Skyrim - Invalidation.bsa";
-}
-
-bool SkyrimInfo::isInvalidationBSA(const std::wstring &bsaName)
-{
- static LPCWSTR invalidation[] = { L"Skyrim - Invalidation.bsa", NULL };
-
- for (int i = 0; invalidation[i] != NULL; ++i) {
- if (wcscmp(bsaName.c_str(), invalidation[i]) == 0) {
- return true;
- }
- }
- return false;
-}
-
-
GameInfo::LoadOrderMechanism SkyrimInfo::getLoadOrderMechanism() const
{
- std::wstring fileName = getGameDirectory().append(L"\\TESV.exe");
+ std::wstring fileName = getGameDirectory() + L"\\TESV.exe";
try {
VS_FIXEDFILEINFO versionInfo = GetFileVersion(fileName);
@@ -113,42 +91,6 @@ GameInfo::LoadOrderMechanism SkyrimInfo::getLoadOrderMechanism() const
}
}
-std::wstring SkyrimInfo::getDocumentsDir()
-{
- std::wostringstream temp;
- temp << getMyGamesDirectory() << L"\\Skyrim";
-
- return temp.str();
-}
-
-std::wstring SkyrimInfo::getSaveGameDir()
-{
- std::wostringstream temp;
- temp << getDocumentsDir() << L"\\Saves";
- return temp.str();
-}
-
-std::vector<std::wstring> SkyrimInfo::getPrimaryPlugins()
-{
- return boost::assign::list_of(L"skyrim.esm")(L"update.esm");
-}
-
-std::vector<std::wstring> SkyrimInfo::getVanillaBSAs()
-{
- return boost::assign::list_of(L"Skyrim - Misc.bsa")
- (L"Skyrim - Shaders.bsa")
- (L"Skyrim - Textures.bsa")
- (L"HighResTexturePack01.bsa")
- (L"HighResTexturePack02.bsa")
- (L"HighResTexturePack03.bsa")
- (L"Skyrim - Interface.bsa")
- (L"Skyrim - Animations.bsa")
- (L"Skyrim - Meshes.bsa")
- (L"Skyrim - Sounds.bsa")
- (L"Skyrim - Voices.bsa")
- (L"Skyrim - VoicesExtra.bsa");
-}
-
std::vector<std::wstring> SkyrimInfo::getDLCPlugins()
{
return boost::assign::list_of (L"Dawnguard.esm")
@@ -170,35 +112,12 @@ std::vector<std::wstring> SkyrimInfo::getIniFileNames()
return boost::assign::list_of(L"skyrim.ini")(L"skyrimprefs.ini");
}
-std::wstring SkyrimInfo::getSaveGameExtension()
-{
- return L"*.ess";
-}
-
std::wstring SkyrimInfo::getReferenceDataFile()
{
return L"Skyrim - Meshes.bsa";
}
-std::wstring SkyrimInfo::getOMODExt()
-{
- return L"fomod";
-}
-
-
-std::wstring SkyrimInfo::getSteamAPPId(int) const
-{
- return L"72850";
-}
-
-
-std::wstring SkyrimInfo::getSEName()
-{
- return L"skse";
-}
-
-
std::wstring SkyrimInfo::getNexusPage(bool nmmScheme)
{
if (nmmScheme) {
@@ -220,85 +139,18 @@ int SkyrimInfo::getNexusModIDStatic()
return 1334;
}
-
-void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
-{
- { // copy plugins.txt
- std::wstring target = directory + L"\\plugins.txt";
- if (!FileExists(target)) {
- std::wostringstream source;
- source << getLocalAppFolder() << "\\Skyrim\\plugins.txt";
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
- HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- ::CloseHandle(file);
- }
- }
- target = directory + L"\\loadorder.txt";
- if (!FileExists(target)) {
- std::wstring source = getLocalAppFolder() + L"\\Skyrim\\loadorder.txt";
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- HANDLE file = ::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
- ::CloseHandle(file);
- }
- }
- }
-
- { // copy skyrim.ini-file
- std::wstring target = directory + L"\\skyrim.ini";
- if (!FileExists(target)) {
- std::wstring source;
- if (useDefaults) {
- source = getGameDirectory() + L"\\skyrim_default.ini";
- } else {
- source = getMyGamesDirectory() + L"\\Skyrim";
- if (FileExists(source, L"skyrim.ini")) {
- source += L"\\skyrim.ini";
- } else {
- source = getGameDirectory() + L"\\skyrim_default.ini";
- }
- }
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- if (::GetLastError() != ERROR_FILE_EXISTS) {
- throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
- }
- }
- }
- }
-
- { // copy skyrimprefs.ini-file
- std::wstring target = directory + L"\\skyrimprefs.ini";
- if (!FileExists(target)) {
- std::wstring source = getMyGamesDirectory() + L"\\Skyrim\\skyrimprefs.ini";
- if (!::CopyFileW(source.c_str(), target.c_str(), true)) {
- log("failed to copy ini file %ls", source.c_str());
- // create empty
- if (::CreateFileW(target.c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL) == INVALID_HANDLE_VALUE) {
- throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
- }
- }
- }
- }
-}
-
-
-void SkyrimInfo::repairProfile(const std::wstring &directory)
-{
- createProfile(directory, false);
-}
-
-
bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath)
{
- static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", NULL };
+ static LPCWSTR profileFiles[] = { L"skyrim.ini", L"skyrimprefs.ini", L"loadorder.txt", nullptr };
- for (int i = 0; profileFiles[i] != NULL; ++i) {
+ for (int i = 0; profileFiles[i] != nullptr; ++i) {
if (_wcsicmp(fileName, profileFiles[i]) == 0) {
return true;
}
}
if ((_wcsicmp(fileName, L"plugins.txt") == 0) &&
- (m_AppData.empty() || (StrStrIW(fullPath, m_AppData.c_str()) != NULL))) {
+ (m_AppData.empty() || (StrStrIW(fullPath, m_AppData.c_str()) != nullptr))) {
return true;
}
@@ -306,17 +158,4 @@ bool SkyrimInfo::rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPa
}
-std::vector<ExecutableInfo> SkyrimInfo::getExecutables()
-{
- std::vector<ExecutableInfo> result;
- result.push_back(ExecutableInfo(L"SKSE", L"skse_loader.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"SBW", L"SBW.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Skyrim", L"TESV.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"Skyrim Launcher", L"SkyrimLauncher.exe", L"", L"", DEFAULT_CLOSE));
- result.push_back(ExecutableInfo(L"BOSS", L"BOSS/BOSS.exe", L"", L"", DEFAULT_STAY));
- result.push_back(ExecutableInfo(L"Creation Kit", L"CreationKit.exe", L"", L"", DEFAULT_STAY, L"202480"));
-
- return result;
-}
-
} // namespace MOShared
diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h
index 33a612df..5951f910 100644
--- a/src/shared/skyriminfo.h
+++ b/src/shared/skyriminfo.h
@@ -35,8 +35,6 @@ public:
virtual ~SkyrimInfo() {}
- virtual unsigned long getBSAVersion();
-
static std::wstring getRegPathStatic();
virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"TESV.exe"; }
@@ -48,21 +46,6 @@ public:
virtual LoadOrderMechanism getLoadOrderMechanism() const;
- virtual bool requiresBSAInvalidation() const { return true; }
-// virtual bool requiresSteam() const { return true; }
-
- virtual std::wstring getInvalidationBSA();
-
- virtual bool isInvalidationBSA(const std::wstring &bsaName);
-
- // full path to this games "My Games"-directory
- virtual std::wstring getDocumentsDir();
-
- virtual std::wstring getSaveGameDir();
-
- virtual std::vector<std::wstring> getPrimaryPlugins();
-
- virtual std::vector<std::wstring> getVanillaBSAs();
virtual std::vector<std::wstring> getDLCPlugins();
virtual std::vector<std::wstring> getSavegameAttachmentExtensions();
@@ -70,13 +53,7 @@ public:
// file name of this games ini (no path)
virtual std::vector<std::wstring> getIniFileNames();
- virtual std::wstring getSaveGameExtension();
virtual std::wstring getReferenceDataFile();
- virtual std::wstring getOMODExt();
-
- virtual std::wstring getSteamAPPId(int variant = 0) const;
-
- virtual std::wstring getSEName();
virtual std::wstring getNexusPage(bool nmmScheme = true);
@@ -87,20 +64,11 @@ public:
static int getNexusGameIDStatic() { return 110; }
virtual int getNexusGameID() { return getNexusGameIDStatic(); }
- virtual void createProfile(const std::wstring &directory, bool useDefaults);
- virtual void repairProfile(const std::wstring &directory);
-
virtual bool rerouteToProfile(const wchar_t *fileName, const wchar_t *fullPath);
- // get a list of executables (game binary and known-to-work 3rd party tools). All of these are relative to
- // the game directory
- virtual std::vector<ExecutableInfo> getExecutables();
-
- virtual std::wstring archiveListKey() { return L"SResourceArchiveList"; }
-
private:
- SkyrimInfo(const std::wstring &moDirectory, const std::wstring &gameDirectory);
+ SkyrimInfo(const std::wstring &moDirectory, const std::wstring &moDataDirectory, const std::wstring &gameDirectory);
static bool identifyGame(const std::wstring &searchPath);
diff --git a/src/shared/stackdata.cpp b/src/shared/stackdata.cpp
index 016fb346..43acd90a 100644
--- a/src/shared/stackdata.cpp
+++ b/src/shared/stackdata.cpp
@@ -1,9 +1,9 @@
#include "stackdata.h"
+#include "util.h"
#include <DbgHelp.h>
#include <sstream>
#include <TlHelp32.h>
-#include <util.h>
#include <set>
#include "error_report.h"
#include <boost/predef.h>
@@ -135,7 +135,6 @@ void StackData::initTrace() {
}
}
-#pragma warning( enable : 4748 )
bool MOShared::operator==(const StackData &LHS, const StackData &RHS) {
if (LHS.m_Count != RHS.m_Count) {
diff --git a/src/shared/util.cpp b/src/shared/util.cpp
index 0f49d036..2ce88eca 100644
--- a/src/shared/util.cpp
+++ b/src/shared/util.cpp
@@ -55,15 +55,18 @@ std::string ToString(const std::wstring &source, bool utf8)
{
std::string result;
if (source.length() > 0) {
- UINT codepage = utf8 ? CP_UTF8 : GetACP();
- int sizeRequired = ::WideCharToMultiByte(codepage, 0, &source[0], -1, NULL, 0, NULL, NULL);
+ UINT codepage = CP_UTF8;
+ if (!utf8) {
+ codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
+ }
+ int sizeRequired = ::WideCharToMultiByte(codepage, 0, &source[0], -1, nullptr, 0, nullptr, nullptr);
if (sizeRequired == 0) {
throw windows_error("failed to convert string to multibyte");
}
// the size returned by WideCharToMultiByte contains zero termination IF -1 is specified for the length.
// we don't want that \0 in the string because then the length field would be wrong. Because madness
result.resize(sizeRequired - 1, '\0');
- ::WideCharToMultiByte(codepage, 0, &source[0], (int)source.size(), &result[0], sizeRequired, NULL, NULL);
+ ::WideCharToMultiByte(codepage, 0, &source[0], (int)source.size(), &result[0], sizeRequired, nullptr, nullptr);
}
return result;
@@ -73,8 +76,11 @@ std::wstring ToWString(const std::string &source, bool utf8)
{
std::wstring result;
if (source.length() > 0) {
- UINT codepage = utf8 ? CP_UTF8 : GetACP();
- int sizeRequired = ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), NULL, 0);
+ UINT codepage = CP_UTF8;
+ if (!utf8) {
+ codepage = AreFileApisANSI() ? GetACP() : GetOEMCP();
+ }
+ int sizeRequired = ::MultiByteToWideChar(codepage, 0, source.c_str(), source.length(), nullptr, 0);
if (sizeRequired == 0) {
throw windows_error("failed to convert string to wide character");
}
@@ -113,7 +119,7 @@ std::wstring ToLower(const std::wstring &text)
VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName)
{
- DWORD handle;
+ DWORD handle = 0UL;
DWORD size = ::GetFileVersionInfoSizeW(fileName.c_str(), &handle);
if (size == 0) {
throw windows_error("failed to determine file version info size");
@@ -121,11 +127,12 @@ VS_FIXEDFILEINFO GetFileVersion(const std::wstring &fileName)
void *buffer = new char[size];
try {
+ handle = 0UL;
if (!::GetFileVersionInfoW(fileName.c_str(), handle, size, buffer)) {
throw windows_error("failed to determine file version info");
}
- void *versionInfoPtr = NULL;
+ void *versionInfoPtr = nullptr;
UINT versionInfoLength = 0;
if (!::VerQueryValue(buffer, L"\\", &versionInfoPtr, &versionInfoLength)) {
throw windows_error("failed to determine file version");
diff --git a/src/shared/windows_error.cpp b/src/shared/windows_error.cpp
index 647a5bfb..97a58a20 100644
--- a/src/shared/windows_error.cpp
+++ b/src/shared/windows_error.cpp
@@ -27,13 +27,13 @@ std::string windows_error::constructMessage(const std::string& input, int inErro
std::ostringstream finalMessage;
finalMessage << input;
- LPSTR buffer = NULL;
+ LPSTR buffer = nullptr;
DWORD errorCode = inErrorCode != -1 ? inErrorCode : ::GetLastError();
// TODO: the message is not english?
if (FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, NULL) == 0) {
+ nullptr, errorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)&buffer, 0, nullptr) == 0) {
finalMessage << " (errorcode " << errorCode << ")";
} else {
LPSTR lastChar = buffer + strlen(buffer) - 2;