Skip to content

Commit

Permalink
Merge branch 'new_vfs_library' of https://github.com/TanninOne/modorg…
Browse files Browse the repository at this point in the history
…anizer into new_vfs_library
  • Loading branch information
TanninOne committed Dec 28, 2015
2 parents 1bfc910 + d417229 commit ddf8414
Show file tree
Hide file tree
Showing 11 changed files with 107 additions and 58 deletions.
99 changes: 66 additions & 33 deletions massage_messages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from collections import defaultdict

import fileinput
import re
import subprocess
Expand Down Expand Up @@ -28,14 +30,19 @@ class QWidget;
namespace Ui { class AboutDialog; } // lines 31-31
---
"""

removing = None
includes = dict()

includes = dict
adding = None
added = dict()

foundline = 0
foundline = None

errors = False

messages = defaultdict(list)

def process_next_line(line, outfile):
""" Read a line of output/error from include-what-you use
Turn clang errors into a form QT creator recognises
Expand All @@ -45,34 +52,53 @@ def process_next_line(line, outfile):
global includes
global foundline
global errors
global added
global adding
line = line.rstrip()
print >> outfile, line
if removing:
if line == '':
removing = None
print
return

if line.endswith(' should remove these lines:'):
adding = None
removing = (line.split(' '))[0]
elif line.endswith(' should add these lines:'):
removing = None
adding = (line.split(' '))[0]
elif line == '' or line.startswith(' the full include-list'):
adding = None
removing = None
elif adding:
m = re.match(r'.*class (.*);', line)
if m:
added[m.group(1)] = (adding, line)
else:
added[line] = (adding, line)
elif removing:
# Really we should stash these so that if we get a 'class xxx' in
# the add lines we can print it here. also we could do the case
# fixing.
m = re.match(r'- #include [<"](.*)[">] +// lines (.*)-', line)
if m:
foundline = m.group(2)
if m.group(1) in added:
messages[removing].append(
'%s(%s) : warning I0004: Replace include of %s with '
'forward reference %s' % (
removing, m.group(2), m.group(1), added[m.group(1)][1]))
del added[m.group(1)]
else:
messages[removing].append(
'%s(%s) : warning I0001: Unnecessary include of %s' % (
removing, m.group(2), m.group(1)))

else:
# Really we should stash these so that if we get a 'class xxx' in
# the add lines we can print it here. also we could do the case
# fixing.
m = re.match(r'- #include [<"](.*)[">] +// lines (.*)-', line)
m = re.match(r'- (.*) +// lines (.*)-', line)
if m:
# If there is an added line with the same class, print it here
print '%s(%s) : warning I0001: Unnecessary include of %s' %\
(removing, m.group(2), m.group(1))
foundline = m.group(1)
messages[removing].append(
'%s(%s) : warning I0002: Unnecessary forward ref of %s' % (
removing, m.group(2), m.group(1)))
else:
m = re.match(r'- (.*) +// lines (.*)-', line)
if m:
print '%s(%s) : warning I0002: '\
'Unnecessary forward ref of %s' %\
(removing, m.group(2), m.group(1))
foundline = m.group(1)
else:
print '********* I got confused **********'

if line.startswith('In file included from'):
print '********* I got confused **********'
elif line.startswith('In file included from'):
line = re.sub(r'^(In file included from)(.*):(\d+):',
r' \2(\3) : \1 here',
line)
Expand All @@ -88,14 +114,6 @@ def process_next_line(line, outfile):
errors = True

print line
if line.endswith(' should remove these lines:'):
removing = (line.split(' '))[0]
elif line.endswith(' should add these lines:'):
adding = (line.split(' '))[0]

# also process the other lines

# added lines should come after the first entry with a line number.

