[Scummvm-cvs-logs] SF.net SVN: scummvm: [29500] scummvm/trunk/engines/lure

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Wed Nov 14 12:46:55 CET 2007


Revision: 29500
          http://scummvm.svn.sourceforge.net/scummvm/?rev=29500&view=rev
Author:   dreammaster
Date:     2007-11-14 03:46:55 -0800 (Wed, 14 Nov 2007)

Log Message:
-----------
Fixed clipping issues that were still occurring in some rooms

Modified Paths:
--------------
    scummvm/trunk/engines/lure/room.cpp
    scummvm/trunk/engines/lure/room.h

Modified: scummvm/trunk/engines/lure/room.cpp
===================================================================
--- scummvm/trunk/engines/lure/room.cpp	2007-11-13 21:21:17 UTC (rev 29499)
+++ scummvm/trunk/engines/lure/room.cpp	2007-11-14 11:46:55 UTC (rev 29500)
@@ -39,9 +39,10 @@
 	loadScreen(screenId);	
 	byte *screenData = data().data();
 	int cellY;
+	int cellIndex = 0;
 
 	// Reset all the cells to unused
-	Common::set_to((bool *) _cells, (bool *) _cells + GRID_SIZE, false);
+	Common::set_to((uint8 *) _cells, (uint8 *) _cells + GRID_SIZE, 0xff);
 
 	// Loop through each cell of the screen
 	for (cellY = 0; cellY < NUM_VERT_RECTS; ++cellY) {
@@ -64,7 +65,8 @@
 				}
 			}
 
-			_cells[cellY + NUM_EDGE_RECTS][cellX + NUM_EDGE_RECTS] = hasPixels;
+			_cells[cellY + NUM_EDGE_RECTS][cellX + NUM_EDGE_RECTS] = 
+				hasPixels ? cellIndex++ : 0xff;
 		}
 	}
 }
@@ -302,7 +304,7 @@
 
 		int layerNum = 1;
 		while ((layerNum < 4) && (_layers[layerNum] != NULL) &&
-				!_layers[layerNum]->isOccupied(xStart, yEnd)) 
+				(_layers[layerNum]->getCell(xStart, yEnd) == 0xff))
 			++layerNum;
 		if ((layerNum == 4) || (_layers[layerNum] == NULL)) continue;
 
@@ -318,7 +320,7 @@
 	Surface &s = _screen.screen();
 
 	while ((layerNum < 4) && (_layers[layerNum] != NULL) &&
-			!_layers[layerNum]->isOccupied(xp + NUM_EDGE_RECTS, yp + NUM_EDGE_RECTS))
+			(_layers[layerNum]->getCell(xp + NUM_EDGE_RECTS, yp + NUM_EDGE_RECTS) >= 0xfe))
 		++layerNum;
 	if ((layerNum == 4) || (_layers[layerNum] == NULL)) return;
 
@@ -370,6 +372,43 @@
 	}					
 }
 
+void Room::layersPostProcess() {
+	for (int layerNum = 1; layerNum < 4; ++layerNum) {
+		if (_layers[layerNum] == NULL)
+			continue;
+
+		// Layer optimisation
+		for (int xp = NUM_EDGE_RECTS; xp < NUM_HORIZ_RECTS + NUM_EDGE_RECTS; ++xp) {
+			bool priorFlag = false, nextFlag = false;
+
+			for (int yp = NUM_EDGE_RECTS; yp < NUM_VERT_RECTS + NUM_EDGE_RECTS; ++yp) {
+				if (_layers[layerNum]->getCell(xp, yp) == 0xff) {
+					priorFlag = false;
+					nextFlag = false;
+					continue;
+				}
+
+				if (priorFlag && (_layers[layerNum]->getCell(xp - 1, yp) == 0xff))
+					_layers[layerNum]->setCell(xp - 1, yp, 0xfe);
+				if (nextFlag && (_layers[layerNum]->getCell(xp + 1, yp) == 0xff))
+					_layers[layerNum]->setCell(xp + 1, yp, 0xfe);
+
+				priorFlag = _layers[layerNum]->getCell(xp - 1, yp) != 0xff;
+				nextFlag = _layers[layerNum]->getCell(xp + 1, yp) != 0xff;
+			}
+		}
+
+		// Layer extension of final row to off-screen edge rows below
+
+		for (int xp = NUM_EDGE_RECTS + NUM_HORIZ_RECTS - 1; xp >= NUM_EDGE_RECTS; --xp) {
+			if (_layers[layerNum]->getCell(xp, NUM_EDGE_RECTS + NUM_VERT_RECTS - 1) != 0xff) {
+				for (int yp = NUM_VERT_RECTS + NUM_EDGE_RECTS; yp < FULL_VERT_RECTS; ++yp)
+					_layers[layerNum]->setCell(xp, yp, 0xfe);
+			}
+		}
+	}
+}
+
 void Room::update() {
 	Surface &s = _screen.screen();
 	Resources &res = Resources::getReference();
@@ -519,6 +558,7 @@
 			layerNum == 0);
 
 	blockMerge();
+	layersPostProcess();
 
 	// Generate the palette for the room that will be faded in
 	//Palette p(MAIN_PALETTE_SIZE, NULL, RGB64);

Modified: scummvm/trunk/engines/lure/room.h
===================================================================
--- scummvm/trunk/engines/lure/room.h	2007-11-13 21:21:17 UTC (rev 29499)
+++ scummvm/trunk/engines/lure/room.h	2007-11-14 11:46:55 UTC (rev 29500)
@@ -47,12 +47,18 @@
 
 class RoomLayer: public Surface {
 private:
-	bool _cells[FULL_VERT_RECTS][FULL_HORIZ_RECTS];
+	byte _cells[FULL_VERT_RECTS][FULL_HORIZ_RECTS];
 public:
 	RoomLayer(uint16 screenId, bool backgroundLayer);
 	bool isOccupied(byte cellX, byte cellY) {
+		return _cells[cellY][cellX] < 0xfe;
+	}
+	uint8 getCell(byte cellX, byte cellY) {
 		return _cells[cellY][cellX];
 	}
+	void setCell(byte cellX, byte cellY, byte value) {
+		_cells[cellY][cellX] = value;
+	}
 };
 
 enum CursorState {CS_NONE, CS_ACTION, CS_SEQUENCE, CS_TALKING, CS_BUMPED};
@@ -84,6 +90,7 @@
 	void addLayers(Hotspot &h);
 	void addCell(int16 xp, int16 yp, int layerNum);
 	void blockMerge();
+	void layersPostProcess();
 public:
 	RoomPathsDecompressedData tempLayer;
 	Room();


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