rarch_main - reduce a lot of code duplication

This commit is contained in:
twinaphex 2016-05-17 08:19:50 +02:00
parent 80ce237878
commit e2e53026aa
2 changed files with 26 additions and 39 deletions

View File

@ -103,15 +103,12 @@ void main_exit(void *args)
**/
int rarch_main(int argc, char *argv[], void *data)
{
char *fullpath = NULL;
rarch_system_info_t *system = NULL;
void *args = (void*)data;
#ifndef HAVE_MAIN
int ret = 0;
#endif
rarch_ctl(RARCH_CTL_PREINIT, NULL);
frontend_driver_init_first(args);
rarch_ctl(RARCH_CTL_INIT, NULL);
@ -140,28 +137,6 @@ int rarch_main(int argc, char *argv[], void *data)
return 0;
}
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
if (content_is_inited() || content_does_not_need_content())
{
char tmp[PATH_MAX_LENGTH];
struct retro_system_info *info = system ? &system->info : NULL;
strlcpy(tmp, fullpath, sizeof(tmp));
/* Path can be relative here.
* Ensure we're pushing absolute path. */
if (*tmp)
path_resolve_realpath(tmp, sizeof(tmp));
if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL) || !info)
content_push_to_history_playlist(
content_does_not_need_content() || *tmp,
*tmp ? tmp : NULL,
info);
}
ui_companion_driver_init_first();
#ifndef HAVE_MAIN

View File

@ -1842,7 +1842,6 @@ static bool content_load_wrapper(
{
char name[PATH_MAX_LENGTH];
char msg[PATH_MAX_LENGTH];
bool add_to_playlist = false;
char *fullpath = NULL;
runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath);
@ -1871,25 +1870,38 @@ static bool content_load_wrapper(
}
}
add_to_playlist = !string_is_empty(fullpath);
#ifdef HAVE_MENU
if (!add_to_playlist)
add_to_playlist = menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL);
#endif
/* Push entry to top of playlist */
if (add_to_playlist)
/* Push entry to top of history playlist */
if (content_is_inited() || content_does_not_need_content())
{
char tmp[PATH_MAX_LENGTH];
struct retro_system_info *info = NULL;
rarch_system_info_t *system = NULL;
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system);
if (system)
info = &system->info;
#ifdef HAVE_MENU
if (launched_from_menu)
menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &info);
else
#endif
runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info);
content_push_to_history_playlist(true, fullpath, info);
playlist_write_file(g_defaults.history);
strlcpy(tmp, fullpath, sizeof(tmp));
if (!launched_from_menu)
{
/* Path can be relative here.
* Ensure we're pushing absolute path. */
if (*tmp)
path_resolve_realpath(tmp, sizeof(tmp));
}
if (info && *tmp)
{
content_push_to_history_playlist(
true, tmp, info);
playlist_write_file(g_defaults.history);
}
}
return true;