2005-11-12 06:01:24 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-05-05 00:42:37 +00:00
|
|
|
* Copyright (C) 2001 Ludvig Strigeus
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2001-2006 The ScummVM project
|
2005-11-12 06:01:24 +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.
|
|
|
|
*
|
2006-02-11 12:46:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2005-11-12 06:01:24 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/stdafx.h"
|
|
|
|
|
|
|
|
#include "base/plugins.h"
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
|
|
|
#include "common/file.h"
|
2006-06-24 08:07:48 +00:00
|
|
|
#include "common/fs.h"
|
2005-11-12 06:01:24 +00:00
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
#include "agos/agos.h"
|
2006-03-09 14:30:43 +00:00
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
namespace AGOS {
|
2006-03-28 13:33:18 +00:00
|
|
|
static DetectedGameList GAME_detectGames(const FSList &fslist);
|
2006-03-09 14:30:43 +00:00
|
|
|
}
|
|
|
|
|
2005-11-12 06:01:24 +00:00
|
|
|
using Common::File;
|
|
|
|
|
2006-03-09 14:30:43 +00:00
|
|
|
struct ObsoleteGameID {
|
|
|
|
const char *from;
|
|
|
|
const char *to;
|
|
|
|
Common::Platform platform;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Conversion table mapping old obsolete target names to the
|
|
|
|
* corresponding new target and platform combination.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static const ObsoleteGameID obsoleteGameIDsTable[] = {
|
|
|
|
{"simon1acorn", "simon1", Common::kPlatformAcorn},
|
|
|
|
{"simon1amiga", "simon1", Common::kPlatformAmiga},
|
|
|
|
{"simon1cd32", "simon1", Common::kPlatformAmiga},
|
2006-05-04 06:55:35 +00:00
|
|
|
{"simon1demo", "simon1", Common::kPlatformPC},
|
2006-03-09 14:30:43 +00:00
|
|
|
{"simon1dos", "simon1", Common::kPlatformPC},
|
|
|
|
{"simon1talkie", "simon1", Common::kPlatformPC},
|
|
|
|
{"simon1win", "simon1", Common::kPlatformWindows},
|
|
|
|
{"simon2dos", "simon2", Common::kPlatformPC},
|
|
|
|
{"simon2talkie", "simon2", Common::kPlatformPC},
|
|
|
|
{"simon2mac", "simon2", Common::kPlatformMacintosh},
|
|
|
|
{"simon2win", "simon2", Common::kPlatformWindows},
|
|
|
|
{NULL, NULL, Common::kPlatformUnknown}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const PlainGameDescriptor simonGames[] = {
|
2006-10-06 05:17:54 +00:00
|
|
|
{"elvira1", "Elvira - Mistress of the Dark"},
|
2006-10-06 09:21:34 +00:00
|
|
|
{"elvira2", "Elvira II - The Jaws of Cerberus"},
|
2006-09-29 03:44:55 +00:00
|
|
|
{"waxworks", "Waxworks"},
|
|
|
|
{"simon1", "Simon the Sorcerer 1"},
|
|
|
|
{"simon2", "Simon the Sorcerer 2"},
|
|
|
|
{"feeble", "The Feeble Files"},
|
2006-09-29 05:33:22 +00:00
|
|
|
{"dimp", "Demon in my Pocket"},
|
2006-09-28 23:22:07 +00:00
|
|
|
{"jumble", "Jumble"},
|
2006-09-29 04:48:04 +00:00
|
|
|
{"puzzle", "NoPatience"},
|
2006-09-28 23:22:07 +00:00
|
|
|
{"swampy", "Swampy Adventures"},
|
2006-03-09 14:30:43 +00:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
GameList Engine_AGOS_gameIDList() {
|
2006-03-09 14:30:43 +00:00
|
|
|
GameList games;
|
|
|
|
const PlainGameDescriptor *g = simonGames;
|
|
|
|
while (g->gameid) {
|
|
|
|
games.push_back(*g);
|
|
|
|
g++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return games;
|
|
|
|
}
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
GameDescriptor Engine_AGOS_findGameID(const char *gameid) {
|
2006-03-09 14:30:43 +00:00
|
|
|
// First search the list of supported game IDs.
|
|
|
|
const PlainGameDescriptor *g = simonGames;
|
|
|
|
while (g->gameid) {
|
2006-09-19 11:59:13 +00:00
|
|
|
if (!scumm_stricmp(gameid, g->gameid))
|
2006-03-09 14:30:43 +00:00
|
|
|
return *g;
|
|
|
|
g++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If we didn't find the gameid in the main list, check if it
|
|
|
|
// is an obsolete game id.
|
|
|
|
GameDescriptor gs;
|
|
|
|
const ObsoleteGameID *o = obsoleteGameIDsTable;
|
|
|
|
while (o->from) {
|
|
|
|
if (0 == scumm_stricmp(gameid, o->from)) {
|
|
|
|
gs.gameid = gameid;
|
|
|
|
gs.description = "Obsolete game ID";
|
|
|
|
return gs;
|
|
|
|
}
|
|
|
|
o++;
|
|
|
|
}
|
|
|
|
return gs;
|
|
|
|
}
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
DetectedGameList Engine_AGOS_detectGames(const FSList &fslist) {
|
2006-09-29 09:44:30 +00:00
|
|
|
return AGOS::GAME_detectGames(fslist);
|
2006-03-09 14:30:43 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
PluginError Engine_AGOS_create(OSystem *syst, Engine **engine) {
|
2006-08-26 11:25:08 +00:00
|
|
|
assert(syst);
|
|
|
|
assert(engine);
|
2006-04-15 17:39:14 +00:00
|
|
|
const char *gameid = ConfMan.get("gameid").c_str();
|
2006-03-09 14:30:43 +00:00
|
|
|
|
2006-04-15 17:39:14 +00:00
|
|
|
for (const ObsoleteGameID *o = obsoleteGameIDsTable; o->from; ++o) {
|
|
|
|
if (!scumm_stricmp(gameid, o->from)) {
|
|
|
|
// Match found, perform upgrade
|
|
|
|
gameid = o->to;
|
2006-03-09 14:30:43 +00:00
|
|
|
ConfMan.set("gameid", o->to);
|
|
|
|
|
|
|
|
if (o->platform != Common::kPlatformUnknown)
|
|
|
|
ConfMan.set("platform", Common::getPlatformCode(o->platform));
|
|
|
|
|
|
|
|
warning("Target upgraded from %s to %s", o->from, o->to);
|
|
|
|
ConfMan.flushToDisk();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-08-26 11:25:08 +00:00
|
|
|
FSList fslist;
|
|
|
|
FilesystemNode dir(ConfMan.get("path"));
|
|
|
|
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
2006-09-29 09:44:30 +00:00
|
|
|
warning("AGOSEngine: invalid game path '%s'", dir.path().c_str());
|
2006-08-26 11:25:08 +00:00
|
|
|
return kInvalidPathError;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Invoke the detector
|
2006-09-29 08:14:27 +00:00
|
|
|
DetectedGameList detectedGames = Engine_AGOS_detectGames(fslist);
|
2006-08-26 11:25:08 +00:00
|
|
|
|
|
|
|
for (uint i = 0; i < detectedGames.size(); i++) {
|
|
|
|
if (detectedGames[i].gameid == gameid) {
|
2006-09-29 09:44:30 +00:00
|
|
|
*engine = new AGOS::AGOSEngine(syst);
|
2006-08-26 11:25:08 +00:00
|
|
|
return kNoError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
warning("AGOSEngine: Unable to locate game data at path '%s'", dir.path().c_str());
|
2006-08-26 11:25:08 +00:00
|
|
|
return kNoGameDataFoundError;
|
2006-03-09 14:30:43 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 08:14:27 +00:00
|
|
|
REGISTER_PLUGIN(AGOS, "AGOS", "AGOS (C) Adventure Soft");
|
2006-03-09 14:30:43 +00:00
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
namespace AGOS {
|
2005-11-12 06:01:24 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
using Common::ADGameFileDescription;
|
|
|
|
using Common::ADGameDescription;
|
|
|
|
|
2006-10-19 12:14:53 +00:00
|
|
|
#include "agosgame.cpp"
|
2005-11-12 06:01:24 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
DetectedGame toDetectedGame(const ADGameDescription &g) {
|
2006-10-01 10:56:12 +00:00
|
|
|
const char *title = 0;
|
2006-09-29 03:44:55 +00:00
|
|
|
|
|
|
|
const PlainGameDescriptor *sg = simonGames;
|
|
|
|
while (sg->gameid) {
|
|
|
|
if (!scumm_stricmp(g.name, sg->gameid))
|
|
|
|
title = sg->description;
|
|
|
|
sg++;
|
|
|
|
}
|
|
|
|
|
2006-04-16 13:12:23 +00:00
|
|
|
DetectedGame dg(g.name, title, g.language, g.platform);
|
|
|
|
dg.updateDesc(g.extra);
|
2006-03-25 19:46:58 +00:00
|
|
|
return dg;
|
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
bool AGOSEngine::initGame() {
|
2006-03-28 13:33:18 +00:00
|
|
|
int gameNumber = -1;
|
|
|
|
|
|
|
|
DetectedGameList detectedGames;
|
2006-10-02 22:21:57 +00:00
|
|
|
Common::AdvancedDetector AdvDetector;
|
|
|
|
Common::ADList matches;
|
|
|
|
Common::ADGameDescList descList;
|
|
|
|
|
2006-03-28 13:33:18 +00:00
|
|
|
Common::Language language = Common::UNK_LANG;
|
|
|
|
Common::Platform platform = Common::kPlatformUnknown;
|
|
|
|
|
|
|
|
if (ConfMan.hasKey("language"))
|
|
|
|
language = Common::parseLanguage(ConfMan.get("language"));
|
|
|
|
if (ConfMan.hasKey("platform"))
|
|
|
|
platform = Common::parsePlatform(ConfMan.get("platform"));
|
|
|
|
|
2006-09-29 18:20:44 +00:00
|
|
|
Common::String gameid = ConfMan.get("gameid");
|
2006-03-28 13:33:18 +00:00
|
|
|
|
2006-09-29 18:20:44 +00:00
|
|
|
// At this point, Engine_AGOS_create() has already verified that the
|
|
|
|
// desired game is in the specified directory. But we've already
|
|
|
|
// forgotten which particular version it was, so we have to do it all
|
|
|
|
// over again...
|
2005-11-12 06:01:24 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
2006-10-02 23:31:14 +00:00
|
|
|
descList.push_back((ADGameDescription *)&gameDescriptions[i]);
|
2006-10-02 22:21:57 +00:00
|
|
|
|
|
|
|
AdvDetector.registerGameDescriptions(descList);
|
|
|
|
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
|
|
|
|
|
|
|
matches = AdvDetector.detectGame(NULL, language, platform);
|
2006-03-28 13:33:18 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
for (uint i = 0; i < matches.size(); i++) {
|
2006-10-02 23:31:14 +00:00
|
|
|
if (toDetectedGame(gameDescriptions[matches[i]].desc).gameid == gameid) {
|
2006-09-29 18:20:44 +00:00
|
|
|
gameNumber = matches[i];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2006-03-28 13:33:18 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
//delete &matches;
|
2006-03-28 13:33:18 +00:00
|
|
|
|
2006-10-08 00:41:29 +00:00
|
|
|
if (gameNumber >= ARRAYSIZE(gameDescriptions) || gameNumber == -1) {
|
2006-09-29 09:44:30 +00:00
|
|
|
error("AGOSEngine::loadGame wrong gameNumber");
|
2006-03-28 13:33:18 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 23:31:14 +00:00
|
|
|
debug(2, "Running %s", toDetectedGame(gameDescriptions[gameNumber].desc).description.c_str());
|
2006-03-28 13:33:18 +00:00
|
|
|
|
|
|
|
_gameDescription = &gameDescriptions[gameNumber];
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DetectedGameList GAME_detectGames(const FSList &fslist) {
|
|
|
|
DetectedGameList detectedGames;
|
2006-10-02 22:21:57 +00:00
|
|
|
Common::AdvancedDetector AdvDetector;
|
|
|
|
Common::ADList matches;
|
|
|
|
Common::ADGameDescList descList;
|
2006-03-28 13:33:18 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
2006-10-02 23:31:14 +00:00
|
|
|
descList.push_back((ADGameDescription *)&gameDescriptions[i]);
|
2006-10-02 22:21:57 +00:00
|
|
|
|
|
|
|
AdvDetector.registerGameDescriptions(descList);
|
|
|
|
AdvDetector.setFileMD5Bytes(FILE_MD5_BYTES);
|
|
|
|
|
|
|
|
matches = AdvDetector.detectGame(&fslist, Common::UNK_LANG, Common::kPlatformUnknown);
|
|
|
|
|
|
|
|
for (uint i = 0; i < matches.size(); i++)
|
2006-10-02 23:31:14 +00:00
|
|
|
detectedGames.push_back(toDetectedGame(gameDescriptions[matches[i]].desc));
|
2006-10-02 22:21:57 +00:00
|
|
|
|
|
|
|
//delete &matches;
|
2006-03-28 13:33:18 +00:00
|
|
|
return detectedGames;
|
2005-11-12 06:01:24 +00:00
|
|
|
}
|
|
|
|
|
2006-09-29 09:44:30 +00:00
|
|
|
} // End of namespace AGOS
|