Commit 889f2115 authored by Libretro-Admin's avatar Libretro-Admin
Browse files

Cleanups

parent 42057b73
......@@ -2035,9 +2035,7 @@ void retro_init(void)
else
log_cb = fallback_log;
#ifdef NEED_CD
CDUtility_Init();
#endif
eject_state = false;
......@@ -2223,12 +2221,10 @@ end:
fclose(fp);
}
#ifdef NEED_CD
static std::vector<CDIF *> CDInterfaces; // FIXME: Cleanup on error out.
#endif
// TODO: LoadCommon()
static MDFNGI *MDFNI_LoadCD(const char *force_module, const char *devicename)
static MDFNGI *MDFNI_LoadCD(const char *devicename)
{
uint8 LayoutMD5[16];
......@@ -2314,13 +2310,8 @@ static MDFNGI *MDFNI_LoadCD(const char *force_module, const char *devicename)
if(!(LoadCD(&CDInterfaces)))
{
for(unsigned i = 0; i < CDInterfaces.size(); i++)
delete CDInterfaces[i];
CDInterfaces.clear();
Cleanup();
MDFNGameInfo = NULL;
return(0);
return NULL;
}
//MDFNI_SetLayerEnableMask(~0ULL);
......@@ -2332,14 +2323,17 @@ static MDFNGI *MDFNI_LoadCD(const char *force_module, const char *devicename)
}
#endif
static MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
static MDFNGI *MDFNI_LoadGame(const char *name)
{
MDFNFILE *GameFile;
MDFNFILE *GameFile = NULL;
#ifdef NEED_CD
if(strlen(name) > 4 && (!strcasecmp(name + strlen(name) - 4, ".cue") || !strcasecmp(name + strlen(name) - 4, ".ccd") || !strcasecmp(name + strlen(name) - 4, ".toc") || !strcasecmp(name + strlen(name) - 4, ".m3u") || !strcasecmp(name + strlen(name) - 4, ".pbp")))
return MDFNI_LoadCD(force_module, name);
#endif
{
MDFNGI *gi = MDFNI_LoadCD(name);
if (!gi)
goto error;
return gi;
}
GameFile = file_open(name);
......@@ -2355,6 +2349,9 @@ static MDFNGI *MDFNI_LoadGame(const char *force_module, const char *name)
return(MDFNGameInfo);
error:
for(unsigned i = 0; i < CDInterfaces.size(); i++)
delete CDInterfaces[i];
CDInterfaces.clear();
if (GameFile)
file_close(GameFile);
GameFile = NULL;
......@@ -2535,7 +2532,7 @@ bool retro_load_game(const struct retro_game_info *info)
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble) && log_cb)
log_cb(RETRO_LOG_INFO, "Rumble interface supported!\n");
if (!MDFNI_LoadGame(MEDNAFEN_CORE_NAME_MODULE, retro_cd_path))
if (!MDFNI_LoadGame(retro_cd_path))
{
failed_init = true;
return false;
......@@ -2583,11 +2580,9 @@ void retro_unload_game(void)
MDFNGameInfo = NULL;
#ifdef NEED_CD
for(unsigned i = 0; i < CDInterfaces.size(); i++)
delete CDInterfaces[i];
CDInterfaces.clear();
#endif
retro_cd_base_directory[0] = '\0';
retro_cd_path[0] = '\0';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment