2009-02-17 15:20:21 +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.
|
2009-02-15 06:10:59 +00:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2009-02-15 08:20:53 +00:00
|
|
|
#include "engines/advancedDetector.h"
|
2009-02-15 06:10:59 +00:00
|
|
|
#include "base/plugins.h"
|
2010-02-17 23:38:43 +00:00
|
|
|
#include "common/file.h"
|
2009-10-11 15:51:43 +00:00
|
|
|
#include "common/savefile.h"
|
2010-02-17 23:37:32 +00:00
|
|
|
#include "common/system.h"
|
2009-10-11 15:51:43 +00:00
|
|
|
#include "graphics/thumbnail.h"
|
2010-11-19 01:37:04 +00:00
|
|
|
#include "graphics/surface.h"
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-02-15 11:03:21 +00:00
|
|
|
#include "sci/sci.h"
|
2009-08-18 10:01:18 +00:00
|
|
|
#include "sci/engine/kernel.h"
|
2009-10-11 15:51:43 +00:00
|
|
|
#include "sci/engine/savegame.h"
|
2010-05-19 15:57:58 +00:00
|
|
|
#include "sci/engine/script.h"
|
2009-08-17 05:55:21 +00:00
|
|
|
#include "sci/engine/seg_manager.h"
|
2009-10-11 15:51:43 +00:00
|
|
|
#include "sci/engine/state.h"
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-02-20 14:45:28 +00:00
|
|
|
namespace Sci {
|
|
|
|
|
2009-02-15 06:10:59 +00:00
|
|
|
// Titles of the games
|
2010-06-25 16:16:29 +00:00
|
|
|
static const PlainGameDescriptor s_sciGameTitles[] = {
|
2009-02-22 14:40:56 +00:00
|
|
|
{"sci", "Sierra SCI Game"},
|
|
|
|
{"sci-fanmade", "Fanmade SCI Game"},
|
2010-01-31 08:28:10 +00:00
|
|
|
// === SCI0 games =========================================================
|
2009-02-15 06:10:59 +00:00
|
|
|
{"astrochicken", "Astro Chicken"},
|
2009-02-20 23:00:27 +00:00
|
|
|
{"christmas1988", "Christmas Card 1988"},
|
2009-02-15 06:10:59 +00:00
|
|
|
{"iceman", "Codename: Iceman"},
|
|
|
|
{"camelot", "Conquests of Camelot: King Arthur, Quest for the Grail"},
|
2010-01-31 08:28:10 +00:00
|
|
|
{"funseeker", "Fun Seeker's Guide"},
|
|
|
|
{"hoyle1", "Hoyle Official Book of Games: Volume 1"},
|
|
|
|
{"hoyle2", "Hoyle Official Book of Games: Volume 2"},
|
2011-01-04 19:46:18 +00:00
|
|
|
{"kq4sci", "King's Quest IV: The Perils of Rosella"}, // Note: There was also an AGI version of this
|
2010-01-31 08:28:10 +00:00
|
|
|
{"laurabow", "Laura Bow: The Colonel's Bequest"},
|
|
|
|
{"lsl2", "Leisure Suit Larry 2: Goes Looking for Love (in Several Wrong Places)"},
|
|
|
|
{"lsl3", "Leisure Suit Larry 3: Passionate Patti in Pursuit of the Pulsating Pectorals"},
|
2010-09-03 17:49:22 +00:00
|
|
|
{"mothergoose", "Mixed-Up Mother Goose"},
|
2010-01-31 08:28:10 +00:00
|
|
|
{"pq2", "Police Quest II: The Vengeance"},
|
2011-01-04 09:09:56 +00:00
|
|
|
{"qfg1", "Quest for Glory I: So You Want to Be a Hero"}, // Note: There was also a SCI11 VGA remake of this (further down)
|
2010-01-31 08:28:10 +00:00
|
|
|
{"sq3", "Space Quest III: The Pirates of Pestulon"},
|
|
|
|
// === SCI01 games ========================================================
|
|
|
|
{"qfg2", "Quest for Glory II: Trial by Fire"},
|
2011-01-04 19:46:18 +00:00
|
|
|
{"kq1sci", "King's Quest I: Quest for the Crown"}, // Note: There was also an AGI version of this
|
2010-01-31 08:28:10 +00:00
|
|
|
// === SCI1 games =========================================================
|
|
|
|
{"castlebrain", "Castle of Dr. Brain"},
|
|
|
|
{"christmas1990", "Christmas Card 1990: The Seasoned Professional"},
|
2009-09-01 19:05:21 +00:00
|
|
|
{"cnick-lsl", "Crazy Nick's Software Picks: Leisure Suit Larry's Casino"},
|
|
|
|
{"cnick-kq", "Crazy Nick's Software Picks: King Graham's Board Game Challenge"},
|
|
|
|
{"cnick-laurabow", "Crazy Nick's Software Picks: Parlor Games with Laura Bow"},
|
|
|
|
{"cnick-longbow", "Crazy Nick's Software Picks: Robin Hood's Game of Skill and Chance"},
|
|
|
|
{"cnick-sq", "Crazy Nick's Software Picks: Roger Wilco's Spaced Out Game Pack"},
|
2010-01-31 08:28:10 +00:00
|
|
|
{"ecoquest", "EcoQuest: The Search for Cetus"}, // floppy is SCI1, CD SCI1.1
|
|
|
|
{"fairytales", "Mixed-up Fairy Tales"},
|
2009-05-02 15:35:57 +00:00
|
|
|
{"hoyle3", "Hoyle Official Book of Games: Volume 3"},
|
2009-02-15 06:10:59 +00:00
|
|
|
{"jones", "Jones in the Fast Lane"},
|
|
|
|
{"kq5", "King's Quest V: Absence Makes the Heart Go Yonder"},
|
2010-01-31 08:28:10 +00:00
|
|
|
{"longbow", "Conquests of the Longbow: The Adventures of Robin Hood"},
|
2011-01-04 19:46:18 +00:00
|
|
|
{"lsl1sci", "Leisure Suit Larry in the Land of the Lounge Lizards"}, // Note: There was also an AGI version of this
|
2009-02-15 06:10:59 +00:00
|
|
|
{"lsl5", "Leisure Suit Larry 5: Passionate Patti Does a Little Undercover Work"},
|
2010-09-03 17:49:22 +00:00
|
|
|
{"mothergoose256", "Mixed-Up Mother Goose"},
|
2009-02-22 23:32:28 +00:00
|
|
|
{"msastrochicken", "Ms. Astro Chicken"},
|
2011-01-04 19:46:18 +00:00
|
|
|
{"pq1sci", "Police Quest: In Pursuit of the Death Angel"}, // Note: There was also an AGI version of this
|
2009-02-15 06:10:59 +00:00
|
|
|
{"pq3", "Police Quest III: The Kindred"},
|
2011-01-04 19:46:18 +00:00
|
|
|
{"sq1sci", "Space Quest I: The Sarien Encounter"}, // Note: There was also an AGI version of this
|
2010-01-31 08:28:10 +00:00
|
|
|
{"sq4", "Space Quest IV: Roger Wilco and the Time Rippers"}, // floppy is SCI1, CD SCI1.1
|
|
|
|
// === SCI1.1 games =======================================================
|
|
|
|
{"christmas1992", "Christmas Card 1992"},
|
|
|
|
{"ecoquest2", "EcoQuest II: Lost Secret of the Rainforest"},
|
|
|
|
{"freddypharkas", "Freddy Pharkas: Frontier Pharmacist"},
|
|
|
|
{"hoyle4", "Hoyle Classic Card Games"},
|
|
|
|
{"kq6", "King's Quest VI: Heir Today, Gone Tomorrow"},
|
|
|
|
{"laurabow2", "Laura Bow 2: The Dagger of Amon Ra"},
|
2011-01-04 19:46:18 +00:00
|
|
|
{"qfg1vga", "Quest for Glory I: So You Want to Be a Hero"}, // Note: There was also a SCI0 version of this (further up)
|
2010-01-31 08:28:10 +00:00
|
|
|
{"qfg3", "Quest for Glory III: Wages of War"},
|
2009-02-15 06:10:59 +00:00
|
|
|
{"sq5", "Space Quest V: The Next Mutation"},
|
|
|
|
{"islandbrain", "The Island of Dr. Brain"},
|
2010-01-31 08:28:10 +00:00
|
|
|
{"lsl6", "Leisure Suit Larry 6: Shape Up or Slip Out!"},
|
|
|
|
{"pepper", "Pepper's Adventure in Time"},
|
|
|
|
{"slater", "Slater & Charlie Go Camping"},
|
|
|
|
// === SCI2 games =========================================================
|
2009-08-26 10:01:05 +00:00
|
|
|
{"gk1", "Gabriel Knight: Sins of the Fathers"}, // demo is SCI11, full version SCI32
|
2010-01-31 08:28:10 +00:00
|
|
|
{"pq4", "Police Quest IV: Open Season"}, // floppy is SCI2, CD SCI2.1
|
|
|
|
{"qfg4", "Quest for Glory IV: Shadows of Darkness"}, // floppy is SCI2, CD SCI2.1
|
|
|
|
// === SCI2.1 games ========================================================
|
2009-03-30 07:53:32 +00:00
|
|
|
{"gk2", "The Beast Within: A Gabriel Knight Mystery"},
|
2010-01-31 08:28:10 +00:00
|
|
|
// TODO: Inside The Chest/Behind the Developer's Shield
|
2009-03-30 07:53:32 +00:00
|
|
|
{"kq7", "King's Quest VII: The Princeless Bride"},
|
2010-01-31 08:28:10 +00:00
|
|
|
// TODO: King's Questions
|
2010-07-12 19:55:42 +00:00
|
|
|
{"lsl6hires", "Leisure Suit Larry 6: Shape Up or Slip Out!"},
|
2011-01-07 00:19:54 +00:00
|
|
|
{"mothergoosehires","Mixed-Up Mother Goose Deluxe"},
|
2009-03-30 07:53:32 +00:00
|
|
|
{"phantasmagoria", "Phantasmagoria"},
|
2009-05-02 15:35:57 +00:00
|
|
|
{"pqswat", "Police Quest: SWAT"},
|
2009-03-30 07:53:32 +00:00
|
|
|
{"shivers", "Shivers"},
|
|
|
|
{"sq6", "Space Quest 6: The Spinal Frontier"},
|
2009-02-15 06:10:59 +00:00
|
|
|
{"torin", "Torin's Passage"},
|
2010-01-31 08:28:10 +00:00
|
|
|
// === SCI3 games =========================================================
|
|
|
|
{"lsl7", "Leisure Suit Larry 7: Love for Sail!"},
|
|
|
|
{"lighthouse", "Lighthouse: The Dark Being"},
|
|
|
|
{"phantasmagoria2", "Phantasmagoria II: A Puzzle of Flesh"},
|
2010-11-09 22:01:12 +00:00
|
|
|
//{"shivers2", "Shivers II: Harvest of Souls"}, // Not SCI
|
2010-01-31 08:28:10 +00:00
|
|
|
{"rama", "RAMA"},
|
2009-02-15 06:10:59 +00:00
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
2010-06-25 16:16:29 +00:00
|
|
|
struct GameIdStrToEnum {
|
|
|
|
const char *gameidStr;
|
|
|
|
SciGameId gameidEnum;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const GameIdStrToEnum s_gameIdStrToEnum[] = {
|
|
|
|
{ "astrochicken", GID_ASTROCHICKEN },
|
|
|
|
{ "camelot", GID_CAMELOT },
|
|
|
|
{ "castlebrain", GID_CASTLEBRAIN },
|
|
|
|
{ "christmas1988", GID_CHRISTMAS1988 },
|
|
|
|
{ "christmas1990", GID_CHRISTMAS1990 },
|
|
|
|
{ "christmas1992", GID_CHRISTMAS1992 },
|
|
|
|
{ "cnick-kq", GID_CNICK_KQ },
|
|
|
|
{ "cnick-laurabow", GID_CNICK_LAURABOW },
|
|
|
|
{ "cnick-longbow", GID_CNICK_LONGBOW },
|
|
|
|
{ "cnick-lsl", GID_CNICK_LSL },
|
|
|
|
{ "cnick-sq", GID_CNICK_SQ },
|
|
|
|
{ "ecoquest", GID_ECOQUEST },
|
|
|
|
{ "ecoquest2", GID_ECOQUEST2 },
|
|
|
|
{ "fairytales", GID_FAIRYTALES },
|
|
|
|
{ "freddypharkas", GID_FREDDYPHARKAS },
|
|
|
|
{ "funseeker", GID_FUNSEEKER },
|
|
|
|
{ "gk1", GID_GK1 },
|
|
|
|
{ "gk2", GID_GK2 },
|
|
|
|
{ "hoyle1", GID_HOYLE1 },
|
|
|
|
{ "hoyle2", GID_HOYLE2 },
|
|
|
|
{ "hoyle3", GID_HOYLE3 },
|
|
|
|
{ "hoyle4", GID_HOYLE4 },
|
|
|
|
{ "iceman", GID_ICEMAN },
|
|
|
|
{ "islandbrain", GID_ISLANDBRAIN },
|
|
|
|
{ "jones", GID_JONES },
|
|
|
|
{ "kq1sci", GID_KQ1 },
|
|
|
|
{ "kq4sci", GID_KQ4 },
|
|
|
|
{ "kq5", GID_KQ5 },
|
|
|
|
{ "kq6", GID_KQ6 },
|
|
|
|
{ "kq7", GID_KQ7 },
|
|
|
|
{ "laurabow", GID_LAURABOW },
|
|
|
|
{ "laurabow2", GID_LAURABOW2 },
|
|
|
|
{ "lighthouse", GID_LIGHTHOUSE },
|
|
|
|
{ "longbow", GID_LONGBOW },
|
|
|
|
{ "lsl1sci", GID_LSL1 },
|
|
|
|
{ "lsl2", GID_LSL2 },
|
|
|
|
{ "lsl3", GID_LSL3 },
|
|
|
|
{ "lsl5", GID_LSL5 },
|
|
|
|
{ "lsl6", GID_LSL6 },
|
2010-07-12 19:55:42 +00:00
|
|
|
{ "lsl6hires", GID_LSL6HIRES },
|
2010-06-25 16:16:29 +00:00
|
|
|
{ "lsl7", GID_LSL7 },
|
|
|
|
{ "mothergoose", GID_MOTHERGOOSE },
|
2010-08-23 16:33:19 +00:00
|
|
|
{ "mothergoose256", GID_MOTHERGOOSE256 },
|
2010-07-27 19:09:57 +00:00
|
|
|
{ "mothergoosehires",GID_MOTHERGOOSEHIRES },
|
2010-06-25 16:16:29 +00:00
|
|
|
{ "msastrochicken", GID_MSASTROCHICKEN },
|
|
|
|
{ "pepper", GID_PEPPER },
|
|
|
|
{ "phantasmagoria", GID_PHANTASMAGORIA },
|
|
|
|
{ "phantasmagoria2", GID_PHANTASMAGORIA2 },
|
|
|
|
{ "pq1sci", GID_PQ1 },
|
|
|
|
{ "pq2", GID_PQ2 },
|
|
|
|
{ "pq3", GID_PQ3 },
|
|
|
|
{ "pq4", GID_PQ4 },
|
|
|
|
{ "pqswat", GID_PQSWAT },
|
|
|
|
{ "qfg1", GID_QFG1 },
|
2010-07-14 11:53:12 +00:00
|
|
|
{ "qfg1vga", GID_QFG1VGA },
|
2010-06-25 16:16:29 +00:00
|
|
|
{ "qfg2", GID_QFG2 },
|
|
|
|
{ "qfg3", GID_QFG3 },
|
|
|
|
{ "qfg4", GID_QFG4 },
|
|
|
|
{ "rama", GID_RAMA },
|
|
|
|
{ "sci-fanmade", GID_FANMADE }, // FIXME: Do we really need/want this?
|
|
|
|
{ "shivers", GID_SHIVERS },
|
2010-11-09 22:01:12 +00:00
|
|
|
//{ "shivers2", GID_SHIVERS2 }, // Not SCI
|
2010-06-25 16:16:29 +00:00
|
|
|
{ "slater", GID_SLATER },
|
|
|
|
{ "sq1sci", GID_SQ1 },
|
|
|
|
{ "sq3", GID_SQ3 },
|
|
|
|
{ "sq4", GID_SQ4 },
|
|
|
|
{ "sq5", GID_SQ5 },
|
|
|
|
{ "sq6", GID_SQ6 },
|
|
|
|
{ "torin", GID_TORIN },
|
|
|
|
{ NULL, (SciGameId)-1 }
|
|
|
|
};
|
|
|
|
|
2010-05-23 10:28:03 +00:00
|
|
|
struct OldNewIdTableEntry {
|
|
|
|
const char *oldId;
|
|
|
|
const char *newId;
|
|
|
|
SciVersion version;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const OldNewIdTableEntry s_oldNewTable[] = {
|
|
|
|
{ "arthur", "camelot", SCI_VERSION_NONE },
|
|
|
|
{ "brain", "castlebrain", SCI_VERSION_1_MIDDLE }, // Amiga
|
|
|
|
{ "brain", "castlebrain", SCI_VERSION_1_LATE },
|
|
|
|
{ "demo", "christmas1988", SCI_VERSION_NONE },
|
|
|
|
{ "card", "christmas1990", SCI_VERSION_1_EARLY, },
|
|
|
|
{ "card", "christmas1992", SCI_VERSION_1_1 },
|
|
|
|
{ "RH Budget", "cnick-longbow", SCI_VERSION_NONE },
|
|
|
|
// iceman is the same
|
|
|
|
{ "icedemo", "iceman", SCI_VERSION_NONE },
|
|
|
|
// longbow is the same
|
|
|
|
{ "eco", "ecoquest", SCI_VERSION_NONE },
|
|
|
|
{ "eco2", "ecoquest2", SCI_VERSION_NONE }, // EcoQuest 2 demo
|
|
|
|
{ "rain", "ecoquest2", SCI_VERSION_NONE }, // EcoQuest 2 full
|
2010-06-01 22:06:52 +00:00
|
|
|
{ "tales", "fairytales", SCI_VERSION_NONE },
|
2010-05-23 10:28:03 +00:00
|
|
|
{ "fp", "freddypharkas", SCI_VERSION_NONE },
|
|
|
|
{ "emc", "funseeker", SCI_VERSION_NONE },
|
|
|
|
{ "gk", "gk1", SCI_VERSION_NONE },
|
2010-06-01 22:06:52 +00:00
|
|
|
// gk2 is the same
|
2010-05-23 10:28:03 +00:00
|
|
|
{ "hoyledemo", "hoyle1", SCI_VERSION_NONE },
|
|
|
|
{ "cardgames", "hoyle1", SCI_VERSION_NONE },
|
|
|
|
{ "solitare", "hoyle2", SCI_VERSION_NONE },
|
|
|
|
// hoyle3 is the same
|
|
|
|
// hoyle4 is the same
|
|
|
|
{ "brain", "islandbrain", SCI_VERSION_1_1 },
|
|
|
|
{ "demo000", "kq1sci", SCI_VERSION_NONE },
|
|
|
|
{ "kq1", "kq1sci", SCI_VERSION_NONE },
|
|
|
|
{ "kq4", "kq4sci", SCI_VERSION_NONE },
|
2010-06-01 22:06:52 +00:00
|
|
|
// kq5 is the same
|
|
|
|
// kq6 is the same
|
|
|
|
// kq7 is the same
|
2010-05-23 10:28:03 +00:00
|
|
|
{ "mm1", "laurabow", SCI_VERSION_NONE },
|
|
|
|
{ "cb1", "laurabow", SCI_VERSION_NONE },
|
|
|
|
{ "lb2", "laurabow2", SCI_VERSION_NONE },
|
|
|
|
{ "rh", "longbow", SCI_VERSION_NONE },
|
|
|
|
{ "ll1", "lsl1sci", SCI_VERSION_NONE },
|
|
|
|
{ "lsl1", "lsl1sci", SCI_VERSION_NONE },
|
|
|
|
// lsl2 is the same
|
|
|
|
{ "lsl3", "lsl3", SCI_VERSION_NONE },
|
|
|
|
{ "ll5", "lsl5", SCI_VERSION_NONE },
|
|
|
|
// lsl5 is the same
|
|
|
|
// lsl6 is the same
|
|
|
|
{ "mg", "mothergoose", SCI_VERSION_NONE },
|
|
|
|
{ "twisty", "pepper", SCI_VERSION_NONE },
|
2010-06-01 22:06:52 +00:00
|
|
|
{ "scary", "phantasmagoria", SCI_VERSION_NONE },
|
|
|
|
// TODO: distinguish the full version of Phantasmagoria from the demo
|
2010-05-23 10:28:03 +00:00
|
|
|
{ "pq1", "pq1sci", SCI_VERSION_NONE },
|
|
|
|
{ "pq", "pq2", SCI_VERSION_NONE },
|
|
|
|
// pq3 is the same
|
|
|
|
// pq4 is the same
|
|
|
|
{ "hq", "qfg1", SCI_VERSION_NONE }, // QFG1 SCI0/EGA
|
|
|
|
{ "glory", "qfg1", SCI_VERSION_0_LATE }, // QFG1 SCI0/EGA
|
|
|
|
{ "trial", "qfg2", SCI_VERSION_NONE },
|
|
|
|
{ "hq2demo", "qfg2", SCI_VERSION_NONE },
|
2010-06-01 22:06:52 +00:00
|
|
|
// rama is the same
|
|
|
|
// TODO: distinguish the full version of rama from the demo
|
2010-05-23 10:28:03 +00:00
|
|
|
{ "thegame", "slater", SCI_VERSION_NONE },
|
|
|
|
{ "sq1demo", "sq1sci", SCI_VERSION_NONE },
|
|
|
|
{ "sq1", "sq1sci", SCI_VERSION_NONE },
|
|
|
|
// sq3 is the same
|
|
|
|
// sq4 is the same
|
|
|
|
// sq5 is the same
|
2010-06-01 22:06:52 +00:00
|
|
|
// sq6 is the same
|
|
|
|
// TODO: distinguish the full version of SQ6 from the demo
|
2010-05-23 10:28:03 +00:00
|
|
|
// torin is the same
|
|
|
|
|
2010-06-01 22:06:52 +00:00
|
|
|
|
|
|
|
// TODO: SCI3 IDs
|
2010-05-23 10:28:03 +00:00
|
|
|
|
|
|
|
{ "", "", SCI_VERSION_NONE }
|
|
|
|
};
|
|
|
|
|
2010-06-10 07:32:05 +00:00
|
|
|
/**
|
|
|
|
* Converts the builtin Sierra game IDs to the ones we use in ScummVM
|
|
|
|
* @param[in] gameId The internal game ID
|
|
|
|
* @param[in] gameFlags The game's flags, which are adjusted accordingly for demos
|
|
|
|
* @return The equivalent ScummVM game id
|
|
|
|
*/
|
2010-05-23 10:28:03 +00:00
|
|
|
Common::String convertSierraGameId(Common::String sierraId, uint32 *gameFlags, ResourceManager *resMan) {
|
|
|
|
// Convert the id to lower case, so that we match all upper/lower case variants.
|
|
|
|
sierraId.toLowercase();
|
|
|
|
|
|
|
|
// If the game has less than the expected scripts, it's a demo
|
|
|
|
uint32 demoThreshold = 100;
|
|
|
|
// ...but there are some exceptions
|
|
|
|
if (sierraId == "brain" || sierraId == "lsl1" ||
|
|
|
|
sierraId == "mg" || sierraId == "pq" ||
|
|
|
|
sierraId == "jones" ||
|
|
|
|
sierraId == "cardgames" || sierraId == "solitare" ||
|
|
|
|
sierraId == "hoyle3" || sierraId == "hoyle4")
|
|
|
|
demoThreshold = 40;
|
|
|
|
if (sierraId == "fp" || sierraId == "gk" || sierraId == "pq4")
|
|
|
|
demoThreshold = 150;
|
|
|
|
|
2010-08-02 22:27:26 +00:00
|
|
|
Common::ScopedPtr<Common::List<ResourceId> > resources(resMan->listResources(kResourceTypeScript, -1));
|
2010-05-23 10:28:03 +00:00
|
|
|
if (resources->size() < demoThreshold) {
|
|
|
|
*gameFlags |= ADGF_DEMO;
|
|
|
|
|
|
|
|
// Crazy Nick's Picks
|
|
|
|
if (sierraId == "lsl1" && resources->size() == 34)
|
|
|
|
return "cnick-lsl";
|
|
|
|
if (sierraId == "sq4" && resources->size() == 34)
|
|
|
|
return "cnick-sq";
|
|
|
|
|
|
|
|
// TODO: cnick-kq, cnick-laurabow and cnick-longbow (their resources can't be read)
|
|
|
|
|
|
|
|
// Handle Astrochicken 1 (SQ3) and 2 (SQ4)
|
|
|
|
if (sierraId == "sq3" && resources->size() == 20)
|
|
|
|
return "astrochicken";
|
|
|
|
if (sierraId == "sq4")
|
|
|
|
return "msastrochicken";
|
|
|
|
}
|
|
|
|
|
2010-06-01 22:06:52 +00:00
|
|
|
if (sierraId == "torin" && resources->size() == 226) // Torin's Passage demo
|
|
|
|
*gameFlags |= ADGF_DEMO;
|
|
|
|
|
2010-05-23 10:28:03 +00:00
|
|
|
for (const OldNewIdTableEntry *cur = s_oldNewTable; cur->oldId[0]; ++cur) {
|
|
|
|
if (sierraId == cur->oldId) {
|
|
|
|
// Distinguish same IDs from the SCI version
|
|
|
|
if (cur->version != SCI_VERSION_NONE && cur->version != getSciVersion())
|
|
|
|
continue;
|
|
|
|
|
|
|
|
return cur->newId;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sierraId == "glory") {
|
|
|
|
// This could either be qfg1 VGA, qfg3 or qfg4 demo (all SCI1.1),
|
|
|
|
// or qfg4 full (SCI2)
|
|
|
|
// qfg1 VGA doesn't have view 1
|
|
|
|
if (!resMan->testResource(ResourceId(kResourceTypeView, 1)))
|
2010-07-14 11:53:12 +00:00
|
|
|
return "qfg1vga";
|
2010-05-23 10:28:03 +00:00
|
|
|
|
|
|
|
// qfg4 full is SCI2
|
|
|
|
if (getSciVersion() == SCI_VERSION_2)
|
|
|
|
return "qfg4";
|
|
|
|
|
|
|
|
// qfg4 demo has less than 50 scripts
|
|
|
|
if (resources->size() < 50)
|
|
|
|
return "qfg4";
|
|
|
|
|
|
|
|
// Otherwise it's qfg3
|
|
|
|
return "qfg3";
|
|
|
|
}
|
|
|
|
|
|
|
|
return sierraId;
|
|
|
|
}
|
|
|
|
|
2009-08-24 07:57:04 +00:00
|
|
|
#include "sci/detection_tables.h"
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2009-02-19 02:04:31 +00:00
|
|
|
/**
|
|
|
|
* The fallback game descriptor used by the SCI engine's fallbackDetector.
|
2010-02-17 23:36:50 +00:00
|
|
|
* Contents of this struct are overwritten by the fallbackDetector.
|
2009-02-19 02:04:31 +00:00
|
|
|
*/
|
2009-10-09 23:19:53 +00:00
|
|
|
static ADGameDescription s_fallbackDesc = {
|
|
|
|
"",
|
|
|
|
"",
|
|
|
|
AD_ENTRY1(0, 0), // This should always be AD_ENTRY1(0, 0) in the fallback descriptor
|
|
|
|
Common::UNK_LANG,
|
|
|
|
Common::kPlatformPC,
|
|
|
|
ADGF_NO_FLAGS,
|
|
|
|
Common::GUIO_NONE
|
2009-02-19 02:04:31 +00:00
|
|
|
};
|
|
|
|
|
2010-02-17 23:36:50 +00:00
|
|
|
static char s_fallbackGameIdBuf[256];
|
|
|
|
|
2009-02-19 02:04:31 +00:00
|
|
|
|
2009-02-15 08:20:53 +00:00
|
|
|
static const ADParams detectionParams = {
|
2009-02-15 06:10:59 +00:00
|
|
|
// Pointer to ADGameDescription or its superset structure
|
2009-08-24 07:57:04 +00:00
|
|
|
(const byte *)Sci::SciGameDescriptions,
|
2009-02-15 06:10:59 +00:00
|
|
|
// Size of that superset structure
|
2009-10-09 23:19:53 +00:00
|
|
|
sizeof(ADGameDescription),
|
2009-02-15 06:10:59 +00:00
|
|
|
// Number of bytes to compute MD5 sum for
|
|
|
|
5000,
|
|
|
|
// List of all engine targets
|
2010-06-25 16:16:29 +00:00
|
|
|
s_sciGameTitles,
|
2009-02-15 06:10:59 +00:00
|
|
|
// Structure for autoupgrading obsolete targets
|
|
|
|
0,
|
|
|
|
// Name of single gameid (optional)
|
|
|
|
"sci",
|
|
|
|
// List of files for file-based fallback detection (optional)
|
2009-02-18 21:05:05 +00:00
|
|
|
0,
|
2009-02-15 06:10:59 +00:00
|
|
|
// Flags
|
2009-06-06 17:56:41 +00:00
|
|
|
0,
|
|
|
|
// Additional GUI options (for every game}
|
2010-06-14 14:50:23 +00:00
|
|
|
Common::GUIO_NONE,
|
|
|
|
// Maximum directory depth
|
2010-06-15 10:59:23 +00:00
|
|
|
1,
|
|
|
|
// List of directory globs
|
|
|
|
0
|
2009-02-15 06:10:59 +00:00
|
|
|
};
|
|
|
|
|
2009-02-15 08:20:53 +00:00
|
|
|
class SciMetaEngine : public AdvancedMetaEngine {
|
2009-02-15 06:10:59 +00:00
|
|
|
public:
|
2009-02-15 08:20:53 +00:00
|
|
|
SciMetaEngine() : AdvancedMetaEngine(detectionParams) {}
|
2009-02-15 06:10:59 +00:00
|
|
|
|
|
|
|
virtual const char *getName() const {
|
2009-03-30 07:53:32 +00:00
|
|
|
return "SCI Engine [SCI0, SCI01, SCI10, SCI11"
|
|
|
|
#ifdef ENABLE_SCI32
|
|
|
|
", SCI32"
|
|
|
|
#endif
|
|
|
|
"]";
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
|
|
|
|
2009-03-05 12:04:58 +00:00
|
|
|
virtual const char *getOriginalCopyright() const {
|
2009-02-15 06:10:59 +00:00
|
|
|
return "Sierra's Creative Interpreter (C) Sierra Online";
|
|
|
|
}
|
|
|
|
|
2009-02-15 08:20:53 +00:00
|
|
|
virtual bool createInstance(OSystem *syst, Engine **engine, const ADGameDescription *gd) const;
|
2009-02-18 21:05:05 +00:00
|
|
|
const ADGameDescription *fallbackDetect(const Common::FSList &fslist) const;
|
2009-10-11 15:51:43 +00:00
|
|
|
virtual bool hasFeature(MetaEngineFeature f) const;
|
|
|
|
virtual SaveStateList listSaves(const char *target) const;
|
|
|
|
virtual int getMaximumSaveSlot() const;
|
|
|
|
virtual void removeSaveState(const char *target, int slot) const;
|
|
|
|
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const;
|
2009-02-15 06:10:59 +00:00
|
|
|
};
|
|
|
|
|
2009-08-26 00:27:14 +00:00
|
|
|
Common::Language charToScummVMLanguage(const char c) {
|
|
|
|
switch (c) {
|
|
|
|
case 'F':
|
|
|
|
return Common::FR_FRA;
|
|
|
|
case 'S':
|
|
|
|
return Common::ES_ESP;
|
|
|
|
case 'I':
|
|
|
|
return Common::IT_ITA;
|
|
|
|
case 'G':
|
|
|
|
return Common::DE_DEU;
|
|
|
|
case 'J':
|
|
|
|
case 'j':
|
|
|
|
return Common::JA_JPN;
|
|
|
|
case 'P':
|
|
|
|
return Common::PT_BRA;
|
|
|
|
default:
|
|
|
|
return Common::UNK_LANG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-18 21:05:05 +00:00
|
|
|
const ADGameDescription *SciMetaEngine::fallbackDetect(const Common::FSList &fslist) const {
|
2009-02-19 02:04:31 +00:00
|
|
|
bool foundResMap = false;
|
|
|
|
bool foundRes000 = false;
|
2009-02-18 22:20:28 +00:00
|
|
|
|
2009-08-24 13:47:38 +00:00
|
|
|
// Set some defaults
|
2009-10-09 23:19:53 +00:00
|
|
|
s_fallbackDesc.extra = "";
|
|
|
|
s_fallbackDesc.language = Common::EN_ANY;
|
|
|
|
s_fallbackDesc.flags = ADGF_NO_FLAGS;
|
|
|
|
s_fallbackDesc.platform = Common::kPlatformPC; // default to PC platform
|
|
|
|
s_fallbackDesc.gameid = "sci";
|
2009-08-24 13:47:38 +00:00
|
|
|
|
2009-02-18 22:20:28 +00:00
|
|
|
// First grab all filenames
|
|
|
|
for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) {
|
2009-02-20 14:45:28 +00:00
|
|
|
if (file->isDirectory())
|
|
|
|
continue;
|
|
|
|
|
2009-02-18 22:20:28 +00:00
|
|
|
Common::String filename = file->getName();
|
|
|
|
filename.toLowercase();
|
2009-02-20 14:45:28 +00:00
|
|
|
|
2010-05-10 18:29:13 +00:00
|
|
|
if (filename.contains("resource.map") || filename.contains("resmap.00") || filename.contains("Data1")) {
|
2009-02-19 02:04:31 +00:00
|
|
|
foundResMap = true;
|
2009-08-18 10:01:18 +00:00
|
|
|
}
|
2009-02-20 14:45:28 +00:00
|
|
|
|
2009-08-24 13:47:38 +00:00
|
|
|
// Determine if we got a CD version and set the CD flag accordingly, by checking for
|
2009-08-26 10:01:05 +00:00
|
|
|
// resource.aud for SCI1.1 CD games, or audio001.002 for SCI1 CD games. We assume that
|
|
|
|
// the file should be over 10MB, as it contains all the game speech and is usually
|
|
|
|
// around 450MB+. The size check is for some floppy game versions like KQ6 floppy, which
|
|
|
|
// also have a small resource.aud file
|
|
|
|
if (filename.contains("resource.aud") || filename.contains("audio001.002")) {
|
2009-08-24 13:47:38 +00:00
|
|
|
Common::SeekableReadStream *tmpStream = file->createReadStream();
|
|
|
|
if (tmpStream->size() > 10 * 1024 * 1024) {
|
|
|
|
// We got a CD version, so set the CD flag accordingly
|
2009-10-09 23:19:53 +00:00
|
|
|
s_fallbackDesc.flags |= ADGF_CD;
|
|
|
|
s_fallbackDesc.extra = "CD";
|
2009-08-24 13:47:38 +00:00
|
|
|
}
|
|
|
|
delete tmpStream;
|
|
|
|
}
|
|
|
|
|
2009-02-19 02:04:31 +00:00
|
|
|
if (filename.contains("resource.000") || filename.contains("resource.001")
|
|
|
|
|| filename.contains("ressci.000") || filename.contains("ressci.001"))
|
|
|
|
foundRes000 = true;
|
2009-08-26 00:27:14 +00:00
|
|
|
|
2010-05-10 18:29:13 +00:00
|
|
|
// Data1 contains both map and volume for SCI1.1+ Mac games
|
|
|
|
if (filename.contains("Data1")) {
|
|
|
|
foundResMap = foundRes000 = true;
|
|
|
|
s_fallbackDesc.platform = Common::kPlatformMacintosh;
|
|
|
|
}
|
|
|
|
|
2009-08-26 00:27:14 +00:00
|
|
|
// Determine the game platform
|
|
|
|
// The existence of any of these files indicates an Amiga game
|
|
|
|
if (filename.contains("9.pat") || filename.contains("spal") ||
|
|
|
|
filename.contains("patch.005") || filename.contains("bank.001"))
|
2009-10-09 23:19:53 +00:00
|
|
|
s_fallbackDesc.platform = Common::kPlatformAmiga;
|
2009-08-26 00:27:14 +00:00
|
|
|
|
2010-08-02 14:38:20 +00:00
|
|
|
// The existence of 7.pat or patch.200 indicates a Mac game
|
|
|
|
if (filename.contains("7.pat") || filename.contains("patch.200"))
|
2009-10-09 23:19:53 +00:00
|
|
|
s_fallbackDesc.platform = Common::kPlatformMacintosh;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-08-26 00:27:14 +00:00
|
|
|
// The data files for Atari ST versions are the same as their DOS counterparts
|
2009-02-18 22:20:28 +00:00
|
|
|
}
|
2009-02-20 14:45:28 +00:00
|
|
|
|
2009-02-19 02:04:31 +00:00
|
|
|
// If these files aren't found, it can't be SCI
|
2009-08-21 22:25:55 +00:00
|
|
|
if (!foundResMap && !foundRes000) {
|
2009-02-19 02:04:31 +00:00
|
|
|
return 0;
|
2009-08-21 22:25:55 +00:00
|
|
|
}
|
2009-02-20 14:45:28 +00:00
|
|
|
|
2010-06-15 12:15:52 +00:00
|
|
|
ResourceManager *resMan = new ResourceManager();
|
|
|
|
assert(resMan);
|
|
|
|
resMan->addAppropriateSources(fslist);
|
2010-11-09 17:07:34 +00:00
|
|
|
resMan->init(true);
|
2010-06-15 12:15:52 +00:00
|
|
|
// TODO: Add error handling.
|
|
|
|
|
2010-09-18 09:47:18 +00:00
|
|
|
#ifndef ENABLE_SCI32
|
|
|
|
// Is SCI32 compiled in? If not, and this is a SCI32 game,
|
|
|
|
// stop here
|
|
|
|
if (getSciVersion() >= SCI_VERSION_2) {
|
|
|
|
delete resMan;
|
|
|
|
return (const ADGameDescription *)&s_fallbackDesc;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-09-02 12:02:37 +00:00
|
|
|
ViewType gameViews = resMan->getViewType();
|
2009-08-24 13:47:38 +00:00
|
|
|
|
|
|
|
// Have we identified the game views? If not, stop here
|
2010-06-05 14:09:52 +00:00
|
|
|
// Can't be SCI (or unsupported SCI views). Pinball Creep by sierra also uses resource.map/resource.000 files
|
|
|
|
// but doesnt share sci format at all, if we dont return 0 here we will detect this game as SCI
|
2009-08-24 13:47:38 +00:00
|
|
|
if (gameViews == kViewUnknown) {
|
2009-09-02 12:02:37 +00:00
|
|
|
delete resMan;
|
2010-01-17 22:32:53 +00:00
|
|
|
return 0;
|
2009-08-24 13:47:38 +00:00
|
|
|
}
|
|
|
|
|
2009-08-26 00:27:14 +00:00
|
|
|
// Set the platform to Amiga if the game is using Amiga views
|
|
|
|
if (gameViews == kViewAmiga)
|
2009-10-09 23:19:53 +00:00
|
|
|
s_fallbackDesc.platform = Common::kPlatformAmiga;
|
2009-02-18 22:20:28 +00:00
|
|
|
|
2009-08-17 05:55:21 +00:00
|
|
|
// Determine the game id
|
2010-06-02 02:55:55 +00:00
|
|
|
Common::String sierraGameId = resMan->findSierraGameId();
|
|
|
|
|
|
|
|
// If we don't have a game id, the game is not SCI
|
|
|
|
if (sierraGameId.empty()) {
|
|
|
|
delete resMan;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String gameId = convertSierraGameId(sierraGameId, &s_fallbackDesc.flags, resMan);
|
2010-02-17 23:36:50 +00:00
|
|
|
strncpy(s_fallbackGameIdBuf, gameId.c_str(), sizeof(s_fallbackGameIdBuf) - 1);
|
|
|
|
s_fallbackGameIdBuf[sizeof(s_fallbackGameIdBuf) - 1] = 0; // Make sure string is NULL terminated
|
|
|
|
s_fallbackDesc.gameid = s_fallbackGameIdBuf;
|
2009-08-26 00:27:14 +00:00
|
|
|
|
|
|
|
// Try to determine the game language
|
|
|
|
// Load up text 0 and start looking for "#" characters
|
|
|
|
// Non-English versions contain strings like XXXX#YZZZZ
|
|
|
|
// Where XXXX is the English string, #Y a separator indicating the language
|
2009-08-26 00:37:04 +00:00
|
|
|
// (e.g. #G for German) and ZZZZ is the translated text
|
2009-08-26 01:26:56 +00:00
|
|
|
// NOTE: This doesn't work for games which use message instead of text resources
|
2010-01-25 01:39:44 +00:00
|
|
|
// (like, for example, Eco Quest 1 and all SCI1.1 games and newer, e.g. Freddy Pharkas).
|
2009-08-26 10:01:05 +00:00
|
|
|
// As far as we know, these games store the messages of each language in separate
|
|
|
|
// resources, and it's not possible to detect that easily
|
2010-01-06 18:25:43 +00:00
|
|
|
// Also look for "%J" which is used in japanese games
|
2009-09-02 12:02:37 +00:00
|
|
|
Resource *text = resMan->findResource(ResourceId(kResourceTypeText, 0), 0);
|
2009-08-26 00:27:14 +00:00
|
|
|
uint seeker = 0;
|
|
|
|
if (text) {
|
|
|
|
while (seeker < text->size) {
|
2010-01-06 18:25:43 +00:00
|
|
|
if (text->data[seeker] == '#') {
|
|
|
|
if (seeker + 1 < text->size)
|
|
|
|
s_fallbackDesc.language = charToScummVMLanguage(text->data[seeker + 1]);
|
2009-08-26 00:27:14 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-01-06 18:25:43 +00:00
|
|
|
if (text->data[seeker] == '%') {
|
|
|
|
if ((seeker + 1 < text->size) && (text->data[seeker + 1] == 'J')) {
|
|
|
|
s_fallbackDesc.language = charToScummVMLanguage(text->data[seeker + 1]);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-08-26 00:27:14 +00:00
|
|
|
seeker++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-17 05:55:21 +00:00
|
|
|
|
2009-09-01 19:40:29 +00:00
|
|
|
// Fill in extras field
|
2011-01-04 19:46:18 +00:00
|
|
|
|
|
|
|
if (gameId.hasSuffix("sci")) {
|
|
|
|
s_fallbackDesc.extra = "SCI";
|
|
|
|
|
2011-01-04 09:09:56 +00:00
|
|
|
// Differentiate EGA versions from the VGA ones, where needed
|
2011-01-04 19:46:18 +00:00
|
|
|
if (gameViews == kViewEga && s_fallbackDesc.platform != Common::kPlatformAmiga)
|
|
|
|
s_fallbackDesc.extra = "SCI/EGA";
|
|
|
|
} else {
|
2011-01-04 09:09:56 +00:00
|
|
|
if (gameViews == kViewEga && s_fallbackDesc.platform != Common::kPlatformAmiga)
|
|
|
|
s_fallbackDesc.extra = "EGA";
|
|
|
|
}
|
2009-09-01 19:40:29 +00:00
|
|
|
|
2009-09-24 07:18:38 +00:00
|
|
|
// Add "demo" to the description for demos
|
2009-10-09 23:19:53 +00:00
|
|
|
if (s_fallbackDesc.flags & ADGF_DEMO)
|
2011-01-04 19:46:18 +00:00
|
|
|
s_fallbackDesc.extra = (gameId.hasSuffix("sci")) ? "SCI/Demo" : "Demo";
|
2009-09-24 07:18:38 +00:00
|
|
|
|
2010-06-05 19:55:03 +00:00
|
|
|
delete resMan;
|
|
|
|
|
2009-08-15 12:09:47 +00:00
|
|
|
return (const ADGameDescription *)&s_fallbackDesc;
|
2009-02-18 21:05:05 +00:00
|
|
|
}
|
|
|
|
|
2010-06-25 16:16:29 +00:00
|
|
|
bool SciMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
|
|
|
|
const GameIdStrToEnum *g = s_gameIdStrToEnum;
|
|
|
|
for (; g->gameidStr; ++g) {
|
|
|
|
if (0 == strcmp(desc->gameid, g->gameidStr)) {
|
|
|
|
*engine = new SciEngine(syst, desc, g->gameidEnum);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2009-02-15 06:10:59 +00:00
|
|
|
|
2010-06-25 16:16:29 +00:00
|
|
|
return false;
|
2009-02-15 06:10:59 +00:00
|
|
|
}
|
|
|
|
|
2009-10-11 15:51:43 +00:00
|
|
|
bool SciMetaEngine::hasFeature(MetaEngineFeature f) const {
|
|
|
|
return
|
|
|
|
(f == kSupportsListSaves) ||
|
2010-01-21 22:20:16 +00:00
|
|
|
(f == kSupportsLoadingDuringStartup) ||
|
2009-10-11 15:51:43 +00:00
|
|
|
(f == kSupportsDeleteSave) ||
|
|
|
|
(f == kSavesSupportMetaInfo) ||
|
|
|
|
(f == kSavesSupportThumbnail) ||
|
2010-10-31 01:45:24 +00:00
|
|
|
(f == kSavesSupportCreationDate) ||
|
|
|
|
(f == kSavesSupportPlayTime);
|
2009-10-11 15:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SciEngine::hasFeature(EngineFeature f) const {
|
|
|
|
return
|
2010-08-01 13:11:24 +00:00
|
|
|
(f == kSupportsRTL) ||
|
2010-07-18 14:21:38 +00:00
|
|
|
(f == kSupportsLoadingDuringRuntime); // ||
|
|
|
|
//(f == kSupportsSavingDuringRuntime);
|
2010-07-18 19:19:49 +00:00
|
|
|
// We can't allow saving through ScummVM menu, because
|
|
|
|
// a) lots of games don't like saving everywhere (e.g. castle of dr. brain)
|
|
|
|
// b) some games even dont allow saving in certain rooms (e.g. lsl6)
|
|
|
|
// c) somehow some games even get mad when doing this (execstackbase was 1 all of a sudden in lsl3)
|
|
|
|
// d) for sci0/sci01 games we should at least wait till status bar got drawn, although this may not be enough
|
|
|
|
// we can't make sure that the scripts are fine with us saving at a specific location, doing so may work sometimes
|
|
|
|
// and some other times it won't work.
|
2009-10-11 15:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SaveStateList SciMetaEngine::listSaves(const char *target) const {
|
|
|
|
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
|
2010-03-18 15:54:40 +00:00
|
|
|
Common::StringArray filenames;
|
2009-10-11 15:51:43 +00:00
|
|
|
Common::String pattern = target;
|
|
|
|
pattern += ".???";
|
|
|
|
|
|
|
|
filenames = saveFileMan->listSavefiles(pattern);
|
|
|
|
sort(filenames.begin(), filenames.end()); // Sort (hopefully ensuring we are sorted numerically..)
|
|
|
|
|
|
|
|
SaveStateList saveList;
|
|
|
|
int slotNum = 0;
|
2010-03-18 15:54:40 +00:00
|
|
|
for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); ++file) {
|
2009-10-11 15:51:43 +00:00
|
|
|
// Obtain the last 3 digits of the filename, since they correspond to the save slot
|
|
|
|
slotNum = atoi(file->c_str() + file->size() - 3);
|
|
|
|
|
2010-08-24 09:05:54 +00:00
|
|
|
if (slotNum >= 0 && slotNum <= 99) {
|
2009-10-11 15:51:43 +00:00
|
|
|
Common::InSaveFile *in = saveFileMan->openForLoading(*file);
|
|
|
|
if (in) {
|
|
|
|
SavegameMetadata meta;
|
|
|
|
if (!get_savegame_metadata(in, &meta)) {
|
|
|
|
// invalid
|
|
|
|
delete in;
|
|
|
|
continue;
|
|
|
|
}
|
2010-10-31 01:45:24 +00:00
|
|
|
saveList.push_back(SaveStateDescriptor(slotNum, meta.name));
|
2009-10-11 15:51:43 +00:00
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return saveList;
|
|
|
|
}
|
|
|
|
|
|
|
|
SaveStateDescriptor SciMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
|
2010-11-01 16:02:28 +00:00
|
|
|
Common::String fileName = Common::String::format("%s.%03d", target, slot);
|
2009-10-11 15:51:43 +00:00
|
|
|
Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fileName);
|
|
|
|
|
|
|
|
if (in) {
|
|
|
|
SavegameMetadata meta;
|
|
|
|
if (!get_savegame_metadata(in, &meta)) {
|
|
|
|
// invalid
|
|
|
|
delete in;
|
|
|
|
|
|
|
|
SaveStateDescriptor desc(slot, "Invalid");
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
2010-10-31 01:45:24 +00:00
|
|
|
SaveStateDescriptor desc(slot, meta.name);
|
2009-10-11 15:51:43 +00:00
|
|
|
|
|
|
|
Graphics::Surface *thumbnail = new Graphics::Surface();
|
|
|
|
assert(thumbnail);
|
|
|
|
if (!Graphics::loadThumbnail(*in, *thumbnail)) {
|
|
|
|
delete thumbnail;
|
|
|
|
thumbnail = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
desc.setThumbnail(thumbnail);
|
|
|
|
|
|
|
|
desc.setDeletableFlag(true);
|
|
|
|
desc.setWriteProtectedFlag(false);
|
|
|
|
|
2010-10-31 01:45:24 +00:00
|
|
|
int day = (meta.saveDate >> 24) & 0xFF;
|
|
|
|
int month = (meta.saveDate >> 16) & 0xFF;
|
|
|
|
int year = meta.saveDate & 0xFFFF;
|
2009-10-11 15:51:43 +00:00
|
|
|
|
|
|
|
desc.setSaveDate(year, month, day);
|
|
|
|
|
2010-10-31 01:45:24 +00:00
|
|
|
int hour = (meta.saveTime >> 16) & 0xFF;
|
|
|
|
int minutes = (meta.saveTime >> 8) & 0xFF;
|
2009-10-11 15:51:43 +00:00
|
|
|
|
|
|
|
desc.setSaveTime(hour, minutes);
|
|
|
|
|
2010-10-31 01:45:24 +00:00
|
|
|
desc.setPlayTime(meta.playTime * 1000);
|
2009-10-11 15:51:43 +00:00
|
|
|
|
|
|
|
delete in;
|
|
|
|
|
|
|
|
return desc;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SaveStateDescriptor();
|
|
|
|
}
|
|
|
|
|
2010-08-24 09:05:54 +00:00
|
|
|
int SciMetaEngine::getMaximumSaveSlot() const { return 99; }
|
2009-10-11 15:51:43 +00:00
|
|
|
|
|
|
|
void SciMetaEngine::removeSaveState(const char *target, int slot) const {
|
2010-11-01 16:02:28 +00:00
|
|
|
Common::String fileName = Common::String::format("%s.%03d", target, slot);
|
2009-10-11 15:51:43 +00:00
|
|
|
g_system->getSavefileManager()->removeSavefile(fileName);
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error SciEngine::loadGameState(int slot) {
|
2010-11-01 16:02:28 +00:00
|
|
|
Common::String fileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
|
2009-10-11 15:51:43 +00:00
|
|
|
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
|
|
|
|
Common::SeekableReadStream *in = saveFileMan->openForLoading(fileName);
|
|
|
|
|
|
|
|
if (in) {
|
|
|
|
// found a savegame file
|
2010-01-31 01:26:06 +00:00
|
|
|
gamestate_restore(_gamestate, in);
|
2009-10-11 15:51:43 +00:00
|
|
|
delete in;
|
|
|
|
}
|
|
|
|
|
2010-01-31 01:26:06 +00:00
|
|
|
if (_gamestate->r_acc != make_reg(0, 1)) {
|
2009-10-11 15:51:43 +00:00
|
|
|
return Common::kNoError;
|
|
|
|
} else {
|
2009-10-13 20:52:05 +00:00
|
|
|
warning("Restoring gamestate '%s' failed", fileName.c_str());
|
2009-10-11 15:51:43 +00:00
|
|
|
return Common::kUnknownError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error SciEngine::saveGameState(int slot, const char *desc) {
|
2010-11-01 16:02:28 +00:00
|
|
|
Common::String fileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
|
2009-10-11 15:51:43 +00:00
|
|
|
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
|
|
|
|
Common::OutSaveFile *out = saveFileMan->openForSaving(fileName);
|
|
|
|
const char *version = "";
|
|
|
|
if (!out) {
|
2010-01-31 10:02:38 +00:00
|
|
|
warning("Opening savegame \"%s\" for writing failed", fileName.c_str());
|
2009-10-11 15:51:43 +00:00
|
|
|
return Common::kWritingFailed;
|
|
|
|
}
|
|
|
|
|
2010-06-15 08:39:03 +00:00
|
|
|
if (!gamestate_save(_gamestate, out, desc, version)) {
|
2010-01-31 10:02:38 +00:00
|
|
|
warning("Saving the game state to '%s' failed", fileName.c_str());
|
2010-01-31 08:28:10 +00:00
|
|
|
return Common::kWritingFailed;
|
|
|
|
} else {
|
|
|
|
out->finalize();
|
|
|
|
if (out->err()) {
|
2010-09-18 10:55:16 +00:00
|
|
|
warning("Writing the savegame failed");
|
2010-01-31 08:28:10 +00:00
|
|
|
return Common::kWritingFailed;
|
|
|
|
}
|
|
|
|
delete out;
|
2009-10-11 15:51:43 +00:00
|
|
|
}
|
2010-01-31 08:28:10 +00:00
|
|
|
|
|
|
|
return Common::kNoError;
|
2009-10-11 15:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SciEngine::canLoadGameStateCurrently() {
|
2010-06-10 11:18:10 +00:00
|
|
|
return !_gamestate->executionStackBase;
|
2009-10-11 15:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool SciEngine::canSaveGameStateCurrently() {
|
2010-06-10 11:18:10 +00:00
|
|
|
return !_gamestate->executionStackBase;
|
2009-10-11 15:51:43 +00:00
|
|
|
}
|
|
|
|
|
2009-02-20 14:45:28 +00:00
|
|
|
} // End of namespace Sci
|
|
|
|
|
2009-02-15 06:10:59 +00:00
|
|
|
#if PLUGIN_ENABLED_DYNAMIC(SCI)
|
2009-02-20 14:45:28 +00:00
|
|
|
REGISTER_PLUGIN_DYNAMIC(SCI, PLUGIN_TYPE_ENGINE, Sci::SciMetaEngine);
|
2009-02-15 06:10:59 +00:00
|
|
|
#else
|
2009-02-20 14:45:28 +00:00
|
|
|
REGISTER_PLUGIN_STATIC(SCI, PLUGIN_TYPE_ENGINE, Sci::SciMetaEngine);
|
2009-02-15 06:10:59 +00:00
|
|
|
#endif
|