]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Restore disk swapper paths from statefile.
authorToni Wilen <twilen@winuae.net>
Sun, 8 Apr 2018 10:42:29 +0000 (13:42 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 8 Apr 2018 10:42:29 +0000 (13:42 +0300)
cfgfile.cpp
savestate.cpp

index 138f805836d94218130490a074f1c615f97d9757..d7995e4e1611027595c27dacd700dfcfd1c267cf 100644 (file)
@@ -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)
index f9cf1ec539a5c80b8e5d6ae3e86eddb7c458e98e..94aec00bb60475adf5b91419d3413a1d15f65fa6 100644 (file)
@@ -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);