- Renamed GameSettings to PlainGameDescriptor

- Added new GameDescriptor struct (similar to PlainGameDescriptor but with
  Common::String members instead of const char * ones)
- Changed DetectedGame to subclass GameDescriptor
- Removed toGameSettings() in favor of new (template) constructors in
  DetectedGame and GameDescriptor
- Fixed a bug in the obsolete gameid handling in the SCUMM & SIMON engines

svn-id: r21150
This commit is contained in:
Max Horn 2006-03-09 02:52:51 +00:00
parent d2f78184af
commit 86565fcca5
17 changed files with 126 additions and 131 deletions

View file

@ -239,7 +239,7 @@ void listGames() {
for (iter = plugins.begin(); iter != plugins.end(); ++iter) { for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
GameList list = (*iter)->getSupportedGames(); GameList list = (*iter)->getSupportedGames();
for (GameList::iterator v = list.begin(); v != list.end(); ++v) { for (GameList::iterator v = list.begin(); v != list.end(); ++v) {
printf("%-20s %s\n", v->gameid, v->description); printf("%-20s %s\n", v->gameid.c_str(), v->description.c_str());
} }
} }
} }
@ -262,8 +262,8 @@ void listTargets() {
// to find the proper desc. In fact, the platform probably should // to find the proper desc. In fact, the platform probably should
// be taken into account, too. // be taken into account, too.
String gameid(name); String gameid(name);
GameSettings g = GameDetector::findGame(gameid); GameDescriptor g = GameDetector::findGame(gameid);
if (g.description) if (g.description.size() > 0)
description = g.description; description = g.description;
} }
@ -271,15 +271,15 @@ void listTargets() {
} }
} }
GameSettings GameDetector::findGame(const String &gameName, const Plugin **plugin) { GameDescriptor GameDetector::findGame(const String &gameName, const Plugin **plugin) {
// Find the GameSettings for this target // Find the GameDescriptor for this target
const PluginList &plugins = PluginManager::instance().getPlugins(); const PluginList &plugins = PluginManager::instance().getPlugins();
GameSettings result = {NULL, NULL}; GameDescriptor result;
PluginList::const_iterator iter = plugins.begin(); PluginList::const_iterator iter = plugins.begin();
for (iter = plugins.begin(); iter != plugins.end(); ++iter) { for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
result = (*iter)->findGame(gameName.c_str()); result = (*iter)->findGame(gameName.c_str());
if (result.gameid) { if (result.gameid.size() > 0) {
if (plugin) if (plugin)
*plugin = *iter; *plugin = *iter;
break; break;
@ -384,7 +384,7 @@ void GameDetector::parseCommandLine(int argc, char **argv) {
// To verify this, check if there is either a game domain (i.e. // To verify this, check if there is either a game domain (i.e.
// a configured target) matching this argument, or if we can // a configured target) matching this argument, or if we can
// find any target with that name. // find any target with that name.
if (i == (argc - 1) && (ConfMan.hasGameDomain(s) || findGame(s).gameid)) { if (i == (argc - 1) && (ConfMan.hasGameDomain(s) || findGame(s).gameid.size() > 0)) {
setTarget(s); setTarget(s);
} else { } else {
if (current_option == NULL) if (current_option == NULL)
@ -641,15 +641,15 @@ bool GameDetector::detectMain() {
_gameid = _targetName; _gameid = _targetName;
printf("Looking for %s\n", _gameid.c_str()); printf("Looking for %s\n", _gameid.c_str());
GameSettings game = findGame(_gameid, &_plugin); GameDescriptor game = findGame(_gameid, &_plugin);
if (!game.gameid) { if (game.gameid.size() == 0) {
printf("Failed game detection\n"); printf("Failed game detection\n");
warning("%s is an invalid target. Use the --list-targets option to list targets", _targetName.c_str()); warning("%s is an invalid target. Use the --list-targets option to list targets", _targetName.c_str());
return false; return false;
} }
printf("Trying to start game '%s'\n", game.description); printf("Trying to start game '%s'\n", game.description.c_str());
String gameDataPath(ConfMan.get("path")); String gameDataPath(ConfMan.get("path"));
if (gameDataPath.isEmpty()) { if (gameDataPath.isEmpty()) {

View file

@ -34,25 +34,32 @@ namespace Audio {
class Mixer; class Mixer;
} }
struct GameSettings { struct PlainGameDescriptor {
const char *gameid; const char *gameid;
const char *description; // TODO: Rename this to "title" or so const char *description; // TODO: Rename this to "title" or so
}; };
/** struct GameDescriptor {
* This template function allows to easily convert structs that mimic GameSettings Common::String gameid;
* to a GameSettings instance. Common::String description; // TODO: Rename this to "title" or so
*
* Normally, one would just subclass GameSettings to get this effect much easier. GameDescriptor() {}
* However, subclassing a struct turns it into a non-POD type. One of the GameDescriptor(Common::String g, Common::String d) :
* consequences is that you can't have inline intialized arrays of that type. gameid(g), description(d) {}
* But we heavily rely on those, hence we can't subclass GameSettings...
*/ /**
template <class T> * This template constructor allows to easily convert structs that mimic GameDescriptor
GameSettings toGameSettings(const T &g) { * to a GameDescriptor instance.
GameSettings dummy = { g.gameid, g.description }; *
return dummy; * Normally, one would just subclass GameDescriptor to get this effect much easier.
} * However, subclassing a struct turns it into a non-POD type. One of the
* consequences is that you can't have inline intialized arrays of that type.
* But we heavily rely on those, hence we can't subclass GameDescriptor...
*/
template <class T>
GameDescriptor(const T &g) :
gameid(g.gameid), description(g.description) {}
};
class GameDetector { class GameDetector {
@ -78,7 +85,7 @@ public:
static Audio::Mixer *createMixer(); static Audio::Mixer *createMixer();
static GameSettings findGame(const String &gameName, const Plugin **plugin = NULL); static GameDescriptor findGame(const String &gameName, const Plugin **plugin = NULL);
//protected: //protected:
void setTarget(const String &name); // TODO: This should be protected void setTarget(const String &name); // TODO: This should be protected

View file

@ -291,8 +291,8 @@ static int runGame(GameDetector &detector, OSystem &system, const Common::String
// Set the window caption to the game name // Set the window caption to the game name
Common::String caption(ConfMan.get("description", detector._targetName)); Common::String caption(ConfMan.get("description", detector._targetName));
const char *desc = GameDetector::findGame(detector._gameid).description; Common::String desc = GameDetector::findGame(detector._gameid).description;
if (caption.isEmpty() && desc) if (caption.isEmpty() && !desc.isEmpty())
caption = desc; caption = desc;
if (caption.isEmpty()) if (caption.isEmpty())
caption = detector._targetName; caption = detector._targetName;

View file

@ -32,7 +32,7 @@
typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst); typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst);
typedef const char *(*NameFunc)(); typedef const char *(*NameFunc)();
typedef GameSettings (*GameIDQueryFunc)(const char *gameid); typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid);
typedef GameList (*GameIDListFunc)(); typedef GameList (*GameIDListFunc)();
typedef DetectedGameList (*DetectFunc)(const FSList &fslist); typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
@ -93,7 +93,7 @@ public:
GameList getSupportedGames() const { return _plugin->_games; } GameList getSupportedGames() const { return _plugin->_games; }
GameSettings findGame(const char *gameid) const { GameDescriptor findGame(const char *gameid) const {
assert(_plugin->_qf); assert(_plugin->_qf);
return (*_plugin->_qf)(gameid); return (*_plugin->_qf)(gameid);
} }
@ -134,7 +134,7 @@ public:
GameList getSupportedGames() const { return _games; } GameList getSupportedGames() const { return _games; }
GameSettings findGame(const char *gameid) const { GameDescriptor findGame(const char *gameid) const {
assert(_qf); assert(_qf);
return (*_qf)(gameid); return (*_qf)(gameid);
} }

View file

@ -27,7 +27,7 @@
#include "common/array.h" #include "common/array.h"
#include "common/singleton.h" #include "common/singleton.h"
#include "common/util.h" #include "common/util.h"
#include "base/gameDetector.h" // For GameSettings #include "base/gameDetector.h" // For GameDescriptor
class Engine; class Engine;
class FSList; class FSList;
@ -35,33 +35,27 @@ class GameDetector;
class OSystem; class OSystem;
/** List of games. */ /** List of games. */
typedef Common::Array<GameSettings> GameList; typedef Common::Array<GameDescriptor> GameList;
/** /**
* A detected game. Carries the GameSettings, but also (optionally) * A detected game. Carries the GameDescriptor, but also (optionally)
* information about the language and platform of the detected game. * information about the language and platform of the detected game.
*/ */
struct DetectedGame { struct DetectedGame : public GameDescriptor {
const char *gameid;
const char *description;
Common::Language language; Common::Language language;
Common::Platform platform; Common::Platform platform;
DetectedGame(const char *g = 0, const char *d = 0, DetectedGame(const char *g = 0, const char *d = 0,
Common::Language l = Common::UNK_LANG, Common::Language l = Common::UNK_LANG,
Common::Platform p = Common::kPlatformUnknown) Common::Platform p = Common::kPlatformUnknown)
: gameid(g), description(d), language(l), platform(p) {} : GameDescriptor(g, d), language(l), platform(p) {}
DetectedGame(const GameSettings &game,
template <class T>
DetectedGame(const T &game,
Common::Language l = Common::UNK_LANG, Common::Language l = Common::UNK_LANG,
Common::Platform p = Common::kPlatformUnknown) Common::Platform p = Common::kPlatformUnknown)
: gameid(game.gameid), description(game.description), language(l), platform(p) {} : GameDescriptor(game.gameid, game.description), language(l), platform(p) {}
}; };
template <class T>
DetectedGame toDetectedGame(const T &g) {
DetectedGame dummy(g.gameid, g.description);
return dummy;
}
/** List of detected games. */ /** List of detected games. */
typedef Common::Array<DetectedGame> DetectedGameList; typedef Common::Array<DetectedGame> DetectedGameList;
@ -83,7 +77,7 @@ public:
virtual int getVersion() const { return 0; } // TODO! virtual int getVersion() const { return 0; } // TODO!
virtual GameList getSupportedGames() const = 0; virtual GameList getSupportedGames() const = 0;
virtual GameSettings findGame(const char *gameid) const = 0; virtual GameDescriptor findGame(const char *gameid) const = 0;
virtual DetectedGameList detectGames(const FSList &fslist) const = 0; virtual DetectedGameList detectGames(const FSList &fslist) const = 0;
virtual Engine *createInstance(GameDetector *detector, OSystem *syst) const = 0; virtual Engine *createInstance(GameDetector *detector, OSystem *syst) const = 0;
@ -99,8 +93,8 @@ public:
* Each plugin has to define the following functions: * Each plugin has to define the following functions:
* - GameList Engine_##ID##_gameIDList() * - GameList Engine_##ID##_gameIDList()
* -> returns a list of gameid/desc pairs. Only used to implement '--list-games'. * -> returns a list of gameid/desc pairs. Only used to implement '--list-games'.
* - GameSettings Engine_##ID##_findGameID(const char *gameid) * - GameDescriptor Engine_##ID##_findGameID(const char *gameid)
* -> asks the Engine for a GameSettings matching the gameid. If that is not * -> asks the Engine for a GameDescriptor matching the gameid. If that is not
* possible, the engine MUST set the gameid of the returned value to 0. * possible, the engine MUST set the gameid of the returned value to 0.
* Note: This MUST succeed for every gameID on the list returned by * Note: This MUST succeed for every gameID on the list returned by
* gameIDList(), but MAY also work for additional gameids (e.g. to support * gameIDList(), but MAY also work for additional gameids (e.g. to support
@ -130,7 +124,7 @@ public:
extern "C" { \ extern "C" { \
PLUGIN_EXPORT const char *PLUGIN_name() { return name; } \ PLUGIN_EXPORT const char *PLUGIN_name() { return name; } \
PLUGIN_EXPORT GameList PLUGIN_gameIDList() { return Engine_##ID##_gameIDList(); } \ PLUGIN_EXPORT GameList PLUGIN_gameIDList() { return Engine_##ID##_gameIDList(); } \
PLUGIN_EXPORT GameSettings PLUGIN_findGameID(const char *gameid) { return Engine_##ID##_findGameID(gameid); } \ PLUGIN_EXPORT GameDescriptor PLUGIN_findGameID(const char *gameid) { return Engine_##ID##_findGameID(gameid); } \
PLUGIN_EXPORT Engine *PLUGIN_createEngine(GameDetector *detector, OSystem *syst) { return Engine_##ID##_create(detector, syst); } \ PLUGIN_EXPORT Engine *PLUGIN_createEngine(GameDetector *detector, OSystem *syst) { return Engine_##ID##_create(detector, syst); } \
PLUGIN_EXPORT DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \ PLUGIN_EXPORT DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \
} }
@ -144,7 +138,7 @@ public:
class PluginRegistrator { class PluginRegistrator {
friend class StaticPlugin; friend class StaticPlugin;
public: public:
typedef GameSettings (*GameIDQueryFunc)(const char *gameid); typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid);
typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst); typedef Engine *(*EngineFactory)(GameDetector *detector, OSystem *syst);
typedef DetectedGameList (*DetectFunc)(const FSList &fslist); typedef DetectedGameList (*DetectFunc)(const FSList &fslist);

View file

@ -63,9 +63,8 @@ struct CINEGameSettings {
byte id; byte id;
uint32 features; uint32 features;
const char *detectname; const char *detectname;
GameSettings toGameSettings() const { GameDescriptor toGameDescriptor() const {
GameSettings dummy = { name, description }; return GameDescriptor(name, description);
return dummy;
} }
}; };
@ -80,21 +79,21 @@ GameList Engine_CINE_gameIDList() {
const CINEGameSettings *g = cine_settings; const CINEGameSettings *g = cine_settings;
while (g->name) { while (g->name) {
games.push_back(g->toGameSettings()); games.push_back(g->toGameDescriptor());
g++; g++;
} }
return games; return games;
} }
GameSettings Engine_CINE_findGameID(const char *gameid) { GameDescriptor Engine_CINE_findGameID(const char *gameid) {
const CINEGameSettings *g = cine_settings; const CINEGameSettings *g = cine_settings;
while (g->name) { while (g->name) {
if (0 == scumm_stricmp(gameid, g->name)) if (0 == scumm_stricmp(gameid, g->name))
break; break;
g++; g++;
} }
return g->toGameSettings(); return g->toGameDescriptor();
} }
DetectedGameList Engine_CINE_detectGames(const FSList &fslist) { DetectedGameList Engine_CINE_detectGames(const FSList &fslist) {
@ -109,7 +108,7 @@ DetectedGameList Engine_CINE_detectGames(const FSList &fslist) {
if (0 == scumm_stricmp(g->detectname, gameName)) { if (0 == scumm_stricmp(g->detectname, gameName)) {
// Match found, add to list of candidates, then abort inner loop. // Match found, add to list of candidates, then abort inner loop.
detectedGames.push_back(g->toGameSettings()); detectedGames.push_back(g->toGameDescriptor());
break; break;
} }
} }

View file

@ -118,7 +118,7 @@ static const GobGameSettings gob_games[] = {
}; };
// Keep list of different supported games // Keep list of different supported games
static const GameSettings gob_list[] = { static const PlainGameDescriptor gob_list[] = {
{"gob1", "Gobliiins"}, {"gob1", "Gobliiins"},
{"gob2", "Gobliins 2"}, {"gob2", "Gobliins 2"},
{0, 0} {0, 0}
@ -275,7 +275,7 @@ using namespace Gob;
GameList Engine_GOB_gameIDList() { GameList Engine_GOB_gameIDList() {
GameList games; GameList games;
const GameSettings *g = gob_list; const PlainGameDescriptor *g = gob_list;
while (g->gameid) { while (g->gameid) {
games.push_back(*g); games.push_back(*g);
@ -285,8 +285,8 @@ GameList Engine_GOB_gameIDList() {
return games; return games;
} }
GameSettings Engine_GOB_findGameID(const char *gameid) { GameDescriptor Engine_GOB_findGameID(const char *gameid) {
const GameSettings *g = gob_list; const PlainGameDescriptor *g = gob_list;
while (g->gameid) { while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid)) if (0 == scumm_stricmp(gameid, g->gameid))
break; break;
@ -328,7 +328,7 @@ DetectedGameList Engine_GOB_detectGames(const FSList &fslist) {
if (detectedGames.isEmpty()) { if (detectedGames.isEmpty()) {
printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str); printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
const GameSettings *g1 = gob_list; const PlainGameDescriptor *g1 = gob_list;
while (g1->gameid) { while (g1->gameid) {
detectedGames.push_back(*g1); detectedGames.push_back(*g1);
g1++; g1++;

View file

@ -96,7 +96,7 @@ static const KyraGameSettings kyra_games[] = {
}; };
// Keep list of different supported games // Keep list of different supported games
static const GameSettings kyra_list[] = { static const PlainGameDescriptor kyra_list[] = {
{ "kyra1", "The Legend of Kyrandia" }, { "kyra1", "The Legend of Kyrandia" },
{ 0, 0 } { 0, 0 }
}; };
@ -131,7 +131,7 @@ static Common::Language convertKyraLang(uint32 features) {
GameList Engine_KYRA_gameIDList() { GameList Engine_KYRA_gameIDList() {
GameList games; GameList games;
const GameSettings *g = kyra_list; const PlainGameDescriptor *g = kyra_list;
while (g->gameid) { while (g->gameid) {
games.push_back(*g); games.push_back(*g);
@ -140,8 +140,8 @@ GameList Engine_KYRA_gameIDList() {
return games; return games;
} }
GameSettings Engine_KYRA_findGameID(const char *gameid) { GameDescriptor Engine_KYRA_findGameID(const char *gameid) {
const GameSettings *g = kyra_list; const PlainGameDescriptor *g = kyra_list;
while (g->gameid) { while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid)) if (0 == scumm_stricmp(gameid, g->gameid))
break; break;
@ -187,7 +187,7 @@ DetectedGameList Engine_KYRA_detectGames(const FSList &fslist) {
if (detectedGames.isEmpty()) { if (detectedGames.isEmpty()) {
printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str); printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
const GameSettings *g1 = kyra_list; const PlainGameDescriptor *g1 = kyra_list;
while (g1->gameid) { while (g1->gameid) {
detectedGames.push_back(*g1); detectedGames.push_back(*g1);
g1++; g1++;

View file

@ -68,14 +68,14 @@ static const LureGameSettings lure_games[] = {
// Keep list of different supported games // Keep list of different supported games
static const GameSettings lure_list[] = { static const PlainGameDescriptor lure_list[] = {
{ "lure", "Lure of the Temptress" }, { "lure", "Lure of the Temptress" },
{ 0, 0 } { 0, 0 }
}; };
GameList Engine_LURE_gameIDList() { GameList Engine_LURE_gameIDList() {
GameList games; GameList games;
const GameSettings *g = lure_list; const PlainGameDescriptor *g = lure_list;
while (g->gameid) { while (g->gameid) {
games.push_back(*g); games.push_back(*g);
@ -84,8 +84,8 @@ GameList Engine_LURE_gameIDList() {
return games; return games;
} }
GameSettings Engine_LURE_findGameID(const char *gameid) { GameDescriptor Engine_LURE_findGameID(const char *gameid) {
const GameSettings *g = lure_list; const PlainGameDescriptor *g = lure_list;
while (g->gameid) { while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid)) if (0 == scumm_stricmp(gameid, g->gameid))
break; break;
@ -125,13 +125,13 @@ DetectedGameList Engine_LURE_detectGames(const FSList &fslist) {
} }
for (g = lure_games; g->gameid; g++) { for (g = lure_games; g->gameid; g++) {
if (strcmp(g->md5sum, (char *)md5str) == 0) { if (strcmp(g->md5sum, (char *)md5str) == 0) {
detectedGames.push_back(toDetectedGame(*g)); detectedGames.push_back(*g);
} }
} }
if (detectedGames.isEmpty()) { if (detectedGames.isEmpty()) {
debug("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str); debug("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
const GameSettings *g1 = lure_list; const PlainGameDescriptor *g1 = lure_list;
while (g1->gameid) { while (g1->gameid) {
detectedGames.push_back(*g1); detectedGames.push_back(*g1);
g1++; g1++;

View file

@ -55,7 +55,7 @@ bool isSmartphone();
#endif #endif
/* Flight of the Amazon Queen */ /* Flight of the Amazon Queen */
static const GameSettings queen_setting[] = { static const PlainGameDescriptor queen_setting[] = {
{ "queen", "Flight of the Amazon Queen" }, { "queen", "Flight of the Amazon Queen" },
{ "queen", "Flight of the Amazon Queen (Demo)" }, { "queen", "Flight of the Amazon Queen (Demo)" },
{ "queen", "Flight of the Amazon Queen (Interview)" }, { "queen", "Flight of the Amazon Queen (Interview)" },
@ -68,15 +68,14 @@ GameList Engine_QUEEN_gameIDList() {
return games; return games;
} }
GameSettings Engine_QUEEN_findGameID(const char *gameid) { GameDescriptor Engine_QUEEN_findGameID(const char *gameid) {
if (0 == scumm_stricmp(gameid, queen_setting[0].gameid)) if (0 == scumm_stricmp(gameid, queen_setting[0].gameid))
return queen_setting[0]; return queen_setting[0];
GameSettings dummy = { 0, 0 }; return GameDescriptor();
return dummy;
} }
GameSettings determineTarget(uint32 size) { GameDescriptor determineTarget(uint32 size) {
switch (size) { switch (size) {
case 3724538: //regular demo case 3724538: //regular demo
case 3732177: case 3732177:

View file

@ -56,7 +56,7 @@
#include "saga/objectmap.h" #include "saga/objectmap.h"
#include "saga/resnames.h" #include "saga/resnames.h"
static const GameSettings saga_games[] = { static const PlainGameDescriptor saga_games[] = {
{"ite", "Inherit the Earth"}, {"ite", "Inherit the Earth"},
{"ihnm", "I Have No Mouth and I Must Scream"}, {"ihnm", "I Have No Mouth and I Must Scream"},
{0, 0} {0, 0}
@ -64,7 +64,7 @@ static const GameSettings saga_games[] = {
GameList Engine_SAGA_gameIDList() { GameList Engine_SAGA_gameIDList() {
GameList games; GameList games;
const GameSettings *g = saga_games; const PlainGameDescriptor *g = saga_games;
while (g->gameid) { while (g->gameid) {
games.push_back(*g); games.push_back(*g);
@ -74,8 +74,8 @@ GameList Engine_SAGA_gameIDList() {
return games; return games;
} }
GameSettings Engine_SAGA_findGameID(const char *gameid) { GameDescriptor Engine_SAGA_findGameID(const char *gameid) {
const GameSettings *g = saga_games; const PlainGameDescriptor *g = saga_games;
while (g->gameid) { while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid)) if (0 == scumm_stricmp(gameid, g->gameid))
break; break;

View file

@ -55,7 +55,6 @@ enum {
kMD5FileSizeLimit = 1024 * 1024 kMD5FileSizeLimit = 1024 * 1024
}; };
struct ObsoleteGameID { struct ObsoleteGameID {
const char *from; const char *from;
const char *to; const char *to;
@ -75,7 +74,7 @@ static const Common::Platform UNK = Common::kPlatformUnknown;
* This table contains all game IDs supported by the SCUMM engine, and maps * This table contains all game IDs supported by the SCUMM engine, and maps
* them to the full humand readable game name. * them to the full humand readable game name.
*/ */
static const GameSettings gameDescriptions[] = { static const PlainGameDescriptor gameDescriptions[] = {
{ "atlantis", "Indiana Jones and the Fate of Atlantis" }, { "atlantis", "Indiana Jones and the Fate of Atlantis" },
{ "indy3", "Indiana Jones and the Last Crusade" }, { "indy3", "Indiana Jones and the Last Crusade" },
{ "loom", "Loom" }, { "loom", "Loom" },
@ -851,7 +850,7 @@ static const ScummGameSettings multiple_versions_md5_settings[] = {
static const char *findDescriptionFromGameID(const char *gameid) { static const char *findDescriptionFromGameID(const char *gameid) {
const GameSettings *g = gameDescriptions; const PlainGameDescriptor *g = gameDescriptions;
while (g->gameid) { while (g->gameid) {
if (!scumm_stricmp(g->gameid, gameid)) { if (!scumm_stricmp(g->gameid, gameid)) {
return g->description; return g->description;
@ -874,32 +873,32 @@ static int compareMD5Table(const void *a, const void *b) {
GameList Engine_SCUMM_gameIDList() { GameList Engine_SCUMM_gameIDList() {
const GameSettings *g = gameDescriptions; const PlainGameDescriptor *g = gameDescriptions;
GameList games; GameList games;
while (g->gameid) { while (g->gameid) {
games.push_back(*g); games.push_back(GameDescriptor(g->gameid, g->description));
g++; g++;
} }
return games; return games;
} }
GameSettings Engine_SCUMM_findGameID(const char *gameid) { GameDescriptor Engine_SCUMM_findGameID(const char *gameid) {
// First search the list of supported game IDs. // First search the list of supported game IDs.
const GameSettings *g = gameDescriptions; const PlainGameDescriptor *g = gameDescriptions;
while (g->gameid) { while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid)) if (0 == scumm_stricmp(gameid, g->gameid))
return *g; return GameDescriptor(g->gameid, g->description);
g++; g++;
} }
// If we didn't find the gameid in the main list, check if it // If we didn't find the gameid in the main list, check if it
// is an obsolete game id. // is an obsolete game id.
GameSettings gs = { 0, 0 }; GameDescriptor gs;
const ObsoleteGameID *o = obsoleteGameIDsTable; const ObsoleteGameID *o = obsoleteGameIDsTable;
while (o->from) { while (o->from) {
if (0 == scumm_stricmp(gameid, o->from)) { if (0 == scumm_stricmp(gameid, o->from)) {
gs.gameid = gameid; gs.gameid = gameid;
gs.gameid = "Obsolete game ID"; gs.description = "Obsolete game ID";
return gs; return gs;
} }
o++; o++;
@ -1072,7 +1071,7 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
if we find something which has an unknown MD5, assume if we find something which has an unknown MD5, assume
that it is an (so far unknown) version of Indy3. that it is an (so far unknown) version of Indy3.
We can combin this with a look at the resource headers: We can combine this with a look at the resource headers:
Indy3: Indy3:
_numGlobalObjects 1000 _numGlobalObjects 1000
@ -1189,7 +1188,7 @@ DetectedGameList Engine_SCUMM_detectGames(const FSList &fslist) {
const char *gameid = elem->gameid; const char *gameid = elem->gameid;
// Find the GameSettings for that gameid // Find the GameDescriptor for that gameid
for (g = scumm_settings; g->gameid; ++g) { for (g = scumm_settings; g->gameid; ++g) {
if (0 == scumm_stricmp(g->gameid, gameid)) if (0 == scumm_stricmp(g->gameid, gameid))
break; break;
@ -1318,7 +1317,7 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) {
} }
// Now search our 'database' for the MD5; if a match is found, we use // Now search our 'database' for the MD5; if a match is found, we use
// the information in the 'database' to correct the GameSettings. // the information in the 'database' to correct the GameDescriptor.
g = multiple_versions_md5_settings; g = multiple_versions_md5_settings;
while (g->gameid) { while (g->gameid) {
if (!scumm_stricmp(md5, g->gameid)) { if (!scumm_stricmp(md5, g->gameid)) {
@ -1366,7 +1365,7 @@ Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst) {
if (!elem) if (!elem)
printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5); printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5);
// Finally, we have massaged the GameSettings to our satisfaction, and can // Finally, we have massaged the GameDescriptor to our satisfaction, and can
// instantiate the appropriate game engine. Hooray! // instantiate the appropriate game engine. Hooray!
switch (game.version) { switch (game.version) {
case 1: case 1:

View file

@ -76,7 +76,7 @@ static const ObsoleteGameID obsoleteGameIDsTable[] = {
{NULL, NULL, Common::kPlatformUnknown} {NULL, NULL, Common::kPlatformUnknown}
}; };
static const GameSettings simonGames[] = { static const PlainGameDescriptor simonGames[] = {
// Simon the Sorcerer 1 & 2 // Simon the Sorcerer 1 & 2
{"feeble", "The Feeble Files"}, {"feeble", "The Feeble Files"},
{"simon1", "Simon the Sorcerer 1"}, {"simon1", "Simon the Sorcerer 1"},
@ -87,32 +87,32 @@ static const GameSettings simonGames[] = {
GameList Engine_SIMON_gameIDList() { GameList Engine_SIMON_gameIDList() {
GameList games; GameList games;
const GameSettings *g = simonGames; const PlainGameDescriptor *g = simonGames;
while (g->gameid) { while (g->gameid) {
games.push_back(*g); games.push_back(GameDescriptor(g->gameid, g->description));
g++; g++;
} }
return games; return games;
} }
GameSettings Engine_SIMON_findGameID(const char *gameid) { GameDescriptor Engine_SIMON_findGameID(const char *gameid) {
// First search the list of supported game IDs. // First search the list of supported game IDs.
const GameSettings *g = simonGames; const PlainGameDescriptor *g = simonGames;
while (g->gameid) { while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid)) if (0 == scumm_stricmp(gameid, g->gameid))
return *g; return GameDescriptor(g->gameid, g->description);
g++; g++;
} }
// If we didn't find the gameid in the main list, check if it // If we didn't find the gameid in the main list, check if it
// is an obsolete game id. // is an obsolete game id.
GameSettings gs = { 0, 0 }; GameDescriptor gs;
const ObsoleteGameID *o = obsoleteGameIDsTable; const ObsoleteGameID *o = obsoleteGameIDsTable;
while (o->from) { while (o->from) {
if (0 == scumm_stricmp(gameid, o->from)) { if (0 == scumm_stricmp(gameid, o->from)) {
gs.gameid = gameid; gs.gameid = gameid;
gs.gameid = "Obsolete game ID"; gs.description = "Obsolete game ID";
return gs; return gs;
} }
o++; o++;

View file

@ -77,7 +77,7 @@ extern bool isSmartphone(void);
With apologies to the CD32 SteelSky file. With apologies to the CD32 SteelSky file.
*/ */
static const GameSettings skySetting = static const PlainGameDescriptor skySetting =
{"sky", "Beneath a Steel Sky" }; {"sky", "Beneath a Steel Sky" };
GameList Engine_SKY_gameIDList() { GameList Engine_SKY_gameIDList() {
@ -86,11 +86,10 @@ GameList Engine_SKY_gameIDList() {
return games; return games;
} }
GameSettings Engine_SKY_findGameID(const char *gameid) { GameDescriptor Engine_SKY_findGameID(const char *gameid) {
if (0 == scumm_stricmp(gameid, skySetting.gameid)) if (0 == scumm_stricmp(gameid, skySetting.gameid))
return skySetting; return skySetting;
GameSettings dummy = { 0, 0 }; return GameDescriptor();
return dummy;
} }
DetectedGameList Engine_SKY_detectGames(const FSList &fslist) { DetectedGameList Engine_SKY_detectGames(const FSList &fslist) {

View file

@ -48,9 +48,9 @@
using namespace Sword1; using namespace Sword1;
/* Broken Sword 1 */ /* Broken Sword 1 */
static const GameSettings sword1FullSettings = static const PlainGameDescriptor sword1FullSettings =
{"sword1", "Broken Sword 1: The Shadow of the Templars"}; {"sword1", "Broken Sword 1: The Shadow of the Templars"};
static const GameSettings sword1DemoSettings = static const PlainGameDescriptor sword1DemoSettings =
{"sword1demo", "Broken Sword 1: The Shadow of the Templars (Demo)"}; {"sword1demo", "Broken Sword 1: The Shadow of the Templars (Demo)"};
// check these subdirectories (if present) // check these subdirectories (if present)
@ -73,13 +73,12 @@ GameList Engine_SWORD1_gameIDList() {
return games; return games;
} }
GameSettings Engine_SWORD1_findGameID(const char *gameid) { GameDescriptor Engine_SWORD1_findGameID(const char *gameid) {
if (0 == scumm_stricmp(gameid, sword1FullSettings.gameid)) if (0 == scumm_stricmp(gameid, sword1FullSettings.gameid))
return sword1FullSettings; return sword1FullSettings;
if (0 == scumm_stricmp(gameid, sword1DemoSettings.gameid)) if (0 == scumm_stricmp(gameid, sword1DemoSettings.gameid))
return sword1DemoSettings; return sword1DemoSettings;
GameSettings dummy = { 0, 0 }; return GameDescriptor();
return dummy;
} }
void Sword1CheckDirectory(const FSList &fslist, bool *filesFound) { void Sword1CheckDirectory(const FSList &fslist, bool *filesFound) {

View file

@ -67,20 +67,20 @@ GameList Engine_SWORD2_gameIDList() {
const Sword2GameSettings *g = sword2_settings; const Sword2GameSettings *g = sword2_settings;
GameList games; GameList games;
while (g->gameid) { while (g->gameid) {
games.push_back(toGameSettings(*g)); games.push_back(*g);
g++; g++;
} }
return games; return games;
} }
GameSettings Engine_SWORD2_findGameID(const char *gameid) { GameDescriptor Engine_SWORD2_findGameID(const char *gameid) {
const Sword2GameSettings *g = sword2_settings; const Sword2GameSettings *g = sword2_settings;
while (g->gameid) { while (g->gameid) {
if (0 == scumm_stricmp(gameid, g->gameid)) if (0 == scumm_stricmp(gameid, g->gameid))
break; break;
g++; g++;
} }
return toGameSettings(*g); return *g;
} }
DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) { DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) {
@ -99,7 +99,7 @@ DetectedGameList Engine_SWORD2_detectGames(const FSList &fslist) {
if (0 == scumm_stricmp(g->detectname, gameName)) { if (0 == scumm_stricmp(g->detectname, gameName)) {
// Match found, add to list of candidates, then abort inner loop. // Match found, add to list of candidates, then abort inner loop.
detectedGames.push_back(toDetectedGame(*g)); detectedGames.push_back(*g);
break; break;
} }
} }

View file

@ -114,7 +114,7 @@ class EditGameDialog : public OptionsDialog {
typedef Common::String String; typedef Common::String String;
typedef Common::StringList StringList; typedef Common::StringList StringList;
public: public:
EditGameDialog(const String &domain, const char *desc); EditGameDialog(const String &domain, const String &desc);
void open(); void open();
void close(); void close();
@ -137,7 +137,7 @@ protected:
CheckboxWidget *_globalVolumeOverride; CheckboxWidget *_globalVolumeOverride;
}; };
EditGameDialog::EditGameDialog(const String &domain, const char *desc) EditGameDialog::EditGameDialog(const String &domain, const String &desc)
: OptionsDialog(domain, 10, 40, 320 - 2 * 10, 140) { : OptionsDialog(domain, 10, 40, 320 - 2 * 10, 140) {
const int screenW = g_system->getOverlayWidth(); const int screenW = g_system->getOverlayWidth();
@ -176,7 +176,7 @@ EditGameDialog::EditGameDialog(const String &domain, const char *desc)
// GAME: Determine the description string // GAME: Determine the description string
String description(ConfMan.get("description", domain)); String description(ConfMan.get("description", domain));
if (description.isEmpty() && desc) { if (description.isEmpty() && !desc.isEmpty()) {
description = desc; description = desc;
} }
@ -570,8 +570,8 @@ void LauncherDialog::updateListing() {
if (gameid.isEmpty()) if (gameid.isEmpty())
gameid = iter->_key; gameid = iter->_key;
if (description.isEmpty()) { if (description.isEmpty()) {
GameSettings g = GameDetector::findGame(gameid); GameDescriptor g = GameDetector::findGame(gameid);
if (g.description) if (!g.description.isEmpty())
description = g.description; description = g.description;
} }
@ -667,17 +667,16 @@ void LauncherDialog::addGame() {
// Adapt the description string if custom platform/language is set // Adapt the description string if custom platform/language is set
if (customLanguage || customPlatform) { if (customLanguage || customPlatform) {
String desc = result.description; result.description += " (";
desc += " (";
if (customLanguage) if (customLanguage)
desc += Common::getLanguageDescription(result.language); result.description += Common::getLanguageDescription(result.language);
if (customLanguage && customPlatform) if (customLanguage && customPlatform)
desc += "/"; result.description += "/";
if (customPlatform) if (customPlatform)
desc += Common::getPlatformDescription(result.platform); result.description += Common::getPlatformDescription(result.platform);
desc += ")"; result.description += ")";
ConfMan.set("description", desc, domain); ConfMan.set("description", result.description, domain);
} }
// Display edit dialog for the new entry // Display edit dialog for the new entry