mirror of
https://github.com/libretro/RetroArch
synced 2025-01-26 09:35:21 +00:00
Create runloop_check_cheevos
This commit is contained in:
parent
94915815ae
commit
fad523ea3e
42
cheevos.c
42
cheevos.c
@ -273,7 +273,6 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int loaded;
|
||||
int console_id;
|
||||
bool core_supports;
|
||||
|
||||
@ -285,9 +284,9 @@ typedef struct
|
||||
retro_ctx_memory_info_t meminfo[4];
|
||||
} cheevos_locals_t;
|
||||
|
||||
|
||||
static cheevos_locals_t cheevos_locals =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
true,
|
||||
{NULL, 0},
|
||||
@ -295,8 +294,9 @@ static cheevos_locals_t cheevos_locals =
|
||||
{0}
|
||||
};
|
||||
|
||||
static int cheats_are_enabled = 0;
|
||||
static int cheats_were_enabled = 0;
|
||||
bool cheevos_loaded = false;
|
||||
int cheats_are_enabled = 0;
|
||||
int cheats_were_enabled = 0;
|
||||
|
||||
/*****************************************************************************
|
||||
Supporting functions.
|
||||
@ -2558,7 +2558,7 @@ bool cheevos_load(const void *data)
|
||||
|
||||
url[0] = '\0';
|
||||
|
||||
cheevos_locals.loaded = 0;
|
||||
cheevos_loaded = 0;
|
||||
|
||||
/* Just return OK if the core doesn't support cheevos, or info is NULL. */
|
||||
if (!cheevos_locals.core_supports || !info)
|
||||
@ -2676,7 +2676,7 @@ found:
|
||||
{
|
||||
cheevos_deactivate_unlocks(game_id, &timeout);
|
||||
free((void*)json);
|
||||
cheevos_locals.loaded = 1;
|
||||
cheevos_loaded = true;
|
||||
|
||||
cheevos_make_playing_url(game_id, url, sizeof(url));
|
||||
task_push_http_transfer(url, true, NULL,
|
||||
@ -2698,17 +2698,13 @@ void cheevos_reset_game(void)
|
||||
const cheevo_t *end = cheevo + cheevos_locals.core.count;
|
||||
|
||||
for (; cheevo < end; cheevo++)
|
||||
{
|
||||
cheevo->last = 1;
|
||||
}
|
||||
|
||||
cheevo = cheevos_locals.unofficial.cheevos;
|
||||
end = cheevo + cheevos_locals.unofficial.count;
|
||||
|
||||
for (; cheevo < end; cheevo++)
|
||||
{
|
||||
cheevo->last = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void cheevos_populate_menu(void *data, bool hardcore)
|
||||
@ -2840,13 +2836,13 @@ bool cheevos_apply_cheats(bool *data_bool)
|
||||
|
||||
bool cheevos_unload(void)
|
||||
{
|
||||
if (!cheevos_locals.loaded)
|
||||
if (!cheevos_loaded)
|
||||
return false;
|
||||
|
||||
cheevos_free_cheevo_set(&cheevos_locals.core);
|
||||
cheevos_free_cheevo_set(&cheevos_locals.unofficial);
|
||||
|
||||
cheevos_locals.loaded = 0;
|
||||
cheevos_loaded = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -2876,28 +2872,18 @@ bool cheevos_toggle_hardcore_mode(void)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cheevos_test(void)
|
||||
void cheevos_test(void)
|
||||
{
|
||||
if (!cheevos_locals.loaded)
|
||||
return false;
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
if (!cheats_are_enabled && !cheats_were_enabled)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
if (!settings->cheevos.enable)
|
||||
return false;
|
||||
cheevos_test_cheevo_set(&cheevos_locals.core);
|
||||
|
||||
cheevos_test_cheevo_set(&cheevos_locals.core);
|
||||
|
||||
if (settings->cheevos.test_unofficial)
|
||||
cheevos_test_cheevo_set(&cheevos_locals.unofficial);
|
||||
if (settings->cheevos.test_unofficial)
|
||||
cheevos_test_cheevo_set(&cheevos_locals.unofficial);
|
||||
|
||||
#if 0
|
||||
cheevos_test_leaderboards();
|
||||
cheevos_test_leaderboards();
|
||||
#endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cheevos_set_cheats(void)
|
||||
|
@ -53,7 +53,7 @@ bool cheevos_unload(void);
|
||||
|
||||
bool cheevos_toggle_hardcore_mode(void);
|
||||
|
||||
bool cheevos_test(void);
|
||||
void cheevos_test(void);
|
||||
|
||||
bool cheevos_set_cheats(void);
|
||||
|
||||
@ -65,6 +65,10 @@ void cheevos_parse_guest_addr(cheevos_var_t *var, unsigned value);
|
||||
|
||||
uint8_t *cheevos_get_memory(const cheevos_var_t *var);
|
||||
|
||||
extern bool cheevos_loaded;
|
||||
extern int cheats_are_enabled;
|
||||
extern int cheats_were_enabled;
|
||||
|
||||
RETRO_END_DECLS
|
||||
|
||||
#endif /* __RARCH_CHEEVOS_H */
|
||||
|
@ -760,6 +760,8 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
||||
*/
|
||||
#define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !video_driver_is_alive() || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL) || (runloop_max_frames && (*(video_driver_get_frame_count_ptr()) >= runloop_max_frames)) || runloop_exec)
|
||||
|
||||
#define runloop_check_cheevos() (settings->cheevos.enable && cheevos_loaded && (!cheats_are_enabled && !cheats_were_enabled))
|
||||
|
||||
static enum runloop_state runloop_check_state(
|
||||
settings_t *settings,
|
||||
uint64_t current_input,
|
||||
@ -1244,7 +1246,8 @@ int runloop_iterate(unsigned *sleep_ms)
|
||||
core_run();
|
||||
|
||||
#ifdef HAVE_CHEEVOS
|
||||
cheevos_test();
|
||||
if (runloop_check_cheevos())
|
||||
cheevos_test();
|
||||
#endif
|
||||
|
||||
for (i = 0; i < settings->input.max_users; i++)
|
||||
|
Loading…
x
Reference in New Issue
Block a user