Skip to content
Permalink
Browse files

SaveState: Use latest version if initial missing.

This may be useful for debugging or if we decide on a buffer between
versions.
  • Loading branch information...
unknownbrackets committed Jun 15, 2018
1 parent 006ef96 commit 16b11138b4e63c11465452b3ba49be36f4a4efc6
Showing with 11 additions and 5 deletions.
  1. +7 −1 Common/ChunkFile.cpp
  2. +2 −2 Common/ChunkFile.h
  3. +2 −2 Core/SaveState.cpp
@@ -225,7 +225,7 @@ CChunkFileReader::Error CChunkFileReader::GetFileTitle(const std::string &filena
return LoadFileHeader(pFile, header, title);
}

CChunkFileReader::Error CChunkFileReader::LoadFile(const std::string &filename, const char *gitVersion, u8 *&_buffer, size_t &sz, std::string *failureReason) {
CChunkFileReader::Error CChunkFileReader::LoadFile(const std::string &filename, std::string *gitVersion, u8 *&_buffer, size_t &sz, std::string *failureReason) {
if (!File::Exists(filename)) {
*failureReason = "LoadStateDoesntExist";
ERROR_LOG(SAVESTATE, "ChunkReader: File doesn't exist");
@@ -264,6 +264,12 @@ CChunkFileReader::Error CChunkFileReader::LoadFile(const std::string &filename,
delete [] buffer;
}

if (header.GitVersion[31]) {
*gitVersion = std::string(header.GitVersion, 32);
} else {
*gitVersion = header.GitVersion;
}

return ERROR_NONE;
}

@@ -622,7 +622,7 @@ class CChunkFileReader

// Load file template
template<class T>
static Error Load(const std::string &filename, const char *gitVersion, T& _class, std::string *failureReason)
static Error Load(const std::string &filename, std::string *gitVersion, T& _class, std::string *failureReason)
{
*failureReason = "LoadStateWrongVersion";

@@ -700,7 +700,7 @@ class CChunkFileReader
REVISION_CURRENT = REVISION_TITLE,
};

static Error LoadFile(const std::string &filename, const char *gitVersion, u8 *&buffer, size_t &sz, std::string *failureReason);
static Error LoadFile(const std::string &filename, std::string *gitVersion, u8 *&buffer, size_t &sz, std::string *failureReason);
static Error SaveFile(const std::string &filename, const std::string &title, const char *gitVersion, u8 *buffer, size_t sz);
static Error LoadFileHeader(File::IOFile &pFile, SChunkHeader &header, std::string *title);
};
@@ -268,7 +268,6 @@ namespace SaveState
p.Do(saveStateInitialGitVersion);
} else {
saveStateGeneration = 1;
saveStateInitialGitVersion = "v0.0.1";
}

// Gotta do CoreTiming first since we'll restore into it.
@@ -699,7 +698,8 @@ namespace SaveState
{
case SAVESTATE_LOAD:
INFO_LOG(SAVESTATE, "Loading state from %s", op.filename.c_str());
result = CChunkFileReader::Load(op.filename, PPSSPP_GIT_VERSION, state, &reason);
// Use the state's latest version as a guess for saveStateInitialGitVersion.
result = CChunkFileReader::Load(op.filename, &saveStateInitialGitVersion, state, &reason);
if (result == CChunkFileReader::ERROR_NONE) {
callbackMessage = sc->T("Loaded State");
callbackResult = Status::SUCCESS;

0 comments on commit 16b1113

Please sign in to comment.
You can’t perform that action at this time.