[Scummvm-cvs-logs] SF.net SVN: scummvm:[53835] scummvm/trunk/engines/sword25

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Oct 26 00:41:25 CEST 2010


Revision: 53835
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53835&view=rev
Author:   fingolfin
Date:     2010-10-25 22:41:25 +0000 (Mon, 25 Oct 2010)

Log Message:
-----------
SWORD25: Get rid of most of the 'kernel service/superclass' code

Modified Paths:
--------------
    scummvm/trunk/engines/sword25/fmv/movieplayer.cpp
    scummvm/trunk/engines/sword25/gfx/graphicengine.cpp
    scummvm/trunk/engines/sword25/input/inputengine.cpp
    scummvm/trunk/engines/sword25/kernel/kernel.cpp
    scummvm/trunk/engines/sword25/kernel/kernel.h
    scummvm/trunk/engines/sword25/kernel/kernel_script.cpp
    scummvm/trunk/engines/sword25/math/geometry.cpp
    scummvm/trunk/engines/sword25/package/packagemanager.cpp
    scummvm/trunk/engines/sword25/script/luascript.cpp
    scummvm/trunk/engines/sword25/sfx/soundengine.cpp
    scummvm/trunk/engines/sword25/sword25.cpp

Removed Paths:
-------------
    scummvm/trunk/engines/sword25/kernel/service_ids.h

Modified: scummvm/trunk/engines/sword25/fmv/movieplayer.cpp
===================================================================
--- scummvm/trunk/engines/sword25/fmv/movieplayer.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/fmv/movieplayer.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -47,10 +47,6 @@
 
 #define FLT_EPSILON     1.192092896e-07F        /* smallest such that 1.0+FLT_EPSILON != 1.0 */
 
-Service *OggTheora_CreateObject(Kernel *pKernel) {
-	return new MoviePlayer(pKernel);
-}
-
 #ifdef USE_THEORADEC
 MoviePlayer::MoviePlayer(Kernel *pKernel) : Service(pKernel), _decoder(g_system->getMixer()) {
 	if (!registerScriptBindings())

Modified: scummvm/trunk/engines/sword25/gfx/graphicengine.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/graphicengine.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/gfx/graphicengine.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -91,10 +91,6 @@
 	delete _thumbnail;
 }
 
