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

drmccoy at users.sourceforge.net drmccoy at users.sourceforge.net
Sun Jul 5 21:56:03 CEST 2009


Revision: 42142
          http://scummvm.svn.sourceforge.net/scummvm/?rev=42142&view=rev
Author:   drmccoy
Date:     2009-07-05 19:56:03 +0000 (Sun, 05 Jul 2009)

Log Message:
-----------
Encapsulating hotspot state reading

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 16:29:17 UTC (rev 42141)
+++ scummvm/trunk/engines/gob/hotspots.cpp	2009-07-05 19:56:03 UTC (rev 42142)
@@ -93,6 +93,10 @@
 	return (flags & 0xF000) >> 12;
 }
 
+uint8 Hotspots::Hotspot::getState() const {
+	return (id & 0xF000) >> 12;
+}
+
 bool Hotspots::Hotspot::isEnd() const {
 	return (left == 0xFFFF);
 }
@@ -235,7 +239,7 @@
 
 		// Re-read the flags too, if applicable
 		uint16 flags = 0;
-		if ((spot.id & 0xF000) == 0xA000)
+		if (spot.getState() == 0xA)
 			flags = _vm->_game->_script->readValExpr();
 
 		// Apply backDelta, if needed
@@ -260,7 +264,7 @@
 		spot.right  = left + width  - 1;
 		spot.bottom = top  + height - 1;
 
-		if ((spot.id & 0xF000) == 0xA000)
+		if (spot.getState() == 0xA)
 			spot.flags = flags;
 
 		// Return
@@ -285,9 +289,9 @@
 		     // Don't save the global ones
 		    ((all == 0) && (spot.id >= 20)) ||
 		     // Only save the ones with the correct state
-		    ((all == 2) && (((spot.id & 0xF000) == 0xD000) ||
-		                    ((spot.id & 0xF000) == 0x4000) ||
-		                    ((spot.id & 0xF000) == 0xE000)))) {
+		    ((all == 2) && ((spot.getState() == 0xD) ||
+		                    (spot.getState() == 0x4) ||
+		                    (spot.getState() == 0xE)))) {
 			size++;
 		}
 
@@ -313,9 +317,9 @@
 		     // Don't save the global ones
 		    ((all == 0) && (spot.id >= 20)) ||
 		     // Only save the ones with the correct state