outfile = open(sys.argv[1], 'w')
process = subprocess.Popen(sys.argv[2:],
Expand All @@ -107,6 +125,21 @@ def process_next_line(line, outfile):
if output:
process_next_line(output, outfile)

# A note: We should probably do some work as we use the source code line for
# messages in include files...

if foundline is None:
foundline = '1'

for add in added:
messages[added[add][0]].append(
'%s(%s) : warning I0003: Need to include %s' % (
added[add][0], foundline, added[add][1]))

for file in sorted(messages.keys(), reverse = True):
for line in messages[file]:
print line

rc = process.poll()
# The return code you get appears to be more to do with the amount of output
# generated than any real error, so instead we should error if any ': error:'
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ Here is a complete list:
* https://github.com/TanninOne/modorganizer-game_skyrim
* https://github.com/TanninOne/modorganizer-game_oblivion
* https://github.com/TanninOne/modorganizer-game_fallout3
* https://github.com/TanninOne/modorganizer-game_fallout4
* https://github.com/TanninOne/modorganizer-game_falloutnv
* https://github.com/TanninOne/modorganizer-game_gamebryo
* https://github.com/TanninOne/modorganizer-game_features
* https://github.com/TanninOne/modorganizer-check_fnis
* https://github.com/TanninOne/modorganizer-plugin_python
* https://github.com/TanninOne/modorganizer-bsa_extractor
* https://github.com/TanninOne/usvfs
5 changes: 2 additions & 3 deletions src/downloadmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,14 +1244,13 @@ int DownloadManager::startDownloadURLs(const QStringList &urls)
return m_ActiveDownloads.size() - 1;
}

/* This doesn't appear to be used by anything
int DownloadManager::startDownloadNexusFile(int modID, int fileID)
{
int newID = m_ActiveDownloads.size();
addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(ToQString(MOShared::GameInfo::instance().getGameName())).arg(modID).arg(fileID));
addNXMDownload(QString("nxm://%1/mods/%2/files/%3").arg(m_ManagedGame->getGameShortName()).arg(modID).arg(fileID));
return newID;
}
*/

