2008-11-10 20:38:54 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2014-02-18 01:34:26 +00:00
|
|
|
*
|
2008-11-10 20:38:54 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2014-02-18 01:34:26 +00:00
|
|
|
*
|
2008-11-10 20:38:54 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
2009-01-29 22:13:01 +00:00
|
|
|
#include "engines/advancedDetector.h"
|
2008-11-10 20:38:54 +00:00
|
|
|
#include "common/savefile.h"
|
|
|
|
#include "common/system.h"
|
2008-12-03 22:15:05 +00:00
|
|
|
#include "common/fs.h"
|
2008-11-10 20:38:54 +00:00
|
|
|
#include "base/plugins.h"
|
2018-03-01 19:15:47 +00:00
|
|
|
#include "graphics/thumbnail.h"
|
2008-11-10 20:38:54 +00:00
|
|
|
|
|
|
|
#include "tucker/tucker.h"
|
|
|
|
|
|
|
|
static const PlainGameDescriptor tuckerGames[] = {
|
|
|
|
{ "tucker", "Bud Tucker in Double Trouble" },
|
2018-07-04 09:45:34 +00:00
|
|
|
{ nullptr, nullptr }
|
2008-11-10 20:38:54 +00:00
|
|
|
};
|
|
|
|
|
2009-01-29 22:13:01 +00:00
|
|
|
static const ADGameDescription tuckerGameDescriptions[] = {
|
2008-11-10 20:38:54 +00:00
|
|
|
{
|
|
|
|
"tucker",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1s("infobar.txt", "f1e42a95972643462b9c3c2ea79d6683", 543),
|
|
|
|
Common::FR_FRA,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2009-06-06 17:56:41 +00:00
|
|
|
Tucker::kGameFlagNoSubtitles,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2008-11-10 20:38:54 +00:00
|
|
|
},
|
2008-11-10 22:08:52 +00:00
|
|
|
{
|
|
|
|
"tucker",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1s("infobar.txt", "9c1ddeafc5283b90d1a284bd0924831c", 462),
|
|
|
|
Common::EN_ANY,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2009-06-06 17:56:41 +00:00
|
|
|
Tucker::kGameFlagEncodedData,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2008-11-10 22:08:52 +00:00
|
|
|
},
|
2008-11-14 09:45:42 +00:00
|
|
|
{
|
|
|
|
"tucker",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1s("infobar.txt", "1b3ea79d8528ea3c7df83dd0ed345e37", 525),
|
|
|
|
Common::ES_ESP,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2008-12-17 21:29:56 +00:00
|
|
|
Tucker::kGameFlagEncodedData,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2008-11-14 09:45:42 +00:00
|
|
|
},
|
2008-11-30 11:30:29 +00:00
|
|
|
{
|
|
|
|
"tucker",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1s("infobrgr.txt", "4df9eb65722418d1a1723508115b146c", 552),
|
2008-12-12 21:42:38 +00:00
|
|
|
Common::DE_DEU,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2009-06-06 17:56:41 +00:00
|
|
|
Tucker::kGameFlagEncodedData,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2008-11-30 11:30:29 +00:00
|
|
|
},
|
2008-12-16 22:05:16 +00:00
|
|
|
{
|
|
|
|
"tucker",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1s("infobar.txt", "5f85285bbc23ce57cbc164021ee1f23c", 525),
|
|
|
|
Common::PL_POL,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2008-12-17 21:29:56 +00:00
|
|
|
0,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2008-12-16 22:05:16 +00:00
|
|
|
},
|
2008-12-16 22:09:55 +00:00
|
|
|
{
|
|
|
|
"tucker",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1s("infobar.txt", "e548994877ff31ca304f6352ce022a8e", 497),
|
|
|
|
Common::CZ_CZE,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2009-06-06 17:56:41 +00:00
|
|
|
Tucker::kGameFlagEncodedData,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2008-12-16 22:09:55 +00:00
|
|
|
},
|
2018-12-30 18:52:27 +00:00
|
|
|
{ // Russian fan translation
|
|
|
|
"tucker",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1s("infobrgr.txt", "4b5a315e449a7f9eaf2025ec87466cd8", 552),
|
|
|
|
Common::RU_RUS,
|
|
|
|
Common::kPlatformDOS,
|
|
|
|
Tucker::kGameFlagEncodedData,
|
|
|
|
GUIO0()
|
|
|
|
},
|
2009-01-24 21:03:44 +00:00
|
|
|
{
|
|
|
|
"tucker",
|
|
|
|
"Demo",
|
|
|
|
AD_ENTRY1s("infobar.txt", "010b055de42097b140d5bcb6e95a5c7c", 203),
|
|
|
|
Common::EN_ANY,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2009-01-29 22:13:01 +00:00
|
|
|
ADGF_DEMO | Tucker::kGameFlagDemo,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2009-01-24 21:03:44 +00:00
|
|
|
},
|
2008-11-10 20:38:54 +00:00
|
|
|
AD_TABLE_END_MARKER
|
|
|
|
};
|
|
|
|
|
2009-01-29 22:13:01 +00:00
|
|
|
static const ADGameDescription tuckerDemoGameDescription = {
|
2008-12-03 22:15:05 +00:00
|
|
|
"tucker",
|
2009-01-24 21:03:44 +00:00
|
|
|
"Non-Interactive Demo",
|
2008-12-03 22:15:05 +00:00
|
|
|
AD_ENTRY1(0, 0),
|
|
|
|
Common::EN_ANY,
|
2013-05-02 22:26:58 +00:00
|
|
|
Common::kPlatformDOS,
|
2009-06-06 17:56:41 +00:00
|
|
|
ADGF_DEMO | Tucker::kGameFlagDemo | Tucker::kGameFlagIntroOnly,
|
2011-11-16 21:38:58 +00:00
|
|
|
GUIO0()
|
2008-12-03 22:15:05 +00:00
|
|
|
};
|
|
|
|
|
2009-01-29 22:13:01 +00:00
|
|
|
class TuckerMetaEngine : public AdvancedMetaEngine {
|
2008-11-10 20:38:54 +00:00
|
|
|
public:
|
2011-06-10 13:53:58 +00:00
|
|
|
TuckerMetaEngine() : AdvancedMetaEngine(tuckerGameDescriptions, sizeof(ADGameDescription), tuckerGames) {
|
2011-06-11 15:52:32 +00:00
|
|
|
_md5Bytes = 512;
|
2016-03-08 17:30:58 +00:00
|
|
|
_singleId = "tucker";
|
2008-11-10 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual const char *getName() const {
|
2016-09-15 18:04:14 +00:00
|
|
|
return "Bud Tucker in Double Trouble";
|
2008-11-10 20:38:54 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 12:04:58 +00:00
|
|
|
virtual const char *getOriginalCopyright() const {
|
2008-11-10 20:38:54 +00:00
|
|
|
return "Bud Tucker in Double Trouble (C) Merit Studios";
|
|
|
|
}
|
|
|
|
|
2008-11-28 23:56:25 +00:00
|
|
|
virtual bool hasFeature(MetaEngineFeature f) const {
|
|
|
|
switch (f) {
|
|
|
|
case kSupportsListSaves:
|
2011-03-20 17:31:18 +00:00
|
|
|
case kSupportsLoadingDuringStartup:
|
2008-11-28 23:56:25 +00:00
|
|
|
case kSupportsDeleteSave:
|
2018-03-01 19:15:47 +00:00
|
|
|
case kSavesSupportMetaInfo:
|
|
|
|
case kSavesSupportThumbnail:
|
|
|
|
case kSavesSupportCreationDate:
|
|
|
|
case kSavesSupportPlayTime:
|
2008-11-28 23:56:25 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-29 22:13:01 +00:00
|
|
|
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
2008-11-10 20:38:54 +00:00
|
|
|
if (desc) {
|
2008-12-17 21:29:56 +00:00
|
|
|
*engine = new Tucker::TuckerEngine(syst, desc->language, desc->flags);
|
2008-11-10 20:38:54 +00:00
|
|
|
}
|
2018-07-04 09:45:34 +00:00
|
|
|
return desc != nullptr;
|
2008-11-10 20:38:54 +00:00
|
|
|
}
|
2008-11-28 23:56:25 +00:00
|
|
|
|
2017-12-02 16:14:22 +00:00
|
|
|
virtual ADDetectedGame fallbackDetect(const FileMap &allFiles, const Common::FSList &fslist) const override {
|
2008-12-03 22:15:05 +00:00
|
|
|
for (Common::FSList::const_iterator d = fslist.begin(); d != fslist.end(); ++d) {
|
|
|
|
Common::FSList audiofslist;
|
2008-12-13 09:39:00 +00:00
|
|
|
if (d->isDirectory() && d->getName().equalsIgnoreCase("audio") && d->getChildren(audiofslist, Common::FSNode::kListFilesOnly)) {
|
2008-12-03 22:15:05 +00:00
|
|
|
for (Common::FSList::const_iterator f = audiofslist.begin(); f != audiofslist.end(); ++f) {
|
2008-12-13 09:39:00 +00:00
|
|
|
if (!f->isDirectory() && f->getName().equalsIgnoreCase("demorolc.raw")) {
|
2017-12-02 16:14:22 +00:00
|
|
|
return ADDetectedGame(&tuckerDemoGameDescription);
|
2008-12-03 22:15:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-12-02 16:14:22 +00:00
|
|
|
|
|
|
|
return ADDetectedGame();
|
2008-12-03 22:15:05 +00:00
|
|
|
}
|
|
|
|
|
2008-11-28 23:56:25 +00:00
|
|
|
virtual SaveStateList listSaves(const char *target) const {
|
|
|
|
Common::String pattern = Tucker::generateGameStateFileName(target, 0, true);
|
2010-03-18 15:54:40 +00:00
|
|
|
Common::StringArray filenames = g_system->getSavefileManager()->listSavefiles(pattern);
|
2018-03-01 19:15:47 +00:00
|
|
|
Tucker::TuckerEngine::SavegameHeader header;
|
2008-11-28 23:56:25 +00:00
|
|
|
SaveStateList saveList;
|
2018-03-01 19:15:47 +00:00
|
|
|
|
2010-03-18 15:54:40 +00:00
|
|
|
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
|
2008-11-28 23:56:25 +00:00
|
|
|
int slot;
|
|
|
|
const char *ext = strrchr(file->c_str(), '.');
|
2008-11-30 12:23:24 +00:00
|
|
|
if (ext && (slot = atoi(ext + 1)) >= 0 && slot <= Tucker::kLastSaveSlot) {
|
2009-05-29 14:38:22 +00:00
|
|
|
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(*file);
|
2008-11-28 23:56:25 +00:00
|
|
|
if (in) {
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-05 22:06:38 +00:00
|
|
|
if (Tucker::TuckerEngine::readSavegameHeader(in, header) == Tucker::TuckerEngine::kSavegameNoError) {
|
2018-03-01 19:15:47 +00:00
|
|
|
saveList.push_back(SaveStateDescriptor(slot, header.description));
|
|
|
|
}
|
|
|
|
|
2008-11-28 23:56:25 +00:00
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-03-01 19:15:47 +00:00
|
|
|
|
2016-02-25 18:55:14 +00:00
|
|
|
// Sort saves based on slot number.
|
|
|
|
Common::sort(saveList.begin(), saveList.end(), SaveStateDescriptorSlotComparator());
|
2008-11-28 23:56:25 +00:00
|
|
|
return saveList;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual int getMaximumSaveSlot() const {
|
2008-11-30 12:23:24 +00:00
|
|
|
return Tucker::kLastSaveSlot;
|
2008-11-28 23:56:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual void removeSaveState(const char *target, int slot) const {
|
|
|
|
Common::String filename = Tucker::generateGameStateFileName(target, slot);
|
2009-05-29 14:38:22 +00:00
|
|
|
g_system->getSavefileManager()->removeSavefile(filename);
|
2008-11-28 23:56:25 +00:00
|
|
|
}
|
2018-03-01 19:15:47 +00:00
|
|
|
|
|
|
|
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const {
|
|
|
|
Common::String fileName = Common::String::format("%s.%d", target, slot);
|
|
|
|
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName);
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
Tucker::TuckerEngine::SavegameHeader header;
|
ALL: Load savegame thumbnail only when necessary
This commit introduces the following changes:
1. Graphics::loadThumbnail()
Now returns a boolean and takes a new argument skipThumbnail which
defaults to false. In case of true, loadThumbnail() reads past the
thumbnail data in the input stream instead of actually loading the
thumbnail. This simplifies savegame handling where, up until now,
many engines always read the whole savegame metadata (including
the thumbnail) and then threw away the thumbnail when not needed
(which is in almost all cases, the most common exception being
MetaEngine::querySaveMetaInfos() which is responsible for loading
savegame metadata for displaying it in the GUI launcher.
2. readSavegameHeader()
Engines which already implement such a method (name varies) now take
a new argument skipThumbnail (default: true) which is passed
through to loadThumbnail(). This means that the default case for
readSavegameHeader() is now _not_ loading the thumbnail from a
savegame and just reading past it. In those cases, e.g.
querySaveMetaInfos(), where we actually are interested in loading
the thumbnail readSavegameHeader() needs to explicitely be called
with skipThumbnail == false.
Engines whose readSavegameHeader() (name varies) already takes an
argument loadThumbnail have been adapted to have a similar
prototype and semantics.
I.e. readSaveHeader(in, loadThumbnail, header) now is
readSaveHeader(in, header, skipThumbnail).
3. Error handling
Engines which previously did not check the return value of
readSavegameHeader() (name varies) now do so ensuring that possibly
broken savegames (be it a broken thumbnail or something else) don't
make it into the GUI launcher list in the first place.
2018-04-05 22:06:38 +00:00
|
|
|
Tucker::TuckerEngine::SavegameError savegameError = Tucker::TuckerEngine::readSavegameHeader(file, header, false);
|
2018-03-01 19:15:47 +00:00
|
|
|
if (savegameError) {
|
|
|
|
delete file;
|
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveStateDescriptor desc(slot, header.description);
|
|
|
|
|
|
|
|
if (slot == Tucker::kAutoSaveSlot) {
|
|
|
|
bool autosaveAllowed = Tucker::TuckerEngine::isAutosaveAllowed(target);
|
|
|
|
desc.setDeletableFlag(!autosaveAllowed);
|
|
|
|
desc.setWriteProtectedFlag(autosaveAllowed);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (header.version >= 2) {
|
|
|
|
// creation/play time
|
|
|
|
if (header.saveDate) {
|
|
|
|
int day = (header.saveDate >> 24) & 0xFF;
|
|
|
|
int month = (header.saveDate >> 16) & 0xFF;
|
|
|
|
int year = header.saveDate & 0xFFFF;
|
|
|
|
desc.setSaveDate(year, month, day);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (header.saveTime) {
|
|
|
|
int hour = (header.saveTime >> 16) & 0xFF;
|
|
|
|
int minutes = (header.saveTime >> 8) & 0xFF;
|
|
|
|
desc.setSaveTime(hour, minutes);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (header.playTime) {
|
|
|
|
desc.setPlayTime(header.playTime * 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
// thumbnail
|
|
|
|
if (header.thumbnail) {
|
|
|
|
desc.setThumbnail(header.thumbnail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete file;
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
2008-11-10 20:38:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(TUCKER)
|
|
|
|
REGISTER_PLUGIN_DYNAMIC(TUCKER, PLUGIN_TYPE_ENGINE, TuckerMetaEngine);
|
|
|
|
#else
|
|
|
|
REGISTER_PLUGIN_STATIC(TUCKER, PLUGIN_TYPE_ENGINE, TuckerMetaEngine);
|
|
|
|
#endif
|