Navigation Menu

Skip to content

Commit

Permalink
Savegame Converter: Basic mechanism for savegame conversion using Sav…
Browse files Browse the repository at this point in the history
…egame Tool
  • Loading branch information
danij-deng committed Mar 20, 2014
1 parent 194eb9a commit e735ce0
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions doomsday/plugins/savegameconverter/src/savegameconverter.cpp
Expand Up @@ -17,18 +17,52 @@
* 02110-1301 USA</small>
*/

#include <QCoreApplication>
#include <de/CommandLine>
#include <de/Log>
#include <de/NativePath>
#include <de/String>

#include "savegameconverter.h"

using namespace de;

int SavegameConvertHook(int /*hook_type*/, int /*parm*/, void * /*data*/)
int SavegameConvertHook(int /*hook_type*/, int /*parm*/, void *data)
{
DENG2_ASSERT(data != 0);
ddhook_savegame_convert_t const &parm = *static_cast<ddhook_savegame_convert_t *>(data);

LOG_AS("SavegameConverter");
LOG_NOTE("No conversion attempted. Returning false");
return false; // Conversion failed.

CommandLine cmd;

#ifdef MACOSX
// First locate the savegametool executable.
NativePath bin = NativePath(qApp->applicationDirPath()) / "../Resources/savegametool";
/// @todo fixme: Need to try alternate locations?
#elif WIN32
NativePath bin = NativePath(qApp->applicationDirPath()) / "savegametool.exe";
#else // UNIX
NativePath bin = NativePath(qApp->applicationDirPath()) / "savegametool";
/// @todo fixme: Need to try alternate locations?
#endif
if(!bin.exists())
{
LOG_RES_ERROR("Failed to locate Savegame Tool");
return false;
}
cmd.append(bin);

cmd.append("-idkey");
cmd.append(Str_Text(&parm.fallbackGameIdentityKey));

cmd.append(Str_Text(&parm.inputFilePath));

LOG_RES_NOTE("Starting conversion of \"%s\" using Savegame Tool")
<< NativePath(Str_Text(&parm.inputFilePath)).pretty();
cmd.execute();

return true; // A conversion attempt was made (using Savegame Tool).
}

/**
Expand Down

0 comments on commit e735ce0

Please sign in to comment.