summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/browserdialog.cpp2
-rw-r--r--src/categories.cpp8
-rw-r--r--src/installationmanager.h2
-rw-r--r--src/main.cpp11
-rw-r--r--src/mainwindow.cpp55
-rw-r--r--src/modinfo.cpp2
-rw-r--r--src/modlist.cpp8
-rw-r--r--src/modlist.h2
-rw-r--r--src/modlistsortproxy.cpp2
-rw-r--r--src/nexusinterface.cpp5
-rw-r--r--src/pluginlist.cpp50
-rw-r--r--src/profile.cpp4
-rw-r--r--src/selfupdater.h3
-rw-r--r--src/settings.cpp2
-rw-r--r--src/shared/directoryentry.cpp6
-rw-r--r--src/shared/directoryentry.h2
-rw-r--r--src/shared/fallout3info.cpp21
-rw-r--r--src/shared/fallout3info.h6
-rw-r--r--src/shared/falloutnvinfo.cpp58
-rw-r--r--src/shared/falloutnvinfo.h6
-rw-r--r--src/shared/gameinfo.cpp40
-rw-r--r--src/shared/leaktrace.cpp2
-rw-r--r--src/shared/oblivioninfo.cpp21
-rw-r--r--src/shared/oblivioninfo.h6
-rw-r--r--src/shared/skyriminfo.cpp53
-rw-r--r--src/shared/skyriminfo.h8
26 files changed, 176 insertions, 209 deletions
diff --git a/src/browserdialog.cpp b/src/browserdialog.cpp
index 521459d0..f93ffcae 100644
--- a/src/browserdialog.cpp
+++ b/src/browserdialog.cpp
@@ -22,10 +22,10 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "messagedialog.h"
#include "report.h"
-#include "json.h"
#include "persistentcookiejar.h"
#include <gameinfo.h>
+#include "json.h"
#include <utility.h>
#include <gameinfo.h>
diff --git a/src/categories.cpp b/src/categories.cpp
index 28b1f4a2..57e18a28 100644
--- a/src/categories.cpp
+++ b/src/categories.cpp
@@ -232,7 +232,7 @@ void CategoryFactory::loadDefaultCategories()
int CategoryFactory::getParentID(unsigned int index) const
{
- if ((index < 0) || (index >= m_Categories.size())) {
+ if (index >= m_Categories.size()) {
throw MyException(QObject::tr("invalid index %1").arg(index));
}
@@ -267,7 +267,7 @@ bool CategoryFactory::isDecendantOf(int id, int parentID) const
bool CategoryFactory::hasChildren(unsigned int index) const
{
- if ((index < 0) || (index >= m_Categories.size())) {
+ if (index >= m_Categories.size()) {
throw MyException(QObject::tr("invalid index %1").arg(index));
}
@@ -277,7 +277,7 @@ bool CategoryFactory::hasChildren(unsigned int index) const
QString CategoryFactory::getCategoryName(unsigned int index) const
{
- if ((index < 0) || (index >= m_Categories.size())) {
+ if (index >= m_Categories.size()) {
throw MyException(QObject::tr("invalid index %1").arg(index));
}
@@ -287,7 +287,7 @@ QString CategoryFactory::getCategoryName(unsigned int index) const
int CategoryFactory::getCategoryID(unsigned int index) const
{
- if ((index < 0) || (index >= m_Categories.size())) {
+ if (index >= m_Categories.size()) {
throw MyException(QObject::tr("invalid index %1").arg(index));
}
diff --git a/src/installationmanager.h b/src/installationmanager.h
index d430c065..336c1ce3 100644
--- a/src/installationmanager.h
+++ b/src/installationmanager.h
@@ -55,7 +55,7 @@ public:
**/
explicit InstallationManager(QWidget *parent);
- ~InstallationManager();
+ virtual ~InstallationManager();
/**
* @brief update the directory where mods are to be installed
diff --git a/src/main.cpp b/src/main.cpp
index 3198208a..642bfa1a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -455,14 +455,9 @@ int main(int argc, char *argv[])
settings.setValue("gamePath", gamePath.toUtf8().constData());
}
- int edition = 0;
- if (settings.contains("game_edition")) {
- edition = settings.value("game_edition").toInt();
- } else {
+ if (!settings.contains("game_edition")) {
std::vector<std::wstring> editions = GameInfo::instance().getSteamVariants();
- if (editions.size() < 2) {
- edition = 0;
- } else {
+ if (editions.size() > 1) {
SelectionDialog selection(QObject::tr("Please select the game edition you have (MO can't start the game correctly if this is set incorrectly!)"), NULL);
int index = 0;
for (auto iter = editions.begin(); iter != editions.end(); ++iter) {
@@ -475,7 +470,7 @@ int main(int argc, char *argv[])
}
}
}
-
+#pragma message("edition isn't used?")
qDebug("managing game at %s", qPrintable(QDir::toNativeSeparators(gamePath)));
ExecutablesList executablesList;
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index ae5c1e48..19be758e 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -1137,7 +1137,6 @@ void MainWindow::registerPluginTool(IPluginTool *tool)
void MainWindow::registerModPage(IPluginModPage *modPage)
{
- QToolButton *browserBtn = NULL;
// turn the browser action into a drop-down menu if necessary
if (ui->actionNexus->menu() == NULL) {
QAction *nexusAction = ui->actionNexus;
@@ -1147,10 +1146,8 @@ void MainWindow::registerModPage(IPluginModPage *modPage)
ui->toolBar->removeAction(nexusAction);
actionToToolButton(ui->actionNexus);
- browserBtn = qobject_cast<QToolButton*>(ui->toolBar->widgetForAction(ui->actionNexus));
+ QToolButton *browserBtn = qobject_cast<QToolButton*>(ui->toolBar->widgetForAction(ui->actionNexus));
browserBtn->menu()->addAction(nexusAction);
- } else {
- browserBtn = qobject_cast<QToolButton*>(ui->toolBar->widgetForAction(ui->actionNexus));
}
QAction *action = new QAction(modPage->icon(), modPage->displayName(), ui->toolBar);
@@ -1434,30 +1431,32 @@ void MainWindow::spawnBinary(const QFileInfo &binary, const QString &arguments,
DWORD retLen;
JOBOBJECT_BASIC_PROCESS_ID_LIST info;
- bool isJobHandle = true;
+ {
+ bool isJobHandle = true;
- DWORD res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
- while ((res != WAIT_FAILED) && (res != WAIT_OBJECT_0) && !dialog->unlockClicked()) {
- if (isJobHandle) {
- if (::QueryInformationJobObject(processHandle, JobObjectBasicProcessIdList, &info, sizeof(info), &retLen) > 0) {
- if (info.NumberOfProcessIdsInList == 0) {
- break;
- }
- } else {
- // the info-object I passed only provides space for 1 process id. but since this code only cares about whether there
- // is more than one that's good enough. ERROR_MORE_DATA simply signals there are at least two processes running.
- // any other error probably means the handle is a regular process handle, probably caused by running MO in a job without
- // the right to break out.
- if (::GetLastError() != ERROR_MORE_DATA) {
- isJobHandle = false;
+ DWORD res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
+ while ((res != WAIT_FAILED) && (res != WAIT_OBJECT_0) && !dialog->unlockClicked()) {
+ if (isJobHandle) {
+ if (::QueryInformationJobObject(processHandle, JobObjectBasicProcessIdList, &info, sizeof(info), &retLen) > 0) {
+ if (info.NumberOfProcessIdsInList == 0) {
+ break;
+ }
+ } else {
+ // the info-object I passed only provides space for 1 process id. but since this code only cares about whether there
+ // is more than one that's good enough. ERROR_MORE_DATA simply signals there are at least two processes running.
+ // any other error probably means the handle is a regular process handle, probably caused by running MO in a job without
+ // the right to break out.
+ if (::GetLastError() != ERROR_MORE_DATA) {
+ isJobHandle = false;
+ }
}
}
- }
- // keep processing events so the app doesn't appear dead
- QCoreApplication::processEvents();
+ // keep processing events so the app doesn't appear dead
+ QCoreApplication::processEvents();
- res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
+ res = ::MsgWaitForMultipleObjects(1, &processHandle, false, 1000, QS_KEY | QS_MOUSE);
+ }
}
::CloseHandle(processHandle);
@@ -2191,11 +2190,7 @@ void MainWindow::storeSettings()
QSettings::Status result = QSettings::NoError;
{
QSettings settings(iniFile + ".new", QSettings::IniFormat);
- if (m_CurrentProfile != NULL) {
- settings.setValue("selected_profile", m_CurrentProfile->getName().toUtf8().constData());
- } else {
- settings.remove("selected_profile");
- }
+ settings.setValue("selected_profile", m_CurrentProfile->getName().toUtf8().constData());
settings.setValue("mod_list_state", ui->modList->header()->saveState());
settings.setValue("plugin_list_state", ui->espList->header()->saveState());
@@ -5560,11 +5555,11 @@ void MainWindow::on_bossButton_clicked()
DWORD retLen;
JOBOBJECT_BASIC_PROCESS_ID_LIST info;
- bool isJobHandle = true;
- ULONG lastProcessID;
HANDLE processHandle = loot;
if (loot != INVALID_HANDLE_VALUE) {
+ bool isJobHandle = true;
+ ULONG lastProcessID;
DWORD res = ::MsgWaitForMultipleObjects(1, &loot, false, 1000, QS_KEY | QS_MOUSE);
while ((res != WAIT_FAILED) && (res != WAIT_OBJECT_0)) {
if (isJobHandle) {
diff --git a/src/modinfo.cpp b/src/modinfo.cpp
index 796dab71..189e67b2 100644
--- a/src/modinfo.cpp
+++ b/src/modinfo.cpp
@@ -156,7 +156,7 @@ bool ModInfo::removeMod(unsigned int index)
auto iter = s_ModsByModID.find(modInfo->getNexusID());
if (iter != s_ModsByModID.end()) {
std::vector<unsigned int> indices = iter->second;
- std::remove(indices.begin(), indices.end(), index);
+ indices.erase(std::remove(indices.begin(), indices.end(), index), indices.end());
s_ModsByModID[modInfo->getNexusID()] = indices;
}
diff --git a/src/modlist.cpp b/src/modlist.cpp
index eedf1ec6..fb8df15e 100644
--- a/src/modlist.cpp
+++ b/src/modlist.cpp
@@ -49,8 +49,12 @@ using namespace MOBase;
ModList::ModList(QObject *parent)
- : QAbstractItemModel(parent), m_Profile(NULL), m_Modified(false),
- m_FontMetrics(QFont()), m_DropOnItems(false)
+ : QAbstractItemModel(parent)
+ , m_Profile(NULL)
+ , m_NexusInterface(NULL)
+ , m_Modified(false)
+ , m_FontMetrics(QFont())
+ , m_DropOnItems(false)
{
m_ContentIcons[ModInfo::CONTENT_PLUGIN] = std::make_tuple(QIcon(":/MO/gui/content/plugin"), ":/MO/gui/content/plugin", tr("Game plugins (esp/esm)"));
m_ContentIcons[ModInfo::CONTENT_INTERFACE] = std::make_tuple(QIcon(":/MO/gui/content/interface"), ":/MO/gui/content/interface", tr("Interface"));
diff --git a/src/modlist.h b/src/modlist.h
index 632689c6..cf52b2ec 100644
--- a/src/modlist.h
+++ b/src/modlist.h
@@ -267,7 +267,7 @@ private:
struct TModInfo {
TModInfo(unsigned int index, ModInfo::Ptr modInfo)
- : modInfo(modInfo), nameOrder(index) {}
+ : modInfo(modInfo), nameOrder(index), priorityOrder(0), modIDOrder(0), categoryOrder(0) {}
ModInfo::Ptr modInfo;
unsigned int nameOrder;
unsigned int priorityOrder;
diff --git a/src/modlistsortproxy.cpp b/src/modlistsortproxy.cpp
index da5d99d5..8907e712 100644
--- a/src/modlistsortproxy.cpp
+++ b/src/modlistsortproxy.cpp
@@ -298,7 +298,7 @@ bool ModListSortProxy::filterMatchesModOr(ModInfo::Ptr info, bool enabled) const
} break;
case CategoryFactory::CATEGORY_SPECIAL_NOTENDORSED: {
ModInfo::EEndorsedState state = info->endorsedState();
- if ((state == ModInfo::ENDORSED_FALSE) && (state != ModInfo::ENDORSED_NEVER)) return true;
+ if ((state == ModInfo::ENDORSED_FALSE) || (state == ModInfo::ENDORSED_NEVER)) return true;
} break;
case CategoryFactory::CATEGORY_SPECIAL_MANAGED: {
if (!info->hasFlag(ModInfo::FLAG_FOREIGN)) return true;
diff --git a/src/nexusinterface.cpp b/src/nexusinterface.cpp
index 30221f4b..b4006097 100644
--- a/src/nexusinterface.cpp
+++ b/src/nexusinterface.cpp
@@ -20,7 +20,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "nexusinterface.h"
#include "nxmaccessmanager.h"
#include "utility.h"
-#include <json.h>
+#include "json.h"
#include "selectiondialog.h"
#include <QApplication>
#include <utility.h>
@@ -580,6 +580,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, m_URL(url)
, m_SubModule(subModule)
, m_NexusGameID(nexusGameId)
+ , m_Endorse(false)
{}
NexusInterface::NXMRequestInfo::NXMRequestInfo(std::vector<int> modIDList
@@ -600,6 +601,7 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(std::vector<int> modIDList
, m_URL(url)
, m_SubModule(subModule)
, m_NexusGameID(nexusGameId)
+ , m_Endorse(false)
{}
NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
@@ -620,4 +622,5 @@ NexusInterface::NXMRequestInfo::NXMRequestInfo(int modID
, m_URL(url)
, m_SubModule(subModule)
, m_NexusGameID(nexusGameId)
+ , m_Endorse(false)
{}
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp
index ff370fa4..973e3cfc 100644
--- a/src/pluginlist.cpp
+++ b/src/pluginlist.cpp
@@ -685,7 +685,7 @@ QString PluginList::origin(const QString &name) const
{
auto iter = m_ESPsByName.find(name.toLower());
if (iter == m_ESPsByName.end()) {
- return false;
+ return QString();
} else {
return m_ESPs[iter->second].m_OriginName;
}
@@ -836,7 +836,7 @@ QVariant PluginList::data(const QModelIndex &modelIndex, int role) const
std::set_difference(m_ESPs[index].m_Masters.begin(), m_ESPs[index].m_Masters.end(),
m_ESPs[index].m_MasterUnset.begin(), m_ESPs[index].m_MasterUnset.end(),
std::inserter(enabledMasters, enabledMasters.end()));
- if (enabledMasters.size() > 0) {
+ if (!enabledMasters.empty()) {
text += "<br><b>" + tr("Enabled Masters") + "</b>: " + SetJoin(enabledMasters, ", ");
}
if (m_ESPs[index].m_HasIni) {
@@ -1102,34 +1102,34 @@ bool PluginList::eventFilter(QObject *obj, QEvent *event)
((keyEvent->key() == Qt::Key_Up) || (keyEvent->key() == Qt::Key_Down))) {
QItemSelectionModel *selectionModel = itemView->selectionModel();
const QSortFilterProxyModel *proxyModel = qobject_cast<const QSortFilterProxyModel*>(selectionModel->model());
- int diff = -1;
- if (((keyEvent->key() == Qt::Key_Up) && (proxyModel->sortOrder() == Qt::DescendingOrder)) ||
- ((keyEvent->key() == Qt::Key_Down) && (proxyModel->sortOrder() == Qt::AscendingOrder))) {
- diff = 1;
- }
- QModelIndexList rows = selectionModel->selectedRows();
- // remove elements that aren't supposed to be movable
- QMutableListIterator<QModelIndex> iter(rows);
- while (iter.hasNext()) {
- if ((iter.next().flags() & Qt::ItemIsDragEnabled) == 0) {
- iter.remove();
+ if (proxyModel != NULL) {
+ int diff = -1;
+ if (((keyEvent->key() == Qt::Key_Up) && (proxyModel->sortOrder() == Qt::DescendingOrder)) ||
+ ((keyEvent->key() == Qt::Key_Down) && (proxyModel->sortOrder() == Qt::AscendingOrder))) {
+ diff = 1;
}
- }
- if (keyEvent->key() == Qt::Key_Down) {
- for (int i = 0; i < rows.size() / 2; ++i) {
- rows.swap(i, rows.size() - i - 1);
+ QModelIndexList rows = selectionModel->selectedRows();
+ // remove elements that aren't supposed to be movable
+ QMutableListIterator<QModelIndex> iter(rows);
+ while (iter.hasNext()) {
+ if ((iter.next().flags() & Qt::ItemIsDragEnabled) == 0) {
+ iter.remove();
+ }
}
- }
- foreach (QModelIndex idx, rows) {
- if (proxyModel != NULL) {
- idx = proxyModel->mapToSource(idx);
+ if (keyEvent->key() == Qt::Key_Down) {
+ for (int i = 0; i < rows.size() / 2; ++i) {
+ rows.swap(i, rows.size() - i - 1);
+ }
}
- int newPriority = m_ESPs[idx.row()].m_Priority + diff;
- if ((newPriority >= 0) && (newPriority < rowCount())) {
- setPluginPriority(idx.row(), newPriority);
+ foreach (QModelIndex idx, rows) {
+ idx = proxyModel->mapToSource(idx);
+ int newPriority = m_ESPs[idx.row()].m_Priority + diff;
+ if ((newPriority >= 0) && (newPriority < rowCount())) {
+ setPluginPriority(idx.row(), newPriority);
+ }
}
+ refreshLoadOrder();
}
- refreshLoadOrder();
return true;
} else if (keyEvent->key() == Qt::Key_Space) {
QItemSelectionModel *selectionModel = itemView->selectionModel();
diff --git a/src/profile.cpp b/src/profile.cpp
index 77e4f813..958084d7 100644
--- a/src/profile.cpp
+++ b/src/profile.cpp
@@ -585,7 +585,9 @@ void Profile::mergeTweaks(ModInfo::Ptr modInfo, const QString &tweakedIni) const
bool Profile::invalidationActive(bool *supported) const
{
if (GameInfo::instance().requiresBSAInvalidation()) {
- *supported = true;
+ if (supported != NULL) {
+ *supported = true;
+ }
wchar_t buffer[1024];
std::wstring iniFileName = ToWString(QDir::toNativeSeparators(getIniFileName()));
// epic ms fail: GetPrivateProfileString uses errno (for whatever reason) to signal a fail since the return value
diff --git a/src/selfupdater.h b/src/selfupdater.h
index 9648f15a..75b0ff45 100644
--- a/src/selfupdater.h
+++ b/src/selfupdater.h
@@ -65,7 +65,8 @@ public:
* @todo passing the nexus interface is unneccessary
**/
SelfUpdater(NexusInterface *nexusInterface, QWidget *parent);
- ~SelfUpdater();
+
+ virtual ~SelfUpdater();
/**
* @brief start the update process
diff --git a/src/settings.cpp b/src/settings.cpp
index 04a5f279..0ca811a3 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -25,7 +25,7 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <gameinfo.h>
#include <appconfig.h>
#include <utility.h>
-#include <json.h>
+#include "json.h"
#include <QCheckBox>
#include <QLineEdit>
diff --git a/src/shared/directoryentry.cpp b/src/shared/directoryentry.cpp
index 5d785822..24868a93 100644
--- a/src/shared/directoryentry.cpp
+++ b/src/shared/directoryentry.cpp
@@ -325,13 +325,13 @@ static bool ByOriginPriority(DirectoryEntry *entry, int LHS, int RHS)
FileEntry::FileEntry()
- : m_Index(UINT_MAX), m_Name(), m_Parent(NULL), m_LastAccessed(time(NULL))
+ : m_Index(UINT_MAX), m_Name(), m_Origin(-1), m_Parent(NULL), m_LastAccessed(time(NULL))
{
LEAK_TRACE;
}
FileEntry::FileEntry(Index index, const std::wstring &name, DirectoryEntry *parent)
- : m_Index(index), m_Name(name), m_Parent(parent), m_Origin(-1), 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(NULL))
{
LEAK_TRACE;
}
@@ -636,7 +636,7 @@ void DirectoryEntry::insertFile(const std::wstring &filePath, FilesOrigin &origi
void DirectoryEntry::removeFile(FileEntry::Index index)
{
- if (m_Files.size() != 0) {
+ if (!m_Files.empty()) {
auto iter = std::find_if(m_Files.begin(), m_Files.end(),
[&index](const std::pair<std::wstring, FileEntry::Index> &iter) -> bool {
return iter.second == index; } );
diff --git a/src/shared/directoryentry.h b/src/shared/directoryentry.h
index 096f373e..d588ab02 100644
--- a/src/shared/directoryentry.h
+++ b/src/shared/directoryentry.h
@@ -219,7 +219,7 @@ public:
void clear();
bool isPopulated() const { return m_Populated; }
- bool isEmpty() const { return (m_Files.size() == 0) && (m_SubDirectories.size() == 0); }
+ bool isEmpty() const { return m_Files.empty() && m_SubDirectories.empty(); }
const DirectoryEntry *getParent() const { return m_Parent; }
diff --git a/src/shared/fallout3info.cpp b/src/shared/fallout3info.cpp
index 9487d2de..22db91ac 100644
--- a/src/shared/fallout3info.cpp
+++ b/src/shared/fallout3info.cpp
@@ -54,15 +54,17 @@ std::wstring Fallout3Info::getRegPathStatic()
0, KEY_QUERY_VALUE, &key);
if (errorcode != ERROR_SUCCESS) {
- return L"";
+ return std::wstring();
}
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- errorcode = ::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize);
-
- return std::wstring(temp);
+ if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ return std::wstring(temp);
+ } else {
+ return std::wstring();
+ }
}
std::wstring Fallout3Info::getInvalidationBSA()
@@ -233,15 +235,12 @@ void Fallout3Info::createProfile(const std::wstring &directory, bool useDefaults
}
}
{ // copy falloutprefs.ini-file
- std::wstring target = directory.substr().append(L"\\falloutprefs.ini");
+ std::wstring target = directory + L"\\falloutprefs.ini";
if (!FileExists(target)) {
- std::wostringstream source;
- source << getMyGamesDirectory() << L"\\Fallout3\\falloutprefs.ini";
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
+ std::wstring source = getMyGamesDirectory() + L"\\Fallout3\\falloutprefs.ini";
+ if (!::CopyFileW(source.c_str(), target.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());
+ throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
}
}
}
diff --git a/src/shared/fallout3info.h b/src/shared/fallout3info.h
index 8e4c260d..d1356de1 100644
--- a/src/shared/fallout3info.h
+++ b/src/shared/fallout3info.h
@@ -38,7 +38,7 @@ public:
virtual unsigned long getBSAVersion();
static std::wstring getRegPathStatic();
- virtual std::wstring getRegPath() { return Fallout3Info::getRegPathStatic(); }
+ virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"Fallout3.exe"; }
virtual GameInfo::Type getType() { return TYPE_FALLOUT3; }
@@ -75,9 +75,9 @@ public:
virtual std::wstring getNexusPage(bool nmmScheme = true);
static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return Fallout3Info::getNexusInfoUrlStatic(); }
+ virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
static int getNexusModIDStatic();
- virtual int getNexusModID() { return Fallout3Info::getNexusModIDStatic(); }
+ virtual int getNexusModID() { return getNexusModIDStatic(); }
virtual int getNexusGameID() { return 120; }
virtual void createProfile(const std::wstring &directory, bool useDefaults);
diff --git a/src/shared/falloutnvinfo.cpp b/src/shared/falloutnvinfo.cpp
index 9bba7fe4..0dde4db1 100644
--- a/src/shared/falloutnvinfo.cpp
+++ b/src/shared/falloutnvinfo.cpp
@@ -55,15 +55,17 @@ std::wstring FalloutNVInfo::getRegPathStatic()
0, KEY_QUERY_VALUE, &key);
if (errorcode != ERROR_SUCCESS) {
- return L"";
+ return std::wstring();
}
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- errorcode = ::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize);
-
- return std::wstring(temp);
+ if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ return std::wstring(temp);
+ } else {
+ return std::wstring();
+ }
}
std::wstring FalloutNVInfo::getInvalidationBSA()
@@ -162,56 +164,46 @@ std::wstring FalloutNVInfo::getSteamAPPId(int) const
void FalloutNVInfo::createProfile(const std::wstring &directory, bool useDefaults)
{
- std::wostringstream target;
+ std::wstring target = directory + L"\\plugins.txt";
// copy plugins.txt
- target << directory << "\\plugins.txt";
-
- if (!FileExists(target.str())) {
- std::wostringstream source;
- source << getLocalAppFolder() << "\\FalloutNV\\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);
+ 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.str(L""); target.clear();
- target << directory << L"\\fallout.ini";
+ target = directory + L"\\fallout.ini";
- if (!FileExists(target.str())) {
- std::wostringstream source;
+ if (!FileExists(target)) {
+ std::wstring source;
if (useDefaults) {
- source << getGameDirectory() << L"\\fallout_default.ini";
+ source = getGameDirectory() + L"\\fallout_default.ini";
} else {
- source << getMyGamesDirectory() << L"\\FalloutNV";
- if (FileExists(source.str(), L"fallout.ini")) {
- source << L"\\fallout.ini";
+ source = getMyGamesDirectory() + L"\\FalloutNV";
+ if (FileExists(source, L"fallout.ini")) {
+ source += L"\\fallout.ini";
} else {
- source.str(L"");
- source << getGameDirectory() << L"\\fallout_default.ini";
+ source = getGameDirectory() + L"\\fallout_default.ini";
}
}
- if (!::CopyFileW(source.str().c_str(), target.str().c_str(), true)) {
+ if (!::CopyFileW(source.c_str(), target.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());
+ throw windows_error("failed to copy ini file: " + ToString(source, false));
}
}
}
{ // copy falloutprefs.ini-file
- std::wstring target = directory.substr().append(L"\\falloutprefs.ini");
+ std::wstring target = directory + L"\\falloutprefs.ini";
if (!FileExists(target)) {
- std::wostringstream source;
- source << getMyGamesDirectory() << L"\\FalloutNV\\falloutprefs.ini";
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
+ std::wstring source = getMyGamesDirectory() + L"\\FalloutNV\\falloutprefs.ini";
+ if (!::CopyFileW(source.c_str(), target.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());
+ throw windows_error("failed to copy ini file: " + ToString(source, false));
}
}
}
diff --git a/src/shared/falloutnvinfo.h b/src/shared/falloutnvinfo.h
index cfd373c7..50a0d00d 100644
--- a/src/shared/falloutnvinfo.h
+++ b/src/shared/falloutnvinfo.h
@@ -38,7 +38,7 @@ public:
virtual unsigned long getBSAVersion();
static std::wstring getRegPathStatic();
- virtual std::wstring getRegPath() { return FalloutNVInfo::getRegPathStatic(); }
+ virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"FalloutNV.exe"; }
virtual GameInfo::Type getType() { return TYPE_FALLOUTNV; }
@@ -76,9 +76,9 @@ public:
virtual std::wstring getNexusPage(bool nmmScheme = true);
static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return FalloutNVInfo::getNexusInfoUrlStatic(); }
+ virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
static int getNexusModIDStatic();
- virtual int getNexusModID() { return FalloutNVInfo::getNexusModIDStatic(); }
+ virtual int getNexusModID() { return getNexusModIDStatic(); }
virtual int getNexusGameID() { return 130; }
virtual void createProfile(const std::wstring &directory, bool useDefaults);
diff --git a/src/shared/gameinfo.cpp b/src/shared/gameinfo.cpp
index 21e9a586..5439efff 100644
--- a/src/shared/gameinfo.cpp
+++ b/src/shared/gameinfo.cpp
@@ -57,7 +57,7 @@ void GameInfo::identifyMyGamesDirectory(const std::wstring &file)
{
// this function attempts 3 (three!) ways to determine the correct "My Games" folder.
wchar_t myDocuments[MAX_PATH];
- memset(myDocuments, '\0', MAX_PATH);
+ memset(myDocuments, '\0', MAX_PATH * sizeof(wchar_t));
m_MyGamesDirectory.clear();
@@ -137,71 +137,53 @@ std::wstring GameInfo::getGameDirectory() const
std::wstring GameInfo::getModsDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDataDirectory << L"\\mods";
- return temp.str();
+ return m_OrganizerDirectory + L"\\mods";
}
std::wstring GameInfo::getProfilesDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDataDirectory << L"\\profiles";
- return temp.str();
+ return m_OrganizerDirectory + L"\\profiles";
}
std::wstring GameInfo::getIniFilename() const
{
- std::wostringstream temp;
- temp << m_OrganizerDataDirectory << L"\\ModOrganizer.ini";
- return temp.str();
+ return m_OrganizerDirectory + L"\\ModOrganizer.ini";
}
std::wstring GameInfo::getDownloadDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDataDirectory << L"\\downloads";
- return temp.str();
+ return m_OrganizerDirectory + L"\\downloads";
}
std::wstring GameInfo::getCacheDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDataDirectory << L"\\webcache";
- return temp.str();
+ return m_OrganizerDirectory + L"\\webcache";
}
std::wstring GameInfo::getOverwriteDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDataDirectory << "\\overwrite";
- return temp.str();
+ return m_OrganizerDirectory + L"\\overwrite";
}
std::wstring GameInfo::getLogDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDataDirectory << "\\logs";
- return temp.str();
+ return m_OrganizerDirectory + L"\\logs";
}
std::wstring GameInfo::getLootDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDirectory << "\\loot";
- return temp.str();
+ return m_OrganizerDirectory + L"\\loot";
}
std::wstring GameInfo::getTutorialDir() const
{
- std::wostringstream temp;
- temp << m_OrganizerDirectory << "\\tutorials";
- return temp.str();
+ return m_OrganizerDirectory + L"\\tutorials";
}
@@ -219,7 +201,7 @@ std::vector<std::wstring> GameInfo::getSteamVariants() const
std::wstring GameInfo::getLocalAppFolder() const
{
wchar_t localAppFolder[MAX_PATH];
- memset(localAppFolder, '\0', MAX_PATH);
+ memset(localAppFolder, '\0', MAX_PATH * sizeof(wchar_t));
if (::SHGetFolderPathW(NULL, CSIDL_LOCAL_APPDATA, NULL, SHGFP_TYPE_CURRENT, localAppFolder) == S_OK) {
return localAppFolder;
diff --git a/src/shared/leaktrace.cpp b/src/shared/leaktrace.cpp
index 68e57609..729eb42e 100644
--- a/src/shared/leaktrace.cpp
+++ b/src/shared/leaktrace.cpp
@@ -36,7 +36,7 @@ class StackData {
public:
StackData()
- : m_FunctionName("Dummy"), m_CodeLine(0)
+ : m_Count(0), m_Hash(0UL), m_FunctionName("Dummy"), m_CodeLine(0)
{}
StackData(const char *functionName, int line) {
m_Count = ::CaptureStackBackTrace(FRAMES_TO_SKIP, FRAMES_TO_CAPTURE, m_Stack, &m_Hash);
diff --git a/src/shared/oblivioninfo.cpp b/src/shared/oblivioninfo.cpp
index f317812f..790fcdb0 100644
--- a/src/shared/oblivioninfo.cpp
+++ b/src/shared/oblivioninfo.cpp
@@ -55,15 +55,17 @@ std::wstring OblivionInfo::getRegPathStatic()
0, KEY_QUERY_VALUE, &key);
if (errorcode != ERROR_SUCCESS) {
- return L"";
+ return std::wstring();
}
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- errorcode = ::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize);
-
- return std::wstring(temp);
+ if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ return std::wstring(temp);
+ } else {
+ return std::wstring();
+ }
}
std::wstring OblivionInfo::getInvalidationBSA()
@@ -188,16 +190,13 @@ void OblivionInfo::createProfile(const std::wstring &directory, bool useDefaults
}
{ // copy oblivionprefs.ini-file
- std::wstring target = directory.substr().append(L"\\oblivionprefs.ini");
+ std::wstring target = directory + L"\\oblivionprefs.ini";
if (!FileExists(target)) {
- std::wostringstream source;
- source << getMyGamesDirectory() << L"\\Oblivion\\oblivionprefs.ini";
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
+ 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)) {
- std::ostringstream stream;
- stream << "failed to create ini file: " << ToString(target.c_str(), false);
- throw windows_error(stream.str());
+ throw windows_error(std::string("failed to create ini file: ") + ToString(target, false));
}
}
}
diff --git a/src/shared/oblivioninfo.h b/src/shared/oblivioninfo.h
index 02fd90b4..e64ae37b 100644
--- a/src/shared/oblivioninfo.h
+++ b/src/shared/oblivioninfo.h
@@ -36,7 +36,7 @@ public:
virtual unsigned long getBSAVersion();
static std::wstring getRegPathStatic();
- virtual std::wstring getRegPath() { return OblivionInfo::getRegPathStatic(); }
+ virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"Oblivion.exe"; }
virtual GameInfo::Type getType() { return TYPE_OBLIVION; }
@@ -72,9 +72,9 @@ public:
virtual std::wstring getNexusPage(bool nmmScheme = true);
static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return OblivionInfo::getNexusInfoUrlStatic(); }
+ virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
static int getNexusModIDStatic();
- virtual int getNexusModID() { return OblivionInfo::getNexusModIDStatic(); }
+ virtual int getNexusModID() { return getNexusModIDStatic(); }
virtual int getNexusGameID() { return 101; }
virtual void createProfile(const std::wstring &directory, bool useDefaults);
diff --git a/src/shared/skyriminfo.cpp b/src/shared/skyriminfo.cpp
index c985fe9f..319e58d5 100644
--- a/src/shared/skyriminfo.cpp
+++ b/src/shared/skyriminfo.cpp
@@ -63,15 +63,17 @@ std::wstring SkyrimInfo::getRegPathStatic()
0, KEY_QUERY_VALUE, &key);
if (errorcode != ERROR_SUCCESS) {
- return L"";
+ return std::wstring();
}
WCHAR temp[MAX_PATH];
DWORD bufferSize = MAX_PATH;
- errorcode = ::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize);
-
- return std::wstring(temp);
+ if (::RegQueryValueExW(key, L"Installed Path", NULL, NULL, (LPBYTE)temp, &bufferSize) == ERROR_SUCCESS) {
+ return std::wstring(temp);
+ } else {
+ return std::wstring();
+ }
}
@@ -222,7 +224,7 @@ int SkyrimInfo::getNexusModIDStatic()
void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
{
{ // copy plugins.txt
- std::wstring target = directory.substr().append(L"\\plugins.txt");
+ std::wstring target = directory + L"\\plugins.txt";
if (!FileExists(target)) {
std::wostringstream source;
source << getLocalAppFolder() << "\\Skyrim\\plugins.txt";
@@ -231,11 +233,10 @@ void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
::CloseHandle(file);
}
}
- target = directory.substr().append(L"\\loadorder.txt");
+ target = directory + L"\\loadorder.txt";
if (!FileExists(target)) {
- std::wostringstream source;
- source << getLocalAppFolder() << "\\Skyrim\\loadorder.txt";
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
+ 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);
}
@@ -243,42 +244,36 @@ void SkyrimInfo::createProfile(const std::wstring &directory, bool useDefaults)
}
{ // copy skyrim.ini-file
- std::wstring target = directory.substr().append(L"\\skyrim.ini");
+ std::wstring target = directory + L"\\skyrim.ini";
if (!FileExists(target)) {
- std::wostringstream source;
+ std::wstring source;
if (useDefaults) {
- source << getGameDirectory() << L"\\skyrim_default.ini";
+ source = getGameDirectory() + L"\\skyrim_default.ini";
} else {
- source << getMyGamesDirectory() << L"\\Skyrim";
- if (FileExists(source.str(), L"skyrim.ini")) {
- source << L"\\skyrim.ini";
+ source = getMyGamesDirectory() + L"\\Skyrim";
+ if (FileExists(source, L"skyrim.ini")) {
+ source += L"\\skyrim.ini";
} else {
- source.str(L"");
- source << getGameDirectory() << L"\\skyrim_default.ini";
+ source = getGameDirectory() + L"\\skyrim_default.ini";
}
}
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
+ if (!::CopyFileW(source.c_str(), target.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());
+ throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
}
}
}
}
{ // copy skyrimprefs.ini-file
- std::wstring target = directory.substr().append(L"\\skyrimprefs.ini");
+ std::wstring target = directory + L"\\skyrimprefs.ini";
if (!FileExists(target)) {
- std::wostringstream source;
- source << getMyGamesDirectory() << L"\\Skyrim\\skyrimprefs.ini";
- if (!::CopyFileW(source.str().c_str(), target.c_str(), true)) {
- log("failed to copy ini file %ls", source.str().c_str());
+ 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) {
- std::ostringstream stream;
- stream << "failed to copy ini file: " << ToString(source.str(), false);
- throw windows_error(stream.str());
+ throw windows_error(std::string("failed to copy ini file: ") + ToString(source, false));
}
}
}
diff --git a/src/shared/skyriminfo.h b/src/shared/skyriminfo.h
index 132f2aee..a7aff8dc 100644
--- a/src/shared/skyriminfo.h
+++ b/src/shared/skyriminfo.h
@@ -38,7 +38,7 @@ public:
virtual unsigned long getBSAVersion();
static std::wstring getRegPathStatic();
- virtual std::wstring getRegPath() { return SkyrimInfo::getRegPathStatic(); }
+ virtual std::wstring getRegPath() { return getRegPathStatic(); }
virtual std::wstring getBinaryName() { return L"TESV.exe"; }
virtual GameInfo::Type getType() { return TYPE_SKYRIM; }
@@ -81,11 +81,11 @@ public:
virtual std::wstring getNexusPage(bool nmmScheme = true);
static std::wstring getNexusInfoUrlStatic();
- virtual std::wstring getNexusInfoUrl() { return SkyrimInfo::getNexusInfoUrlStatic(); }
+ virtual std::wstring getNexusInfoUrl() { return getNexusInfoUrlStatic(); }
static int getNexusModIDStatic();
- virtual int getNexusModID() { return SkyrimInfo::getNexusModIDStatic(); }
+ virtual int getNexusModID() { return getNexusModIDStatic(); }
static int getNexusGameIDStatic() { return 110; }
- virtual int getNexusGameID() { return SkyrimInfo::getNexusGameIDStatic(); }
+ virtual int getNexusGameID() { return getNexusGameIDStatic(); }
virtual void createProfile(const std::wstring &directory, bool useDefaults);
virtual void repairProfile(const std::wstring &directory);