From: Toni Wilen Date: Sun, 8 Apr 2018 10:42:29 +0000 (+0300) Subject: Restore disk swapper paths from statefile. X-Git-Tag: 4000~132 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=2bb0818111290798cda1dd5f7b8f234ebe838b23;p=francis%2Fwinuae.git Restore disk swapper paths from statefile. --- diff --git a/cfgfile.cpp b/cfgfile.cpp index 138f8058..d7995e4e 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -7141,11 +7141,36 @@ uae_u32 cfgfile_uaelib(TrapContext *ctx, int mode, uae_u32 name, uae_u32 dst, ua uae_u8 *restore_configuration (uae_u8 *src) { - TCHAR *s = au ((char*)src); - //write_log (s); - xfree (s); - src += strlen ((char*)src) + 1; - return src; + struct uae_prefs *p = &currprefs; + TCHAR *sp = au ((char*)src); + TCHAR *s = sp; + for (;;) { + TCHAR option[MAX_DPATH]; + TCHAR value[MAX_DPATH]; + TCHAR tmp[MAX_DPATH]; + + TCHAR *ss = s; + while (*s && *s != 10 && *s != 13) + s++; + if (*s == 0) { + xfree(sp); + return src += strlen((char*)src) + 1; + } + *s++ = 0; + while (*s == 10 || *s == 13) + s++; + if (cfgfile_separate_line(ss, option, value)) { + if (!_tcsncmp(option, _T("diskimage"), 9)) { + for (int i = 0; i < MAX_SPARE_DRIVES; i++) { + _stprintf(tmp, _T("diskimage%d"), i); + if (!_tcscmp(option, tmp)) { + cfgfile_path(option, value, tmp, p->dfxlist[i], sizeof p->dfxlist[i] / sizeof(TCHAR), &p->path_floppy); + break; + } + } + } + } + } } uae_u8 *save_configuration (int *len, bool fullconfig) diff --git a/savestate.cpp b/savestate.cpp index f9cf1ec5..94aec00b 100644 --- a/savestate.cpp +++ b/savestate.cpp @@ -514,6 +514,7 @@ void restore_state (const TCHAR *filename) unsigned int len, totallen; size_t filepos, filesize; int z3num, z2num; + bool end_found = false; chunk = 0; f = zfile_fopen (filename, _T("rb"), ZFD_NORMAL); @@ -542,11 +543,10 @@ void restore_state (const TCHAR *filename) chunk = end = restore_chunk (f, name, &len, &totallen, &filepos); write_log (_T("Chunk '%s' size %u (%u)\n"), name, len, totallen); if (!_tcscmp (name, _T("END "))) { -#ifdef _DEBUG - if (filesize > filepos + 8) - continue; -#endif - break; + if (end_found) + break; + end_found = true; + continue; } if (!_tcscmp (name, _T("CRAM"))) { restore_cram (totallen, filepos);