[Scummvm-cvs-logs] SF.net SVN: scummvm: [20739] scummvm/trunk/base
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Thu Feb 16 16:24:02 CET 2006
Revision: 20739
Author: fingolfin
Date: 2006-02-16 16:22:53 -0800 (Thu, 16 Feb 2006)
ViewCVS: http://svn.sourceforge.net/scummvm?rev=20739&view=rev
Log Message:
-----------
Added global toGameSettings() template function for convenience; simplified GameSettings usage in some engines
Modified Paths:
--------------
scummvm/trunk/base/gameDetector.h
scummvm/trunk/engines/gob/gob.cpp
scummvm/trunk/engines/kyra/kyra.cpp
scummvm/trunk/engines/lure/lure.cpp
scummvm/trunk/engines/sword2/sword2.cpp
Modified: scummvm/trunk/base/gameDetector.h
===================================================================
--- scummvm/trunk/base/gameDetector.h 2006-02-17 00:01:18 UTC (rev 20738)
+++ scummvm/trunk/base/gameDetector.h 2006-02-17 00:22:53 UTC (rev 20739)
@@ -43,10 +43,26 @@
struct GameSettings {
const char *gameid;
- const char *description;
- uint32 features;
+ const char *description; // TODO: Rename this to "title" or so
+ uint32 features; // TODO: Probably should get rid of this field
};
+/**
+ * This template function allows to easily convert structs that mimic GameSettings
+ * to a GameSettings instance.
+ *
+ * Normally, one would just subclass GameSettings 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 GameSettings...
+ */
+template <class T>
+GameSettings toGameSettings(const T &g) {
+ GameSettings dummy = { g.gameid, g.description, g.features };
+ return dummy;
+}
+
+
class GameDetector {
typedef Common::String String;
Modified: scummvm/trunk/engines/gob/gob.cpp
===================================================================
--- scummvm/trunk/engines/gob/gob.cpp 2006-02-17 00:01:18 UTC (rev 20738)
+++ scummvm/trunk/engines/gob/gob.cpp 2006-02-17 00:22:53 UTC (rev 20739)
@@ -107,15 +107,7 @@
};
// Keep list of different supported games
-static const struct GobGameList {
- const char *gameid;
- const char *description;
- uint32 features;
- GameSettings toGameSettings() const {
- GameSettings dummy = { gameid, description, features };
- return dummy;
- }
-} gob_list[] = {
+static const GameSettings gob_list[] = {
{"gob1", "Gobliiins", Gob::GF_GOB1},
{"gob2", "Gobliins 2", Gob::GF_GOB2},
{0, 0, 0}
@@ -124,10 +116,10 @@
GameList Engine_GOB_gameList() {
GameList games;
- const GobGameList *g = gob_list;
+ const GameSettings *g = gob_list;
while (g->gameid) {
- games.push_back(g->toGameSettings());
+ games.push_back(*g);
g++;
}
@@ -167,9 +159,9 @@
if (detectedGames.isEmpty()) {
printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
- const GobGameList *g1 = gob_list;
+ const GameSettings *g1 = gob_list;
while (g1->gameid) {
- detectedGames.push_back(g1->toGameSettings());
+ detectedGames.push_back(*g1);
g1++;
}
}
Modified: scummvm/trunk/engines/kyra/kyra.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra.cpp 2006-02-17 00:01:18 UTC (rev 20738)
+++ scummvm/trunk/engines/kyra/kyra.cpp 2006-02-17 00:22:53 UTC (rev 20739)
@@ -65,10 +65,6 @@
uint32 features;
const char *md5sum;
const char *checkFile;
- GameSettings toGameSettings() const {
- GameSettings dummy = { gameid, description, features };
- return dummy;
- }
};
// We could get rid of md5 detection at least for kyra 1 since we can locate all
@@ -100,17 +96,7 @@
};
// Keep list of different supported games
-struct KyraGameList {
- const char *gameid;
- const char *description;
- uint32 features;
- GameSettings toGameSettings() const {
- GameSettings dummy = { gameid, description, features };
- return dummy;
- }
-};
-
-static const KyraGameList kyra_list[] = {
+static const GameSettings kyra_list[] = {
{ "kyra1", "The Legend of Kyrandia", 0 },
{ 0, 0, 0 }
};
@@ -145,10 +131,10 @@
GameList Engine_KYRA_gameList() {
GameList games;
- const KyraGameList *g = kyra_list;
+ const GameSettings *g = kyra_list;
while (g->gameid) {
- games.push_back(g->toGameSettings());
+ games.push_back(*g);
g++;
}
return games;
@@ -185,15 +171,15 @@
}
for (g = kyra_games; g->gameid; g++) {
if (strcmp(g->md5sum, (char *)md5str) == 0) {
- detectedGames.push_back(DetectedGame(g->toGameSettings(), convertKyraLang(g->features), Common::kPlatformUnknown));
+ detectedGames.push_back(DetectedGame(toGameSettings(*g), convertKyraLang(g->features), Common::kPlatformUnknown));
}
}
if (detectedGames.isEmpty()) {
printf("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
- const KyraGameList *g1 = kyra_list;
+ const GameSettings *g1 = kyra_list;
while (g1->gameid) {
- detectedGames.push_back(g1->toGameSettings());
+ detectedGames.push_back(*g1);
g1++;
}
}
Modified: scummvm/trunk/engines/lure/lure.cpp
===================================================================
--- scummvm/trunk/engines/lure/lure.cpp 2006-02-17 00:01:18 UTC (rev 20738)
+++ scummvm/trunk/engines/lure/lure.cpp 2006-02-17 00:22:53 UTC (rev 20739)
@@ -51,16 +51,12 @@
};
struct LureGameSettings {
- const char *name;
+ const char *gameid;
const char *description;
byte id;
uint32 features;
const char *md5sum;
const char *checkFile;
- GameSettings toGameSettings() const {
- GameSettings dummy = { name, description, features };
- return dummy;
- }
};
//
@@ -72,27 +68,17 @@
// Keep list of different supported games
-struct LureGameList {
- const char *name;
- const char *description;
- uint32 features;
- GameSettings toGameSettings() const {
- GameSettings dummy = { name, description, features };
- return dummy;
- }
-};
-
-static const LureGameList lure_list[] = {
+static const GameSettings lure_list[] = {
{ "lure", "Lure of the Temptress", 0 },
{ 0, 0, 0 }
};
GameList Engine_LURE_gameList() {
GameList games;
- const LureGameList *g = lure_list;
+ const GameSettings *g = lure_list;
- while (g->name) {
- games.push_back(g->toGameSettings());
+ while (g->gameid) {
+ games.push_back(*g);
g++;
}
return games;
@@ -109,7 +95,7 @@
if (file->isDirectory())
continue;
- for (g = lure_games; g->name; g++) {
+ for (g = lure_games; g->gameid; g++) {
if (scumm_stricmp(file->displayName().c_str(), g->checkFile) == 0)
isFound = true;
}
@@ -127,17 +113,17 @@
for (int i = 0; i < 16; i++) {
sprintf(md5str + i * 2, "%02x", (int)md5sum[i]);
}
- for (g = lure_games; g->name; g++) {
+ for (g = lure_games; g->gameid; g++) {
if (strcmp(g->md5sum, (char *)md5str) == 0) {
- detectedGames.push_back(g->toGameSettings());
+ detectedGames.push_back(toGameSettings(*g));
}
}
if (detectedGames.isEmpty()) {
debug("Unknown MD5 (%s)! Please report the details (language, platform, etc.) of this game to the ScummVM team\n", md5str);
- const LureGameList *g1 = lure_list;
- while (g1->name) {
- detectedGames.push_back(g1->toGameSettings());
+ const GameSettings *g1 = lure_list;
+ while (g1->gameid) {
+ detectedGames.push_back(*g1);
g1++;
}
}
@@ -212,7 +198,7 @@
*md5str = 0;
- for (g = lure_games; g->name; g++) {
+ for (g = lure_games; g->gameid; g++) {
if (!Common::File::exists(g->checkFile))
continue;
Modified: scummvm/trunk/engines/sword2/sword2.cpp
===================================================================
--- scummvm/trunk/engines/sword2/sword2.cpp 2006-02-17 00:01:18 UTC (rev 20738)
+++ scummvm/trunk/engines/sword2/sword2.cpp 2006-02-17 00:22:53 UTC (rev 20739)
@@ -51,10 +51,6 @@
const char *description;
uint32 features;
const char *detectname;
- GameSettings toGameSettings() const {
- GameSettings dummy = { gameid, description, features };
- return dummy;
- }
};
static const Sword2GameSettings sword2_settings[] = {
@@ -69,7 +65,7 @@
const Sword2GameSettings *g = sword2_settings;
GameList games;
while (g->gameid) {
- games.push_back(g->toGameSettings());
+ games.push_back(toGameSettings(*g));
g++;
}
return games;
@@ -91,7 +87,7 @@
if (0 == scumm_stricmp(g->detectname, gameName)) {
// Match found, add to list of candidates, then abort inner loop.
- detectedGames.push_back(g->toGameSettings());
+ detectedGames.push_back(toGameSettings(*g));
break;
}
}
More information about the Scummvm-git-logs
mailing list