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

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Sun May 13 16:56:45 CEST 2007


Revision: 26835
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26835&view=rev
Author:   peres001
Date:     2007-05-13 07:56:44 -0700 (Sun, 13 May 2007)

Log Message:
-----------
More cleanup.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/inventory.cpp
    scummvm/trunk/engines/parallaction/location.cpp

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2007-05-13 14:38:05 UTC (rev 26834)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2007-05-13 14:56:44 UTC (rev 26835)
@@ -31,21 +31,7 @@
 extern OSystem *g_system;
 
 namespace Parallaction {
-/*
-//
-//	proportional font glyphs width
-//
-const byte _glyphWidths[126] = {
-  0x04, 0x03, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x04, 0x04, 0x06, 0x06, 0x03, 0x05, 0x03, 0x05,
-  0x06, 0x06, 0x06, 0x06, 0x07, 0x06, 0x06, 0x06, 0x06, 0x06, 0x03, 0x03, 0x05, 0x04, 0x05, 0x05,
-  0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x03, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
-  0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x08, 0x07, 0x07, 0x07, 0x05, 0x06, 0x05, 0x08, 0x07,
-  0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x03, 0x04, 0x05, 0x05, 0x06, 0x06, 0x05,
-  0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x06, 0x07, 0x05, 0x05, 0x05, 0x05, 0x02, 0x05, 0x05, 0x07,
-  0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x04, 0x04,
-  0x05, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x06, 0x05, 0x05, 0x05, 0x05
-};
-*/
+
 byte *		Gfx::_buffers[];
 
 #define BALLOON_WIDTH	12

Modified: scummvm/trunk/engines/parallaction/inventory.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.cpp	2007-05-13 14:38:05 UTC (rev 26834)
+++ scummvm/trunk/engines/parallaction/inventory.cpp	2007-05-13 14:56:44 UTC (rev 26835)
@@ -37,6 +37,7 @@
 //
 
 #define INVENTORY_MAX_ITEMS 		30
+#define INVENTORY_FIRST_ITEM		4		// first four entries are used up by verbs
 
 #define INVENTORYITEM_PITCH 		32
 #define INVENTORYITEM_WIDTH 		24
@@ -93,52 +94,50 @@
 //
 int16 Parallaction::getHoverInventoryItem(int16 x, int16 y) {
 
-	int16 _di = x;
-
-	int16 _si = -1;
+	int16 slot = -1;
 	do {
-		_si++;
-	} while (_inventory[_si]._id != 0);
+		slot++;
+	} while (_inventory[slot]._id != 0);
 
-	_si = (_si + 4) / INVENTORY_ITEMS_PER_LINE;
+	slot = (slot + 4) / INVENTORY_ITEMS_PER_LINE;
 
-	if (_invPosition.x >= _di) return -1;
-	if ((_invPosition.x + INVENTORY_WIDTH) <= _di) return -1;
+	if (_invPosition.x >= x) return -1;
+	if ((_invPosition.x + INVENTORY_WIDTH) <= x) return -1;
 
 	if (_invPosition.y >= y) return -1;
-	if ((_si * INVENTORYITEM_HEIGHT + _invPosition.y) <= y) return -1;
+	if ((slot * INVENTORYITEM_HEIGHT + _invPosition.y) <= y) return -1;
 
-	return ((_di - _invPosition.x) / INVENTORYITEM_WIDTH) + (INVENTORY_ITEMS_PER_LINE * ((y - _invPosition.y) / INVENTORYITEM_HEIGHT));
+	return ((x - _invPosition.x) / INVENTORYITEM_WIDTH) + (INVENTORY_ITEMS_PER_LINE * ((y - _invPosition.y) / INVENTORYITEM_HEIGHT));
 
 }
 
 
 void refreshInventory(const char *character) {
-	for (uint16 _si = 0; _si < INVENTORY_MAX_ITEMS; _si++) {
-		drawInventoryItem(_si, &_inventory[_si]);
+	for (uint16 i = 0; i < INVENTORY_MAX_ITEMS; i++) {
+		drawInventoryItem(i, &_inventory[i]);
 	}
-
 	return;
 }
 
 
 void refreshInventoryItem(const char *character, uint16 index) {
 	drawInventoryItem(index, &_inventory[index]);
-
 	return;
 }
 
 int Parallaction::addInventoryItem(uint16 item) {
 
-	uint16 _si = 0;
-	while (_inventory[_si]._id != 0) _si++;
-	if (_si == INVENTORY_MAX_ITEMS)
+	uint16 slot = 0;
+	while (_inventory[slot]._id != 0)
+		slot++;
+
+	if (slot == INVENTORY_MAX_ITEMS)
 		return -1;
 
-	_inventory[_si]._id = MAKE_INVENTORY_ID(item);
-	_inventory[_si]._index = item;
+	_inventory[slot]._id = MAKE_INVENTORY_ID(item);
+	_inventory[slot]._index = item;
 
-	refreshInventoryItem(_characterName, _si);
+	refreshInventoryItem(_characterName, slot);
 
 	return 0;
 }
@@ -146,16 +145,16 @@
 
 void Parallaction::dropItem(uint16 v) {
 
-	uint16 _di = 0;
-	for (uint16 _si = 0; _si < INVENTORY_MAX_ITEMS - 1; _si++) {
+	bool found = false;
+	for (uint16 slot = 0; slot < INVENTORY_MAX_ITEMS - 1; slot++) {
 
-		if (v + 4 == _inventory[_si]._index) {
-			_di = 1;
+		if (v + INVENTORY_FIRST_ITEM == _inventory[slot]._index) {
+			found = true;
 		}
 
-		if (_di == 0) continue;
+		if (!found) continue;
 
-		memcpy(&_inventory[_si], &_inventory[_si+1], sizeof(InventoryItem));
+		memcpy(&_inventory[slot], &_inventory[slot+1], sizeof(InventoryItem));
 	}
 
 	refreshInventory(_characterName);
@@ -166,8 +165,8 @@
 
 int16 Parallaction::isItemInInventory(int32 v) {
 
-	for (uint16 _si = 0; _si < INVENTORY_MAX_ITEMS; _si++) {
-		if (_inventory[_si]._id == (uint)v)
+	for (uint16 slot = 0; slot < INVENTORY_MAX_ITEMS; slot++) {
+		if (_inventory[slot]._id == (uint)v)
 			return 1;
 	}
 
@@ -259,13 +258,13 @@
 void jobShowInventory(void *parm, Job *j) {
 //	printf("job_showInventory()...");
 
-	_numInvLines = 0;
+	uint16 slots = 0;
+	while (_inventory[slots]._id != 0)
+		slots++;
 
-	while (_inventory[_numInvLines]._id != 0) _numInvLines++;
+	uint16 lines = (slots + 4) / INVENTORY_ITEMS_PER_LINE;
 
-	_numInvLines = (_numInvLines + 4) / INVENTORY_ITEMS_PER_LINE;
-
-	Common::Rect r(INVENTORY_WIDTH, _numInvLines * INVENTORYITEM_HEIGHT);
+	Common::Rect r(INVENTORY_WIDTH, lines * INVENTORYITEM_HEIGHT);
 	r.moveTo(_invPosition);
 
 	_vm->_gfx->copyRect(
@@ -305,14 +304,13 @@
 
 
 void openInventory() {
-//	printf("openInventory()\n");
-
-	uint16 _si = 0;
 	_engineFlags |= kEngineInventory;
 
-	while (_inventory[_si]._id != 0) _si++;
+	uint16 slot = 0;
+	while (_inventory[slot]._id != 0)
+		slot++;
 
-	uint16 _LOCALinventory_lines = (_si + 4) / INVENTORY_ITEMS_PER_LINE;
+	uint16 lines = (slot + 4) / INVENTORY_ITEMS_PER_LINE;
 
 	_invPosition.x = _vm->_mousePos.x - (INVENTORY_WIDTH / 2);
 	if (_invPosition.x < 0)
@@ -321,12 +319,12 @@
 	if ((_invPosition.x + INVENTORY_WIDTH) > SCREEN_WIDTH)
 		_invPosition.x = SCREEN_WIDTH - INVENTORY_WIDTH;
 
-	_invPosition.y = _vm->_mousePos.y - 2 - (_LOCALinventory_lines * INVENTORYITEM_HEIGHT);
+	_invPosition.y = _vm->_mousePos.y - 2 - (lines * INVENTORYITEM_HEIGHT);
 	if (_invPosition.y < 0)
 		_invPosition.y = 0;
 
-	if (_invPosition.y > SCREEN_HEIGHT - _LOCALinventory_lines * INVENTORYITEM_HEIGHT)
-		_invPosition.y = SCREEN_HEIGHT - _LOCALinventory_lines * INVENTORYITEM_HEIGHT;
+	if (_invPosition.y > SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT)
+		_invPosition.y = SCREEN_HEIGHT - lines * INVENTORYITEM_HEIGHT;
 
 	return;
 
@@ -335,21 +333,18 @@
 
 
 void closeInventory() {
-//	printf("closeInventory()\n");
-
 	_engineFlags &= ~kEngineInventory;
 }
 
 void initInventory() {
-	_buffer = (byte*)malloc(INVENTORY_WIDTH * INVENTORY_HEIGHT);	  // this buffer is also used by menu so it must stay this size
-
+	_buffer = (byte*)malloc(INVENTORY_WIDTH * INVENTORY_HEIGHT);
 }
 
 void cleanInventory() {
 
-	for (uint16 _si = 4; _si < 30; _si++) {
-		_inventory[_si]._id = 0;
-		_inventory[_si]._index = 0;
+	for (uint16 slot = INVENTORY_FIRST_ITEM; slot < INVENTORY_MAX_ITEMS; slot++) {
+		_inventory[slot]._id = 0;
+		_inventory[slot]._index = 0;
 	}
 
 	return;

Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp	2007-05-13 14:38:05 UTC (rev 26834)
+++ scummvm/trunk/engines/parallaction/location.cpp	2007-05-13 14:56:44 UTC (rev 26835)
@@ -27,13 +27,8 @@
 
 namespace Parallaction {
 
-void resolveLocationForwards();
-void switchBackground(const char* background, const char* mask);
 
-
-
 void Parallaction::parseLocation(const char *filename) {
-//	printf("parseLocation(%s)", filename);
     debugC(1, kDebugLocation, "parseLocation('%s')", filename);
 
 	uint16 _si = 1;
@@ -43,7 +38,6 @@
 
 	fillBuffers(*_locationScript, true);
 	while (scumm_stricmp(_tokens[0], "ENDLOCATION")) {
-//		printf("token[0] = %s", _tokens[0]);
 
 		if (!scumm_stricmp(_tokens[0], "LOCATION")) {
 			// The parameter for location is 'location.mask'.
@@ -163,8 +157,6 @@
 }
 
 void Parallaction::resolveLocationForwards() {
-//	printf("resolveLocationForwards()");
-//	printf("# forwards: %i", _numForwards);
 
 	for (uint16 _si = 0; _forwardedCommands[_si]; _si++) {
 		_forwardedCommands[_si]->u._animation = findAnimation(_forwardedAnimationNames[_si]);
@@ -189,31 +181,21 @@
 	_localFlagNames = new Table(120);
 	_localFlagNames->addData("visited");
 
-	debugC(7, kDebugLocation, "freeLocation: localflags names freed");
-
 	_location._walkNodes.clear();
-	debugC(7, kDebugLocation, "freeLocation: walk nodes freed");
 
 	// TODO (LIST): helperNode should be rendered useless by the use of a Common::List<>
 	// to store Zones and Animations. Right now, it holds a list of Zones to be preserved
 	// but that'll pretty meaningless with a single list approach.
 	freeZones();
-	debugC(7, kDebugLocation, "freeLocation: zones freed");
-
 	freeAnimations();
-	debugC(7, kDebugLocation, "freeLocation: animations freed");
 
 	if (_location._comment) {
 		free(_location._comment);
 	}
 	_location._comment = NULL;
-	debugC(7, kDebugLocation, "freeLocation: comments freed");
 
 	_location._commands.clear();
-	debugC(7, kDebugLocation, "freeLocation: commands freed");
-
 	_location._aCommands.clear();
-	debugC(7, kDebugLocation, "freeLocation: acommands freed");
 
 	return;
 }
@@ -417,7 +399,8 @@
 void Parallaction::doLocationEnterTransition() {
 	debugC(1, kDebugLocation, "doLocationEnterTransition");
 
-	if (_localFlags[_currentLocationIndex] & kFlagsVisited) return; // visited
+	if (_localFlags[_currentLocationIndex] & kFlagsVisited)
+		return; // visited
 
 	byte pal[PALETTE_SIZE];
 	_gfx->buildBWPalette(pal);
@@ -431,21 +414,15 @@
 	_gfx->swapBuffers();
 	_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
 
-	int16 v7C, v7A;
-	_gfx->getStringExtent(_location._comment, 130, &v7C, &v7A);
+	int16 w, h;
+	_gfx->getStringExtent(_location._comment, 130, &w, &h);
 
-	Common::Rect r(10 + v7C, 5 + v7A);
+	Common::Rect r(10 + w, 5 + h);
 	r.moveTo(5, 5);
 	_gfx->floodFill(Gfx::kBitFront, r, 0);
 	r.grow(-1);
 	_gfx->floodFill(Gfx::kBitFront, r, 1);
 	_gfx->displayWrappedString(_location._comment, 3, 5, 130, 0);
-	// FIXME: ???
-#if 0
-	do {
-		mouseFunc1();
-	} while (_mouseButtons != kMouseLeftUp);
-#endif
 
 	_gfx->updateScreen();
 	waitUntilLeftClick();
@@ -454,9 +431,9 @@
 
 	// fades maximum intensity palette towards approximation of main palette
 	for (uint16 _si = 0; _si<6; _si++) {
-		waitTime( 1 );
 		_gfx->quickFadePalette(pal);
 		_gfx->setPalette(pal);
+		waitTime( 1 );
 	}
 
 	debugC(1, kDebugLocation, "doLocationEnterTransition completed");
@@ -464,8 +441,4 @@
 	return;
 }
 
-void mouseFunc1() {
-	// FIXME: implement this
-}
-
 } // namespace Parallaction


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