-		    ((all == 2) && (((spot.id & 0xF000) == 0xD000) ||
-		                    ((spot.id & 0xF000) == 0x4000) ||
-		                    ((spot.id & 0xF000) == 0xE000)))) {
+		    ((all == 2) && ((spot.getState() == 0xD) ||
+		                    (spot.getState() == 0x4) ||
+		                    (spot.getState() == 0xE)))) {
 
 			memcpy(destPtr, &spot, sizeof(Hotspot));
 			destPtr++;
@@ -400,7 +404,7 @@
 
 	Hotspot &spot = _hotspots[index];
 
-	if (((spot.id & 0xF000) == 0xA000) || ((spot.id & 0xF000) == 0x9000))
+	if ((spot.getState() == 0xA) || (spot.getState() == 0x9))
 		WRITE_VAR(17, -(spot.id & 0x0FFF));
 
 	if (spot.funcEnter != 0)
@@ -415,7 +419,7 @@
 
 	Hotspot &spot = _hotspots[index];
 
-	if (((spot.id & 0xF000) == 0xA000) || ((spot.id & 0xF000) == 0x9000))
+	if ((spot.getState() == 0xA) || (spot.getState() == 0x9))
 		WRITE_VAR(17, spot.id & 0x0FFF);
 
 	if (spot.funcLeave != 0)
@@ -431,7 +435,7 @@
 		for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 			Hotspot &spot = _hotspots[i];
 
-			if (spot.id & 0x4000)
+			if (spot.getState() & 0x4)
 				continue;
 
 			if (spot.getType() > kTypeMove)
@@ -456,7 +460,7 @@
 		for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 			Hotspot &spot = _hotspots[i];
 
-			if (spot.id & 0x4000)
+			if (spot.getState() & 0x4)
 				continue;
 
 			if (spot.getWindow() != 0)
@@ -928,7 +932,7 @@
 		if (spot.isEnd())
 			continue;
 
-		if ((spot.id & 0xC000) != 0x8000)
+		if ((spot.getState() & 0xC) != 0x8)
 			continue;
 
 		if (spot.getType() < kTypeInput1NoLeave)
@@ -974,7 +978,7 @@
 			if (spot.isEnd())
 				continue;
 
-			if ((spot.id & 0xC000) != 0x8000)
+			if ((spot.getState() & 0xC) != 0x8)
 				continue;
 
 			if (spot.getType() < kTypeInput1NoLeave)
@@ -1017,7 +1021,7 @@
 					if (spot.getWindow() != 0)
 						continue;
 
-					if ((spot.id & 0x4000))
+					if (spot.getState() & 0x4)
 						continue;
 
 					if (!spot.isIn(_vm->_global->_inter_mouseX, _vm->_global->_inter_mouseY))
@@ -1050,7 +1054,7 @@
 				if (spot.isEnd())
 					continue;
 
-				if ((spot.id & 0xC000) != 0x8000)
+				if ((spot.getState() & 0xC) != 0x8)
 					continue;
 
 				if (spot.getType() < kTypeInput1NoLeave)
@@ -1286,7 +1290,7 @@
 			for (int j = 0; j < kHotspotCount; j++) {
 				Hotspot &spot = _hotspots[j];
 
-				if ((spot.id & 0xF000) == 0xE000) {
+				if (spot.getState() == 0xE) {
 					spot.id       &= 0xBFFF;
 					spot.funcEnter = _vm->_game->_script->pos();
 					spot.funcLeave = _vm->_game->_script->pos();
@@ -1302,7 +1306,7 @@
 			for (int j = 0; j < kHotspotCount; j++) {
 				Hotspot &spot = _hotspots[j];
 
-				if ((spot.id & 0xF000) == 0xD000) {
+				if (spot.getState() == 0xD) {
 					spot.id       &= 0xBFFF;
 					spot.funcEnter = _vm->_game->_script->pos();
 					spot.funcLeave = _vm->_game->_script->pos();
@@ -1367,7 +1371,7 @@
 				for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 					Hotspot &spot = _hotspots[i];
 
-					if ((spot.id & 0xC000) != 0x8000)
+					if ((spot.getState() & 0xC) != 0x8)
 						continue;
 
 					if ((spot.getType() & 1) != 0)
@@ -1395,7 +1399,7 @@
 				for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 					Hotspot &spot = _hotspots[i];
 
-					if ((spot.id & 0xC000) != 0x8000)
+					if ((spot.getState() & 0xC) != 0x8)
 						continue;
 
 					if ((spot.key == key) || (spot.key == 0x7FFF)) {
@@ -1409,7 +1413,7 @@
 					for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 						Hotspot &spot = _hotspots[i];
 
-						if ((spot.id & 0xC000) != 0x8000)
+						if ((spot.getState() & 0xC) != 0x8)
 							continue;
 
 						if ((spot.key & 0xFF00) != 0)
@@ -1432,7 +1436,7 @@
 					for (int i = endIndex; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 						Hotspot &spot = _hotspots[i];
 
-						if ((spot.id & 0xF000) != 0x8000)
+						if (spot.getState() != 0x8)
 							continue;
 
 						collStackPos++;
@@ -1488,7 +1492,7 @@
 						for (int i = endIndex; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 							Hotspot &spot = _hotspots[i];
 
-							if ((spot.id & 0xF000) == 0x8000) {
+							if (spot.getState() == 0x8) {
 								if (++counter == descIndex) {
 									id    = spot.id;
 									index = i;
@@ -1503,7 +1507,7 @@
 						for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 							Hotspot &spot = _hotspots[i];
 
-							if ((spot.id & 0xF000) == 0x8000) {
+							if (spot.getState() == 0x8) {
 								id    = spot.id;
 								index = i;
 								break;
@@ -1552,7 +1556,7 @@
 			if (spot.isEnd())
 				continue;
 
-			if ((spot.id & 0xC000) != 0x8000)
+			if ((spot.getState() & 0xC) != 0x8)
 				continue;
 
 			if (spot.getType() < kTypeInput1NoLeave)
@@ -1634,7 +1638,7 @@
 	for (int i = 0; i < kHotspotCount; i++) {
 		Hotspot &spot = _hotspots[i];
 
-		if (((spot.id & 0xF000) == 0xA000) || ((spot.id & 0xF000) == 0x9000))
+		if ((spot.getState() == 0xA) || (spot.getState() == 0x9))
 			spot.id |= 0x4000;
 	}
 
@@ -1646,7 +1650,7 @@
 	for (int i = 0; (i < kHotspotCount) && !_hotspots[i].isEnd(); i++) {
 		Hotspot &spot = _hotspots[i];
 
-		if ((spot.getWindow() != 0) || (spot.id & 0x4000))
+		if ((spot.getWindow() != 0) || (spot.getState() & 0x4))
 			continue;
 
 		if (!spot.isIn(x, y))

Modified: scummvm/trunk/engines/gob/hotspots.h
===================================================================
--- scummvm/trunk/engines/gob/hotspots.h	2009-07-05 16:29:17 UTC (rev 42141)
+++ scummvm/trunk/engines/gob/hotspots.h	2009-07-05 19:56:03 UTC (rev 42142)
@@ -107,6 +107,7 @@
 		MouseButtons getButton() const;
 		uint8 getWindow() const;
 		uint8 getCursor() const;
+		uint8 getState() const;
 
 		/** Is this hotspot the block end marker? */
 		bool isEnd() const;


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