[Scummvm-cvs-logs] SF.net SVN: scummvm:[42124] scummvm/trunk/engines/gob

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Jul 5 13:28:09 CEST 2009


Revision: 42124
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42124&view=rev
Author:   drmccoy
Date:     2009-07-05 11:28:09 +0000 (Sun, 05 Jul 2009)

Log Message:
-----------
Wrapping the block end marker checks into Hotspots::Hotspot::isEnd()

Modified Paths:
--------------
    scummvm/trunk/engines/gob/hotspots.cpp
    scummvm/trunk/engines/gob/hotspots.h

Modified: scummvm/trunk/engines/gob/hotspots.cpp
===================================================================
--- scummvm/trunk/engines/gob/hotspots.cpp	2009-07-05 11:27:54 UTC (rev 42123)
+++ scummvm/trunk/engines/gob/hotspots.cpp	2009-07-05 11:28:09 UTC (rev 42124)
@@ -93,6 +93,10 @@
 	return (flags & 0xF000) >> 12;
 }
 
+bool Hotspots::Hotspot::isEnd() const {
+	return (left == 0xFFFF);
+}
+
 bool Hotspots::Hotspot::isIn(uint16 x, uint16 y) const {
 	if (x < left)
 		return false;
@@ -164,8 +168,8 @@
 	for (int i = 0; i < kHotspotCount; i++) {
 		Hotspot &spot = _hotspots[i];
 
-		//       free space => add         same id => update
-		if (! ((spot.left == 0xFFFF) || (spot.id == hotspot.id)))
+		//     free space => add    same id => update
+		if (! (spot.isEnd() || (spot.id == hotspot.id)))
 			continue;
 
 		// When updating, keep bit 0x4000 intact
@@ -204,13 +208,9 @@
 }
 
 void Hotspots::recalculate(bool force) {
-	for (int i = 0; i < kHotspotCount; i++) {
+	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 		Hotspot &spot = _hotspots[i];
 
-		if (spot.left == 0xFFFF)
-			// End reached
-			break;
-
 		if (!force && ((spot.flags & 0x80) != 0))
 			continue;
 
@@ -277,13 +277,9 @@
 
 	// Count the hotspots
 	uint32 size = 0;
-	for (int i = 0; i < kHotspotCount; i++) {
+	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 		Hotspot &spot = _hotspots[i];
 
-		if (spot.left == 0xFFFF)
-			// End reached
-			break;
-
 		     // Save all of them
 		if ( (all == 1) ||
 		     // Don't save the global ones
@@ -309,13 +305,9 @@
 
 	// Copy the hotspots
 	Hotspot *destPtr = backup.hotspots;
-	for (int i = 0; i < kHotspotCount; i++) {
+	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 		Hotspot &spot = _hotspots[i];
 
-		if (spot.left == 0xFFFF)
-			// End reached
-			break;
-
 		     // Save all of them
 		if ( (all == 1) ||
 		     // Don't save the global ones
@@ -328,7 +320,7 @@
 			memcpy(destPtr, &spot, sizeof(Hotspot));
 			destPtr++;
 
-			spot.left = 0xFFFF;
+			spot.clear();
 		}
 
 	}
@@ -351,7 +343,7 @@
 	int i;
 	Hotspot *destPtr = _hotspots;
 	for (i = 0; i < kHotspotCount; i++, destPtr++)
-		if (destPtr->left == 0xFFFF)
+		if (destPtr->isEnd())
 			break;
 
 	if (((uint32) (kHotspotCount - i)) < backup.size)
@@ -436,12 +428,9 @@
 
 	if        (type == kTypeMove) {
 
-		for (int i = 0; i < kHotspotCount; i++) {
+		for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 			Hotspot &spot = _hotspots[i];
 
-			if (spot.left == 0xFFFF)
-				break;
-
 			if (spot.id & 0x4000)
 				continue;
 
@@ -464,12 +453,9 @@
 
 	} else if (type == kTypeClick) {
 
-		for (int i = 0; i < kHotspotCount; i++) {
+		for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 			Hotspot &spot = _hotspots[i];
 
-			if (spot.left == 0xFFFF)
-				break;
-
 			if (spot.id & 0x4000)
 				continue;
 
@@ -939,7 +925,7 @@
 	for (int i = 0; i < kHotspotCount; i++) {
 		Hotspot &spot = _hotspots[i];
 
-		if (spot.left == 0xFFFF)
+		if (spot.isEnd())
 			continue;
 
 		if ((spot.id & 0xC000) != 0x8000)
@@ -985,7 +971,7 @@
 		for (int i = 0; i < kHotspotCount; i++) {
 			Hotspot &spot = _hotspots[i];
 
-			if (spot.left == 0xFFFF)
+			if (spot.isEnd())
 				continue;
 
 			if ((spot.id & 0xC000) != 0x8000)
@@ -1025,12 +1011,9 @@
 				return 0;
 
 			if (_vm->_game->_mouseButtons != kMouseButtonsNone) {
-				for (int i = 0; i < kHotspotCount; i++) {
+				for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 					Hotspot &spot = _hotspots[i];
 
-					if (spot.left == 0xFFFF)
-						break;
-
 					if (spot.getWindow() != 0)
 						continue;
 
@@ -1064,7 +1047,7 @@
 			for (int i = 0; i < kHotspotCount; i++) {
 				Hotspot &spot = _hotspots[i];
 
-				if (spot.left == 0xFFFF)
+				if (spot.isEnd())
 					continue;
 
 				if ((spot.id & 0xC000) != 0x8000)
@@ -1133,7 +1116,7 @@
 	push(0);
 
 	uint16 endIndex = 0;
-	while (_hotspots[endIndex].left != 0xFFFF)
+	while (!_hotspots[endIndex].isEnd())
 		endIndex++;
 
 	_shouldPush = false;
@@ -1381,12 +1364,9 @@
 
 			WRITE_VAR(55, curEditIndex);
 			if (key == kKeyReturn) {
-				for (int i = 0; i < kHotspotCount; i++) {
+				for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 					Hotspot &spot = _hotspots[i];
 
-					if (spot.left == 0xFFFF)
-						break;
-
 					if ((spot.id & 0xC000) != 0x8000)
 						continue;
 
@@ -1412,12 +1392,9 @@
 
 		if (id == 0) {
 			if (key != 0) {
-				for (int i = 0; i < kHotspotCount; i++) {
+				for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 					Hotspot &spot = _hotspots[i];
 
-					if (spot.left == 0xFFFF)
-						break;
-
 					if ((spot.id & 0xC000) != 0x8000)
 						continue;
 
@@ -1429,12 +1406,9 @@
 				}
 
 				if (id == 0) {
-					for (int i = 0; i < kHotspotCount; i++) {
+					for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 						Hotspot &spot = _hotspots[i];
 
-						if (spot.left == 0xFFFF)
-							break;
-
 						if ((spot.id & 0xC000) != 0x8000)
 							continue;
 
@@ -1455,12 +1429,9 @@
 				if (stackPos2 != 0) {
 					collStackPos = 0;
 
-					for (int i = endIndex; i < kHotspotCount; i++) {
+					for (int i = endIndex; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 						Hotspot &spot = _hotspots[i];
 
-						if (spot.left == 0xFFFF)
-							break;
-
 						if ((spot.id & 0xF000) != 0x8000)
 							continue;
 
@@ -1514,12 +1485,9 @@
 					if (descIndex != 0) {
 
 						counter = 0;
-						for (int i = endIndex; i < kHotspotCount; i++) {
+						for (int i = endIndex; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 							Hotspot &spot = _hotspots[i];
 
-							if (spot.left == 0xFFFF)
-								break;
-
 							if ((spot.id & 0xF000) == 0x8000) {
 								if (++counter == descIndex) {
 									id    = spot.id;
@@ -1532,12 +1500,9 @@
 
 					} else {
 
-						for (int i = 0; i < kHotspotCount; i++) {
+						for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 							Hotspot &spot = _hotspots[i];
 
-							if (spot.left == 0xFFFF)
-								break;
-
 							if ((spot.id & 0xF000) == 0x8000) {
 								id    = spot.id;
 								index = i;
@@ -1584,7 +1549,7 @@
 		for (int i = 0; i < kHotspotCount; i++) {
 			Hotspot &spot = _hotspots[i];
 
-			if (spot.left == 0xFFFF)
+			if (spot.isEnd())
 				continue;
 
 			if ((spot.id & 0xC000) != 0x8000)
@@ -1678,12 +1643,9 @@
 int16 Hotspots::findCursor(uint16 x, uint16 y) const {
 	int16 cursor = 0;
 
-	for (int i = 0; i < kHotspotCount; i++) {
+	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 		Hotspot &spot = _hotspots[i];
 
-		if (spot.left == 0xFFFF)
-			break;
-
 		if ((spot.getWindow() != 0) || (spot.id & 0x4000))
 			continue;
 

Modified: scummvm/trunk/engines/gob/hotspots.h
===================================================================
--- scummvm/trunk/engines/gob/hotspots.h	2009-07-05 11:27:54 UTC (rev 42123)
+++ scummvm/trunk/engines/gob/hotspots.h	2009-07-05 11:28:09 UTC (rev 42124)
@@ -108,6 +108,9 @@
 		uint8 getWindow() const;
 		uint8 getCursor() const;
 
+		/** Is this hotspot the block end marker? */
+		bool isEnd() const;
+
 		/** Are the specified coordinates in the hotspot? */
 		bool isIn(uint16 x, uint16 y) const;
 		/** Does the specified button trigger the hotspot? */


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