2004-04-12 21:40:49 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2004-2006 The ScummVM project
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
* The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
|
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
2006-02-11 12:44:16 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-04-12 21:40:49 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2004-05-01 09:07:31 +00:00
|
|
|
// Game detection, general game parameters
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2004-08-02 16:20:35 +00:00
|
|
|
#include "saga/saga.h"
|
2004-12-22 19:34:41 +00:00
|
|
|
|
2004-04-23 11:40:51 +00:00
|
|
|
#include "common/file.h"
|
2006-06-24 08:07:48 +00:00
|
|
|
#include "common/fs.h"
|
2005-10-14 04:28:20 +00:00
|
|
|
#include "common/config-manager.h"
|
2006-10-02 22:21:57 +00:00
|
|
|
#include "common/advancedDetector.h"
|
2004-05-01 23:42:22 +00:00
|
|
|
#include "base/plugins.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-07-19 19:05:52 +00:00
|
|
|
#include "saga/rscfile.h"
|
2004-08-06 01:39:17 +00:00
|
|
|
#include "saga/interface.h"
|
2004-08-11 23:42:02 +00:00
|
|
|
#include "saga/scene.h"
|
2006-05-13 10:30:38 +00:00
|
|
|
#include "saga/sagaresnames.h"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-08-10 18:27:18 +00:00
|
|
|
|
2006-03-09 14:33:07 +00:00
|
|
|
namespace Saga {
|
2006-03-27 16:56:08 +00:00
|
|
|
static DetectedGameList GAME_detectGames(const FSList &fslist);
|
2006-03-09 14:33:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const PlainGameDescriptor saga_games[] = {
|
|
|
|
{"ite", "Inherit the Earth: Quest for the Orb"},
|
|
|
|
{"ihnm", "I Have No Mouth and I Must Scream"},
|
|
|
|
{0, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
GameList Engine_SAGA_gameIDList() {
|
|
|
|
GameList games;
|
|
|
|
const PlainGameDescriptor *g = saga_games;
|
|
|
|
|
|
|
|
while (g->gameid) {
|
|
|
|
games.push_back(*g);
|
|
|
|
g++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return games;
|
|
|
|
}
|
|
|
|
|
|
|
|
GameDescriptor Engine_SAGA_findGameID(const char *gameid) {
|
|
|
|
const PlainGameDescriptor *g = saga_games;
|
|
|
|
while (g->gameid) {
|
|
|
|
if (0 == scumm_stricmp(gameid, g->gameid))
|
|
|
|
break;
|
|
|
|
g++;
|
|
|
|
}
|
|
|
|
return *g;
|
|
|
|
}
|
|
|
|
|
|
|
|
DetectedGameList Engine_SAGA_detectGames(const FSList &fslist) {
|
2006-03-27 16:56:08 +00:00
|
|
|
return Saga::GAME_detectGames(fslist);
|
2006-03-09 14:33:07 +00:00
|
|
|
}
|
|
|
|
|
2006-04-29 00:27:20 +00:00
|
|
|
PluginError Engine_SAGA_create(OSystem *syst, Engine **engine) {
|
2006-08-26 11:33:15 +00:00
|
|
|
assert(syst);
|
2006-04-29 00:27:20 +00:00
|
|
|
assert(engine);
|
2006-08-26 11:33:15 +00:00
|
|
|
|
|
|
|
FSList fslist;
|
|
|
|
FilesystemNode dir(ConfMan.get("path"));
|
|
|
|
if (!dir.listDir(fslist, FilesystemNode::kListFilesOnly)) {
|
|
|
|
warning("SagaEngine: invalid game path '%s'", dir.path().c_str());
|
|
|
|
return kInvalidPathError;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Invoke the detector
|
|
|
|
Common::String gameid = ConfMan.get("gameid");
|
|
|
|
DetectedGameList detectedGames = Engine_SAGA_detectGames(fslist);
|
|
|
|
|
|
|
|
for (uint i = 0; i < detectedGames.size(); i++) {
|
|
|
|
if (detectedGames[i].gameid == gameid) {
|
|
|
|
*engine = new Saga::SagaEngine(syst);
|
|
|
|
return kNoError;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
warning("SagaEngine: Unable to locate game data at path '%s'", dir.path().c_str());
|
|
|
|
return kNoGameDataFoundError;
|
2006-03-09 14:33:07 +00:00
|
|
|
}
|
|
|
|
|
2006-07-31 13:41:21 +00:00
|
|
|
REGISTER_PLUGIN(SAGA, "SAGA Engine", "Inherit the Earth (C) Wyrmkeep Entertainment");
|
2006-03-09 14:33:07 +00:00
|
|
|
|
2004-04-12 21:40:49 +00:00
|
|
|
namespace Saga {
|
2006-10-02 22:21:57 +00:00
|
|
|
|
|
|
|
using Common::ADGameFileDescription;
|
|
|
|
using Common::ADGameDescription;
|
|
|
|
|
2006-05-13 10:30:38 +00:00
|
|
|
#include "sagagame.cpp"
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2006-10-02 23:31:14 +00:00
|
|
|
DetectedGame toDetectedGame(const SAGAGameDescription &g) {
|
2006-03-27 16:56:08 +00:00
|
|
|
const char *title;
|
2006-04-16 13:12:23 +00:00
|
|
|
title = saga_games[g.gameType].description;
|
2006-10-02 23:31:14 +00:00
|
|
|
DetectedGame dg(g.desc.name, title, g.desc.language, g.desc.platform);
|
|
|
|
dg.updateDesc(g.desc.extra);
|
2006-03-14 13:28:28 +00:00
|
|
|
return dg;
|
|
|
|
}
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
bool SagaEngine::initGame() {
|
|
|
|
uint16 gameCount = ARRAYSIZE(gameDescriptions);
|
|
|
|
int gameNumber = -1;
|
|
|
|
|
|
|
|
DetectedGameList detectedGames;
|
2006-10-02 22:21:57 +00:00
|
|
|
Common::AdvancedDetector AdvDetector;
|
|
|
|
Common::ADList matches;
|
|
|
|
Common::ADGameDescList descList;
|
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
Common::Language language = Common::UNK_LANG;
|
|
|
|
Common::Platform platform = Common::kPlatformUnknown;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
if (ConfMan.hasKey("language"))
|
|
|
|
language = Common::parseLanguage(ConfMan.get("language"));
|
|
|
|
if (ConfMan.hasKey("platform"))
|
|
|
|
platform = Common::parsePlatform(ConfMan.get("platform"));
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2005-01-02 20:29:27 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
2006-10-24 09:44:20 +00:00
|
|
|
descList.push_back((const 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);
|
2004-05-01 23:42:22 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
if (matches.size() == 0) {
|
2006-03-27 16:56:08 +00:00
|
|
|
warning("No valid games were found in the specified directory.");
|
|
|
|
return false;
|
2004-12-24 13:01:47 +00:00
|
|
|
}
|
2004-05-01 23:42:22 +00:00
|
|
|
|
2006-10-02 22:21:57 +00:00
|
|
|
if (matches.size() != 1)
|
|
|
|
warning("Conflicting targets detected (%d)", matches.size());
|
2004-05-01 23:42:22 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
gameNumber = matches[0];
|
2004-12-24 13:01:47 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
if (gameNumber >= gameCount || gameNumber == -1) {
|
|
|
|
error("SagaEngine::loadGame wrong gameNumber");
|
|
|
|
}
|
2004-12-24 13:01:47 +00:00
|
|
|
|
2006-10-02 23:31:14 +00:00
|
|
|
_gameTitle = toDetectedGame(gameDescriptions[gameNumber]).description;
|
2006-03-27 16:56:08 +00:00
|
|
|
debug(2, "Running %s", _gameTitle.c_str());
|
2004-12-24 13:01:47 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
_gameNumber = gameNumber;
|
|
|
|
_gameDescription = &gameDescriptions[gameNumber];
|
|
|
|
_gameDisplayInfo = *_gameDescription->gameDisplayInfo;
|
|
|
|
_displayClip.right = _gameDisplayInfo.logicalWidth;
|
|
|
|
_displayClip.bottom = _gameDisplayInfo.logicalHeight;
|
2004-12-24 13:01:47 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
if (!_resource->createContexts()) {
|
|
|
|
return false;
|
2004-05-01 23:42:22 +00:00
|
|
|
}
|
2006-03-27 16:56:08 +00:00
|
|
|
return true;
|
|
|
|
}
|
2004-05-01 23:42:22 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
for (int i = 0; i < ARRAYSIZE(gameDescriptions); i++)
|
2006-10-24 09:44:20 +00:00
|
|
|
descList.push_back((const 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]]));
|
2006-10-02 22:21:57 +00:00
|
|
|
//delete matches;
|
2004-04-12 21:40:49 +00:00
|
|
|
|
2006-03-27 16:56:08 +00:00
|
|
|
return detectedGames;
|
2004-04-12 21:40:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Saga
|