[Scummvm-cvs-logs] SF.net SVN: scummvm:[48215] scummvm/trunk/engines/drascula

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Wed Mar 10 00:35:30 CET 2010


Revision: 48215
          http://scummvm.svn.sourceforge.net/scummvm/?rev=48215&view=rev
Author:   fingolfin
Date:     2010-03-09 23:35:30 +0000 (Tue, 09 Mar 2010)

Log Message:
-----------
DRASCULA: Some cleanup; turn some global C++ objects into members of DrasculaEngine

Modified Paths:
--------------
    scummvm/trunk/engines/drascula/drascula.cpp
    scummvm/trunk/engines/drascula/drascula.h
    scummvm/trunk/engines/drascula/palette.cpp
    scummvm/trunk/engines/drascula/rooms.cpp
    scummvm/trunk/engines/drascula/talk.cpp

Modified: scummvm/trunk/engines/drascula/drascula.cpp
===================================================================
--- scummvm/trunk/engines/drascula/drascula.cpp	2010-03-09 05:03:38 UTC (rev 48214)
+++ scummvm/trunk/engines/drascula/drascula.cpp	2010-03-09 23:35:30 UTC (rev 48215)
@@ -102,12 +102,16 @@
 	_lang = kEnglish;
 
 	_keyBufferHead = _keyBufferTail = 0;
+
+	_roomHandlers = 0;
 }
 
 DrasculaEngine::~DrasculaEngine() {
 	delete _rnd;
 	stopSound();
 
+	freeRoomsTable();
+
 	free(_charMap);
 	free(_itemLocations);
 	free(_polX);
@@ -748,15 +752,15 @@
 }
 
 void DrasculaEngine::delay(int ms) {
-	_system->delayMillis(ms * 2); // originaly was 1
+	_system->delayMillis(ms * 2); // originally was 1
 }
 
 void DrasculaEngine::pause(int duration) {
-	_system->delayMillis(duration * 30); // was originaly 2
+	_system->delayMillis(duration * 30); // was originally 2
 }
 
 int DrasculaEngine::getTime() {
-	return _system->getMillis() / 20; // originaly was 1
+	return _system->getMillis() / 20; // originally was 1
 }
 
 void DrasculaEngine::reduce_hare_chico(int xx1, int yy1, int xx2, int yy2, int width, int height, int factor, byte *dir_inicio, byte *dir_fin) {
@@ -1029,7 +1033,7 @@
 	if (!ptr)
 		return;
 
-	free(ptr[0]);
+	free(*ptr);
 	free(ptr);
 }
 

Modified: scummvm/trunk/engines/drascula/drascula.h
===================================================================
--- scummvm/trunk/engines/drascula/drascula.h	2010-03-09 05:03:38 UTC (rev 48214)
+++ scummvm/trunk/engines/drascula/drascula.h	2010-03-09 23:35:30 UTC (rev 48215)
@@ -311,9 +311,11 @@
 
 #define KEYBUFSIZE		16
 
-static const int interf_x[] ={ 1, 65, 129, 193, 1, 65, 129 };
-static const int interf_y[] ={ 51, 51, 51, 51, 83, 83, 83 };
+static const int interf_x[] = { 1, 65, 129, 193, 1, 65, 129 };
+static const int interf_y[] = { 51, 51, 51, 51, 83, 83, 83 };
 
+struct RoomHandlers;
+
 class DrasculaEngine : public ::Engine {
 protected:
 	// Engine APIs
@@ -597,6 +599,7 @@
 	int whichObject();
 	bool checkMenuFlags();
 	void setupRoomsTable();
+	void freeRoomsTable();
 	bool roomParse(int, int);
 	void cleanupString(char *string);
 	void playTalkSequence(int sequence);
@@ -780,6 +783,9 @@
 
 	char **loadTexts(Common::File &in);
 	void freeTexts(char **ptr);
+
+protected:
+	RoomHandlers	*_roomHandlers;
 };
 
 

