reinitialize rewind buffer after loading game with achievements (#15934)

* reinitialize rewind buffer after loading game with achievements

* fix #endif placement for HAVE_GFX_WIDGETS
This commit is contained in:
Jamiras 2023-11-22 09:50:09 -07:00 committed by GitHub
parent a40f695cb8
commit 39a44414ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 5 deletions

View File

@ -586,6 +586,8 @@ static void rcheevos_progress_hide(rcheevos_locals_t* locals)
gfx_widget_set_achievement_progress(NULL, NULL); gfx_widget_set_achievement_progress(NULL, NULL);
} }
#endif
static void rcheevos_client_log_message(const char* message, const rc_client_t* client) static void rcheevos_client_log_message(const char* message, const rc_client_t* client)
{ {
CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", message); CHEEVOS_LOG(RCHEEVOS_TAG "%s\n", message);
@ -668,8 +670,6 @@ static void rcheevos_client_event_handler(const rc_client_event_t* event, rc_cli
} }
} }
#endif
int rcheevos_get_richpresence(char* s, size_t len) int rcheevos_get_richpresence(char* s, size_t len)
{ {
if (!rcheevos_is_player_active()) if (!rcheevos_is_player_active())
@ -2433,13 +2433,13 @@ static void rcheevos_client_load_game_callback(int result,
#ifdef HAVE_THREADS #ifdef HAVE_THREADS
if (!task_is_on_main_thread()) if (!task_is_on_main_thread())
{ {
/* Have to "schedule" this. CMD_EVENT_REWIND_INIT should /* Have to "schedule" this. CMD_EVENT_REWIND_REINIT should
* only be called on the main thread */ * only be called on the main thread */
rcheevos_locals.queued_command = CMD_EVENT_REWIND_INIT; rcheevos_locals.queued_command = CMD_EVENT_REWIND_REINIT;
} }
else else
#endif #endif
command_event(CMD_EVENT_REWIND_INIT, NULL); command_event(CMD_EVENT_REWIND_REINIT, NULL);
} }
#endif #endif
} }
@ -3144,6 +3144,7 @@ bool rcheevos_load(const void *data)
{ {
rcheevos_enforce_hardcore_settings(); rcheevos_enforce_hardcore_settings();
} }
#ifndef HAVE_RC_CLIENT
else else
{ {
#if HAVE_REWIND #if HAVE_REWIND
@ -3167,6 +3168,7 @@ bool rcheevos_load(const void *data)
} }
#endif #endif
} }
#endif
/* provide hooks for reading files */ /* provide hooks for reading files */
rc_hash_reset_cdreader_hooks(); rc_hash_reset_cdreader_hooks();

View File

@ -88,6 +88,8 @@ enum event_command
CMD_EVENT_REWIND_DEINIT, CMD_EVENT_REWIND_DEINIT,
/* Initializes rewind. */ /* Initializes rewind. */
CMD_EVENT_REWIND_INIT, CMD_EVENT_REWIND_INIT,
/* Reinitializes rewind (primarily if the state size changes). */
CMD_EVENT_REWIND_REINIT,
/* Toggles rewind. */ /* Toggles rewind. */
CMD_EVENT_REWIND_TOGGLE, CMD_EVENT_REWIND_TOGGLE,
/* Initializes autosave. */ /* Initializes autosave. */

View File

@ -2995,6 +2995,17 @@ bool command_event(enum event_command cmd, void *data)
} }
} }
} }
#endif
break;
case CMD_EVENT_REWIND_REINIT:
#ifdef HAVE_REWIND
/* to reinitialize the the rewind state manager, we have to recreate it.
* the easiest way to do that is a full deinit followed by an init. */
if (runloop_st->rewind_st.state != NULL)
{
command_event(CMD_EVENT_REWIND_DEINIT, NULL);
command_event(CMD_EVENT_REWIND_INIT, NULL);
}
#endif #endif
break; break;
case CMD_EVENT_REWIND_TOGGLE: case CMD_EVENT_REWIND_TOGGLE: