Ticket #9149: autodetect_diskimg.patch

File autodetect_diskimg.patch, 8.9 KB (added by SF/tobigun, 14 years ago)
  • detection.cpp

     
    3838#include "scumm/he/intern_he.h"
    3939#include "scumm/scumm_v0.h"
    4040#include "scumm/scumm_v8.h"
     41#include "scumm/file.h"
    4142
    4243#include "engines/metaengine.h"
    4344
     
    209210        return false;
    210211}
    211212
     213static ScummDiskImage *openDiskImage(const Common::FSNode &node, const GameFilenamePattern *gfp) {
     214        Common::String disk1 = node.getName();
     215
     216        // setup necessary game settings for disk image reader
     217        GameSettings gs;
     218        memset(&gs, 0, sizeof(GameSettings));
     219        gs.gameid = gfp->gameid;
     220        gs.id = (Common::String(gfp->gameid) == "maniac" ? GID_MANIAC : GID_ZAK);
     221        gs.platform = gfp->platform;
     222
     223        // determine second disk file name
     224        Common::String disk2(disk1);
     225        for (Common::String::iterator it = disk2.begin(); it != disk2.end(); ++it) {
     226                // replace "xyz1.(d64|dsk)" by "xyz2.(d64|dsk)"
     227                if (*it == '1') {
     228                        *it = '2';
     229                        break;
     230                }
     231        }
     232
     233        // open image
     234        SearchMan.addDirectory("tmpDiskImgDir", node.getParent());
     235        ScummDiskImage *diskImg = new ScummDiskImage(disk1.c_str(), disk2.c_str(), gs);
     236        if (diskImg->open(disk1.c_str()) && diskImg->openSubFile("00.LFL")) {
     237                return diskImg;
     238        }
     239        delete diskImg;
     240        return 0;
     241}
     242
     243static void closeDiskImage(ScummDiskImage *img) {
     244        if (img)
     245                img->close();
     246        SearchMan.remove("tmpDiskImgDir");
     247}
     248
    212249// The following function tries to detect the language for COMI and DIG
    213250static Common::Language detectLanguage(const Common::FSList &fslist, byte id) {
    214251        // First try to detect Chinese translation
     
    389426                //
    390427                DetectorDesc &d = fileMD5Map[file];
    391428                if (d.md5.empty()) {
    392                         Common::File tmp;
    393                         if (tmp.open(d.node) && Common::md5_file_string(tmp, md5str, kMD5FileSizeLimit)) {
     429                        Common::File *tmp = 0;
     430                        bool isDiskImg = (file.hasSuffix(".d64") || file.hasSuffix(".dsk"));
     431                       
     432                        if (isDiskImg) {
     433                                tmp = openDiskImage(d.node, gfp);
     434                        } else {
     435                                tmp = new Common::File;
     436                                tmp->open(d.node);
     437                        }
    394438
     439                        if (tmp && tmp->isOpen() && Common::md5_file_string(*tmp, md5str, kMD5FileSizeLimit)) {
     440
    395441                                d.md5 = md5str;
    396442                                d.md5Entry = findInMD5Table(md5str);
    397443
     
    409455                                        results.push_back(dr);
    410456                                }
    411457                        }
     458
     459                        if (isDiskImg)
     460                                closeDiskImage((ScummDiskImage*)tmp);
     461                        delete tmp;
    412462                }
    413463
    414464                // If an exact match for this file has already been found, don't bother
  • detection_tables.h

     
    426426        { "maniac", "Maniac Mansion (Sp).prg", kGenUnchanged, Common::ES_ESP, Common::kPlatformNES, "NES" },
    427427
    428428        { "zak", "%02d.LFL", kGenRoomNum, UNK_LANG, UNK, 0 },
    429         { "zak", "zak1.d64", kGenUnchanged, UNK_LANG, Common::kPlatformC64, 0 },         // ... and zak2.d64
     429        { "zak", "zak1.d64", kGenUnchanged, UNK_LANG, Common::kPlatformC64, "V1" },         // ... and zak2.d64
    430430
    431431        { "indy3", "%02d.LFL", kGenRoomNum, UNK_LANG, UNK, 0 },
    432432
  • scumm-md5.h

     
    181181        { "41958e24d03181ff9a381a66d048a581", "ft", "", "", -1, Common::PT_BRA, Common::kPlatformUnknown },
    182182        { "425205754fa749f4f0b0dd9d09fa45fd", "football", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
    183183        { "430bc518017b6fac046f58bab6baad5d", "monkey2", "", "", -1, Common::JA_JPN, Common::kPlatformFMTowns },
     184        { "439a7f4adf510489981ac52308e7d7a2", "maniac", "C64", "", -1, Common::DE_DEU, Common::kPlatformC64 },
    184185        { "45082a5c9f42ba14dacfe1fdeeba819d", "freddicove", "HE 100", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
    185186        { "45152f7cf2ba8f43cf8a8ea2e740ae09", "monkey", "VGA", "VGA", 8357, Common::ES_ESP, Common::kPlatformPC },
    186187        { "4521138d15d1fd7649c31fb981746231", "pajama2", "HE 98.5", "Demo", -1, Common::DE_DEU, Common::kPlatformUnknown },
     
    190191        { "47e75b1bdcb44c78cb94883d1731ccf8", "fbear", "HE 61", "Demo", 6203, Common::EN_ANY, Common::kPlatformPC },
    191192        { "48b9f04b348bc5013327753f0d12a144", "loom", "EGA", "EGA", -1, Common::ES_ESP, Common::kPlatformAmiga },
    192193        { "49210e124e4c2b30f1290a9ef6306301", "monkey", "EGA", "EGA", 8357, Common::EN_ANY, Common::kPlatformPC },
    193         { "4973bbc3899e3826dbf316e1d7271ec7", "zak", "V1", "", 196608, Common::DE_DEU, Common::kPlatformC64 },
    194194        { "499c958affc394f2a3868f1eb568c3ee", "freddi4", "HE 99", "Demo", -1, Common::NL_NLD, Common::kPlatformWindows },
    195195        { "49a1739981a89066b1121fac04b710f4", "spyfox2", "HE CUP", "Preview", 5756234, Common::UNK_LANG, Common::kPlatformUnknown },
    196196        { "4aa93cb30e485b728504ba3a693f12bf", "pajama", "HE 100", "", -1, Common::RU_RUS, Common::kPlatformWindows },
     
    227227        { "54a68a5f5e3c86da42b7ca5f51e79b1d", "maniac", "NES", "", 262144, Common::IT_ITA, Common::kPlatformNES },
    228228        { "54a936ad06161ff7bfefcb96200f7bff", "monkey", "VGA", "VGA Demo", -1, Common::EN_ANY, Common::kPlatformAmiga },
    229229        { "55518cd73cf9c6d23ea29c51ee06bdfe", "ft", "", "", -1, Common::IT_ITA, Common::kPlatformUnknown },
    230         { "55d3987641bf229c83bc729210173383", "zak", "V1", "", 174848, Common::EN_ANY, Common::kPlatformC64 },
     230        //{ "55d3987641bf229c83bc729210173383", "zak", "V1", "", 174848, Common::EN_ANY, Common::kPlatformC64 },
    231231        { "55e4cc866ff9046824e1c638ba2b8c7f", "ft", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown },
    232232        { "55f4e9402bec2bded383843123f37c5c", "pajama2", "HE 98.5", "", -1, Common::DE_DEU, Common::kPlatformWindows },
    233233        { "566165a7338fa11029e7c14d94fa70d0", "freddi", "HE 73", "Demo", 9800, Common::EN_ANY, Common::kPlatformWindows },
     
    329329        { "78c07ca088526d8d4446a4c2cb501203", "freddi3", "HE 99", "", -1, Common::FR_FRA, Common::kPlatformUnknown },
    330330        { "7974365d3dc0f43a2748c975f91ff042", "monkey2", "", "", -1, Common::ES_ESP, Common::kPlatformPC },
    331331        { "79b05f628586837e7166e82b2279bb50", "loom", "PC-Engine", "", -1, Common::JA_JPN, Common::kPlatformPCEngine },
    332         { "7b60620558b8d6b7d7313b8ac7bb5a98", "zak", "V1", "", 174848, Common::IT_ITA, Common::kPlatformC64 },
     332        //{ "7b60620558b8d6b7d7313b8ac7bb5a98", "zak", "V1", "", 174848, Common::IT_ITA, Common::kPlatformC64 },
    333333        { "7bad72e332a59f9fcc1d437f4edad32a", "puttcircus", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown },
    334334        { "7c2e76087027eeee9c8f8985f93a1cc5", "freddi4", "", "Demo", 13584, Common::EN_ANY, Common::kPlatformUnknown },
    335335        { "7c8100e360e8ef05f88069d4cfa0afd1", "puttrace", "HE 99", "Demo", 13108, Common::EN_GRB, Common::kPlatformWindows },
     
    393393        { "94db6519da85b8d08c976d8e9a858ea7", "baseball", "HE CUP", "Preview", 10044774, Common::UNK_LANG, Common::kPlatformUnknown },
    394394        { "95818b178d473c989ac753574e8892aa", "readtime", "", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
    395395        { "95b3806e043be08668c54c3ffe98650f", "BluesABCTime", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
     396        { "95be99181bd0f10fef4872c2d4a771cb", "zak", "V1", "", -1, Common::DE_DEU, Common::kPlatformC64 },
    396397        { "96a3069a3c63caa7329588ce1fef41ee", "spyozon", "", "", -1, Common::RU_RUS, Common::kPlatformUnknown },
    397398        { "9708cf716ed8bcc9ff3fcfc69413b746", "puttputt", "HE 61", "", -1, Common::EN_ANY, Common::kPlatformPC },
    398399        { "9781422e4288dbc090720e4563168ba7", "puttzoo", "", "", -1, Common::FR_FRA, Common::kPlatformWindows },
     
    487488        { "c3b22fa4654bb580b20325ebf4174841", "puttzoo", "", "", -1, Common::NL_NLD, Common::kPlatformWindows },
    488489        { "c3df37df9d3b481b45f75283a9907c47", "loom", "EGA", "EGA", -1, Common::IT_ITA, Common::kPlatformPC },
    489490        { "c4787c3e8b5e2dfda90850ee800af00f", "zak", "V2", "V2", -1, Common::FR_FRA, Common::kPlatformPC },
    490         { "c4a7f7398ac9ae588940f9912ea5fd8f", "maniac", "C64", "", -1, Common::DE_DEU, Common::kPlatformC64 },
    491491        { "c4ffae9fac495475d6bc3343ccc8faf9", "Soccer2004", "", "", -1, Common::EN_ANY, Common::kPlatformUnknown },
    492492        { "c5cc7cba02a2fbd539c4439e775b0536", "puttzoo", "HE 99", "Updated", 43470, Common::DE_DEU, Common::kPlatformWindows },
    493493        { "c5d10e190d4b4d59114b824f2fdbd00e", "loom", "FM-TOWNS", "", -1, Common::EN_ANY, Common::kPlatformFMTowns },
     
    544544        { "d74122362a77ec24525fdd50297dfd82", "freddi4", "", "", -1, Common::FR_FRA, Common::kPlatformMacintosh },
    545545        { "d7ab7cd6105546016e6a0d46fb36b964", "pajama", "HE 100", "Demo", -1, Common::EN_ANY, Common::kPlatformUnknown },
    546546        { "d7b247c26bf1f01f8f7daf142be84de3", "balloon", "HE 99", "Updated", -1, Common::EN_ANY, Common::kPlatformWindows },
    547         { "d831f7c048574dd9d5d85db2a1468099", "maniac", "C64", "", -1, Common::EN_ANY, Common::kPlatformC64 },
     547        //{ "d831f7c048574dd9d5d85db2a1468099", "maniac", "C64", "", -1, Common::EN_ANY, Common::kPlatformC64 },
    548548        { "d8323015ecb8b10bf53474f6e6b0ae33", "dig", "", "", 16304, Common::UNK_LANG, Common::kPlatformUnknown },
    549549        { "d8d07efcb88f396bee0b402b10c3b1c9", "maniac", "NES", "", 262144, Common::EN_GRB, Common::kPlatformNES },
    550550        { "d917f311a448e3cc7239c31bddb00dd2", "samnmax", "", "CD", 9080, Common::EN_ANY, Common::kPlatformUnknown },