]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Support broken cue files with "TRACK 0" instead of "TRACK 01".
authorToni Wilen <twilen@winuae.net>
Sat, 23 Aug 2025 17:45:31 +0000 (20:45 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 23 Aug 2025 17:45:31 +0000 (20:45 +0300)
blkdev_cdimage.cpp

index 9facba504846307c2344d606915c16ff28ec513b..76aa985a3f66bd4f9d7618ced47e0eb5ae87ae94 100644 (file)
@@ -1738,7 +1738,13 @@ static int parsecue (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img, c
                        index0 = -1;
                        lastpregap = 0;
                        lastpostgap = 0;
+                       skipspace(&p);
+                       TCHAR *pt = p;
                        tracknum = _tstoi (nextstring (&p));
+                       // fix broken "TRACK 0"
+                       if (tracknum == 0 && pt[0] == '0' && pt[1] == 0 && cdu->tracks == 0) {
+                               tracknum = 1;
+                       }
                        tracktype = nextstring (&p);
                        if (!tracktype)
                                break;
@@ -1765,7 +1771,9 @@ static int parsecue (struct cdunit *cdu, struct zfile *zcue, const TCHAR *img, c
 
                                if (tracknum > 1 && newfile) {
                                        t--;
-                                       secoffset += (int)(t->filesize / t->size);
+                                       if (t->size) {
+                                               secoffset += (int)(t->filesize / t->size);
+                                       }
                                        t++;
                                }