Core: Fix issues with 0 rewind states

This commit is contained in:
Jeffrey Pfau 2016-09-14 10:34:14 -07:00
parent 72b499dc8e
commit f97a1524be
2 changed files with 10 additions and 7 deletions

View File

@ -107,7 +107,7 @@ static THREAD_ENTRY _mCoreThreadRun(void* context) {
core->setSync(core, &threadContext->sync);
core->reset(core);
if (core->opts.rewindEnable) {
if (core->opts.rewindEnable && core->opts.rewindBufferCapacity > 0) {
mCoreRewindContextInit(&threadContext->rewind, core->opts.rewindBufferCapacity);
}
@ -487,11 +487,13 @@ void mCoreThreadFrameStarted(struct mCoreThread* thread) {
if (!thread) {
return;
}
if (thread->core->opts.rewindEnable && thread->state != THREAD_REWINDING) {
mCoreRewindAppend(&thread->rewind, thread->core);
} else if (thread->state == THREAD_REWINDING) {
if (!mCoreRewindRestore(&thread->rewind, thread->core)) {
if (thread->core->opts.rewindEnable && thread->core->opts.rewindBufferCapacity > 0) {
if (thread->state != THREAD_REWINDING) {
mCoreRewindAppend(&thread->rewind, thread->core);
} else if (thread->state == THREAD_REWINDING) {
if (!mCoreRewindRestore(&thread->rewind, thread->core)) {
mCoreRewindAppend(&thread->rewind, thread->core);
}
}
}
}

View File

@ -659,11 +659,12 @@ void GameController::frameAdvance() {
void GameController::setRewind(bool enable, int capacity) {
if (m_gameOpen) {
threadInterrupt();
if (m_threadContext.core->opts.rewindEnable) {
if (m_threadContext.core->opts.rewindEnable && m_threadContext.core->opts.rewindBufferCapacity > 0) {
mCoreRewindContextDeinit(&m_threadContext.rewind);
}
m_threadContext.core->opts.rewindEnable = enable;
if (enable) {
m_threadContext.core->opts.rewindBufferCapacity = capacity;
if (enable && capacity > 0) {
mCoreRewindContextInit(&m_threadContext.rewind, capacity);
}
threadContinue();