Minor updates to rewind:

- comments are now more in line with what actually happens when adding a state
- changed Serializer::reset() to Serializer::rewind(), to more accurately indicate what it does
This commit is contained in:
Stephen Anthony 2017-12-06 11:44:40 -03:30
parent 90be9bb607
commit a79ccf400f
6 changed files with 13 additions and 11 deletions

View File

@ -42,7 +42,8 @@
In the case of methods which wrap the C++ 'splice()' method, the In the case of methods which wrap the C++ 'splice()' method, the
semantics of splice are followed wrt invalid/out-of-range/etc semantics of splice are followed wrt invalid/out-of-range/etc
iterators. See the applicable documentation for such behaviour. iterators. See the applicable C++ STL documentation for such
behaviour.
@author Stephen Anthony @author Stephen Anthony
*/ */

View File

@ -48,7 +48,7 @@ bool RewindManager::addState(const string& message)
RewindState& state = myStateList.current(); RewindState& state = myStateList.current();
Serializer& s = state.data; Serializer& s = state.data;
s.reset(); // rewind Serializer internal buffers s.rewind(); // rewind Serializer internal buffers
if(myStateManager.saveState(s) && myOSystem.console().tia().saveDisplay(s)) if(myStateManager.saveState(s) && myOSystem.console().tia().saveDisplay(s))
{ {
state.message = message; state.message = message;
@ -70,7 +70,7 @@ bool RewindManager::rewindState()
string message = getMessage(state); string message = getMessage(state);
cerr << "rewind " << state.count << endl; cerr << "rewind " << state.count << endl;
s.reset(); // rewind Serializer internal buffers s.rewind(); // rewind Serializer internal buffers
myStateManager.loadState(s); myStateManager.loadState(s);
myOSystem.console().tia().loadDisplay(s); myOSystem.console().tia().loadDisplay(s);

View File

@ -34,8 +34,9 @@ class StateManager;
Unwinding involves moving the internal iterator forwards in time (towards Unwinding involves moving the internal iterator forwards in time (towards
the end of the list). the end of the list).
Any time a new state is added, the internal iterator moves back to the Any time a new state is added, all states from the current iterator position
insertion point of the data (the end of the list). to the end of the list (aka, all future states) are removed, and the internal
iterator moves to the insertion point of the data (the end of the list).
@author Stephen Anthony @author Stephen Anthony
*/ */

View File

@ -466,7 +466,7 @@ void CartridgeCTY::saveScore(uInt8 index)
memcpy(scoreRAM + (index << 6) + 4, myRAM+4, 60); memcpy(scoreRAM + (index << 6) + 4, myRAM+4, 60);
// Save score RAM // Save score RAM
serializer.reset(); serializer.rewind();
try try
{ {
serializer.putByteArray(scoreRAM, 256); serializer.putByteArray(scoreRAM, 256);

View File

@ -35,7 +35,7 @@ Serializer::Serializer(const string& filename, bool readonly)
{ {
myStream = std::move(str); myStream = std::move(str);
myStream->exceptions( ios_base::failbit | ios_base::badbit | ios_base::eofbit ); myStream->exceptions( ios_base::failbit | ios_base::badbit | ios_base::eofbit );
reset(); rewind();
} }
} }
} }
@ -56,7 +56,7 @@ Serializer::Serializer(const string& filename, bool readonly)
{ {
myStream = std::move(str); myStream = std::move(str);
myStream->exceptions( ios_base::failbit | ios_base::badbit | ios_base::eofbit ); myStream->exceptions( ios_base::failbit | ios_base::badbit | ios_base::eofbit );
reset(); rewind();
} }
} }
} }
@ -73,12 +73,12 @@ Serializer::Serializer()
{ {
myStream->exceptions( ios_base::failbit | ios_base::badbit | ios_base::eofbit ); myStream->exceptions( ios_base::failbit | ios_base::badbit | ios_base::eofbit );
putBool(true); putBool(true);
reset(); rewind();
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Serializer::reset() void Serializer::rewind()
{ {
myStream->clear(); myStream->clear();
myStream->seekg(ios_base::beg); myStream->seekg(ios_base::beg);

View File

@ -59,7 +59,7 @@ class Serializer
/** /**
Resets the read/write location to the beginning of the stream. Resets the read/write location to the beginning of the stream.
*/ */
void reset(); void rewind();
/** /**
Reads a byte value (unsigned 8-bit) from the current input stream. Reads a byte value (unsigned 8-bit) from the current input stream.