-Service *GraphicEngine_CreateObject(Kernel *pKernel) {
-	return new GraphicEngine(pKernel);
-}
-
 bool GraphicEngine::init(int width, int height, int bitDepth, int backbufferCount, bool isWindowed_) {
 	// Warnung ausgeben, wenn eine nicht unterst\xFCtzte Bittiefe gew\xE4hlt wurde.
 	if (bitDepth != BIT_DEPTH) {

Modified: scummvm/trunk/engines/sword25/input/inputengine.cpp
===================================================================
--- scummvm/trunk/engines/sword25/input/inputengine.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/input/inputengine.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -80,10 +80,6 @@
 	unregisterScriptBindings();
 }
 
-Service *InputEngine_CreateObject(Kernel *pKernel) {
-	return new InputEngine(pKernel);
-}
-
 bool InputEngine::init() {
 	// No initialisation needed
 	return true;

Modified: scummvm/trunk/engines/sword25/kernel/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sword25/kernel/kernel.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/kernel/kernel.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -38,9 +38,9 @@
 #include "sword25/input/inputengine.h"
 #include "sword25/kernel/kernel.h"
 #include "sword25/kernel/persistenceservice.h"
-#include "sword25/kernel/service_ids.h"
+#include "sword25/math/geometry.h"
 #include "sword25/package/packagemanager.h"
-#include "sword25/script/script.h"
+#include "sword25/script/luascript.h"
 #include "sword25/sfx/soundengine.h"
 
 namespace Sword25 {
@@ -50,35 +50,26 @@
 Kernel *Kernel::_instance = 0;
 
 Kernel::Kernel() :
-	_running(false),
-	_pResourceManager(NULL),
-	_initSuccess(false) {
+	_resourceManager(NULL),
+	_initSuccess(false),
+	_gfx(0),
+	_sfx(0),
+	_input(0),
+	_package(0),
+	_script(0),
+	_fmv(0)
+	{
 
 	// Log that the kernel is beign created
 	BS_LOGLN("created.");
+	_instance = this;
 
-	// Read the BS_SERVICE_TABLE and prepare kernel structures
-	for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) {
-		// Is the superclass already registered?
-		Superclass *pCurSuperclass = NULL;
-		Common::Array<Superclass *>::iterator iter;
-		for (iter = _superclasses.begin(); iter != _superclasses.end(); ++iter)
-			if ((*iter)->getIdentifier() == BS_SERVICE_TABLE[i].superclassId) {
-				pCurSuperclass = *iter;
-				break;
-			}
-
-		// If the superclass isn't already registered, then add it in
-		if (!pCurSuperclass)
-			_superclasses.push_back(new Superclass(this, BS_SERVICE_TABLE[i].superclassId));
-	}
-
 	// Create the resource manager
-	_pResourceManager = new ResourceManager(this);
+	_resourceManager = new ResourceManager(this);
 
 	// Initialise the script engine
-	ScriptEngine *pScript = static_cast<ScriptEngine *>(newService("script", "lua"));
-	if (!pScript || !pScript->init()) {
+	_script = new LuaScriptEngine(this);
+	if (!_script || !_script->init()) {
 		_initSuccess = false;
 		return;
 	}
@@ -91,251 +82,62 @@
 	}
 	BS_LOGLN("Script bindings registered.");
 
-	_initSuccess = true;
-}
+	_input = new InputEngine(this);
+	assert(_input);
 
-Kernel::~Kernel() {
-	// Services are de-registered in reverse order of creation
-	while (!_serviceCreationOrder.empty()) {
-		Superclass *superclass = getSuperclassByIdentifier(_serviceCreationOrder.top());
-		if (superclass)
-			superclass->disconnectService();
-		_serviceCreationOrder.pop();
-	}
+	_gfx = new GraphicEngine(this);
+	assert(_gfx);
 
-	// Empty the Superclass list
-	while (_superclasses.size()) {
-		delete _superclasses.back();
-		_superclasses.pop_back();
-	}
+	_sfx = new SoundEngine(this);
+	assert(_sfx);
 
-	// Resource-Manager freigeben
-	delete _pResourceManager;
+	_package = new PackageManager(this);
+	assert(_package);
 
-	BS_LOGLN("destroyed.");
-}
+	_geometry = new Geometry(this);
+	assert(_geometry);
 
-Kernel::Superclass::Superclass(Kernel *pKernel, const Common::String &identifier) :
-	_pKernel(pKernel),
-	_identifier(identifier),
-	_serviceCount(0),
-	_activeService(NULL) {
-	for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++)
-		if (BS_SERVICE_TABLE[i].superclassId == _identifier)
-			_serviceCount++;
-}
+#ifdef USE_THEORADEC
+	_fmv = new MoviePlayer(this);
+	assert(_fmv);
+#endif
 
-Kernel::Superclass::~Superclass() {
-	disconnectService();
+	_initSuccess = true;
 }
 
-/**
- * Gets the identifier of a service with a given superclass.
- * The number of services in a superclass can be learned with GetServiceCount().
- * @param superclassId      The name of the superclass
- *         e.g.: "sfx", "gfx", "package" ...
- * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
- *         Hierbei ist zu beachten, dass der erste Service die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
- *         0 und GetServiceCount() - 1 sein.
- */
-Common::String Kernel::Superclass::getServiceIdentifier(uint number) {
-	if (number > _serviceCount)
-		return NULL;
+Kernel::~Kernel() {
+	// Services are de-registered in reverse order of creation
 
-	uint curServiceOrd = 0;
-	for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++) {
-		if (BS_SERVICE_TABLE[i].superclassId == _identifier) {
-			if (number == curServiceOrd)
-				return BS_SERVICE_TABLE[i].serviceId;
-			else
-				curServiceOrd++;
-		}
-	}
+	delete _input;
+	_input = 0;
 
-	return Common::String();
-}
+	delete _gfx;
+	_gfx = 0;
 
-/**
- * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
- * service could not be created
- * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
- * @param superclassId      The name of the superclass of the service
- *         e.g.: "sfx", "gfx", "package" ...
- * @param serviceId         The name of the service
- *         For the superclass "sfx" an example could be "Fmod" or "directsound"
- */
-Service *Kernel::Superclass::newService(const Common::String &serviceId) {
-	for (uint i = 0; i < ARRAYSIZE(BS_SERVICE_TABLE); i++)
-		if (BS_SERVICE_TABLE[i].superclassId == _identifier &&
-		        BS_SERVICE_TABLE[i].serviceId == serviceId) {
-			Service *newService_ = BS_SERVICE_TABLE[i].create(_pKernel);
+	delete _sfx;
+	_sfx = 0;
 
-			if (newService_) {
-				disconnectService();
-				BS_LOGLN("Service '%s' created from superclass '%s'.", serviceId.c_str(), _identifier.c_str());
-				_activeService = newService_;
-				_activeServiceName = BS_SERVICE_TABLE[i].serviceId;
-				return _activeService;
-			} else {
-				BS_LOG_ERRORLN("Failed to create service '%s' from superclass '%s'.", serviceId.c_str(), _identifier.c_str());
-				return NULL;
-			}
-		}
+	delete _package;
+	_package = 0;
 
-	BS_LOG_ERRORLN("Service '%s' is not avaliable from superclass '%s'.", serviceId.c_str(), _identifier.c_str());
-	return NULL;
-}
+	delete _geometry;
+	_geometry = 0;
 
-/**
- * Ends the current service of a superclass. Returns true on success, and false if the superclass
- * does not exist or if not service was active
- * @param superclassId       The name of the superclass which is to be disconnected
- *         e.g.: "sfx", "gfx", "package" ...
- */
-bool Kernel::Superclass::disconnectService() {
-	if (_activeService) {
-		delete _activeService;
-		_activeService = 0;
-		BS_LOGLN("Active service '%s' disconnected from superclass '%s'.", _activeServiceName.c_str(), _identifier.c_str());
-		return true;
-	}
+#ifdef USE_THEORADEC
+	delete _fmv;
+	_fmv = 0;
+#endif
 
-	return false;
-}
+	delete _script;
+	_script = 0;
 
-Kernel::Superclass *Kernel::getSuperclassByIdentifier(const Common::String &identifier) const {
-	Common::Array<Superclass *>::const_iterator iter;
-	for (iter = _superclasses.begin(); iter != _superclasses.end(); ++iter) {
-		if ((*iter)->getIdentifier() == identifier)
-			return *iter;
-	}
+	// Resource-Manager freigeben
+	delete _resourceManager;
 
-	// BS_LOG_ERRORLN("Superclass '%s' does not exist.", identifier.c_str());
-	return NULL;
+	BS_LOGLN("destroyed.");
 }
 
 /**
- * Returns the number of register superclasses
- */
-uint Kernel::getSuperclassCount() const {
-	return _superclasses.size();
-}
-
-/**
- * Returns the name of a superclass with the specified index.
- * Note: The number of superclasses can be retrieved using GetSuperclassCount
- * @param Number        The number of the superclass to return the identifier for.
- * It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
- */
-Common::String Kernel::getSuperclassIdentifier(uint number) const {
-	if (number > _superclasses.size())
-		return NULL;
-
-	uint curSuperclassOrd = 0;
-	Common::Array<Superclass *>::const_iterator iter;
-	for (iter = _superclasses.begin(); iter != _superclasses.end(); ++iter) {
-		if (curSuperclassOrd == number)
-			return ((*iter)->getIdentifier());
-
-		curSuperclassOrd++;
-	}
-
-	return Common::String();
-}
-
-/**
- * Returns the number of services registered with a given superclass
- * @param superclassId      The name of the superclass
- *         e.g.: "sfx", "gfx", "package" ...
- */
-uint Kernel::getServiceCount(const Common::String &superclassId) const {
-	Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
-	if (!pSuperclass)
-		return 0;
-
-	return pSuperclass->getServiceCount();
-
-}
-
-/**
- * Gets the identifier of a service with a given superclass.
- * The number of services in a superclass can be learned with GetServiceCount().
- * @param superclassId      The name of the superclass
- *         e.g.: "sfx", "gfx", "package" ...
- * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
- *         Hierbei ist zu beachten, dass der erste Service die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
- *         0 und GetServiceCount() - 1 sein.
- */
-Common::String Kernel::getServiceIdentifier(const Common::String &superclassId, uint number) const {
-	Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
-	if (!pSuperclass)
-		return NULL;
-
-	return (pSuperclass->getServiceIdentifier(number));
-}
-
-/**
- * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
- * service could not be created
- * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
- * @param superclassId      The name of the superclass of the service
- *         e.g.: "sfx", "gfx", "package" ...
- * @param serviceId         The name of the service
- *         For the superclass "sfx" an example could be "Fmod" or "directsound"
- */
-Service *Kernel::newService(const Common::String &superclassId, const Common::String &serviceId) {
-	Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
-	if (!pSuperclass)
-		return NULL;
-
-	// Die Reihenfolge merken, in der Services erstellt werden, damit sie sp\xE4ter in umgekehrter Reihenfolge entladen werden k\xF6nnen.
-	_serviceCreationOrder.push(superclassId);
-
-	return pSuperclass->newService(serviceId);
-}
-
-/**
- * Ends the current service of a superclass. 
- * @param superclassId       The name of the superclass which is to be disconnected
- *         e.g.: "sfx", "gfx", "package" ...
- * @return true on success, and false if the superclass does not exist or if not service was active.
- */
-bool Kernel::disconnectService(const Common::String &superclassId) {
-	Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
-	if (!pSuperclass)
-		return false;
-
-	return pSuperclass->disconnectService();
-}
-
-/**
- * Returns a pointer to the currently active service object of a superclass.
- * @param superclassId       The name of the superclass
- *         e.g.: "sfx", "gfx", "package" ...
- */
-Service *Kernel::getService(const Common::String &superclassId) {
-	Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
-	if (!pSuperclass)
-		return NULL;
-
-	return (pSuperclass->getActiveService());
-}
-
-/**
- * Returns the name of the currently active service object of a superclass.
- * If an error occurs, then an empty string is returned
- * @param superclassId       The name of the superclass
- *         e.g.: "sfx", "gfx", "package" ...
- */
-Common::String Kernel::getActiveServiceIdentifier(const Common::String &superclassId) {
-	Superclass *pSuperclass = getSuperclassByIdentifier(superclassId);
-	if (!pSuperclass)
-		return Common::String();
-
-	return pSuperclass->getActiveServiceName();
-}
-
-/**
  * Returns a random number
  * @param Min       The minimum allowed value
  * @param Max       The maximum allowed value
@@ -364,42 +166,42 @@
  * Returns a pointer to the active Gfx Service, or NULL if no Gfx service is active.
  */
 GraphicEngine *Kernel::getGfx() {
-	return static_cast<GraphicEngine *>(getService("gfx"));
+	return _gfx;
 }
 
 /**
  * Returns a pointer to the active Sfx Service, or NULL if no Sfx service is active.
  */
 SoundEngine *Kernel::getSfx() {
-	return static_cast<SoundEngine *>(getService("sfx"));
+	return _sfx;
 }
 
 /**
  * Returns a pointer to the active input service, or NULL if no input service is active.
  */
 InputEngine *Kernel::getInput() {
-	return static_cast<InputEngine *>(getService("input"));
+	return _input;
 }
 
 /**
  * Returns a pointer to the active package manager, or NULL if no manager is active.
  */
 PackageManager *Kernel::getPackage() {
-	return static_cast<PackageManager *>(getService("package"));
+	return _package;
 }
 
 /**
  * Returns a pointer to the script engine, or NULL if it is not active.
  */
 ScriptEngine *Kernel::getScript() {
-	return static_cast<ScriptEngine *>(getService("script"));
+	return _script;
 }
 
 /**
  * Returns a pointer to the movie player, or NULL if it is not active.
  */
 MoviePlayer *Kernel::getFMV() {
-	return static_cast<MoviePlayer *>(getService("fmv"));
+	return _fmv;
 }
 
 void Kernel::sleep(uint msecs) const {

Modified: scummvm/trunk/engines/sword25/kernel/kernel.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/kernel.h	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/kernel/kernel.h	2010-10-25 22:41:25 UTC (rev 53835)
@@ -58,6 +58,7 @@
 
 // Class definitions
 class Service;
+class Geometry;
 class GraphicEngine;
 class ScriptEngine;
 class SoundEngine;
@@ -74,75 +75,7 @@
 class Kernel {
 public:
 
-	// Service Methods
-	// ---------------
-
 	/**
-	 * Creates a new service with the given identifier. Returns a pointer to the service, or null if the
-	 * service could not be created
-	 * Note: All services must be registered in service_ids.h, otherwise they cannot be created here
-	 * @param SuperclassIdentifier      The name of the superclass of the service
-	 *         z.B: "sfx", "gfx", "package" ...
-	 * @param ServiceIdentifier         The name of the service
-	 *         For the superclass "sfx" an example could be "Fmod" or "directsound"
-	 */
-	Service *newService(const Common::String &superclassIdentifier, const Common::String &serviceIdentifier);
-
-	/**
-	 * Ends the current service of a superclass. Returns true on success, and false if the superclass
-	 * does not exist or if not service was active
-	 * @param SuperclassIdentfier       The name of the superclass which is to be disconnected
-	 *         z.B: "sfx", "gfx", "package" ...
-	 */
-	bool disconnectService(const Common::String &superclassIdentifier);
-
-	/**
-	 * Returns a pointer to the currently active service object of a superclass
-	 * @param SuperclassIdentfier       The name of the superclass
-	 *         z.B: "sfx", "gfx", "package" ...
-	 */
-	Service *getService(const Common::String &superclassIdentifier);
-
-	/**
-	 * Returns the name of the currentl active service object of a superclass.
-	 * If an error occurs, then an empty string is returned
-	 * @param SuperclassIdentfier       The name of the superclass
-	 *         z.B: "sfx", "gfx", "package" ...
-	 */
-	Common::String getActiveServiceIdentifier(const Common::String &superclassIdentifier);
-
-	/**
-	 * Returns the number of register superclasses
-	 */
-	uint getSuperclassCount() const;
-
-	/**
-	 * Returns the name of a superclass with the specified index.
-	 * Note: The number of superclasses can be retrieved using GetSuperclassCount
-	 * @param Number        The number of the superclass to return the identifier for.
-	 * It should be noted that the number should be between 0 und GetSuperclassCount() - 1.
-	 */
-	Common::String getSuperclassIdentifier(uint number) const;
-
-	/**
-	 * Returns the number of services registered with a given superclass
-	 * @param SuperclassIdentifier      The name of the superclass
-	 *         z.B: "sfx", "gfx", "package" ...
-	 */
-	uint getServiceCount(const Common::String &superclassIdentifier) const;
-
-	/**
-	 * Gets the identifier of a service with a given superclass.
-	 * The number of services in a superclass can be learned with GetServiceCount().
-	 * @param SuperclassIdentifier      The name of the superclass
-	 *         z.B: "sfx", "gfx", "package" ...
-	 * @param Number die Nummer des Services, dessen Bezeichner man erfahren will.<br>
-	 *         Hierbei ist zu beachten, dass der erste Service die Nummer 0 erh\xE4lt. Number muss also eine Zahl zwischen
-	 *         0 und GetServiceCount() - 1 sein.
-	 */
-	Common::String getServiceIdentifier(const Common::String &superclassIdentifier, uint number) const;
-
-	/**
 	 * Returns the elapsed time since startup in milliseconds
 	 */
 	uint getMilliTicks();
@@ -157,7 +90,7 @@
 	 * Returns a pointer to the BS_ResourceManager
 	 */
 	ResourceManager *getResourceManager() {
-		return _pResourceManager;
+		return _resourceManager;
 	}
 	/**
 	 * Returns how much memory is being used
@@ -243,43 +176,7 @@
 	// -----------------------------------------------------------------------------
 	static Kernel *_instance;
 
-	// Superclass class
-	// ----------------
-	class Superclass {
-	private:
-		Kernel *_pKernel;
-		uint _serviceCount;
-		Common::String _identifier;
-		Service *_activeService;
-		Common::String _activeServiceName;
-
-	public:
-		Superclass(Kernel *pKernel, const Common::String &identifier);
-		~Superclass();
-
-		uint getServiceCount() const {
-			return _serviceCount;
-		}
-		Common::String getIdentifier() const {
-			return _identifier;
-		}
-		Service *getActiveService() const {
-			return _activeService;
-		}
-		Common::String getActiveServiceName() const {
-			return _activeServiceName;
-		}
-		Common::String getServiceIdentifier(uint number);
-		Service *newService(const Common::String &serviceIdentifier);
-		bool disconnectService();
-	};
-
-	Common::Array<Superclass *>  _superclasses;
-	Common::Stack<Common::String> _serviceCreationOrder;
-	Superclass *getSuperclassByIdentifier(const Common::String &identifier) const;
-
 	bool _initSuccess; // Specifies whether the engine was set up correctly
-	bool _running;  // Specifies whether the application should keep running on the next main loop iteration
 
 	// Random number generator
 	// -----------------------
@@ -287,8 +184,16 @@
 
 	// Resourcemanager
 	// ---------------
-	ResourceManager *_pResourceManager;
+	ResourceManager *_resourceManager;
 
+	GraphicEngine *_gfx;
+	SoundEngine *_sfx;
+	InputEngine *_input;
+	PackageManager *_package;
+	ScriptEngine *_script;
+	Geometry *_geometry;
+	MoviePlayer *_fmv;
+
 	bool registerScriptBindings();
 };
 

Modified: scummvm/trunk/engines/sword25/kernel/kernel_script.cpp
===================================================================
--- scummvm/trunk/engines/sword25/kernel/kernel_script.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/kernel/kernel_script.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -43,58 +43,44 @@
 namespace Sword25 {
 
 static int disconnectService(lua_State *L) {
-	Kernel *pKernel = Kernel::getInstance();
-	BS_ASSERT(pKernel);
+	// This function apparently is not used by the game scripts
+	lua_pushboolean(L, true);
 
-	lua_pushboolean(L, pKernel->disconnectService(luaL_checkstring(L, 1)));
-
 	return 1;
 }
 
 static int getActiveServiceIdentifier(lua_State *L) {
-	Kernel *pKernel = Kernel::getInstance();
-	BS_ASSERT(pKernel);
+	// This function apparently is not used by the game scripts
+	lua_pushstring(L, "QUUX");
 
-	lua_pushstring(L, pKernel->getActiveServiceIdentifier(luaL_checkstring(L, 1)).c_str());
-
 	return 1;
 }
 
 static int getSuperclassCount(lua_State *L) {
-	Kernel *pKernel = Kernel::getInstance();
-	BS_ASSERT(pKernel);
+	// This function is only used by a single function in system/kernel.lua which is never called.
+	lua_pushnumber(L, 0);
 
-	lua_pushnumber(L, pKernel->getSuperclassCount());
-
 	return 1;
 }
 
 static int getSuperclassIdentifier(lua_State *L) {
-	Kernel *pKernel = Kernel::getInstance();
-	BS_ASSERT(pKernel);
+	// This function is only used by a single function in system/kernel.lua which is never called.
+	lua_pushstring(L, "FOO");
 
-	lua_pushstring(L, pKernel->getSuperclassIdentifier(
-	                   static_cast<uint>(luaL_checknumber(L, 1))).c_str());
-
 	return 1;
 }
 
 static int getServiceCount(lua_State *L) {
-	Kernel *pKernel = Kernel::getInstance();
-	BS_ASSERT(pKernel);
+	// This function is only used by a single function in system/kernel.lua which is never called.
+	lua_pushnumber(L, 0);
 
-	lua_pushnumber(L, pKernel->getServiceCount(luaL_checkstring(L, 1)));
-
 	return 1;
 }
 
 static int getServiceIdentifier(lua_State *L) {
-	Kernel *pKernel = Kernel::getInstance();
-	BS_ASSERT(pKernel);
+	// This function is only used by a single function in system/kernel.lua which is never called.
+	lua_pushstring(L, "BAR");
 
-	lua_pushstring(L, pKernel->getServiceIdentifier(luaL_checkstring(L, 1),
-	               static_cast<uint>(luaL_checknumber(L, 2))).c_str());
-
 	return 1;
 }
 
@@ -117,11 +103,10 @@
 }
 
 static int startService(lua_State *L) {
-	Kernel *pKernel = Kernel::getInstance();
-	BS_ASSERT(pKernel);
+	// This function is used by system/boot.lua to init all services.
+	// However, we do nothing here, as we just hard code the init sequence.
+	lua_pushbooleancpp(L, true);
 
-	lua_pushbooleancpp(L, pKernel->newService(luaL_checkstring(L, 1), luaL_checkstring(L, 2)) != NULL);
-
 	return 1;
 }
 

Deleted: scummvm/trunk/engines/sword25/kernel/service_ids.h
===================================================================
--- scummvm/trunk/engines/sword25/kernel/service_ids.h	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/kernel/service_ids.h	2010-10-25 22:41:25 UTC (rev 53835)
@@ -1,86 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * 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.
- *
- * $URL$
- * $Id$
- *
- */
-
-/*
- * This code is based on Broken Sword 2.5 engine
- *
- * Copyright (c) Malte Thiesen, Daniel Queteschiner and Michael Elsdoerfer
- *
- * Licensed under GNU GPL v2
- *
- */
-
-/*
- * service_ids.h
- * -------------
- * This file lists all the services.
- * EVERY new service needs to be entered here, otherwise it cannot be instantiated
- * by pKernel->NewService(..)
- *
- * Autor: Malte Thiesen
- */
-
-#ifndef SWORD25_SERVICE_IDS
-#define SWORD25_SERVICE_IDS
-
-#include "sword25/kernel/common.h"
-
-namespace Sword25 {
-
-Service *GraphicEngine_CreateObject(Kernel *pKernel);
-Service *PackageManager_CreateObject(Kernel *pKernel);
-Service *InputEngine_CreateObject(Kernel *pKernel);
-Service *SoundEngine_CreateObject(Kernel *pKernel);
-Service *LuaScriptEngine_CreateObject(Kernel *pKernel);
-Service *Geometry_CreateObject(Kernel *pKernel);
-Service *OggTheora_CreateObject(Kernel *pKernel);
-
-
-/**
- * This is only a small struct that manages the data of a service.
- */
-struct BS_ServiceInfo {
-	const char *superclassId;
-	const char *serviceId;
-	Service *(*create)(Kernel *);
-};
-
-// Services are recorded in this table
-const BS_ServiceInfo BS_SERVICE_TABLE[] = {
-	// The first two values are the name of the superclass and service.
-	// The third value is the static method of the class that creates an object
-	// of the class and returns it.
-	{ "gfx", "opengl", GraphicEngine_CreateObject },
-	{ "package", "archiveFS", PackageManager_CreateObject },
-	{ "input", "winapi", InputEngine_CreateObject },
-	{ "sfx", "fmodex", SoundEngine_CreateObject },
-	{ "script", "lua", LuaScriptEngine_CreateObject },
-	{ "geometry", "std", Geometry_CreateObject },
-	{ "fmv", "oggtheora", OggTheora_CreateObject }
-};
-
-} // End of namespace Sword25
-
-#endif

Modified: scummvm/trunk/engines/sword25/math/geometry.cpp
===================================================================
--- scummvm/trunk/engines/sword25/math/geometry.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/math/geometry.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -46,8 +46,4 @@
 }
 
 
-Service *Geometry_CreateObject(Kernel *pKernel) {
-	return new Geometry(pKernel);
-}
-
 } // End of namespace Sword25

Modified: scummvm/trunk/engines/sword25/package/packagemanager.cpp
===================================================================
--- scummvm/trunk/engines/sword25/package/packagemanager.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/package/packagemanager.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -75,10 +75,6 @@
 
 }
 
-Service *PackageManager_CreateObject(Kernel *kernelPtr) {
-	return new PackageManager(kernelPtr);
-}
-
 /**
  * Scans through the archive list for a specified file
  */

Modified: scummvm/trunk/engines/sword25/script/luascript.cpp
===================================================================
--- scummvm/trunk/engines/sword25/script/luascript.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/script/luascript.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -64,10 +64,6 @@
 		lua_close(_state);
 }
 
