Refactor rarch_init_rewind/rarch_deinit_rewind

This commit is contained in:
twinaphex 2014-08-02 04:01:25 +02:00
parent d70693345c
commit 15898a98f0
3 changed files with 16 additions and 11 deletions

View File

@ -100,6 +100,7 @@ enum basic_event
RARCH_CMD_PREPARE_DUMMY,
RARCH_CMD_QUIT,
RARCH_CMD_REINIT,
RARCH_CMD_REWIND,
};
enum menu_enums
@ -780,8 +781,6 @@ void rarch_deinit_msg_queue(void);
void rarch_input_poll(void);
void rarch_check_overlay(void);
void rarch_check_block_hotkey(void);
void rarch_init_rewind(void);
void rarch_deinit_rewind(void);
bool rarch_check_fullscreen(void);
void rarch_disk_control_set_eject(bool state, bool log);
void rarch_disk_control_set_index(unsigned index);

View File

@ -1494,7 +1494,7 @@ static void deinit_cheats(void)
g_extern.cheat = NULL;
}
void rarch_init_rewind(void)
static void init_rewind(void)
{
#ifdef HAVE_NETPLAY
if (g_extern.netplay)
@ -1529,7 +1529,7 @@ void rarch_init_rewind(void)
state_manager_push_do(g_extern.state_manager);
}
void rarch_deinit_rewind(void)
static void deinit_rewind(void)
{
if (g_extern.state_manager)
state_manager_free(g_extern.state_manager);
@ -3001,8 +3001,7 @@ int rarch_main_init(int argc, char *argv[])
init_command();
#endif
rarch_init_rewind();
init_rewind();
init_controllers();
#ifdef HAVE_RECORD
@ -3146,6 +3145,12 @@ void rarch_main_command(unsigned action)
case RARCH_CMD_REINIT:
rarch_set_fullscreen(g_settings.video.fullscreen);
break;
case RARCH_CMD_REWIND:
if (g_settings.rewind_enable)
init_rewind();
else
deinit_rewind();
break;
}
}
@ -3292,7 +3297,7 @@ void rarch_main_deinit(void)
#ifdef HAVE_NETPLAY
if (!g_extern.netplay)
#endif
rarch_deinit_rewind();
deinit_rewind();
deinit_cheats();

View File

@ -978,6 +978,7 @@ static void general_read_handler(const void *data)
static void general_write_handler(const void *data)
{
bool has_set_reinit = false;
bool has_set_rewind = false;
const rarch_setting_t *setting = (const rarch_setting_t*)data;
if (!setting)
@ -992,10 +993,7 @@ static void general_write_handler(const void *data)
else if (!strcmp(setting->name, "rewind_enable"))
{
g_settings.rewind_enable = *setting->value.boolean;
if (g_settings.rewind_enable)
rarch_init_rewind();
else
rarch_deinit_rewind();
has_set_rewind = true;
}
else if (!strcmp(setting->name, "rewind_granularity"))
g_settings.rewind_granularity = *setting->value.unsigned_integer;
@ -1341,6 +1339,9 @@ static void general_write_handler(const void *data)
if (has_set_reinit)
rarch_main_command(RARCH_CMD_REINIT);
if (has_set_rewind)
rarch_main_command(RARCH_CMD_REWIND);
}
#define NEXT (list[index++])