QString DownloadManager::downloadPath(int id)
{
return getFilePath(id);
Expand Down
4 changes: 2 additions & 2 deletions src/downloadmanager.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ class DownloadManager : public MOBase::IDownloadManager


virtual int startDownloadURLs(const QStringList &urls);
/* This doesn't appear to be used anywhere

virtual int startDownloadNexusFile(int modID, int fileID);
*/

virtual QString downloadPath(int id);

/**
Expand Down
4 changes: 0 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include <report.h>
#include "modlist.h"
#include "profile.h"
#include "gameinfo.h"
#include "spawn.h"
#include "executableslist.h"
#include "singleinstance.h"
Expand Down Expand Up @@ -556,9 +555,6 @@ int main(int argc, char *argv[])

organizer.setManagedGame(game);

//*sigh just for making it work
GameInfo::init(application.applicationDirPath().toStdWString(), game->gameDirectory().absolutePath().toStdWString());

organizer.createDefaultProfile();

//See the pragma - we apparently don't use this so not sure why we check it
Expand Down
1 change: 0 additions & 1 deletion src/nxmaccessmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "selfupdater.h"
#include "persistentcookiejar.h"
#include "settings.h"
#include <gameinfo.h>
#include <QMessageBox>
#include <QPushButton>
#include <QNetworkProxy>
Expand Down
31 changes: 28 additions & 3 deletions src/organizercore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,31 @@ HANDLE OrganizerCore::spawnBinaryDirect(const QFileInfo &binary, const QString &
// TODO: should also pass arguments
if (m_AboutToRun(binary.absoluteFilePath())) {
m_USVFS.updateMapping(fileMapping());
return startBinary(binary, arguments, currentDirectory, true);
QString modsPath(qApp->property("dataPath").toString() + "/" + QString::fromStdWString(AppConfig::modsPath()));

QString binPath = binary.absoluteFilePath();

if (binPath.startsWith(modsPath, Qt::CaseInsensitive)) {
// binary was installed as a MO mod. Need to start it through a (hooked)
// proxy to ensure pathes are correct

QString cwdPath = currentDirectory.absolutePath();

int binOffset = binPath.indexOf('/', modsPath.length() + 1);
int cwdOffset = cwdPath.indexOf('/', cwdPath.length() + 1);
QString binPath = m_GamePlugin->dataDirectory().absolutePath() + "/" + binPath.mid(binOffset);
QString cwd = m_GamePlugin->dataDirectory().absolutePath() + "/" + cwdPath.mid(cwdOffset);
QString cmdline = QString("launch \"%1\" \"%2\" %3")
.arg(QDir::toNativeSeparators(cwd),
QDir::toNativeSeparators(binPath),
arguments);

return startBinary(QFileInfo(QCoreApplication::applicationDirPath() + "/helper.exe"),
cmdline,
QCoreApplication::applicationDirPath(), true);
} else {
return startBinary(binary, arguments, currentDirectory, true);
}
} else {
qDebug("start of \"%s\" canceled by plugin", qPrintable(binary.absoluteFilePath()));
return INVALID_HANDLE_VALUE;
Expand Down Expand Up @@ -1576,7 +1600,7 @@ std::vector<Mapping> OrganizerCore::fileMapping()

int overwriteId = m_DirectoryStructure->getOriginByName(L"Overwrite").getID();

IPluginGame *game = qApp->property("managed_game").value<IPluginGame *>();
const IPluginGame *game = qApp->property("managed_game").value<const IPluginGame *>();
MappingType result = fileMapping(
QDir::toNativeSeparators(game->dataDirectory().absolutePath()),
"\\",
Expand All @@ -1585,11 +1609,12 @@ std::vector<Mapping> OrganizerCore::fileMapping()

if (m_CurrentProfile->localSavesEnabled()) {
LocalSavegames *localSaves = game->feature<LocalSavegames>();

if (localSaves != nullptr) {
MappingType saveMap = localSaves->mappings(currentProfile()->absolutePath() + "/saves");
result.reserve(result.size() + saveMap.size());
result.insert(result.end(), saveMap.begin(), saveMap.end());
} else {
qWarning("local save games not supported by this game plugin");
}
}

Expand Down
4 changes: 0 additions & 4 deletions src/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ class Profile : public QObject, public MOBase::IProfile

/**
* @brief activate archive invalidation
*
* @param dataDirectory data directory of the game
* @todo passing the data directory as a parameter is useless, the function should
* be able to query it from GameInfo
**/
void activateInvalidation();

Expand Down
1 change: 0 additions & 1 deletion src/profilesdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class ProfilesDialog : public MOBase::TutorableDialog
*
* @param profileName currently enabled profile
* @param parent parent widget
* @todo the game path could be retrieved from GameInfo just as easily
**/
explicit ProfilesDialog(const QString &profileName, MOBase::IPluginGame const *game, QWidget *parent = 0);
~ProfilesDialog();
Expand Down
1 change: 0 additions & 1 deletion src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ along with Mod Organizer. If not, see <http://www.gnu.org/licenses/>.
#include "settingsdialog.h"
#include "utility.h"
#include "helper.h"
#include <gameinfo.h>
#include <appconfig.h>
#include <utility.h>
#include <iplugingame.h>
Expand Down
13 changes: 7 additions & 6 deletions src/transfersavesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ void TransferSavesDialog::on_moveToLocalBtn_clicked()
{
QString selectedCharacter = ui->globalCharacterList->currentItem()->text();
if (QMessageBox::question(this, tr("Confirm"),
tr("Copy all save games of character \"%1\" to the profile?").arg(selectedCharacter),
tr("Move all save games of character \"%1\" to the profile?").arg(selectedCharacter),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
QString destination = m_Profile.absolutePath() + "/saves";
OverwriteMode overwriteMode = OVERWRITE_ASK;
Expand All @@ -176,10 +176,11 @@ void TransferSavesDialog::on_moveToLocalBtn_clicked()
continue;
}
}
if (!QFile::rename(fileInfo.absoluteFilePath(), destinationFile)) {
qCritical("failed to move %s to %s",
if (!shellMove(fileInfo.absoluteFilePath(), destinationFile)) {
qCritical("failed to move %s to %s: %lu",
fileInfo.absoluteFilePath().toUtf8().constData(),
destinationFile.toUtf8().constData());
destinationFile.toUtf8().constData(),
::GetLastError());
}
}
}
Expand Down Expand Up @@ -240,7 +241,7 @@ void TransferSavesDialog::on_moveToGlobalBtn_clicked()
continue;
}
}
if (!QFile::rename(fileInfo.absoluteFilePath(), destinationFile)) {
if (!shellMove(fileInfo.absoluteFilePath(), destinationFile)) {
qCritical("failed to move %s to %s",
fileInfo.absoluteFilePath().toUtf8().constData(),
destinationFile.toUtf8().constData());
Expand Down Expand Up @@ -279,7 +280,7 @@ void TransferSavesDialog::on_copyToGlobalBtn_clicked()
continue;
}
}
if (!QFile::copy(fileInfo.absoluteFilePath(), destinationFile)) {
if (!shellCopy(fileInfo.absoluteFilePath(), destinationFile)) {
qCritical("failed to copy %s to %s",
fileInfo.absoluteFilePath().toUtf8().constData(),
destinationFile.toUtf8().constData());
Expand Down

0 comments on commit ddf8414

Please sign in to comment.