ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

stark/detection.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/advancedDetector.h"
00024 #include "engines/stark/savemetadata.h"
00025 #include "engines/stark/stark.h"
00026 #include "engines/stark/services/stateprovider.h"
00027 
00028 #include "common/savefile.h"
00029 #include "common/system.h"
00030 #include "common/translation.h"
00031 
00032 namespace Stark {
00033 
00034 static const PlainGameDescriptor starkGames[] = {
00035     {"stark", "Stark Game"},
00036     {"tlj", "The Longest Journey"},
00037     {nullptr, nullptr}
00038 };
00039 
00040 static const ADGameDescription gameDescriptions[] = {
00041     // The Longest Journey
00042     // English DVD
00043     {
00044         "tlj", "DVD", {
00045             {"x.xarc", 0, "de8327850d7bba90b690b141eaa23f61", 3032},
00046             {"chapters.ini", 0, "5b5a1f1dd2297d9ce0d3d12216d5d2c5", 485},
00047             {nullptr, 0, nullptr, 0}
00048         },
00049         Common::EN_ANY,
00050         Common::kPlatformWindows,
00051         ADGF_UNSTABLE,
00052         GUIO_NONE
00053     },
00054 
00055     // The Longest Journey
00056     // GOG edition
00057     {
00058         "tlj", "GOG", {
00059             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00060             {"chapters.ini", 0, "5b5a1f1dd2297d9ce0d3d12216d5d2c5", 485},
00061             {nullptr, 0, nullptr, 0}
00062         },
00063         Common::EN_ANY,
00064         Common::kPlatformWindows,
00065         ADGF_UNSTABLE,
00066         GUIO_NONE
00067     },
00068 
00069     // The Longest Journey
00070     // English Old Demo
00071     {
00072         "tlj", "Old Demo", {
00073             {"x.xarc", 0, "97abc1bb9239dee4c208e533f3c97e1c", 98},
00074             {"chapters.ini", 0, "5b5a1f1dd2297d9ce0d3d12216d5d2c5", 485},
00075             {nullptr, 0, nullptr, 0}
00076         },
00077         Common::EN_ANY,
00078         Common::kPlatformWindows,
00079         ADGF_DEMO | ADGF_UNSTABLE,
00080         GUIO_NONE
00081     },
00082 
00083     // The Longest Journey
00084     // English v1.61 Demo
00085     {
00086         "tlj", "v1.61 Demo", {
00087             {"x.xarc", 0, "61093bcd499b386ed5c0345c52f48909", 98},
00088             {"chapters.ini", 0, "5b5a1f1dd2297d9ce0d3d12216d5d2c5", 485},
00089             {nullptr, 0, nullptr, 0}
00090         },
00091         Common::EN_ANY,
00092         Common::kPlatformWindows,
00093         ADGF_DEMO | ADGF_UNSTABLE,
00094         GUIO_NONE
00095     },
00096 
00097     // The Longest Journey
00098     // French Demo
00099     {
00100         "tlj", "Demo", {
00101             {"x.xarc", 0, "97abc1bb9239dee4c208e533f3c97e1c", 98},
00102             {"chapters.ini", 0, "e54f6370dca06496069790840409cf95", 506},
00103             {nullptr, 0, nullptr, 0}
00104         },
00105         Common::FR_FRA,
00106         Common::kPlatformWindows,
00107         ADGF_DEMO | ADGF_UNSTABLE,
00108         GUIO_NONE
00109     },
00110 
00111     // The Longest Journey
00112     // Norwegian Demo
00113     {
00114         "tlj", "Demo", {
00115             {"x.xarc", 0, "97abc1bb9239dee4c208e533f3c97e1c", 98},
00116             {"chapters.ini", 0, "f358f604abd1aa1476ed05d6d271ac70", 473},
00117             {nullptr, 0, nullptr, 0}
00118         },
00119         Common::NB_NOR,
00120         Common::kPlatformWindows,
00121         ADGF_DEMO | ADGF_UNSTABLE,
00122         GUIO_NONE
00123     },
00124 
00125     // The Longest Journey
00126     // Norwegian 4 CD version - supplied by L0ngcat
00127     {
00128         "tlj", "4 CD", {
00129             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00130             {"chapters.ini", 0, "f358f604abd1aa1476ed05d6d271ac70", 473},
00131             {nullptr, 0, nullptr, 0}
00132         },
00133         Common::NB_NOR,
00134         Common::kPlatformWindows,
00135         ADGF_UNSTABLE,
00136         GUIO_NONE
00137     },
00138 
00139     // The Longest Journey
00140     // Norwegian DLC-edition (DVD?)
00141     {
00142         "tlj", "DVD", {
00143             {"x.xarc", 0, "de8327850d7bba90b690b141eaa23f61", 3032},
00144             {"chapters.ini", 0, "f358f604abd1aa1476ed05d6d271ac70", 473},
00145             {nullptr, 0, nullptr, 0}
00146         },
00147         Common::NB_NOR,
00148         Common::kPlatformWindows,
00149         ADGF_UNSTABLE,
00150         GUIO_NONE
00151     },
00152 
00153     // The Longest Journey
00154     // German DVD version supplied by Vorph on the forums
00155     {
00156         "tlj", "DVD", {
00157             {"x.xarc", 0, "de8327850d7bba90b690b141eaa23f61", 3032},
00158             {"chapters.ini", 0, "e4611d143a87b263d8d7a54edc7e7cd7", 515},
00159             {nullptr, 0, nullptr, 0}
00160         },
00161         Common::DE_DEU,
00162         Common::kPlatformWindows,
00163         ADGF_UNSTABLE,
00164         GUIO_NONE
00165     },
00166 
00167     // The Longest Journey
00168     // German 4CD
00169     {
00170         "tlj", "4 CD", {
00171             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00172             {"chapters.ini", 0, "e4611d143a87b263d8d7a54edc7e7cd7", 515},
00173             {nullptr, 0, nullptr, 0}
00174         },
00175         Common::DE_DEU,
00176         Common::kPlatformWindows,
00177         ADGF_UNSTABLE,
00178         GUIO_NONE
00179     },
00180 
00181     // The Longest Journey
00182     // Dutch 4CD
00183     {
00184         "tlj", "4 CD", {
00185             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00186             {"chapters.ini", 0, "c8dadd9a3b41640734d6213e89cd5635", 508},
00187             {nullptr, 0, nullptr, 0}
00188         },
00189         Common::NL_NLD,
00190         Common::kPlatformWindows,
00191         ADGF_UNSTABLE,
00192         GUIO_NONE
00193     },
00194 
00195     // The Longest Journey
00196     // Spanish 4CD
00197     {
00198         "tlj", "4 CD", {
00199             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00200             {"chapters.ini", 0, "3640df6d536b186bff228337284d9631", 525},
00201             {nullptr, 0, nullptr, 0}
00202         },
00203         Common::ES_ESP,
00204         Common::kPlatformWindows,
00205         ADGF_UNSTABLE,
00206         GUIO_NONE
00207     },
00208 
00209     // The Longest Journey
00210     // French 2CD
00211     {
00212         "tlj", "2 CD", {
00213             {"x.xarc", 0, "de8327850d7bba90b690b141eaa23f61", 3032},
00214             {"chapters.ini", 0, "e54f6370dca06496069790840409cf95", 506},
00215             {nullptr, 0, nullptr, 0}
00216         },
00217         Common::FR_FRA,
00218         Common::kPlatformWindows,
00219         ADGF_UNSTABLE,
00220         GUIO_NONE
00221     },
00222 
00223     // The Longest Journey
00224     // French 4CD
00225     {
00226         "tlj", "4 CD", {
00227             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00228             {"chapters.ini", 0, "e54f6370dca06496069790840409cf95", 506},
00229             {nullptr, 0, nullptr, 0}
00230         },
00231         Common::FR_FRA,
00232         Common::kPlatformWindows,
00233         ADGF_UNSTABLE,
00234         GUIO_NONE
00235     },
00236 
00237     // The Longest Journey
00238     // Swedish Demo
00239     {
00240         "tlj", "Demo", {
00241             {"x.xarc", 0, "97abc1bb9239dee4c208e533f3c97e1c", 98},
00242             {"chapters.ini", 0, "f6a2007300209492b7b90b4c0467832d", 462},
00243             {nullptr, 0, nullptr, 0}
00244         },
00245         Common::SE_SWE,
00246         Common::kPlatformWindows,
00247         ADGF_DEMO | ADGF_UNSTABLE,
00248         GUIO_NONE
00249     },
00250 
00251     // The Longest Journey
00252     // Swedish 4CD
00253     {
00254         "tlj", "4 CD", {
00255             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00256             {"chapters.ini", 0, "f6a2007300209492b7b90b4c0467832d", 462},
00257             {nullptr, 0, nullptr, 0}
00258         },
00259         Common::SE_SWE,
00260         Common::kPlatformWindows,
00261         ADGF_UNSTABLE,
00262         GUIO_NONE
00263     },
00264 
00265     // The Longest Journey
00266     // Swedish DVD Nordic Special Edition - supplied by L0ngcat
00267     {
00268         "tlj", "DVD", {
00269             {"x.xarc", 0, "de8327850d7bba90b690b141eaa23f61", 3032},
00270             {"chapters.ini", 0, "f6a2007300209492b7b90b4c0467832d", 462},
00271             {nullptr, 0, nullptr, 0}
00272         },
00273         Common::SE_SWE,
00274         Common::kPlatformWindows,
00275         ADGF_UNSTABLE,
00276         GUIO_NONE
00277     },
00278 
00279     // The Longest Journey
00280     // Polish 4CD
00281     {
00282         "tlj", "4 CD", {
00283             {"x.xarc", 0, "a0559457126caadab0cadac02d35f26f", 3032},
00284             {"chapters.ini", 0, "6abc5c38e6e31face4b675355b117620", 499},
00285             {nullptr, 0, nullptr, 0}
00286         },
00287         Common::PL_POL,
00288         Common::kPlatformWindows,
00289         ADGF_UNSTABLE,
00290         GUIO_NONE
00291     },
00292 
00293     // The Longest Journey
00294     // Russian 2CD by 1C
00295     {
00296         "tlj", "2 CD", {
00297             {"x.xarc", 0, "de8327850d7bba90b690b141eaa23f61", 3032},
00298             {"chapters.ini", 0, "740b97b94e97ed11f064f5fa125ebee1", 486},
00299             {nullptr, 0, nullptr, 0}
00300         },
00301         Common::RU_RUS,
00302         Common::kPlatformWindows,
00303         ADGF_UNSTABLE,
00304         GUIO_NONE
00305     },
00306 
00307     AD_TABLE_END_MARKER
00308 };
00309 
00310 #define GAMEOPTION_ASSETS_MOD       GUIO_GAMEOPTIONS1
00311 #define GAMEOPTION_LINEAR_FILTERING GUIO_GAMEOPTIONS2
00312 
00313 static const ADExtraGuiOptionsMap optionsList[] = {
00314     {
00315         GAMEOPTION_ASSETS_MOD,
00316         {
00317             _s("Load modded assets"),
00318             _s("Enable loading of external replacement assets."),
00319             "enable_assets_mod",
00320             true
00321         }
00322     },
00323     {
00324         GAMEOPTION_LINEAR_FILTERING,
00325         {
00326             _s("Enable linear filtering of the backgrounds images"),
00327             _s("When linear filtering is enabled the background graphics are smoother in full screen mode, at the cost of some details."),
00328             "use_linear_filtering",
00329             true
00330         }
00331     },
00332 
00333     AD_EXTRA_GUI_OPTIONS_TERMINATOR
00334 };
00335 
00336 class StarkMetaEngine : public AdvancedMetaEngine {
00337 public:
00338     StarkMetaEngine() : AdvancedMetaEngine(gameDescriptions, sizeof(ADGameDescription), starkGames, optionsList) {
00339         _singleId = "stark";
00340         _guiOptions = GUIO3(GUIO_NOMIDI, GAMEOPTION_ASSETS_MOD, GAMEOPTION_LINEAR_FILTERING);
00341     }
00342 
00343     const char *getName() const override {
00344         return "Stark Engine";
00345     }
00346 
00347     const char *getOriginalCopyright() const override {
00348         return "(C) Funcom";
00349     }
00350 
00351     bool hasFeature(MetaEngineFeature f) const override {
00352         return
00353             (f == kSupportsListSaves) ||
00354             (f == kSupportsLoadingDuringStartup) ||
00355             (f == kSupportsDeleteSave) ||
00356             (f == kSavesSupportThumbnail) ||
00357             (f == kSavesSupportMetaInfo) ||
00358             (f == kSavesSupportPlayTime) ||
00359             (f == kSavesSupportCreationDate);
00360     }
00361 
00362     int getMaximumSaveSlot() const override {
00363         return 999;
00364     }
00365 
00366     SaveStateList listSaves(const char *target) const override {
00367         Common::String pattern = Common::String::format("%s-###.tlj", target);
00368         Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles(pattern);
00369 
00370         int targetLen = strlen(target);
00371 
00372         SaveStateList saveList;
00373         for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
00374             // Extract the slot number from the filename
00375             char slot[4];
00376             slot[0] = (*filename)[targetLen + 1];
00377             slot[1] = (*filename)[targetLen + 2];
00378             slot[2] = (*filename)[targetLen + 3];
00379             slot[3] = '\0';
00380 
00381             // Read the description from the save
00382             Common::String description;
00383             Common::InSaveFile *save = g_system->getSavefileManager()->openForLoading(*filename);
00384             if (save) {
00385                 StateReadStream stream(save);
00386                 description = stream.readString();
00387             }
00388 
00389             saveList.push_back(SaveStateDescriptor(atoi(slot), description));
00390         }
00391 
00392         Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
00393         return saveList;
00394     }
00395 
00396     SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override {
00397         SaveStateDescriptor descriptor;
00398         if (slot == 0) {
00399             descriptor.setWriteProtectedFlag(true);
00400             descriptor.setDeletableFlag(false);
00401         }
00402 
00403         Common::String filename = StarkEngine::formatSaveName(target, slot);
00404         Common::InSaveFile *save = g_system->getSavefileManager()->openForLoading(filename);
00405         if (!save) {
00406             return descriptor;
00407         }
00408 
00409         SaveMetadata metadata;
00410         Common::ErrorCode readError = metadata.read(save, filename);
00411         if (readError != Common::kNoError) {
00412             delete save;
00413             return descriptor;
00414         }
00415 
00416         descriptor.setDescription(metadata.description);
00417 
00418         if (metadata.version >= 9) {
00419             Graphics::Surface *thumb = metadata.readGameScreenThumbnail(save);
00420             descriptor.setThumbnail(thumb);
00421             descriptor.setPlayTime(metadata.totalPlayTime);
00422             descriptor.setSaveDate(metadata.saveYear, metadata.saveMonth, metadata.saveDay);
00423             descriptor.setSaveTime(metadata.saveHour, metadata.saveMinute);
00424         }
00425 
00426         delete save;
00427 
00428         return descriptor;
00429     }
00430 
00431     void removeSaveState(const char *target, int slot) const override {
00432         Common::String filename = StarkEngine::formatSaveName(target, slot);
00433         g_system->getSavefileManager()->removeSavefile(filename);
00434     }
00435 
00436     bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const override {
00437         if (desc)
00438             *engine = new StarkEngine(syst, desc);
00439 
00440         return desc != nullptr;
00441     }
00442 };
00443 
00444 } // End of namespace Stark
00445 
00446 #if PLUGIN_ENABLED_DYNAMIC(STARK)
00447     REGISTER_PLUGIN_DYNAMIC(STARK, PLUGIN_TYPE_ENGINE, Stark::StarkMetaEngine);
00448 #else
00449     REGISTER_PLUGIN_STATIC(STARK, PLUGIN_TYPE_ENGINE, Stark::StarkMetaEngine);
00450 #endif


Generated on Sat Feb 16 2019 05:00:49 for ResidualVM by doxygen 1.7.1
curved edge   curved edge