From b12c26e746a18e9510ee27d848575767b2118c7b Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 16 Mar 2024 12:21:10 +0200 Subject: [PATCH] Default statefile name = config file name --- cfgfile.cpp | 2 ++ include/uae.h | 1 + od-win32/win32.cpp | 17 +++++++++++++++++ od-win32/win32gui.cpp | 4 +++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/cfgfile.cpp b/cfgfile.cpp index 315c6471..ae26dbaa 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -7201,6 +7201,7 @@ int cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int *type, int ign fetch_configurationpath(tmp, sizeof(tmp) / sizeof(TCHAR)); _tcsncat(tmp, p->config_all_path, sizeof(tmp) / sizeof(TCHAR) - _tcslen(tmp) - 1); type2 = CONFIG_TYPE_HOST | CONFIG_TYPE_HARDWARE; + target_setdefaultstatefilename(filename); cfgfile_load(p, tmp, &type2, 1, 0); } if (p->config_hardware_path[0]) { @@ -7213,6 +7214,7 @@ int cfgfile_load (struct uae_prefs *p, const TCHAR *filename, int *type, int ign fetch_configurationpath (tmp, sizeof (tmp) / sizeof (TCHAR)); _tcsncat (tmp, p->config_host_path, sizeof (tmp) / sizeof (TCHAR) - _tcslen(tmp) - 1); type2 = CONFIG_TYPE_HOST; + target_setdefaultstatefilename(filename); cfgfile_load (p, tmp, &type2, 1, 0); } } diff --git a/include/uae.h b/include/uae.h index 3d5be5f4..2f0a9184 100644 --- a/include/uae.h +++ b/include/uae.h @@ -38,6 +38,7 @@ extern void target_restart (void); extern void target_getdate(int *y, int *m, int *d); extern void target_cpu_speed(void); extern int target_sleep_nanos(int); +void target_setdefaultstatefilename(const TCHAR*); extern bool get_plugin_path (TCHAR *out, int size, const TCHAR *path); extern void stripslashes (TCHAR *p); extern void fixtrailing (TCHAR *p); diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 8b66890d..de3cbe4b 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -5981,6 +5981,23 @@ static void WIN32_HandleRegistryStuff (void) target_load_debugger_config(); } +void target_setdefaultstatefilename(const TCHAR *name) +{ + TCHAR path[MAX_DPATH]; + fetch_path(_T("StatefilePath"), path, sizeof(path) / sizeof(TCHAR)); + if (!name || !name[0]) { + _tcscat(path, _T("default.uss")); + } else { + _tcscat(path, name); + const TCHAR *p = _tcsrchr(name, '.'); + if (p) { + path[_tcslen(path) - ((name + _tcslen(name)) - p)] = 0; + _tcscat(path, _T(".uss")); + } + } + _tcscpy(savestate_fname, path); +} + #if WINUAEPUBLICBETA > 0 static const TCHAR *BETAMESSAGE = { _T("This is unstable beta software. Click cancel if you are not comfortable using software that is incomplete and can have serious programming errors.") diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 5e7084c2..d6d45a43 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -4247,6 +4247,7 @@ static TCHAR *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *con WIN32GUI_LoadUIString (IDS_MUSTSELECTCONFIG, szMessage, MAX_DPATH); pre_gui_message (szMessage); } else { + target_setdefaultstatefilename(config_filename); if (target_cfgfile_load (&workprefs, path, configtypepanel, 0) == 0) { TCHAR szMessage[MAX_DPATH]; WIN32GUI_LoadUIString (IDS_COULDNOTLOADCONFIG, szMessage, MAX_DPATH); @@ -4335,7 +4336,7 @@ static TCHAR *HandleConfiguration (HWND hDlg, int flag, struct ConfigStruct *con break; } - setguititle (NULL); + setguititle(NULL); return ok ? full_path : NULL; } @@ -7356,6 +7357,7 @@ static void load_quickstart (HWND hDlg, int romcheck) addfloppyhistory (hDlg); config_filename[0] = 0; setguititle (NULL); + target_setdefaultstatefilename(config_filename); } static void quickstarthost (HWND hDlg, TCHAR *name) -- 2.47.3