From a79ccf400f0a0dee0aa3a6984bde893c1b6cf7a2 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 6 Dec 2017 11:44:40 -0330 Subject: [PATCH] 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 --- src/common/LinkedObjectPool.hxx | 3 ++- src/common/RewindManager.cxx | 4 ++-- src/common/RewindManager.hxx | 5 +++-- src/emucore/CartCTY.cxx | 2 +- src/emucore/Serializer.cxx | 8 ++++---- src/emucore/Serializer.hxx | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/common/LinkedObjectPool.hxx b/src/common/LinkedObjectPool.hxx index 61fc34ff3..2619acba7 100644 --- a/src/common/LinkedObjectPool.hxx +++ b/src/common/LinkedObjectPool.hxx @@ -42,7 +42,8 @@ In the case of methods which wrap the C++ 'splice()' method, the 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 */ diff --git a/src/common/RewindManager.cxx b/src/common/RewindManager.cxx index 45cc42f2d..69ae2df3b 100644 --- a/src/common/RewindManager.cxx +++ b/src/common/RewindManager.cxx @@ -48,7 +48,7 @@ bool RewindManager::addState(const string& message) RewindState& state = myStateList.current(); 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)) { state.message = message; @@ -70,7 +70,7 @@ bool RewindManager::rewindState() string message = getMessage(state); cerr << "rewind " << state.count << endl; - s.reset(); // rewind Serializer internal buffers + s.rewind(); // rewind Serializer internal buffers myStateManager.loadState(s); myOSystem.console().tia().loadDisplay(s); diff --git a/src/common/RewindManager.hxx b/src/common/RewindManager.hxx index 16358746f..42d7d1cda 100644 --- a/src/common/RewindManager.hxx +++ b/src/common/RewindManager.hxx @@ -34,8 +34,9 @@ class StateManager; Unwinding involves moving the internal iterator forwards in time (towards the end of the list). - Any time a new state is added, the internal iterator moves back to the - insertion point of the data (the end of the list). + Any time a new state is added, all states from the current iterator position + 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 */ diff --git a/src/emucore/CartCTY.cxx b/src/emucore/CartCTY.cxx index 616796792..aa5d2c627 100644 --- a/src/emucore/CartCTY.cxx +++ b/src/emucore/CartCTY.cxx @@ -466,7 +466,7 @@ void CartridgeCTY::saveScore(uInt8 index) memcpy(scoreRAM + (index << 6) + 4, myRAM+4, 60); // Save score RAM - serializer.reset(); + serializer.rewind(); try { serializer.putByteArray(scoreRAM, 256); diff --git a/src/emucore/Serializer.cxx b/src/emucore/Serializer.cxx index 84b10c212..c191b99e4 100644 --- a/src/emucore/Serializer.cxx +++ b/src/emucore/Serializer.cxx @@ -35,7 +35,7 @@ Serializer::Serializer(const string& filename, bool readonly) { myStream = std::move(str); 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->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 ); putBool(true); - reset(); + rewind(); } } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void Serializer::reset() +void Serializer::rewind() { myStream->clear(); myStream->seekg(ios_base::beg); diff --git a/src/emucore/Serializer.hxx b/src/emucore/Serializer.hxx index f590ef60f..4c3b380fa 100644 --- a/src/emucore/Serializer.hxx +++ b/src/emucore/Serializer.hxx @@ -59,7 +59,7 @@ class Serializer /** 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.