18
18
* along with this program; if not, write to the Free Software
19
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21
* $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/tags/release-1-2-1/engines/hugo/detection.cpp $
22
* $Id: detection.cpp 52525 2010-09-04 16:02:16Z strangerke $
26
26
#include "engines/advancedDetector.h"
27
#include "common/system.h"
28
#include "common/savefile.h"
29
#include "common/textconsole.h"
30
#include "graphics/thumbnail.h"
31
#include "graphics/surface.h"
28
33
#include "hugo/hugo.h"
38
43
return _gameDescription->desc.flags;
46
const char *HugoEngine::getGameId() const {
47
return _gameDescription->desc.gameid;
41
51
static const PlainGameDescriptor hugoGames[] = {
43
53
{"hugo1", "Hugo 1: Hugo's House of Horrors"},
44
{"hugo2", "Hugo 2: Hugo's Mystery Adventure"},
45
{"hugo3", "Hugo 3: Hugo's Amazon Adventure"},
54
{"hugo2", "Hugo 2: Whodunit?"},
55
{"hugo3", "Hugo 3: Jungle of Doom"},
177
191
bool HugoMetaEngine::hasFeature(MetaEngineFeature f) const {
193
(f == kSupportsListSaves) ||
194
(f == kSupportsLoadingDuringStartup) ||
195
(f == kSupportsDeleteSave) ||
196
(f == kSavesSupportMetaInfo) ||
197
(f == kSavesSupportThumbnail) ||
198
(f == kSavesSupportCreationDate);
201
int HugoMetaEngine::getMaximumSaveSlot() const { return 99; }
203
SaveStateList HugoMetaEngine::listSaves(const char *target) const {
204
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
205
Common::StringArray filenames;
206
Common::String pattern = target;
207
pattern += "-??.SAV";
209
filenames = saveFileMan->listSavefiles(pattern);
210
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
212
SaveStateList saveList;
215
for (Common::StringArray::const_iterator filename = filenames.begin(); filename != filenames.end(); ++filename) {
216
slot[0] = filename->c_str()[filename->size() - 6];
217
slot[1] = filename->c_str()[filename->size() - 5];
219
// Obtain the last 2 digits of the filename (without extension), since they correspond to the save slot
220
slotNum = atoi(slot);
221
if (slotNum >= 0 && slotNum <= getMaximumSaveSlot()) {
222
Common::InSaveFile *file = saveFileMan->openForLoading(*filename);
224
int saveVersion = file->readByte();
226
if (saveVersion != kSavegameVersion) {
227
warning("Savegame of incompatible version");
233
uint16 nameSize = file->readUint16BE();
234
if (nameSize >= 255) {
239
file->read(name, nameSize);
242
saveList.push_back(SaveStateDescriptor(slotNum, name));
251
SaveStateDescriptor HugoMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
252
Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot);
253
Common::InSaveFile *file = g_system->getSavefileManager()->openForLoading(fileName);
256
int saveVersion = file->readByte();
258
if (saveVersion != kSavegameVersion) {
259
warning("Savegame of incompatible version");
261
return SaveStateDescriptor();
264
uint32 saveNameLength = file->readUint16BE();
266
file->read(saveName, saveNameLength);
267
saveName[saveNameLength] = 0;
269
SaveStateDescriptor desc(slot, saveName);
271
Graphics::Surface *thumbnail = new Graphics::Surface();
273
if (!Graphics::loadThumbnail(*file, *thumbnail)) {
277
desc.setThumbnail(thumbnail);
279
desc.setDeletableFlag(true);
280
desc.setWriteProtectedFlag(false);
282
uint32 saveDate = file->readUint32BE();
283
uint16 saveTime = file->readUint16BE();
285
int day = (saveDate >> 24) & 0xFF;
286
int month = (saveDate >> 16) & 0xFF;
287
int year = saveDate & 0xFFFF;
289
desc.setSaveDate(year, month, day);
291
int hour = (saveTime >> 8) & 0xFF;
292
int minutes = saveTime & 0xFF;
294
desc.setSaveTime(hour, minutes);
296
// Slot 0 is used for the 'restart game' save in all Hugo games, thus
297
// we prevent it from being deleted.
298
desc.setDeletableFlag(slot != 0);
299
desc.setWriteProtectedFlag(slot == 0);
304
return SaveStateDescriptor();
307
void HugoMetaEngine::removeSaveState(const char *target, int slot) const {
308
Common::String fileName = Common::String::format("%s-%02d.SAV", target, slot);
309
g_system->getSavefileManager()->removeSavefile(fileName);
181
311
} // End of namespace Hugo
183
313
#if PLUGIN_ENABLED_DYNAMIC(HUGO)
191
321
void HugoEngine::initGame(const HugoGameDescription *gd) {
194
322
_gameType = gd->gameType;
195
323
_platform = gd->desc.platform;
196
324
_packedFl = (getFeatures() & GF_PACKED);
197
325
_gameVariant = _gameType - 1 + ((_platform == Common::kPlatformWindows) ? 0 : 3);
200
if (gd->desc.platform == Common::kPlatformWindows)
201
sprintf(tmpStr, "%s%c", gd->desc.gameid, 'w');
203
sprintf(tmpStr, "%s%c", gd->desc.gameid, 'd');
205
sprintf(_initFilename, "%s-00.SAV", tmpStr);
206
sprintf(_saveFilename, "%s-%s.SAV", tmpStr, "%d");
209
328
} // End of namespace Hugo