[Scummvm-cvs-logs] CVS: scummvm/common plugins.cpp,NONE,1.1 plugins.h,NONE,1.1 engine.h,1.33,1.34 gameDetector.cpp,1.151,1.152 gameDetector.h,1.58,1.59 module.mk,1.3,1.4
Max Horn
fingolfin at users.sourceforge.net
Mon Sep 8 22:00:03 CEST 2003
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.152,1.153
- Next message: [Scummvm-cvs-logs] CVS: scummvm/common module.mk,1.4,1.5 gameDetector.h,1.61,1.62 gameDetector.cpp,1.154,1.155 engine.cpp,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1:/tmp/cvs-serv18958/common
Modified Files:
engine.h gameDetector.cpp gameDetector.h module.mk
Added Files:
plugins.cpp plugins.h
Log Message:
renamed VersionSettings -> TargetSettings and also renamed some of its members; added GameDetector::findTarget; made launcher use that new method; some initial preparations for Plugin code
--- NEW FILE: plugins.cpp ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2003 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/common/plugins.cpp,v 1.1 2003/09/08 15:38:30 fingolfin Exp $
*
*/
#include "common/plugins.h"
#include "common/engine.h"
PluginManager::PluginManager() {
}
PluginManager::~PluginManager() {
// Explicitly unload all loaded plugins
unloadPlugins();
}
void PluginManager::loadPlugins() {
// TODO
}
void PluginManager::unloadPlugins() {
int i;
for (i = 0; i < _plugins.size(); i++) {
_plugins[i]->unloadPlugin();
delete _plugins[i];
}
_plugins.clear();
}
--- NEW FILE: plugins.h ---
/* ScummVM - Scumm Interpreter
* Copyright (C) 2001 Ludvig Strigeus
* Copyright (C) 2001-2003 The ScummVM project
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Header: /cvsroot/scummvm/scummvm/common/plugins.h,v 1.1 2003/09/08 15:38:30 fingolfin Exp $
*
*/
#ifndef COMMON_PLUGINS_H
#define COMMON_PLUGINS_H
#include "common/list.h"
class Engine;
class GameDetector;
class OSystem;
struct TargetSettings;
/**
* Abstract base class for the plugin system.
* Subclasses for this can be used to wrap both static and dynamic
* plugins.
*/
class Plugin {
public:
virtual void loadPlugin() {}
virtual void unloadPlugin() {}
virtual const char *getName() const = 0;
virtual int getVersion() const = 0;
virtual const TargetSettings *getTargets() const = 0;
virtual Engine *createInstance(GameDetector *detector, OSystem *syst) const = 0;
};
/**
* Instances of this class manage all plugins, including loading them,
* making wrapper objects of class Plugin available, and unloading them.
*
* @todo Add support for dynamic plugins (this may need additional API, e.g. for a plugin path)
*/
class PluginManager {
protected:
typedef ScummVM::List<Plugin *> PluginList;
PluginList _plugins;
public:
PluginManager();
~PluginManager();
void loadPlugins();
void unloadPlugins();
const PluginList &getPlugins() { return _plugins; }
};
#endif
Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/engine.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- engine.h 5 Aug 2003 23:58:24 -0000 1.33
+++ engine.h 8 Sep 2003 15:38:29 -0000 1.34
@@ -49,7 +49,7 @@
class SoundMixer;
class GameDetector;
class Timer;
-struct VersionSettings;
+struct TargetSettings;
/* FIXME - BIG HACK for MidiEmu */
extern OSystem *g_system;
@@ -101,22 +101,22 @@
// 1) Clean seperation from the game modules (scumm, simon) and the generic code
// 2) Faster (compiler doesn't have to parse lengthy header files)
#ifndef DISABLE_SCUMM
-extern const VersionSettings *Engine_SCUMM_targetList();
+extern const TargetSettings *Engine_SCUMM_targetList();
extern Engine *Engine_SCUMM_create(GameDetector *detector, OSystem *syst);
#endif
#ifndef DISABLE_SIMON
extern Engine *Engine_SIMON_create(GameDetector *detector, OSystem *syst);
-extern const VersionSettings *Engine_SIMON_targetList();
+extern const TargetSettings *Engine_SIMON_targetList();
#endif
#ifndef DISABLE_SKY
-extern const VersionSettings *Engine_SKY_targetList();
+extern const TargetSettings *Engine_SKY_targetList();
extern Engine *Engine_SKY_create(GameDetector *detector, OSystem *syst);
#endif
#ifndef DISABLE_SWORD2
-extern const VersionSettings *Engine_SWORD2_targetList();
+extern const TargetSettings *Engine_SWORD2_targetList();
extern Engine *Engine_SWORD2_create(GameDetector *detector, OSystem *syst);
#endif
Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
retrieving revision 1.151
retrieving revision 1.152
diff -u -d -r1.151 -r1.152
--- gameDetector.cpp 6 Sep 2003 04:07:20 -0000 1.151
+++ gameDetector.cpp 8 Sep 2003 15:38:29 -0000 1.152
@@ -100,7 +100,7 @@
;
#endif
// This contains a pointer to a list of all supported games.
-const VersionSettings *version_settings = NULL;
+const TargetSettings *version_settings = NULL;
static const struct GraphicsMode gfx_modes[] = {
{"normal", "Normal (no scaling)", GFX_NORMAL},
@@ -159,9 +159,9 @@
{0, 0, 0}
};
-static int countVersions(const VersionSettings *v) {
+static int countVersions(const TargetSettings *v) {
int count;
- for (count = 0; v->filename; v++, count++)
+ for (count = 0; v->targetName; v++, count++)
;
return count;
}
@@ -220,49 +220,49 @@
// Gather & combine the target lists from the modules
#ifndef DISABLE_SCUMM
- const VersionSettings *scummVersions = Engine_SCUMM_targetList();
+ const TargetSettings *scummVersions = Engine_SCUMM_targetList();
int scummCount = countVersions(scummVersions);
totalCount += scummCount;
#endif
#ifndef DISABLE_SIMON
- const VersionSettings *simonVersions = Engine_SIMON_targetList();
+ const TargetSettings *simonVersions = Engine_SIMON_targetList();
int simonCount = countVersions(simonVersions);
totalCount += simonCount;
#endif
#ifndef DISABLE_SKY
- const VersionSettings *skyVersions = Engine_SKY_targetList();
+ const TargetSettings *skyVersions = Engine_SKY_targetList();
int skyCount = countVersions(skyVersions);
totalCount += skyCount;
#endif
#ifndef DISABLE_SWORD2
- const VersionSettings *sword2Versions = Engine_SWORD2_targetList();
+ const TargetSettings *sword2Versions = Engine_SWORD2_targetList();
int sword2Count = countVersions(sword2Versions);
totalCount += sword2Count;
#endif
- VersionSettings *v = (VersionSettings *)calloc(totalCount + 1, sizeof(VersionSettings));
+ TargetSettings *v = (TargetSettings *)calloc(totalCount + 1, sizeof(TargetSettings));
version_settings = v;
#ifndef DISABLE_SCUMM
- memcpy(v, scummVersions, scummCount * sizeof(VersionSettings));
+ memcpy(v, scummVersions, scummCount * sizeof(TargetSettings));
v += scummCount;
#endif
#ifndef DISABLE_SIMON
- memcpy(v, simonVersions, simonCount * sizeof(VersionSettings));
+ memcpy(v, simonVersions, simonCount * sizeof(TargetSettings));
v += simonCount;
#endif
#ifndef DISABLE_SKY
- memcpy(v, skyVersions, skyCount * sizeof(VersionSettings));
+ memcpy(v, skyVersions, skyCount * sizeof(TargetSettings));
v += skyCount;
#endif
#ifndef DISABLE_SWORD2
- memcpy(v, sword2Versions, sword2Count * sizeof(VersionSettings));
+ memcpy(v, sword2Versions, sword2Count * sizeof(TargetSettings));
v += sword2Count;
#endif
@@ -273,7 +273,7 @@
GameDetector::~GameDetector() {
// This is a previously allocated chunck (line 224)
// so we need to free it to prevent memory leak
- VersionSettings *v = (VersionSettings *)version_settings;
+ TargetSettings *v = (TargetSettings *)version_settings;
free(v);
}
#endif
@@ -349,20 +349,33 @@
}
void GameDetector::list_games() {
- const VersionSettings *v = version_settings;
+ const TargetSettings *v = version_settings;
const char *config;
printf("Game Full Title Config\n"
"---------------- ------------------------------------------------------ -------\n");
- while (v->filename && v->gamename) {
- config = (g_config->has_domain(v->filename)) ? "Yes" : "";
- printf("%-17s%-56s%s\n", v->filename, v->gamename, config);
+ while (v->targetName && v->description) {
+ config = (g_config->has_domain(v->targetName)) ? "Yes" : "";
+ printf("%-17s%-56s%s\n", v->targetName, v->description, config);
v++;
}
}
+const TargetSettings *GameDetector::findTarget(const char *targetName) const {
+ // Find the TargetSettings for this target
+ const TargetSettings *target = version_settings;
+ assert(targetName);
+ while (target->targetName) {
+ if (!scumm_stricmp(target->targetName, targetName)) {
+ return target;
+ }
+ target++;
+ }
+ return 0;
+}
+
void GameDetector::parseCommandLine(int argc, char **argv) {
int i;
char *s;
@@ -678,7 +691,7 @@
}
bool GameDetector::detectGame() {
- const VersionSettings *gnl = version_settings;
+ const TargetSettings *target;
const char *realGame, *basename;
_game.id = 0;
_gameText.clear();
@@ -687,23 +700,22 @@
if (!realGame)
realGame = _gameFileName.c_str();
printf("Looking for %s\n", realGame);
-
- do {
- if (!scumm_stricmp(realGame, gnl->filename)) {
- _game = *gnl;
- if ((basename = g_config->get("basename"))) {
- // FIXME: What is this good for?
- _game.filename = basename;
- }
- _gameText = gnl->gamename;
- printf("Trying to start game '%s'\n",gnl->gamename);
- return true;
+
+ target = findTarget(realGame);
+
+ if (target) {
+ _game = *target;
+ if ((basename = g_config->get("basename"))) {
+ // FIXME: What is this good for?
+ _game.targetName = basename;
}
- } while ((++gnl)->filename);
-
- printf("Failed game detection\n");
-
- return false;
+ _gameText = _game.description;
+ printf("Trying to start game '%s'\n", _game.description);
+ return true;
+ } else {
+ printf("Failed game detection\n");
+ return false;
+ }
}
const ScummVM::String& GameDetector::getGameName() {
Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.h,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- gameDetector.h 5 Sep 2003 16:30:05 -0000 1.58
+++ gameDetector.h 8 Sep 2003 15:38:30 -0000 1.59
@@ -69,9 +69,9 @@
MDT_PREFER_NATIVE = 8
};
-struct VersionSettings {
- const char *filename;
- const char *gamename;
+struct TargetSettings {
+ const char *targetName;
+ const char *description;
byte id, version;
int midi; // MidiDriverType values
uint32 features;
@@ -96,9 +96,6 @@
int id;
};
-extern const VersionSettings *version_settings;
-
-
class GameDetector {
typedef ScummVM::String String;
@@ -142,7 +139,7 @@
int _midi_driver;
String _gameFileName;
- VersionSettings _game;
+ TargetSettings _game;
int _gfx_mode;
bool _default_gfx_mode;
@@ -163,6 +160,8 @@
int parseGraphicsMode(const char *s);
void updateconfig();
+
+ const TargetSettings *findTarget(const char *targetName) const;
protected:
String _gameText;
Index: module.mk
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/module.mk,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- module.mk 10 Aug 2003 20:49:13 -0000 1.3
+++ module.mk 8 Sep 2003 15:38:30 -0000 1.4
@@ -5,6 +5,7 @@
common/file.o \
common/gameDetector.o \
common/main.o \
+ common/plugins.o \
common/scaler.o \
common/str.o \
common/timer.o \
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/scumm resource.cpp,1.152,1.153
- Next message: [Scummvm-cvs-logs] CVS: scummvm/common module.mk,1.4,1.5 gameDetector.h,1.61,1.62 gameDetector.cpp,1.154,1.155 engine.cpp,1.35,1.36
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list