-Service *LuaScriptEngine_CreateObject(Kernel *KernelPtr) {
-	return new LuaScriptEngine(KernelPtr);
-}
-
 namespace {
 int panicCB(lua_State *L) {
 	BS_LOG_ERRORLN("Lua panic. Error message: %s", lua_isnil(L, -1) ? "" : lua_tostring(L, -1));

Modified: scummvm/trunk/engines/sword25/sfx/soundengine.cpp
===================================================================
--- scummvm/trunk/engines/sword25/sfx/soundengine.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/sfx/soundengine.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -67,10 +67,6 @@
 		_handles[i].type = kFreeHandle;
 }
 
-Service *SoundEngine_CreateObject(Kernel *pKernel) {
-	return new SoundEngine(pKernel);
-}
-
 bool SoundEngine::init(uint sampleRate, uint channels) {
 	warning("STUB: SoundEngine::init(%d, %d)", sampleRate, channels);
 

Modified: scummvm/trunk/engines/sword25/sword25.cpp
===================================================================
--- scummvm/trunk/engines/sword25/sword25.cpp	2010-10-25 22:15:47 UTC (rev 53834)
+++ scummvm/trunk/engines/sword25/sword25.cpp	2010-10-25 22:41:25 UTC (rev 53835)
@@ -95,14 +95,8 @@
 		return Common::kUnknownError;
 	}
 
-	// Package-Manager starten, damit die Packfiles geladen werden k\xF6nnen.
-	PackageManager *packageManagerPtr = static_cast<PackageManager *>(Kernel::getInstance()->newService("package", PACKAGE_MANAGER));
-	if (!packageManagerPtr) {
-		BS_LOG_ERRORLN("PackageManager initialization failed.");
-		return Common::kUnknownError;
-	}
-
-	// Packages laden oder das aktuelle Verzeichnis mounten, wenn das \xFCber Kommandozeile angefordert wurde.
+	// Load packages
+	PackageManager *packageManagerPtr = Kernel::getInstance()->getPackage();
 	if (getGameFlags() & GF_EXTRACTED) {
 		if (!packageManagerPtr->loadDirectoryAsPackage(ConfMan.get("path"), "/"))
 			return Common::kUnknownError;
@@ -111,7 +105,7 @@
 			return Common::kUnknownError;
 	}
 
-	// Einen Pointer auf den Skript-Engine holen.
+	// Pass the command line to the script engine.
 	ScriptEngine *scriptPtr = Kernel::getInstance()->getScript();
 	if (!scriptPtr) {
 		BS_LOG_ERRORLN("Script intialization failed.");
@@ -152,7 +146,8 @@
 	BS_ASSERT(packageManagerPtr);
 
 	// Load the main package
-	if (!packageManagerPtr->loadPackage("data.b25c", "/")) return false;
+	if (!packageManagerPtr->loadPackage("data.b25c", "/"))
+		return false;
 
 	// Get the contents of the main program directory and sort them alphabetically
 	Common::FSNode dir(ConfMan.get("path"));


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list