Modified: scummvm/trunk/engines/drascula/palette.cpp
===================================================================
--- scummvm/trunk/engines/drascula/palette.cpp	2010-03-09 05:03:38 UTC (rev 48214)
+++ scummvm/trunk/engines/drascula/palette.cpp	2010-03-09 23:35:30 UTC (rev 48215)
@@ -27,7 +27,7 @@
 
 namespace Drascula {
 
-const char colorTable[][3] = {
+static const char colorTable[][3] = {
 	{    0,    0,    0 }, { 0x10, 0x3E, 0x28 },
 	{    0,    0,    0 },	// unused
 	{ 0x16, 0x3F, 0x16 }, { 0x09, 0x3F, 0x12 },

Modified: scummvm/trunk/engines/drascula/rooms.cpp
===================================================================
--- scummvm/trunk/engines/drascula/rooms.cpp	2010-03-09 05:03:38 UTC (rev 48214)
+++ scummvm/trunk/engines/drascula/rooms.cpp	2010-03-09 23:35:30 UTC (rev 48215)
@@ -35,7 +35,7 @@
 	int flag;
 };
 
-doorInfo doors[] = {
+static const doorInfo doors[] = {
 	{	2,	138,	 0 },	{	2,	136,	 8 },
 	{	2,	156,	16 },	{	2,	163,	17 },
 	{	2,	177,	15 },	{	2,	175,	40 },
@@ -63,15 +63,19 @@
 	Updater proc;
 };
 
-Common::Array<DrasculaRoomParser*> _roomParsers;
-Common::Array<DrasculaUpdater*> _roomPreupdaters;
-Common::Array<DrasculaUpdater*> _roomUpdaters;
+struct RoomHandlers {
+	Common::Array<DrasculaRoomParser *> roomParsers;
+	Common::Array<DrasculaUpdater *> roomPreupdaters;
+	Common::Array<DrasculaUpdater *> roomUpdaters;
+};
 
-#define ROOM(x) _roomParsers.push_back(new DrasculaRoomParser(#x, &DrasculaEngine::x))
-#define PREUPDATEROOM(x) _roomPreupdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x))
-#define UPDATEROOM(x) _roomUpdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x))
+#define ROOM(x) _roomHandlers->roomParsers.push_back(new DrasculaRoomParser(#x, &DrasculaEngine::x))
+#define PREUPDATEROOM(x) _roomHandlers->roomPreupdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x))
+#define UPDATEROOM(x) _roomHandlers->roomUpdaters.push_back(new DrasculaUpdater(#x, &DrasculaEngine::x))
 
 void DrasculaEngine::setupRoomsTable() {
+	_roomHandlers = new RoomHandlers();
+
 	ROOM(room_0);	// default
 	ROOM(room_1);
 	ROOM(room_3);
@@ -135,6 +139,11 @@
 	UPDATEROOM(update_102);
 }
 
+void DrasculaEngine::freeRoomsTable() {
+	delete _roomHandlers;
+	_roomHandlers = 0;
+}
+
 bool DrasculaEngine::roomParse(int rN, int fl) {
 	bool seen = false;
 
@@ -1080,10 +1089,10 @@
 	// Call room-specific updater
 	char rm[20];
 	sprintf(rm, "update_%d", roomNumber);
-	for (uint i = 0; i < _roomUpdaters.size(); i++) {
-		if (!strcmp(rm, _roomUpdaters[i]->desc)) {
+	for (uint i = 0; i < _roomHandlers->roomUpdaters.size(); i++) {
+		if (!strcmp(rm, _roomHandlers->roomUpdaters[i]->desc)) {
 			debug(4, "Calling room updater %d", roomNumber);
-			(this->*(_roomUpdaters[i]->proc))();
+			(this->*(_roomHandlers->roomUpdaters[i]->proc))();
 			break;
 		}
 	}
@@ -1118,10 +1127,10 @@
 	// Call room-specific preupdater
 	char rm[20];
 	sprintf(rm, "update_%d_pre", roomNumber);
-	for (uint i = 0; i < _roomPreupdaters.size(); i++) {
-		if (!strcmp(rm, _roomPreupdaters[i]->desc)) {
+	for (uint i = 0; i < _roomHandlers->roomPreupdaters.size(); i++) {
+		if (!strcmp(rm, _roomHandlers->roomPreupdaters[i]->desc)) {
 			debug(4, "Calling room preupdater %d", roomNumber);
-			(this->*(_roomPreupdaters[i]->proc))();
+			(this->*(_roomHandlers->roomPreupdaters[i]->proc))();
 			break;
 		}
 	}
@@ -1619,11 +1628,11 @@
 		// Call room-specific parser
 		char rm[20];
 		sprintf(rm, "room_%d", rN);
-		for (uint i = 0; i < _roomParsers.size(); i++) {
-			if (!strcmp(rm, _roomParsers[i]->desc)) {
+		for (uint i = 0; i < _roomHandlers->roomParsers.size(); i++) {
+			if (!strcmp(rm, _roomHandlers->roomParsers[i]->desc)) {
 				debug(4, "Calling room parser %d", rN);
 
-				return (this->*(_roomParsers[i]->proc))(fl);
+				return (this->*(_roomHandlers->roomParsers[i]->proc))(fl);
 			}
 		}
 

Modified: scummvm/trunk/engines/drascula/talk.cpp
===================================================================
--- scummvm/trunk/engines/drascula/talk.cpp	2010-03-09 05:03:38 UTC (rev 48214)
+++ scummvm/trunk/engines/drascula/talk.cpp	2010-03-09 23:35:30 UTC (rev 48215)
@@ -27,8 +27,8 @@
 
 namespace Drascula {
 
-int x_talk_dch[6] = {1, 25, 49, 73, 97, 121};
-int x_talk_izq[6] = {145, 169, 193, 217, 241, 265};
+static const int x_talk_dch[6] = {1, 25, 49, 73, 97, 121};
+static const int x_talk_izq[6] = {145, 169, 193, 217, 241, 265};
 
 void DrasculaEngine::talkInit(const char *filename) {
 	_rnd->setSeed((unsigned int)_system->getMillis() / 2);
@@ -55,10 +55,10 @@
 	char filename[20];
 	sprintf(filename, "I%i.als", index);
 	const char *said = _texti[index];
-	int x_talk0[8] = {  56,  82, 108, 134, 160, 186, 212, 238 };
-	int x_talk1[8] = {  56,  86, 116, 146, 176, 206, 236, 266 };
-	int x_talk3[4] = {  80, 102, 124, 146 };
-	int x_talk4[4] = { 119, 158, 197, 236 };
+	static const int x_talk0[8] = {  56,  82, 108, 134, 160, 186, 212, 238 };
+	static const int x_talk1[8] = {  56,  86, 116, 146, 176, 206, 236, 266 };
+	static const int x_talk3[4] = {  80, 102, 124, 146 };
+	static const int x_talk4[4] = { 119, 158, 197, 236 };
 	int face = 0;
 
 	color_abc(kColorWhite);


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