[retro-gtk] core: Factorize load_game() and prepare()
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [retro-gtk] core: Factorize load_game() and prepare()
- Date: Tue, 3 Aug 2021 05:27:45 +0000 (UTC)
commit 38c69c2916da461707ea315a5a98f00c32b5d333
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sat Jul 31 09:02:28 2021 +0200
core: Factorize load_game() and prepare()
They are virtually identical, so let's accept NULL in load_game() and
unconditionally unload any existing game, which is likely the right
thing to do anyway. This makes the code simpler.
retro-runner/retro-core.c | 22 +---------------------
1 file changed, 1 insertion(+), 21 deletions(-)
---
diff --git a/retro-runner/retro-core.c b/retro-runner/retro-core.c
index 7bb64ef..7cd2e15 100644
--- a/retro-runner/retro-core.c
+++ b/retro-runner/retro-core.c
@@ -873,8 +873,6 @@ load_game (RetroCore *self,
gboolean game_loaded;
RetroSystemAvInfo info = {{ 0 }};
- g_assert (game != NULL);
-
if (retro_core_get_game_loaded (self)) {
unload_game = retro_module_get_unload_game (self->module);
unload_game ();
@@ -883,25 +881,7 @@ load_game (RetroCore *self,
load_game = retro_module_get_load_game (self->module);
game_loaded = load_game (game);
set_game_loaded (self, game_loaded);
- get_system_av_info = retro_module_get_get_system_av_info (self->module);
- get_system_av_info (&info);
- retro_core_set_system_av_info (self, &info);
- if (self->renderer)
- retro_renderer_realize (self->renderer, info.geometry.max_width, info.geometry.max_height);
-
- return game_loaded;
-}
-static gboolean
-prepare (RetroCore *self) {
- RetroLoadGame load_game;
- RetroGetSystemAvInfo get_system_av_info;
- gboolean game_loaded;
- RetroSystemAvInfo info = {{ 0 }};
-
- load_game = retro_module_get_load_game (self->module);
- game_loaded = load_game (NULL);
- set_game_loaded (self, game_loaded);
get_system_av_info = retro_module_get_get_system_av_info (self->module);
get_system_av_info (&info);
retro_core_set_system_av_info (self, &info);
@@ -921,7 +901,7 @@ load_medias (RetroCore *self,
length = self->media_uris == NULL ? 0 : g_strv_length (self->media_uris);
if (length == 0) {
- prepare (self);
+ load_game (self, NULL);
return;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]