mirror of https://github.com/stella-emu/stella.git
Added header to state files, so that older state files are automatically
marked as being incompatible. With each future release, if the format changes again, we simply update the header. Also, the header encodes the last version that worked with that format, with 2 bytes per number (ie, version 2.5, or 2.5.0.0, is encoded as 02050000). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1445 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
e0e0a3648b
commit
d0d6697e07
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: StateManager.cxx,v 1.3 2008-02-06 13:45:22 stephena Exp $
|
||||
// $Id: StateManager.cxx,v 1.4 2008-03-25 13:52:38 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <sstream>
|
||||
|
@ -29,6 +29,9 @@
|
|||
|
||||
#include "StateManager.hxx"
|
||||
|
||||
#define STATE_HEADER "02050000state"
|
||||
#define MOVIE_HEADER "02050000movie"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
StateManager::StateManager(OSystem* osystem)
|
||||
: myOSystem(osystem),
|
||||
|
@ -184,12 +187,16 @@ void StateManager::loadState(int slot)
|
|||
return;
|
||||
}
|
||||
|
||||
// Do a complete state load using the Console
|
||||
buf.str("");
|
||||
if(in.getString() == md5 && myOSystem->console().load(in))
|
||||
|
||||
// First test if we have a valid header
|
||||
// If so, do a complete state load using the Console
|
||||
if(in.getString() != STATE_HEADER)
|
||||
buf << "Incompatible state " << slot << " file";
|
||||
else if(in.getString() == md5 && myOSystem->console().load(in))
|
||||
buf << "State " << slot << " loaded";
|
||||
else
|
||||
buf << "Invalid state " << slot << " file";
|
||||
buf << "Invalid data in state " << slot << " file";
|
||||
|
||||
in.close();
|
||||
myOSystem->frameBuffer().showMessage(buf.str());
|
||||
|
@ -218,6 +225,10 @@ void StateManager::saveState(int slot)
|
|||
return;
|
||||
}
|
||||
|
||||
// Add header so that if the state format changes in the future,
|
||||
// we'll know right away, without having to parse the rest of the file
|
||||
out.putString(STATE_HEADER);
|
||||
|
||||
// Prepend the ROM md5 so this state file only works with that ROM
|
||||
out.putString(md5);
|
||||
|
||||
|
|
Loading…
Reference in New Issue