Unverified Commit 77c9d403 authored by Libretro-Admin's avatar Libretro-Admin Committed by GitHub
Browse files

Revert "Move core-generated files (config + saves) to frontend-defined save directory"

parent 74a986f0
......@@ -1264,7 +1264,6 @@ typedef struct
char com_gamedir[MAX_OSPATH];
char com_basedir[MAX_OSPATH];
char com_savedir[MAX_OSPATH];
typedef struct searchpath_s {
char filename[MAX_OSPATH];
......@@ -1975,9 +1974,6 @@ static void COM_InitFilesystem(void)
searchpath_t *search;
#endif
// Set save directory
strcpy(com_savedir, host_parms.savedir);
// -basedir <path>
// Overrides the system supplied base directory (under id1)
i = COM_CheckParm("-basedir");
......@@ -2006,17 +2002,6 @@ static void COM_InitFilesystem(void)
#ifdef QW_HACK
COM_AddGameDirectory(com_basedir, "qw");
#endif
// Hack: Add save directory to search path, otherwise 'exec config.cfg' will fail
// (NB: 'host_parms.use_exernal_savedir' is a bit of a kludge, but since basedir
// changes depending upon the game being loaded and various flags modify the
// final 'rom' directory, it's the cleanest way to prevent the same directory
// being added to the search list twice...)
if (host_parms.use_exernal_savedir != 0)
{
COM_AddGameDirectory(com_savedir, "");
}
//
// -path <dir or packfile> [<dir or packfile>] ...
// Fully specifies the exact search path, overriding the generated one
......
......@@ -199,7 +199,6 @@ struct cache_user_s;
extern char com_basedir[MAX_OSPATH];
extern char com_gamedir[MAX_OSPATH];
extern char com_savedir[MAX_OSPATH];
extern int file_from_pak; // global indicating that file came from a pak
void COM_WriteFile(const char *filename, const void *data, int len);
......
......@@ -322,7 +322,7 @@ void Con_Printf(const char *fmt, ...)
/* log all messages to file */
if (debuglog)
Sys_DebugLog(va("%s/qconsole.log", com_savedir), "%s", msg);
Sys_DebugLog(va("%s/qconsole.log", com_gamedir), "%s", msg);
if (!con_initialized)
return;
......@@ -381,7 +381,7 @@ Con_DPrintf(const char *fmt, ...)
va_start(argptr, fmt);
vsnprintf(msg + 7, sizeof(msg) - 7, fmt, argptr);
va_end(argptr);
Sys_DebugLog(va("%s/qconsole.log", com_savedir), "%s", msg);
Sys_DebugLog(va("%s/qconsole.log", com_gamedir), "%s", msg);
}
return;
}
......
......@@ -271,7 +271,7 @@ Host_WriteConfiguration(void)
// dedicated servers initialize the host but don't parse and set the
// config.cfg cvars
if (host_initialized & !isDedicated) {
f = fopen(va("%s/config.cfg", com_savedir), "w");
f = fopen(va("%s/config.cfg", com_gamedir), "w");
if (!f) {
Con_Printf("Couldn't write config.cfg.\n");
return;
......
......@@ -498,7 +498,7 @@ void Host_Savegame_f(void)
}
}
sprintf(name, "%s%c%s", com_savedir, slash, Cmd_Argv(1));
sprintf(name, "%s%c%s", com_gamedir, slash, Cmd_Argv(1));
COM_DefaultExtension(name, ".sav");
Con_Printf("Saving game to %s...\n", name);
......@@ -572,7 +572,7 @@ void Host_Loadgame_f(void)
cls.demonum = -1; // stop demo loop in case this fails
sprintf(name, "%s%c%s", com_savedir, slash, Cmd_Argv(1));
sprintf(name, "%s%c%s", com_gamedir, slash, Cmd_Argv(1));
COM_DefaultExtension(name, ".sav");
// we can't call SCR_BeginLoadingPlaque, because too much stack space has
......
......@@ -273,6 +273,11 @@ int Sys_FileTime(const char *path)
return buf.st_mtime;
}
void Sys_mkdir(const char *path)
{
path_mkdir(path);
}
void Sys_DebugLog(const char *file, const char *fmt, ...)
{
}
......@@ -797,18 +802,8 @@ static void extract_directory(char *buf, const char *path, size_t size)
bool retro_load_game(const struct retro_game_info *info)
{
// Define slash character
// (Handle Windows nonsense...)
char slash;
#if defined(_WIN32)
slash = '\\';
#else
slash = '/';
#endif
unsigned i;
char g_rom_dir[1024], g_pak_path[1024], g_save_dir[1024];
char g_rom_dir[1024], g_pak_path[1024];
char cfg_file[1024];
char *path_lower;
quakeparms_t parms;
......@@ -829,42 +824,6 @@ bool retro_load_game(const struct retro_game_info *info)
extract_directory(g_rom_dir, info->path, sizeof(g_rom_dir));
snprintf(g_pak_path, sizeof(g_pak_path), "%s", info->path);
// Get save directory...
bool use_external_savedir = false;
// > Get base path
const char *base_save_dir = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &base_save_dir) && base_save_dir)
{
if (strlen(base_save_dir) > 0)
{
// Get game 'name' (i.e. subdirectory)
char game_name[1024];
extract_basename(game_name, g_rom_dir, sizeof(game_name));
// > Build final save path
snprintf(g_save_dir, sizeof(g_save_dir), "%s%c%s", base_save_dir, slash, game_name);
use_external_savedir = true;
// > Create save directory, if required
if (!path_is_directory(g_save_dir))
{
use_external_savedir = path_mkdir(g_save_dir);
}
}
}
// > Error check
if (!use_external_savedir)
{
// > Use ROM directory fallback...
snprintf(g_save_dir, sizeof(g_save_dir), "%s", g_rom_dir);
}
else
{
// > Final check: is the save directory the same as the 'rom' directory?
// (i.e. ensure logical behaviour if user has set a bizarre save path...)
use_external_savedir = (strcmp(g_save_dir, g_rom_dir) != 0);
}
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
log_cb(RETRO_LOG_INFO, "Rumble environment supported.\n");
......@@ -888,8 +847,6 @@ bool retro_load_game(const struct retro_game_info *info)
parms.argc = 1;
parms.basedir = g_rom_dir;
parms.savedir = g_save_dir;
parms.use_exernal_savedir = use_external_savedir ? 1 : 0;
parms.memsize = MEMSIZE_MB * 1024 * 1024;
argv[0] = empty_string;
......@@ -964,9 +921,9 @@ bool retro_load_game(const struct retro_game_info *info)
/* Override some default binds with more modern ones if we are booting the
* game for the first time. */
snprintf(cfg_file, sizeof(cfg_file), "%s%cconfig.cfg", g_save_dir, slash);
snprintf(cfg_file, sizeof(cfg_file), "%s/config.cfg", g_rom_dir);
if (!path_is_valid(cfg_file))
if (path_is_valid(cfg_file))
{
Cvar_Set("gamma", "0.95");
Cmd_ExecuteString("bind ' \"toggleconsole\"", src_command);
......
......@@ -500,7 +500,7 @@ static void M_ScanSaves(void)
strcpy(m_filenames[i], "--- UNUSED SLOT ---");
loadable[i] = false;
sprintf(name, "%s%cs%i.sav", com_savedir, slash, i);
sprintf(name, "%s%cs%i.sav", com_gamedir, slash, i);
f = fopen(name, "r");
if (!f)
continue;
......
......@@ -204,8 +204,6 @@ typedef struct {
typedef struct {
const char *basedir;
const char *savedir;
unsigned short use_exernal_savedir; // should be a bool, but don't want to mess with the headers...
int argc;
const char **argv;
void *membase;
......
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