Cleanups - less settings_t pointer passing

This commit is contained in:
LibretroAdmin 2025-02-11 09:38:54 +01:00
parent 316077a135
commit 6559f4499c
7 changed files with 47 additions and 56 deletions

View File

@ -37,7 +37,7 @@ void autosave_lock(void);
**/
void autosave_unlock(void);
bool autosave_init(void);
bool autosave_init(bool compress_files, unsigned autosave_interval);
void autosave_deinit(void);

View File

@ -2784,72 +2784,64 @@ void core_info_qsort(core_info_list_t *core_info_list,
bool core_info_current_supports_savestate(void)
{
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
if (settings->bools.core_info_savestate_bypass)
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
bool core_info_savestate_bypass = settings->bools.core_info_savestate_bypass;
if (core_info_savestate_bypass)
return true;
/* If no core is currently loaded, assume
* by default that all savestate functionality
* is supported */
if (!p_coreinfo->current)
return true;
return p_coreinfo->current->savestate_support_level >=
CORE_INFO_SAVESTATE_BASIC;
}
bool core_info_current_supports_rewind(void)
{
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
if (settings->bools.core_info_savestate_bypass)
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
bool core_info_savestate_bypass = settings->bools.core_info_savestate_bypass;
if (core_info_savestate_bypass)
return true;
/* If no core is currently loaded, assume
* by default that all savestate functionality
* is supported */
if (!p_coreinfo->current)
return true;
return p_coreinfo->current->savestate_support_level >=
CORE_INFO_SAVESTATE_SERIALIZED;
}
bool core_info_current_supports_netplay(void)
{
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
if (settings->bools.core_info_savestate_bypass)
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
bool core_info_savestate_bypass = settings->bools.core_info_savestate_bypass;
if (core_info_savestate_bypass)
return true;
/* If no core is currently loaded, assume
* by default that all savestate functionality
* is supported */
if (!p_coreinfo->current)
return true;
return p_coreinfo->current->savestate_support_level >=
CORE_INFO_SAVESTATE_DETERMINISTIC;
}
bool core_info_current_supports_runahead(void)
{
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
if (settings->bools.core_info_savestate_bypass)
core_info_state_t *p_coreinfo = &core_info_st;
settings_t *settings = config_get_ptr();
bool core_info_savestate_bypass = settings->bools.core_info_savestate_bypass;
if (core_info_savestate_bypass)
return true;
/* If no core is currently loaded, assume
* by default that all savestate functionality
* is supported */
if (!p_coreinfo->current)
return true;
return p_coreinfo->current->savestate_support_level >=
CORE_INFO_SAVESTATE_DETERMINISTIC;
}

View File

@ -2988,7 +2988,19 @@ bool command_event(enum event_command cmd, void *data)
switch (cmd)
{
case CMD_EVENT_SAVE_FILES:
event_save_files(runloop_st->flags & RUNLOOP_FLAG_USE_SRAM);
event_save_files(
runloop_st->flags & RUNLOOP_FLAG_USE_SRAM,
#if defined(HAVE_ZLIB)
settings->bools.save_file_compression,
#else
false,
#endif
#ifdef HAVE_CHEATS
settings->paths.path_cheat_database
#else
NULL
#endif
);
break;
case CMD_EVENT_OVERLAY_UNLOAD:
#ifdef HAVE_OVERLAY
@ -3771,7 +3783,14 @@ bool command_event(enum event_command cmd, void *data)
RARCH_NETPLAY_CTL_IS_ENABLED, NULL))
#endif
{
if (autosave_init())
if (autosave_init(
#if defined(HAVE_ZLIB)
settings->bools.save_file_compression,
#else
false,
#endif
settings->uints.autosave_interval)
)
runloop_st->flags |= RUNLOOP_FLAG_AUTOSAVE;
else
runloop_st->flags &= ~RUNLOOP_FLAG_AUTOSAVE;

View File

@ -27,6 +27,7 @@
#include <streams/file_stream.h>
#include <time/rtime.h>
#include "configuration.h"
#include "content.h"
#include "core.h"
#include "dynamic.h"

28
save.c
View File

@ -36,7 +36,6 @@
#include "core.h"
#include "core_info.h"
#include "file_path_special.h"
#include "configuration.h"
#include "msg_hash.h"
#include "runloop.h"
#include "verbosity.h"
@ -218,17 +217,10 @@ static void autosave_free(autosave_t *handle)
handle->buffer = NULL;
}
bool autosave_init(void)
bool autosave_init(bool compress_files, unsigned autosave_interval)
{
unsigned i;
autosave_t **list = NULL;
settings_t *settings = config_get_ptr();
unsigned autosave_interval = settings->uints.autosave_interval;
#if defined(HAVE_ZLIB)
bool compress_files = settings->bools.save_file_compression;
#else
bool compress_files = false;
#endif
if (autosave_interval < 1 || !task_save_files)
return false;
@ -501,29 +493,17 @@ fail:
return false;
}
bool event_save_files(bool is_sram_used)
bool event_save_files(bool is_sram_used, bool compress_files,
const char *path_cheat_database)
{
unsigned i;
settings_t *settings = config_get_ptr();
#ifdef HAVE_CHEATS
const char *path_cheat_database = settings->paths.path_cheat_database;
#endif
#if defined(HAVE_ZLIB)
bool compress_files = settings->bools.save_file_compression;
#else
bool compress_files = false;
#endif
#ifdef HAVE_CHEATS
cheat_manager_save_game_specific_cheats(
path_cheat_database);
cheat_manager_save_game_specific_cheats(path_cheat_database);
#endif
if (!task_save_files || !is_sram_used)
return false;
for (i = 0; i < task_save_files->size; i++)
content_save_ram_file(i, compress_files);
return true;
}

View File

@ -1663,7 +1663,8 @@ static void task_push_to_history_list(
label = runloop_st->name.label;
if (
settings && settings->bools.history_list_enable
settings
&& settings->bools.history_list_enable
&& playlist_hist)
{
char subsystem_name[PATH_MAX_LENGTH];
@ -2014,7 +2015,6 @@ bool task_push_load_content_from_playlist_from_menu(
void *user_data)
{
content_information_ctx_t content_ctx;
content_state_t *p_content = content_state_get_ptr();
bool ret = true;
settings_t *settings = config_get_ptr();
@ -2517,7 +2517,6 @@ static bool task_load_content_internal(
bool loading_from_companion_ui)
{
content_information_ctx_t content_ctx;
content_state_t *p_content = content_state_get_ptr();
bool ret = false;
runloop_state_t *runloop_st = runloop_state_get_ptr();
@ -3021,7 +3020,6 @@ bool content_init(void)
content_information_ctx_t content_ctx;
enum msg_hash_enums error_enum = MSG_UNKNOWN;
content_state_t *p_content = content_state_get_ptr();
bool ret = true;
char *error_string = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();

View File

@ -238,7 +238,8 @@ bool take_screenshot(
bool event_load_save_files(bool is_sram_load_disabled);
bool event_save_files(bool sram_used);
bool event_save_files(bool sram_used, bool compress_files,
const char *path_cheat_database);
void path_init_savefile_rtc(const char *savefile_path);