[Scummvm-cvs-logs] CVS: residual actor.cpp,1.32,1.33 costume.cpp,1.19,1.20 engine.cpp,1.50,1.51 engine.h,1.15,1.16 localize.cpp,1.5,1.6 localize.h,1.5,1.6 lua.cpp,1.83,1.84 main.cpp,1.38,1.39 model.cpp,1.19,1.20 objectstate.cpp,1.3,1.4 resource.cpp,1.16,1.17 resource.h,1.11,1.12 scene.cpp,1.28,1.29 smush.cpp,1.51,1.52 textobject.cpp,1.11,1.12

Pawel Kolodziejski aquadran at users.sourceforge.net
Fri Dec 31 13:36:11 CET 2004


Update of /cvsroot/scummvm/residual
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1145

Modified Files:
	actor.cpp costume.cpp engine.cpp engine.h localize.cpp 
	localize.h lua.cpp main.cpp model.cpp objectstate.cpp 
	resource.cpp resource.h scene.cpp smush.cpp textobject.cpp 
Log Message:
replace class instances into global refrences

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/actor.cpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- actor.cpp	28 Dec 2004 08:05:17 -0000	1.32
+++ actor.cpp	31 Dec 2004 21:35:04 -0000	1.33
@@ -37,7 +37,7 @@
 		_turnCostume(NULL), _leftTurnChore(-1), _rightTurnChore(-1),
 		_lastTurnDir(0), _currTurnDir(0),
 		_mumbleCostume(NULL), _mumbleChore(-1) {
-	Engine::instance()->registerActor(this);
+	g_engine->registerActor(this);
 	_lookingMode = false;
 	_constrain = false;
 
@@ -87,7 +87,7 @@
 }
 
 void Actor::walkForward() {
-	float dist = Engine::instance()->perSecond(_walkRate);
+	float dist = g_engine->perSecond(_walkRate);
 	float yaw_rad = _yaw * (M_PI / 180), pitch_rad = _pitch * (M_PI / 180);
 	Vector3d forwardVec(-std::sin(yaw_rad) * std::cos(pitch_rad),
 		std::cos(yaw_rad) * std::cos(pitch_rad),
@@ -98,7 +98,7 @@
 		_pos = destPos;
 		_walkedCur = true;
 	} else {
-		Sector *sector = Engine::instance()->currScene()->findPointSector(destPos, 0x1000);
+		Sector *sector = g_engine->currScene()->findPointSector(destPos, 0x1000);
 		if (sector != NULL) {
 			_pos = sector->projectToPlane(destPos);
 			_walkedCur = true;
@@ -110,7 +110,7 @@
 	float yaw_rad = _yaw * (M_PI / 180);
 	Vector3d forwardVec(-std::sin(yaw_rad), std::cos(yaw_rad), 0);
 
-	Sector *sector = Engine::instance()->currScene()->findPointSector(_pos, 0x1000);
+	Sector *sector = g_engine->currScene()->findPointSector(_pos, 0x1000);
 	if (sector == NULL)
 		return forwardVec;
 	else
@@ -185,7 +185,7 @@
 }
 
 void Actor::turn(int dir) {
-	float delta = Engine::instance()->perSecond(_turnRate) * dir;
+	float delta = g_engine->perSecond(_turnRate) * dir;
 	_yaw += delta;
 	_currTurnDir = dir;
 }
@@ -223,11 +223,11 @@
 //	if (_talkSound) // Only one line at a time, please :)
 //		shutUp();
 
-	std::string msgText = Localizer::instance()->localize(secondSlash + 1);
+	std::string msgText = g_localizer->localize(secondSlash + 1);
  	std::string msgId(msg + 1, secondSlash);
 
-//	_talkSound = ResourceLoader::instance()->loadSound((msgId + ".wav").c_str());
-	_lipSynch = ResourceLoader::instance()->loadLipSynch((msgId + ".lip").c_str());
+//	_talkSound = g_resourceloader->loadSound((msgId + ".wav").c_str());
+	_lipSynch = g_resourceloader->loadLipSynch((msgId + ".lip").c_str());
 
 /*	if (_talkSound != NULL) {
 		Mixer::instance()->playVoice(_talkSound);
@@ -270,7 +270,7 @@
 }
 
 void Actor::pushCostume(const char *name) {
-	Costume *newCost = ResourceLoader::instance()->loadCostume(name, currentCostume());
+	Costume *newCost = g_resourceloader->loadCostume(name, currentCostume());
 	_costumeStack.push_back(newCost);
 }
 
@@ -325,11 +325,11 @@
 	// necessary for example after activating/deactivating
 	// walkboxes, etc.
 	if (_constrain && !_walking) {
-		Engine::instance()->currScene()->findClosestSector(_pos, NULL, &_pos);
+		g_engine->currScene()->findClosestSector(_pos, NULL, &_pos);
 	}
 
 	if (_turning) {
-		float turnAmt = Engine::instance()->perSecond(_turnRate);
+		float turnAmt = g_engine->perSecond(_turnRate);
 		float dyaw = _destYaw - _yaw;
 		while (dyaw > 180)
 			dyaw -= 360;
@@ -353,7 +353,7 @@
 		if (dist > 0)
 			dir /= dist;
 
-		float walkAmt = Engine::instance()->perSecond(_walkRate);
+		float walkAmt = g_engine->perSecond(_walkRate);
 
 		if (walkAmt >= dist) {
 			_pos = _destPos;
@@ -423,7 +423,7 @@
 	}
 
 	if (_lookingMode) {
-		float lookAtAmt = Engine::instance()->perSecond(_lookAtRate);
+		float lookAtAmt = g_engine->perSecond(_lookAtRate);
 	}
 }
 

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/costume.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- costume.cpp	28 Dec 2004 08:05:17 -0000	1.19
+++ costume.cpp	31 Dec 2004 21:35:04 -0000	1.20
@@ -158,7 +158,7 @@
 }
 
 void BitmapComponent::setKey(int val) {
-	ObjectState *state = Engine::instance()->currScene()->findState(_filename.c_str());
+	ObjectState *state = g_engine->currScene()->findState(_filename.c_str());
 
 	if (state != NULL)
 		state->setNumber(val);
@@ -177,9 +177,9 @@
 		// constructor before
 		if (_cmap == NULL) {
 			warning("No colormap specified for %s\n", _filename.c_str());
-			_cmap = ResourceLoader::instance()->loadColormap("item.cmp");
+			_cmap = g_resourceloader->loadColormap("item.cmp");
 		}
-		_obj = ResourceLoader::instance()->loadModel(_filename.c_str(), *_cmap);
+		_obj = g_resourceloader->loadModel(_filename.c_str(), *_cmap);
 		_hier = _obj->copyHierarchy();
 		_hier->_hierVisible = false;
 	}
@@ -279,7 +279,7 @@
 
 ColormapComponent::ColormapComponent(Costume::Component *parent, int parentID, const char *filename) :
 		Costume::Component(parent, parentID) {
-	_cmap = ResourceLoader::instance()->loadColormap(filename);
+	_cmap = g_resourceloader->loadColormap(filename);
 
 	ModelComponent *mc = dynamic_cast<ModelComponent *>(parent);
 	if (mc != NULL)
@@ -312,10 +312,10 @@
 	const char *comma = std::strchr(filename, ',');
 	if (comma != NULL) {
 		std::string realName(filename, comma);
-		_keyf = ResourceLoader::instance()->loadKeyframe(realName.c_str());
+		_keyf = g_resourceloader->loadKeyframe(realName.c_str());
 		std::sscanf(comma + 1, "%d,%d", &_priority1, &_priority2);
 	} else
-		_keyf = ResourceLoader::instance()->loadKeyframe(filename);
+		_keyf = g_resourceloader->loadKeyframe(filename);
 }
 
 void KeyframeComponent::setKey(int val) {
@@ -349,7 +349,7 @@
 	if (_currTime < 0)		// For first time through
 		_currTime = 0;
 	else
-		_currTime += Engine::instance()->frameTime();
+		_currTime += g_engine->frameTime();
 
 	int animLength = (int)(_keyf->length() * 1000);
 
@@ -436,8 +436,8 @@
 	// The parent model and thus all its textures should have been
 	// loaded by now, so passing an arbitrary colormap here
 	// shouldn't cause problems.
-	ResPtr<CMap> cmap = ResourceLoader::instance()->loadColormap("item.cmp");
-	_mat = ResourceLoader::instance()->loadMaterial(_filename.c_str(), *cmap);
+	ResPtr<CMap> cmap = g_resourceloader->loadColormap("item.cmp");
+	_mat = g_resourceloader->loadMaterial(_filename.c_str(), *cmap);
 }
 
 void MaterialComponent::setKey(int val) {
@@ -487,9 +487,9 @@
 	const char *comma = std::strchr(filename, ',');
 	if (comma != NULL) {
 		std::string realName(filename, comma);
-//		_sound = ResourceLoader::instance()->loadSound(realName.c_str());
+//		_sound = g_resourceloader->loadSound(realName.c_str());
 	} else {
-//		_sound = ResourceLoader::instance()->loadSound(filename);
+//		_sound = g_resourceloader->loadSound(filename);
 	}
 }
 
@@ -667,7 +667,7 @@
 	if (_currTime < 0)
 		newTime = 0; // For first time through
 	else
-		newTime = _currTime + Engine::instance()->frameTime();
+		newTime = _currTime + g_engine->frameTime();
 
 	setKeys(_currTime, newTime);
 

Index: engine.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.cpp,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- engine.cpp	31 Dec 2004 20:11:09 -0000	1.50
+++ engine.cpp	31 Dec 2004 21:35:04 -0000	1.51
@@ -31,7 +31,7 @@
 
 #include "driver_gl.h"
 
-Engine *Engine::_instance = NULL;
+Engine *g_engine = NULL;
 
 extern Imuse *g_imuse;
 
@@ -227,11 +227,11 @@
 }
 
 void Engine::savegameGzread(void *data, int size) {
-	gzread(Engine::instance()->_savegameFileHandle, data, size);
+	gzread(g_engine->_savegameFileHandle, data, size);
 }
 
 void Engine::savegameGzwrite(void *data, int size) {
-	gzwrite(Engine::instance()->_savegameFileHandle, data, size);
+	gzwrite(g_engine->_savegameFileHandle, data, size);
 }
 
 void Engine::savegameRestore() {
@@ -334,7 +334,7 @@
 }
 
 void Engine::setScene(const char *name) {
-	Block *b = ResourceLoader::instance()->getFileBlock(name);
+	Block *b = g_resourceloader->getFileBlock(name);
 	if (b == NULL)
 		warning("Could not find scene file %s\n", name);
 	delete _currScene;

Index: engine.h
===================================================================
RCS file: /cvsroot/scummvm/residual/engine.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- engine.h	25 Dec 2004 18:23:06 -0000	1.15
+++ engine.h	31 Dec 2004 21:35:04 -0000	1.16
@@ -88,11 +88,6 @@
 
 class Engine {
 public:
-	static Engine *instance() {
-		if (_instance == NULL)
-			_instance = new Engine;
-		return _instance;
-	}
 
 	void setMode(int mode) { _mode = mode; }
 	void setSpeechMode(int mode) { _speechMode = mode; }
@@ -153,11 +148,10 @@
 	char *_savegameFileName;
 	gzFile _savegameFileHandle;
 
-private:
-	static Engine *_instance;
-
 	Engine();
-	~Engine() { }
+	~Engine() {}
+
+private:
 
 	Scene *_currScene;
 	int _mode;
@@ -172,4 +166,6 @@
 	TextListType _textObjects;
 };
 
+extern Engine *g_engine;
+
 #endif

Index: localize.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/localize.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- localize.cpp	10 Dec 2004 07:26:03 -0000	1.5
+++ localize.cpp	31 Dec 2004 21:35:04 -0000	1.6
@@ -22,13 +22,7 @@
 #include <cstdio>
 #include <cstring>
 
-Localizer *Localizer::_instance = NULL;
-
-Localizer *Localizer::instance() {
-	if (_instance == NULL)
-		_instance = new Localizer;
-	return _instance;
-}
+Localizer *g_localizer = NULL;
 
 Localizer::Localizer() {
 	std::FILE *f;

Index: localize.h
===================================================================
RCS file: /cvsroot/scummvm/residual/localize.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- localize.h	10 Dec 2004 07:26:03 -0000	1.5
+++ localize.h	31 Dec 2004 21:35:04 -0000	1.6
@@ -23,18 +23,17 @@
 
 class Localizer {
 public:
-	static Localizer *instance();
-
 	std::string localize(const char *str) const;
 
-private:
 	Localizer();
 	~Localizer() { }
 
-	static Localizer *_instance;
+private:
 
 	typedef std::map<std::string, std::string> StringMap;
 	StringMap _entries;
 };
 
+extern Localizer *g_localizer;
+
 #endif

Index: lua.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/lua.cpp,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -d -r1.83 -r1.84
--- lua.cpp	30 Dec 2004 22:38:53 -0000	1.83
+++ lua.cpp	31 Dec 2004 21:35:04 -0000	1.84
@@ -196,7 +196,7 @@
 
 static void CheckForFile() {
 	char *filename = luaL_check_string(1);
-	pushbool(ResourceLoader::instance()->fileExists(filename));
+	pushbool(g_resourceloader->fileExists(filename));
 }
 
 // Color functions
@@ -248,7 +248,7 @@
 
 static void LocalizeString() {
 	char *str = luaL_check_string(1);
-	std::string result = Localizer::instance()->localize(str);
+	std::string result = g_localizer->localize(str);
 	lua_pushstring(const_cast<char *>(result.c_str()));
 }
 
@@ -265,7 +265,7 @@
 
 static void SetSelectedActor() {
 	Actor *act = check_actor(1);
-	Engine::instance()->setSelectedActor(act);
+	g_engine->setSelectedActor(act);
 }
 
 static void SetActorTalkColor() {
@@ -659,9 +659,9 @@
 
 static void GetVisibleThings() {
 	lua_Object result = lua_createtable();
-	Actor *sel = Engine::instance()->selectedActor();
-	for (Engine::ActorListType::const_iterator i = Engine::instance()->actorsBegin(); i != Engine::instance()->actorsEnd(); i++) {
-		if (!(*i)->inSet(Engine::instance()->sceneName()))
+	Actor *sel = g_engine->selectedActor();
+	for (Engine::ActorListType::const_iterator i = g_engine->actorsBegin(); i != g_engine->actorsEnd(); i++) {
+		if (!(*i)->inSet(g_engine->sceneName()))
 			continue;
 		if (sel->angleTo(*(*i)) < 90) {
 			lua_pushobject(result);
@@ -717,7 +717,7 @@
 	Actor *act = check_actor(1);
 	int sectorType = check_int(2);
 
-	Sector *result = Engine::instance()->currScene()->findPointSector(act->pos(), sectorType);
+	Sector *result = g_engine->currScene()->findPointSector(act->pos(), sectorType);
 	if (result != NULL) {
 		lua_pushnumber(result->id());
 		lua_pushstring(const_cast<char *>(result->name()));
@@ -732,10 +732,10 @@
 static void IsActorInSector(void) {
 	Actor *act = check_actor(1);
 	const char *name = luaL_check_string(2);
-	int i, numSectors = Engine::instance()->currScene()->getSectorCount();
+	int i, numSectors = g_engine->currScene()->getSectorCount();
 
 	for (i=0; i<numSectors; i++) {
-		Sector *sector = Engine::instance()->currScene()->getSectorBase(i);
+		Sector *sector = g_engine->currScene()->getSectorBase(i);
 
 		if (sector->visible() && strstr(sector->name(), name)) {
 			if (sector->isPointInSector(act->pos())) {
@@ -755,18 +755,18 @@
 	int i = 0, numSectors;
 
 	// FIXME: This happens on initial load. Are we initting something in the wrong order?
-	if (!Engine::instance()->currScene()) {
+	if (!g_engine->currScene()) {
 		warning("!!!! Trying to call MakeSectorActive without a scene!");
 		return;
 	}
 
-	numSectors = Engine::instance()->currScene()->getSectorCount();
+	numSectors = g_engine->currScene()->getSectorCount();
 
 	if (lua_isstring(sectorName)) {
 		char *name = luaL_check_string(1);
 
 		for (i=0; i<numSectors; i++) {
-			Sector *sector = Engine::instance()->currScene()->getSectorBase(i);
+			Sector *sector = g_engine->currScene()->getSectorBase(i);
 			if (strstr(sector->name(), name)) {
 				sector->setVisible(visible);
 				return;
@@ -776,7 +776,7 @@
 		int id = check_int(1);
 
 		for (i=0; i<numSectors; i++) {
-			Sector *sector = Engine::instance()->currScene()->getSectorBase(i);
+			Sector *sector = g_engine->currScene()->getSectorBase(i);
 			if (sector->id() == id) {
 				sector->setVisible(visible);
 				return;
@@ -792,14 +792,14 @@
 
 static void MakeCurrentSet() {
 	const char *name = luaL_check_string(1);
-	Engine::instance()->setScene(name);
+	g_engine->setScene(name);
 }
 
 static void MakeCurrentSetup() {
 	int num = check_int(1);
-	int prevSetup = Engine::instance()->currScene()->setup();
+	int prevSetup = g_engine->currScene()->setup();
 
-	Engine::instance()->currScene()->setSetup(num);
+	g_engine->currScene()->setSetup(num);
 
 	lua_beginblock();
 	lua_Object camChangeHandler = getEventHandler("camChangeHandler");
@@ -821,8 +821,8 @@
 
 static void GetCurrentSetup() {
 	const char *name = luaL_check_string(1);
-	if (std::strcmp(name, Engine::instance()->sceneName()) == 0)
-		lua_pushnumber(Engine::instance()->currScene()->setup());
+	if (std::strcmp(name, g_engine->sceneName()) == 0)
+		lua_pushnumber(g_engine->currScene()->setup());
 	else
 		lua_pushnil();
 }
@@ -1006,17 +1006,17 @@
 
 void PerSecond() {
 	float rate = luaL_check_number(1);
-	lua_pushnumber(Engine::instance()->perSecond(rate));
+	lua_pushnumber(g_engine->perSecond(rate));
 }
 
 void EnableControl() {
 	int num = check_control(1);
-	Engine::instance()->enableControl(num);
+	g_engine->enableControl(num);
 }
 
 void DisableControl() {
 	int num = check_control(1);
-	Engine::instance()->disableControl(num);
+	g_engine->disableControl(num);
 }
 
 void GetControlState() {
@@ -1079,18 +1079,18 @@
 
 	if (lua_isnil(lua_getparam(1))) { // FIXME: check this.. nil is kill all lines?
 		error("KillTextObject(NULL)");
-		//Engine::instance()->killTextObjects();
+		//g_engine->killTextObjects();
 		return;
 	}
 
 	textID = lua_getstring(lua_getparam(1));
 
-	for (Engine::TextListType::const_iterator i = Engine::instance()->textsBegin();
-			i != Engine::instance()->textsEnd(); i++) {
+	for (Engine::TextListType::const_iterator i = g_engine->textsBegin();
+			i != g_engine->textsEnd(); i++) {
 		TextObject *textO = *i;
 
 		if (strstr(textO->name(), textID)) {
-			Engine::instance()->killTextObject(textO);
+			g_engine->killTextObject(textO);
 			delete textO;
 			return;
 		}
@@ -1142,7 +1142,7 @@
 	lua_Object tableObj = lua_getparam(2);
 	TextObject *modifyObject = NULL;
 
-	for (Engine::TextListType::const_iterator i = Engine::instance()->textsBegin(); i != Engine::instance()->textsEnd(); i++) {
+	for (Engine::TextListType::const_iterator i = g_engine->textsBegin(); i != g_engine->textsEnd(); i++) {
 		TextObject *textO = *i;
 
 		if (strstr(textO->name(), textID)) {
@@ -1172,17 +1172,17 @@
 static void SetSpeechMode() {
 	int mode = check_int(1);
 	if ((mode >= 1) && (mode <= 3))
- 		Engine::instance()->setSpeechMode(mode);
+ 		g_engine->setSpeechMode(mode);
 }
 
 static void GetSpeechMode() {
-	int mode = Engine::instance()->getSpeechMode();
+	int mode = g_engine->getSpeechMode();
  	lua_pushnumber(mode);
 }
 
 static void StartFullscreenMovie() {
 	bool mode = getbool(2);
-	Engine::instance()->setMode(ENGINE_MODE_SMUSH);
+	g_engine->setMode(ENGINE_MODE_SMUSH);
 	pushbool(g_smush->play(luaL_check_string(1), 0, 0));
 }
 
@@ -1197,7 +1197,7 @@
 	if (!lua_isnil(lua_getparam(4)))
 		y = check_int(4);
 
-	Engine::instance()->setMode(ENGINE_MODE_NORMAL);
+	g_engine->setMode(ENGINE_MODE_NORMAL);
 	pushbool(g_smush->play(luaL_check_string(1), x, y));
 }
 
@@ -1249,7 +1249,7 @@
 		zbitmap = luaL_check_string(4);
 
 	object = new ObjectState(setupID, pos, bitmap, zbitmap, visible);
-	Engine::instance()->currScene()->addObjectState(object);
+	g_engine->currScene()->addObjectState(object);
 	lua_pushusertag(object, object_tag);
 }
 
@@ -1266,27 +1266,27 @@
 static void Load() {
 	lua_Object fileName = lua_getparam(1);
 	if (lua_isnil(fileName)) {
-		Engine::instance()->_savegameFileName = NULL;
+		g_engine->_savegameFileName = NULL;
 	} else if (lua_isstring(fileName)) {
-		Engine::instance()->_savegameFileName = lua_getstring(fileName);
+		g_engine->_savegameFileName = lua_getstring(fileName);
 	} else {
 		warning("Load() fileName is wrong");
 		return;
 	}
-	Engine::instance()->_savegameLoadRequest = true;
+	g_engine->_savegameLoadRequest = true;
 }
 
 static void Save() {
 	lua_Object fileName = lua_getparam(1);
 	if (lua_isnil(fileName)) {
-		Engine::instance()->_savegameFileName = NULL;
+		g_engine->_savegameFileName = NULL;
 	} else if (lua_isstring(fileName)) {
-		Engine::instance()->_savegameFileName = lua_getstring(fileName);
+		g_engine->_savegameFileName = lua_getstring(fileName);
 	} else {
 		warning("Save() fileName is wrong");
 		return;
 	}
-	Engine::instance()->_savegameSaveRequest = true;
+	g_engine->_savegameSaveRequest = true;
 }
 
 static int SaveCallback(int tag, int value, SaveRestoreFunc saveFunc) {
@@ -1378,7 +1378,7 @@
 	}
 
 	warning("STUB: BlastText(\"%s\", x = %d, y = %d)\n", 
-			Localizer::instance()->localize(str).c_str(), x, y);
+			g_localizer->localize(str).c_str(), x, y);
 }
 
 #define STUB_FUNC(name) static void name() { stubWarning(#name); }
@@ -2143,7 +2143,7 @@
 }
 
 int bundle_dofile(const char *filename) {
-	Block *b = ResourceLoader::instance()->getFileBlock(filename);
+	Block *b = g_resourceloader->getFileBlock(filename);
 	if (b == NULL) {
 		delete b;
 		// Don't print warnings on Scripts\foo.lua,

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/main.cpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- main.cpp	29 Dec 2004 06:32:07 -0000	1.38
+++ main.cpp	31 Dec 2004 21:35:04 -0000	1.39
@@ -23,6 +23,7 @@
 #include "debug.h"
 #include "lua.h"
 #include "registry.h"
+#include "localize.h"
 #include "engine.h"
 #include "timer.h"
 #include "smush.h"
@@ -78,6 +79,8 @@
 	return false;
 }
 
+void quit();
+
 int main(int argc, char *argv[]) {
 	int i;
 
@@ -112,9 +115,11 @@
 	if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
 		return 1;
 
-	atexit(SDL_Quit);
-	atexit(saveRegistry);
+	atexit(quit);
 
+	g_engine = new Engine();
+	g_resourceloader = new ResourceLoader();
+	g_localizer = new Localizer();
 	g_mixer = new SoundMixer();
 	g_mixer->setVolume(255);
 	g_timer = new Timer();
@@ -122,7 +127,7 @@
 	g_driver = new Driver(640, 480, 24);
 	g_imuse = new Imuse(10);
 
-	Bitmap *splash_bm = ResourceLoader::instance()->loadBitmap("splash.bm");
+	Bitmap *splash_bm = g_resourceloader->loadBitmap("splash.bm");
 
 	SDL_Event event;
 	
@@ -155,18 +160,30 @@
 //	lua_pushnumber(0);		// bootParam
 	lua_call("BOOT");
 
-	Engine::instance()->setMode(ENGINE_MODE_NORMAL);
-	Engine::instance()->mainLoop();
+	g_engine->setMode(ENGINE_MODE_NORMAL);
+	g_engine->mainLoop();
 
-	lua_removelibslists();
-	lua_close();
+	quit();
+
+	return 0;
+}
+
+void quit() {
+	saveRegistry();
 
-	delete g_imuse;
 	delete g_smush;
+	delete g_imuse;
+	delete g_localizer;
+	delete g_resourceloader;
+	delete g_engine;
 	delete g_timer;
 	delete g_mixer;
+	delete g_driver;
 
-	return 0;
+	lua_removelibslists();
+	lua_close();
+
+	SDL_Quit();
 }
 
 StackLock::StackLock(MutexRef mutex) :

Index: model.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/model.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- model.cpp	9 Dec 2004 23:55:43 -0000	1.19
+++ model.cpp	31 Dec 2004 21:35:04 -0000	1.20
@@ -41,7 +41,7 @@
 	data += 8;
 	_materials = new ResPtr<Material>[_numMaterials];
 	for (int i = 0; i < _numMaterials; i++) {
-		_materials[i] = ResourceLoader::instance()->loadMaterial(data, cmap);
+		_materials[i] = g_resourceloader->loadMaterial(data, cmap);
 		data += 32;
 	}
 	data += 32; // skip name
@@ -246,7 +246,7 @@
 		int num;
 		char name[32];
 		ts.scanString("%d: %32s", 2, &num, name);
-		_materials[num] = ResourceLoader::instance()->loadMaterial(name, cmap);
+		_materials[num] = g_resourceloader->loadMaterial(name, cmap);
 	}
 
 	ts.expectString("section: geometrydef");

Index: objectstate.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/objectstate.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- objectstate.cpp	9 Dec 2004 23:55:43 -0000	1.3
+++ objectstate.cpp	31 Dec 2004 21:35:04 -0000	1.4
@@ -2,9 +2,9 @@
 
 ObjectState::ObjectState(int setupID, ObjectState::Position pos, const char *bitmap, const char *zbitmap, bool visible) :
 		_setupID(setupID), _pos(pos) {
-	_bitmap = ResourceLoader::instance()->loadBitmap(bitmap);
+	_bitmap = g_resourceloader->loadBitmap(bitmap);
 	if (zbitmap)
-		_zbitmap = ResourceLoader::instance()->loadBitmap(zbitmap);
+		_zbitmap = g_resourceloader->loadBitmap(zbitmap);
 
 	int initialImage = 0;
 	if (visible)

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- resource.cpp	28 Dec 2004 08:05:17 -0000	1.16
+++ resource.cpp	31 Dec 2004 21:35:04 -0000	1.17
@@ -35,7 +35,7 @@
 	std::transform(s.begin(), s.end(), s.begin(), tolower);
 }
 
-ResourceLoader *ResourceLoader::_instance = NULL;
+ResourceLoader *g_resourceloader = NULL;
 
 ResourceLoader::ResourceLoader() {
 	const char *directory = Registry::instance()->get("DataDir");

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/residual/resource.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- resource.h	28 Dec 2004 08:05:17 -0000	1.11
+++ resource.h	31 Dec 2004 21:35:04 -0000	1.12
@@ -89,12 +89,6 @@
 	std::FILE *openNewStream(const char *filename) const;
 	int fileLength(const char *filename) const;
 
-	static ResourceLoader *instance() {
-		if (_instance == NULL)
-			_instance = new ResourceLoader;
-		return _instance;
-	}
-
 	Bitmap *loadBitmap(const char *fname);
 	CMap *loadColormap(const char *fname);
 	Costume *loadCostume(const char *fname, Costume *prevCost);
@@ -104,12 +98,11 @@
 	LipSynch *loadLipSynch(const char *fname);
 	void uncache(const char *fname);
 
-private:
 	ResourceLoader();
 	ResourceLoader(const ResourceLoader &);
-	~ResourceLoader();
+	~ResourceLoader() { }
 
-	static ResourceLoader *_instance;
+private:
 
 	typedef std::list<Lab *> LabList;
 	LabList _labs;
@@ -123,9 +116,11 @@
 	friend class dummy;
 };
 
+extern ResourceLoader *g_resourceloader;
+
 inline void Resource::deref() {
 	if (--_ref == 0) {
-		ResourceLoader::instance()->uncache(_fname.c_str());
+		g_resourceloader->uncache(_fname.c_str());
 		delete this;
 	}
 }

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/scene.cpp,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- scene.cpp	10 Dec 2004 07:26:03 -0000	1.28
+++ scene.cpp	31 Dec 2004 21:35:04 -0000	1.29
@@ -39,7 +39,7 @@
 	char cmap_name[256];
 	for (int i = 0; i < _numCmaps; i++) {
 		ts.scanString(" colormap %256s", 1, cmap_name);
-		_cmaps[i] = ResourceLoader::instance()->loadColormap(cmap_name);
+		_cmaps[i] = g_resourceloader->loadColormap(cmap_name);
 	}
 
 	ts.expectString("section: setups");
@@ -104,14 +104,14 @@
 	_name = buf;
 
 	ts.scanString(" background %256s", 1, buf);
-	_bkgndBm = ResourceLoader::instance()->loadBitmap(buf);
+	_bkgndBm = g_resourceloader->loadBitmap(buf);
 
 	// ZBuffer is optional
 	if (!ts.checkString("zbuffer")) {
 		_bkgndZBm = NULL;
 	} else {
 		ts.scanString(" zbuffer %256s", 1, buf);
-		_bkgndZBm = ResourceLoader::instance()->loadBitmap(buf);
+		_bkgndZBm = g_resourceloader->loadBitmap(buf);
 	}
 
 	ts.scanString(" position %f %f %f", 3, &_pos.x(), &_pos.y(), &_pos.z());

Index: smush.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/smush.cpp,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- smush.cpp	31 Dec 2004 20:17:43 -0000	1.51
+++ smush.cpp	31 Dec 2004 21:35:04 -0000	1.52
@@ -165,7 +165,7 @@
 	_frame++;
 	if (_frame == _nbframes) {
 		_videoFinished = true;
-		Engine::instance()->setMode(ENGINE_MODE_NORMAL);
+		g_engine->setMode(ENGINE_MODE_NORMAL);
 	}
 	
 	_movieTime += _speed / 1000;
@@ -234,7 +234,7 @@
 
 void Smush::stop() { 
 	deinit();
- 	Engine::instance()->setMode(ENGINE_MODE_NORMAL);
+ 	g_engine->setMode(ENGINE_MODE_NORMAL);
 }
 
 bool Smush::play(const char *filename, int x, int y) {
@@ -271,14 +271,14 @@
 	if (filename == NULL || *filename == 0)
 		return false;
 
-	_handle = ResourceLoader::instance()->openNewStream(filename);
+	_handle = g_resourceloader->openNewStream(filename);
 	if (!_handle) {
 		warning("zlibFile %s not found", filename);
 		return false;
 	}
-//	int filePos = ftell(_handle);
-//	_handle = fdopen(fileno(_handle), "rb");
-//	fseek(_handle, filePos, SEEK_SET);
+	int filePos = ftell(_handle);
+	_handle = fdopen(fileno(_handle), "rb");
+	fseek(_handle, filePos, SEEK_SET);
 
 	// Read in the GZ header
 	fread(_inBuf, 2, sizeof(char), _handle);				// Header

Index: textobject.cpp
===================================================================
RCS file: /cvsroot/scummvm/residual/textobject.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- textobject.cpp	9 Dec 2004 23:55:43 -0000	1.11
+++ textobject.cpp	31 Dec 2004 21:35:04 -0000	1.12
@@ -25,7 +25,7 @@
 TextObject::TextObject(const char *text, const int x, const int y, const Color& fgColor) :
 		_fgColor(fgColor), _x(x), _y(y) {
 	strcpy(_textID, text);
-	Engine::instance()->registerTextObject(this);
+	g_engine->registerTextObject(this);
 }
 
 void TextObject::setX(int x) {_x = x; }
@@ -33,7 +33,7 @@
 void TextObject::setColor(Color *newcolor) { _fgColor = newcolor; }
 
 void TextObject::draw() {
-	const char *localString = Localizer::instance()->localize(_textID).c_str();
+	const char *localString = g_localizer->localize(_textID).c_str();
 	// This is also used for things like debugging in addition
 	// to dialogue so there aren't always translations
 	if (strrchr(localString, '/') != NULL) {





More information about the Scummvm-git-logs mailing list