fixed compressStates(), now, with compression enabled, the first element is always kept and the horizon matches

missing "framerate" added, now changes are persisted.
This commit is contained in:
thrust26 2018-01-10 11:48:06 +01:00
parent 74009d2545
commit f241dfd7b7
2 changed files with 9 additions and 11 deletions

View File

@ -214,9 +214,14 @@ uInt32 RewindManager::unwindState(uInt32 numStates)
void RewindManager::compressStates() void RewindManager::compressStates()
{ {
double expectedCycles = myInterval * myFactor * (1 + myFactor); double expectedCycles = myInterval * myFactor * (1 + myFactor);
double maxError = 1; double maxError = 1.5;
uInt32 idx = myStateList.size() - 2; uInt32 idx = myStateList.size() - 2;
//uInt32 removeIdx = 0;
// in case maxError is <= 1.5 remove first state by default:
Common::LinkedObjectPool<RewindState>::const_iter removeIter = myStateList.first(); Common::LinkedObjectPool<RewindState>::const_iter removeIter = myStateList.first();
if(myUncompressed < mySize)
// if compression is enabled, the first but one state is removed by default:
removeIter++;
//cerr << "idx: " << idx << endl; //cerr << "idx: " << idx << endl;
// iterate from last but one to first but one // iterate from last but one to first but one
@ -236,21 +241,13 @@ void RewindManager::compressStates()
{ {
maxError = error; maxError = error;
removeIter = it; removeIter = it;
//removeIdx = idx;
} }
} }
--idx; --idx;
} }
if (maxError < 1) myStateList.remove(removeIter); // remove
{
// the horizon is getting too big (can happen after changing settings)
myStateList.remove(1); // remove oldest but one
//cerr << "remove oldest + 1" << endl;
}
else
{
myStateList.remove(removeIter); // remove
//cerr << "remove " << removeIdx << endl; //cerr << "remove " << removeIdx << endl;
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,6 +34,7 @@ Settings::Settings(OSystem& osystem)
{ {
// Video-related options // Video-related options
setInternal("video", ""); setInternal("video", "");
setInternal("framerate", "0");
setInternal("vsync", "true"); setInternal("vsync", "true");
setInternal("fullscreen", "false"); setInternal("fullscreen", "false");
setInternal("center", "false"); setInternal("center", "false");