[Scummvm-cvs-logs] SF.net SVN: scummvm: [26085] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun Mar 11 15:14:09 CET 2007


Revision: 26085
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26085&view=rev
Author:   peres001
Date:     2007-03-11 07:14:08 -0700 (Sun, 11 Mar 2007)

Log Message:
-----------
wrapped active location data into a new structure

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/callables.cpp
    scummvm/trunk/engines/parallaction/commands.cpp
    scummvm/trunk/engines/parallaction/dialogue.cpp
    scummvm/trunk/engines/parallaction/location.cpp
    scummvm/trunk/engines/parallaction/menu.cpp
    scummvm/trunk/engines/parallaction/music.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp
    scummvm/trunk/engines/parallaction/parallaction.h
    scummvm/trunk/engines/parallaction/saveload.cpp
    scummvm/trunk/engines/parallaction/walk.cpp

Modified: scummvm/trunk/engines/parallaction/callables.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/callables.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/callables.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -300,7 +300,7 @@
 		_vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBit2);
 		waitUntilLeftClick();
 
-		strcpy(_location, "estgrotta.drki");
+		strcpy(_vm->_location._name, "estgrotta.drki");
 
 		_engineFlags |= kEngineChangeLocation;
 	} else {

Modified: scummvm/trunk/engines/parallaction/commands.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/commands.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/commands.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -315,7 +315,7 @@
 			break;
 
 		case CMD_LOCATION:	// location
-			strcpy(_location, u->_string);
+			strcpy(_vm->_location._name, u->_string);
 			_engineFlags |= kEngineChangeLocation;
 			break;
 

Modified: scummvm/trunk/engines/parallaction/dialogue.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/dialogue.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/dialogue.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -225,7 +225,7 @@
 	debugC(1, kDebugDialogue, "runDialogue: enterDialogue ok");
 /*
 	// the only character which can have a dialogue inside the museum location is Dino
-	if (!scumm_stricmp(_location, "museum")) {
+	if (!scumm_stricmp(_name, "museum")) {
 		_vm->_graphics->freeCnv( &_characterFrames );
 		debugC(1, kDebugDialogue, "runDialogue: special trick for 'museum' location");
 	}
@@ -507,7 +507,7 @@
 	// as mentioned in the comment at the beginning of this routine, the only
 	// character which can have a dialogue inside the museum location is Dino,
 	// that's why this hack (with hardcoded Dino) works
-	if (!scumm_stricmp(_location, "museum")) {
+	if (!scumm_stricmp(_name, "museum")) {
 		_vm->_disk->selectArchive("disk1");
 		_vm->_disk->loadFrames(_dinoName, &_characterFrames);
 

Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/location.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -88,8 +88,8 @@
 				_localFlags[_currentLocationIndex] |= kFlagsVisited;	// 'visited'
 			}
 
-			strcpy(_location, _tokens[1]);
-			switchBackground(_location, mask);
+			strcpy(_location._name, _tokens[1]);
+			switchBackground(_location._name, mask);
 
 			if (_tokens[2][0] != '\0') {
 				_yourself._zone.pos._position._x = atoi(_tokens[2]);
@@ -113,10 +113,10 @@
 			_localFlagNames[_si] = 0;
 		}
 		if (!scumm_stricmp(_tokens[0], "COMMANDS")) {
-			_locationCommands = parseCommands(*_locationScript);
+			_location._commands = parseCommands(*_locationScript);
 		}
 		if (!scumm_stricmp(_tokens[0], "ACOMMANDS")) {
-			_locationACommands = parseCommands(*_locationScript);
+			_location._aCommands = parseCommands(*_locationScript);
 		}
 		if (!scumm_stricmp(_tokens[0], "FLAGS")) {
 			if ((_localFlags[_currentLocationIndex] & kFlagsVisited) == 0) {
@@ -135,16 +135,16 @@
 			}
 		}
 		if (!scumm_stricmp(_tokens[0], "COMMENT")) {
-			_locationComment = parseComment(*_locationScript);
+			_location._comment = parseComment(*_locationScript);
 		}
 		if (!scumm_stricmp(_tokens[0], "ENDCOMMENT")) {
-			_locationEndComment = parseComment(*_locationScript);
+			_location._endComment = parseComment(*_locationScript);
 		}
 		if (!scumm_stricmp(_tokens[0], "ZONE")) {
 			parseZone(*_locationScript, &_zones, _tokens[1]);
 		}
 		if (!scumm_stricmp(_tokens[0], "NODES")) {
-			parseWalkNodes(*_locationScript, &_locationWalkNodes);
+			parseWalkNodes(*_locationScript, &_location._walkNodes);
 		}
 		if (!scumm_stricmp(_tokens[0], "ANIMATION")) {
 			parseAnimation(*_locationScript, &_animations, _tokens[1]);
@@ -189,8 +189,8 @@
 	debugC(7, kDebugLocation, "freeLocation: localflags names freed");
 
 
-	freeNodeList(_locationWalkNodes._next);
-	_locationWalkNodes._next = NULL;
+	freeNodeList(_vm->_location._walkNodes._next);
+	_vm->_location._walkNodes._next = NULL;
 	debugC(7, kDebugLocation, "freeLocation: walk nodes freed");
 
 	helperNode._prev = helperNode._next = NULL;
@@ -206,22 +206,22 @@
 	memcpy(&_animations, &helperNode, sizeof(Node));
 	debugC(7, kDebugLocation, "freeLocation: animations freed");
 
-	if (_locationComment) {
-		free(_locationComment);
+	if (_vm->_location._comment) {
+		free(_vm->_location._comment);
 	}
-	_locationComment = NULL;
+	_vm->_location._comment = NULL;
 	debugC(7, kDebugLocation, "freeLocation: comments freed");
 
-	if (_locationCommands) {
-		freeNodeList(&_locationCommands->_node);
+	if (_vm->_location._commands) {
+		freeNodeList(&_vm->_location._commands->_node);
 	}
-	_locationCommands = NULL;
+	_vm->_location._commands = NULL;
 	debugC(7, kDebugLocation, "freeLocation: commands freed");
 
-	if (_locationACommands) {
-		freeNodeList(&_locationACommands->_node);
+	if (_vm->_location._aCommands) {
+		freeNodeList(&_vm->_location._aCommands->_node);
 	}
-	_locationACommands = NULL;
+	_vm->_location._aCommands = NULL;
 	debugC(7, kDebugLocation, "freeLocation: acommands freed");
 
 	return;
@@ -388,29 +388,29 @@
 	_yourself._zone.pos._oldposition._y = -1000;
 
 	_yourself.field_50 = 0;
-	if (_firstPosition._x != -1000) {
-		_yourself._zone.pos._position._x = _firstPosition._x;
-		_yourself._zone.pos._position._y = _firstPosition._y;
-		_yourself._frame = _firstFrame;
-		_firstPosition._y = -1000;
-		_firstPosition._x = -1000;
+	if (_location._startPosition._x != -1000) {
+		_yourself._zone.pos._position._x = _location._startPosition._x;
+		_yourself._zone.pos._position._y = _location._startPosition._y;
+		_yourself._frame = _location._startFrame;
+		_location._startPosition._y = -1000;
+		_location._startPosition._x = -1000;
 
-		debugC(2, kDebugLocation, "changeLocation: initial position set to x: %i, y: %i, f: %i", _firstPosition._x, _firstPosition._y, _firstFrame);
+		debugC(2, kDebugLocation, "changeLocation: initial position set to x: %i, y: %i, f: %i", _location._startPosition._x, _location._startPosition._y, _location._startFrame);
 	}
 
 	byte palette[PALETTE_SIZE];
 	for (uint16 _si = 0; _si < PALETTE_SIZE; _si++) palette[_si] = 0;
 	_graphics->palUnk0(palette);
 	_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
-	if (_locationCommands) {
-		runCommands(_locationCommands);
+	if (_location._commands) {
+		runCommands(_location._commands);
 		runJobs();
 		_graphics->swapBuffers();
 		runJobs();
 		_graphics->swapBuffers();
 	}
 
-	if (_locationComment) {
+	if (_location._comment) {
 		doLocationEnterTransition();
 		debugC(2, kDebugLocation, "changeLocation: shown location comment");
 	}
@@ -419,8 +419,8 @@
 	_graphics->swapBuffers();
 
 	_graphics->palUnk0(_palette);
-	if (_locationACommands) {
-		runCommands(_locationACommands);
+	if (_location._aCommands) {
+		runCommands(_location._aCommands);
 		debugC(1, kDebugLocation, "changeLocation: location acommands run");
 	}
 
@@ -457,10 +457,10 @@
 	_vm->_graphics->copyScreen(Graphics::kBitFront, Graphics::kBitBack);
 
 	int16 v7C, v7A;
-	_vm->_graphics->getStringExtent(_locationComment, 130, &v7C, &v7A);
+	_vm->_graphics->getStringExtent(_vm->_location._comment, 130, &v7C, &v7A);
 	_vm->_graphics->floodFill(0, 5, 5, 10 + v7C, 5 + v7A, Graphics::kBitFront);
 	_vm->_graphics->floodFill(1, 6, 6, 9 + v7C, 4 + v7A, Graphics::kBitFront);
-	_vm->_graphics->displayWrappedString(_locationComment, 3, 5, 130, 0);
+	_vm->_graphics->displayWrappedString(_vm->_location._comment, 3, 5, 130, 0);
 
 	// FIXME: ???
 #if 0

Modified: scummvm/trunk/engines/parallaction/menu.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/menu.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/menu.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -196,7 +196,7 @@
 
 	selectCharacter();
 
-	char *v4 = strchr(_location, '.') + 1;
+	char *v4 = strchr(_vm->_location._name, '.') + 1;
 	strcpy(_engine->_characterName, v4);
 
 	return; // start game
@@ -276,7 +276,7 @@
 
 	// load game
 
-	strcpy(_location, "fogne");
+	strcpy(_vm->_location._name, "fogne");
 	strcpy(_engine->_characterName, "dough");
 
 	_vm->loadGame();
@@ -391,12 +391,12 @@
 
 
 	if (_dino_points > _donna_points && _dino_points > _dough_points) {
-		sprintf(_location, "test.%s", _dinoName);
+		sprintf(_vm->_location._name, "test.%s", _dinoName);
 	} else {
 		if (_donna_points > _dino_points && _donna_points > _dough_points) {
-			sprintf(_location, "test.%s", _donnaName);
+			sprintf(_vm->_location._name, "test.%s", _donnaName);
 		} else {
-			sprintf(_location, "test.%s", _doughName);
+			sprintf(_vm->_location._name, "test.%s", _doughName);
 		}
 	}
 

Modified: scummvm/trunk/engines/parallaction/music.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/music.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/music.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -49,12 +49,12 @@
 void MidiPlayer::play(const char *filename) {
 	stop();
 
-	if (!scumm_strnicmp(_location, "museo", 5)) return;
-	if (!scumm_strnicmp(_location, "intgrottadopo", 13)) return;
-	if (!scumm_strnicmp(_location, "caveau", 6)) return;
-	if (!scumm_strnicmp(_location, "estgrotta", 9)) return;
-	if (!scumm_strnicmp(_location, "plaza1", 6)) return;
-	if (!scumm_strnicmp(_location, "endtgz", 6)) return;
+	if (!scumm_strnicmp(_vm->_location._name, "museo", 5)) return;
+	if (!scumm_strnicmp(_vm->_location._name, "intgrottadopo", 13)) return;
+	if (!scumm_strnicmp(_vm->_location._name, "caveau", 6)) return;
+	if (!scumm_strnicmp(_vm->_location._name, "estgrotta", 9)) return;
+	if (!scumm_strnicmp(_vm->_location._name, "plaza1", 6)) return;
+	if (!scumm_strnicmp(_vm->_location._name, "endtgz", 6)) return;
 
 	char path[PATH_LEN];
 	sprintf(path, "%s.mid", filename);

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -51,7 +51,7 @@
 
 char		_saveData1[30] = { '\0' };
 uint16		_language = 0;
-char		_location[100] = "fogne";
+char		_slideText[2][40];
 uint32		_engineFlags = 0;
 char	   *_objectsNames[100];
 Zone	   *_activeZone = NULL;
@@ -64,10 +64,7 @@
 Cnv 			_yourObjects;
 
 uint16		_score = 1;
-Command    *_locationACommands = NULL;
-Command    *_locationCommands = NULL;
-char	   *_locationComment = NULL;
-char	   *_locationEndComment = NULL;
+
 uint32		_localFlags[120] = { 0 };
 
 static char tmp_visited_str[] = "visited";
@@ -133,13 +130,11 @@
 char		_forwardedAnimationNames[20][20];
 uint16		_numForwards = 0;
 char		_soundFile[20];
-char		_slideText[2][40];
-Point		_firstPosition = { -1000, -1000 };
 
 char	   *_globalTable[32];
-uint16		_firstFrame = 0;
+
 byte		_mouseHidden = 0;
-Node		_locationWalkNodes = { 0, 0 };
+
 uint32		_commandFlags = 0;
 uint16		_introSarcData3 = 200;
 uint16		_introSarcData2 = 1;
@@ -221,7 +216,7 @@
 		return -1;
 	}
 /*
-	strcpy(_location, "taxint");
+	strcpy(_name, "taxint");
 	strcpy(_characterName, "dough");
 	strcpy(_languageDir, "it/");
 	_skipMenu = true;
@@ -252,7 +247,7 @@
 		argv[2][2] = '/';
 		argv[2][3] = '\0';
 
-		strcpy(_location, argv[0]);
+		strcpy(_name, argv[0]);
 		strcpy(_characterName, argv[1]);
 		strcpy(_languageDir, argv[2]);
 		_skipMenu = true;
@@ -266,6 +261,18 @@
 	memset(_locationNames, 0, 120*32);
 	_numLocations = 0;
 
+	_location._startPosition._x = -1000;
+	_location._startPosition._x = -1000;
+	_location._startFrame = 0;
+	_location._walkNodes._prev = NULL;
+	_location._walkNodes._next = NULL;
+	strcpy(_location._name, "fogne");
+	_location._aCommands = NULL;
+	_location._commands = NULL;
+	_location._comment = NULL;
+	_location._endComment = NULL;
+
+
 	_yourTalk._width = 0;
 	_yourTalk._height = 0;
 	_yourTalk._count = 0;
@@ -325,7 +332,7 @@
 		_menu->start();
 	}
 
-	char *v4 = strchr(_location, '.');
+	char *v4 = strchr(_location._name, '.');
 	if (v4) {
 		*v4 = '\0';
 	}
@@ -333,15 +340,15 @@
 	_engineFlags &= ~kEngineChangeLocation;
 	changeCharacter(_characterName);
 
-	strcpy(_saveData1, _location);
-	parseLocation(_location);
+	strcpy(_saveData1, _location._name);
+	parseLocation(_location._name);
 
-	if (_firstPosition._x != -1000) {
-		_yourself._zone.pos._position._x = _firstPosition._x;
-		_yourself._zone.pos._position._y = _firstPosition._y;
-		_yourself._frame = _firstFrame;
-		_firstPosition._y = -1000;
-		_firstPosition._x = -1000;
+	if (_location._startPosition._x != -1000) {
+		_yourself._zone.pos._position._x = _location._startPosition._x;
+		_yourself._zone.pos._position._y = _location._startPosition._y;
+		_yourself._frame = _location._startFrame;
+		_location._startPosition._y = -1000;
+		_location._startPosition._x = -1000;
 	}
 
 	return;
@@ -441,20 +448,20 @@
 
 	_graphics->copyScreen(Graphics::kBitBack, Graphics::kBit2);
 
-	if (_locationCommands)
-		runCommands(_locationCommands);
+	if (_location._commands)
+		runCommands(_location._commands);
 
 	runJobs();
 
 	_graphics->copyScreen(Graphics::kBitBack, Graphics::kBitFront);
 
-	if (_locationComment)
+	if (_location._comment)
 		doLocationEnterTransition();
 
 	changeCursor(kCursorArrow);
 
-	if (_locationACommands)
-		runCommands(_locationACommands);
+	if (_location._aCommands)
+		runCommands(_location._aCommands);
 
 //	printf("entering game loop...\n");
 
@@ -488,7 +495,7 @@
 
 		if (_engineFlags & kEngineChangeLocation) {
 			_engineFlags &= ~kEngineChangeLocation;
-			changeLocation(_location);
+			changeLocation(_location._name);
 			continue;
 		}
 

Modified: scummvm/trunk/engines/parallaction/parallaction.h
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.h	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/parallaction.h	2007-03-11 14:14:08 UTC (rev 26085)
@@ -117,8 +117,8 @@
 
 extern char *_globalTable[];
 extern char _saveData1[];
-extern Point _firstPosition;		 // starting position after load game??
-extern uint16 _firstFrame;	 // starting frame after load game??
+//extern Point _firstPosition;		 // starting position after load game??
+//extern uint16 _firstFrame;	 // starting frame after load game??
 extern byte _mouseHidden;
 extern uint32 _commandFlags;
 
@@ -126,12 +126,12 @@
 
 extern Cnv _characterFrames;
 
-extern char _location[];
-extern Node _locationWalkNodes;
-extern Command *_locationACommands;
-extern Command *_locationCommands;
-extern char *_locationComment;
-extern char *_locationEndComment;
+//extern char _locationName[];
+//extern Node _walkNodes;
+//extern Command *_aCommands;
+//extern Command *_commands;
+//extern char *_comment;
+//extern char *_endComment;
 
 extern char *_objectsNames[];
 extern const char *_zoneTypeNames[];
@@ -237,6 +237,20 @@
 class Menu;
 class MidiPlayer;
 
+struct Location {
+
+	Point		_startPosition;
+	uint16		_startFrame;
+	Node		_walkNodes;
+	char		_name[100];
+
+	Command    *_aCommands;
+	Command    *_commands;
+	char	   *_comment;
+	char	   *_endComment;
+
+};
+
 class Parallaction : public Engine {
 
 public:
@@ -292,6 +306,8 @@
 	int16	_currentLocationIndex;
 	uint16	_numLocations;
 
+	Location	_location;
+
 	InventoryItem	_activeItem;
 
 	Script	*_locationScript;

Modified: scummvm/trunk/engines/parallaction/saveload.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/saveload.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/saveload.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -64,15 +64,15 @@
 	f->readLine(s, 29);
 
 	f->readLine(_vm->_characterName, 15);
-	f->readLine(_location, 15);
+	f->readLine(_vm->_location._name, 15);
 
-	strcat(_location, ".");
+	strcat(_vm->_location._name, ".");
 
 	f->readLine(s, 15);
-	_firstPosition._x = atoi(s);
+	_location._startPosition._x = atoi(s);
 
 	f->readLine(s, 15);
-	_firstPosition._y = atoi(s);
+	_location._startPosition._y = atoi(s);
 
 	f->readLine(s, 15);
 	_score = atoi(s);
@@ -135,7 +135,7 @@
 
 	parseLocation("common");
 
-	strcat(_location, _vm->_characterName);
+	strcat(_vm->_location._name, _vm->_characterName);
 	_engineFlags |= kEngineChangeLocation;
 
 	return;
@@ -375,7 +375,7 @@
 
 void Parallaction::saveGame() {
 
-	if (!scumm_stricmp(_location, "caveau"))
+	if (!scumm_stricmp(_vm->_location._name, "caveau"))
 		return;
 
 	int slot = selectSaveFile( 1, "Save file", "Save" );

Modified: scummvm/trunk/engines/parallaction/walk.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/walk.cpp	2007-03-11 13:43:17 UTC (rev 26084)
+++ scummvm/trunk/engines/parallaction/walk.cpp	2007-03-11 14:14:08 UTC (rev 26085)
@@ -159,7 +159,7 @@
 		while (_closest_node_found != 0) {
 
 			_closest_node_found = 0;
-			WalkNode *location_node = (WalkNode*)_locationWalkNodes._next;
+			WalkNode *location_node = (WalkNode*)_vm->_location._walkNodes._next;
 
 			// scans location path nodes searching for the nearest Node
 			// which can't be farther than the target position
@@ -448,10 +448,10 @@
 	if (z != NULL) {
 
 		if ((z->_flags & kFlagsClosed) == 0) {
-			_firstPosition._x = z->u.door->_startPos._x;
-			_firstPosition._y = z->u.door->_startPos._y;
-			_firstFrame = z->u.door->_startFrame;
-			strcpy( _location, z->u.door->_location );
+			_vm->_location._startPosition._x = z->u.door->_startPos._x;
+			_vm->_location._startPosition._y = z->u.door->_startPos._y;
+			_vm->_location._startFrame = z->u.door->_startFrame;
+			strcpy( _vm->_location._name, z->u.door->_location );
 
 			_engineFlags |= kEngineChangeLocation;
 			_zoneTrap = NULL;


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