[Scummvm-cvs-logs] CVS: scummvm/queen logic.cpp,1.13,1.14 logic.h,1.6,1.7 cutaway.cpp,1.4,1.5 cutaway.h,1.2,1.3

David Eriksson twogood at users.sourceforge.net
Fri Oct 3 05:56:03 CEST 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv6763

Modified Files:
	logic.cpp logic.h cutaway.cpp cutaway.h 
Log Message:
Use struct and not array for objectData.


Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- logic.cpp	3 Oct 2003 06:47:42 -0000	1.13
+++ logic.cpp	3 Oct 2003 12:55:11 -0000	1.14
@@ -50,7 +50,6 @@
 	
 
 	//Object data
-#ifdef USE_STRUCTS_JAS
 	_objectData = new ObjectData[_numObjects + 1];
 	//clear first object
 	_objectData[0].name = 0;
@@ -79,19 +78,6 @@
 		_objectData[i].image = (int16)READ_BE_UINT16(ptr);
 		ptr += 2;
 	}
-#else
-	_objectData = new int16[_numObjects + 1][8];
-		
-	//clear first object
-	for (uint16 j = 0; j < 8; j++)
-		_objectData[0][j] = 0;
-	
-	for (i = 1; i < (_numObjects + 1); i++)
-		for (uint16 j = 0; j < 8; j++) {
-			_objectData[i][j] = (int16)READ_BE_UINT16(ptr);
-			ptr += 2;
-		}
-#endif
 	
 	//Room data
 	_roomData = new uint16[_numRooms + 2];
@@ -194,15 +180,9 @@
 	_oldRoom = room;
 }
 
-#ifdef USE_STRUCTS_JAS
 ObjectData* QueenLogic::objectData(int index) {
   return &_objectData[index];
 }
-#else
-int16* QueenLogic::objectData(int index) {
-	return _objectData[index];
-}
-#endif
 
 uint16 QueenLogic::roomData(int room) {
 	return _roomData[room];
@@ -228,7 +208,6 @@
 	return &_graphicData[index];
 }
 
-#ifdef USE_STRUCTS_JAS
 uint16 QueenLogic::findBob(uint16 obj) {
 
 	uint16 i;
@@ -391,4 +370,3 @@
 	}
 	return framenum;
 }
-#endif

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- logic.h	2 Oct 2003 19:20:00 -0000	1.6
+++ logic.h	3 Oct 2003 12:55:11 -0000	1.7
@@ -55,19 +55,13 @@
 	uint16 currentRoom();
 	void currentRoom(uint16 room);
 	void oldRoom(uint16 room);
-#ifdef USE_STRUCTS_JAS
 	ObjectData* objectData(int index);
-#else 
-	int16 *objectData(int index);
-#endif
 	uint16 roomData(int room);
 	uint16 objMax(int room);
 	GraphicData* findGraphic(int index);
 
-#ifdef USE_STRUCTS_JAS
 	uint16 findBob(uint16 obj); // FIXME: move that to QueenDisplay ?
 	uint16 findFrame(uint16 obj); // FIXME: move that to QueenDisplay ?
-#endif
 
 	int16 *area(int index, int subIndex);
 	uint16 walkOffCount();
@@ -96,11 +90,7 @@
 	uint16 (*_objectBox)[4];
 	uint16 (*_itemData)[5];
 	GraphicData *_graphicData;
-#ifdef USE_STRUCTS_JAS
 	ObjectData *_objectData;
-#else
-	int16 (*_objectData)[8];
-#endif
 	uint16 (*_actorData)[12];
 	int16 (*_area)[11][8];
 	uint16 (*_walkOffData)[3];

Index: cutaway.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- cutaway.cpp	3 Oct 2003 07:45:41 -0000	1.4
+++ cutaway.cpp	3 Oct 2003 12:55:11 -0000	1.5
@@ -30,8 +30,6 @@
 	 
 	 DISP_ROOM
 	 FACE_JOE
-	 FIND_BOB
-	 FIND_FRAME
 	 FIND_GRAPHIC
 	 FIND_SCALE
 	 MOVE_JOE
@@ -321,22 +319,33 @@
 
 void QueenCutaway::limitBob(CutawayObject &object) {
 	if (object.limitBobX1) {
-		warning("QueenCutaway::limitBob() not implemented");
-		// XXX FIND_BOB(object.objectNumber);
-		// K=Param;
-		// bobs[K].x1 = object.limitBobX1;
-		// bobs[K].y1 = object.limitBobY1;
-		// bobs[K].x2 = object.limitBobX2;
-		// bobs[K].y2 = object.limitBobY2;
+
+		if (object.objectNumber < 0) {
+			warning("QueenCutaway::limitBob called with objectNumber = %i", object.objectNumber);
+			return;
+		}	
+		
+		BobSlot *bob = 
+			_queenGraphics->bob( _queenLogic->findBob(object.objectNumber) );
+
+		if (!bob) {
+			warning("Failed to find bob");
+			return;
+		}
+
+		bob->box.x1 = object.limitBobX1;
+		bob->box.y1 = object.limitBobY1;
+		bob->box.x2 = object.limitBobX2;
+		bob->box.y2 = object.limitBobY2;
 	}
 }
 
 void QueenCutaway::restorePersonData() {
 	for (int i = 0; i < _personDataCount; i++) {
 		int index           = _personData[i].index;
-		int16 *objectData   = _queenLogic->objectData(index);
-		objectData[0]       = _personData[i].value0;
-		objectData[7]       = _personData[i].value7;
+		ObjectData *objectData  = _queenLogic->objectData(index);
+		objectData->name        = _personData[i].name;
+		objectData->image       = _personData[i].image;
 	}
 }
 
@@ -351,14 +360,14 @@
 		int lastObjectInRoom  = _queenLogic->roomData(object.room) + 0; // XXX _queenLogic->objMax(object.room);
 
 		for (int i = firstObjectInRoom; i <= lastObjectInRoom; i++) {
-			int16 *objectData  = _queenLogic->objectData(i);
+			ObjectData *objectData  = _queenLogic->objectData(i);
 			
-			if (objectData[7] == -3 || objectData[7] == -4) {
+			if (objectData->image == -3 || objectData->image == -4) {
 
 				//  The object is a person! So record the details...
 				_personData[_personDataCount].index = i;
-				_personData[_personDataCount].value0 = objectData[0];
-				_personData[_personDataCount].value7 = objectData[7];
+				_personData[_personDataCount].name  = objectData->name;
+				_personData[_personDataCount].image = objectData->image;
 				_personDataCount++;
 
 				// Now, check to see if(we need to keep the person on
@@ -372,11 +381,11 @@
 
 				if (on) {
 					// It is needed, so ensure it's ON
-					objectData[0] = abs(objectData[0]);
+					objectData->name = abs(objectData->name);
 				}
 				else {
 					// Not needed, so switch off!
-					objectData[0] = -abs(objectData[0]);
+					objectData->name = -abs(objectData->name);
 				}
 
 			}
@@ -432,9 +441,8 @@
 	if (object.objectNumber > 0) {
 		if (!object.animList) {
 			// No anim frames, so treat as a PERSON, ie. allow to speak/walk
-			int16* objectData = _queenLogic->objectData(object.objectNumber);
-
-			if (objectData[7] == -3 || objectData[7] == -4)
+			ObjectData *objectData = _queenLogic->objectData(object.objectNumber);
+			if (objectData->image == -3 || objectData->image == -4)
 				objectType = OBJECT_TYPE_PERSON;
 		}
 	}
@@ -454,8 +462,8 @@
 		}
 		else {
 			// Same object, so just turn it on!
-			int16* objectData = _queenLogic->objectData(object.objectNumber);
-			objectData[0] = abs(objectData[0]);
+			ObjectData *objectData = _queenLogic->objectData(object.objectNumber);
+			objectData->name = abs(objectData->name);
 		}
 		// XXX REDISP_OBJECT(OBJECT);
 
@@ -505,18 +513,15 @@
 	}
 	else {
 		warning("Stuff not yet implemented in QueenCutaway::handleAnimation()");
-		// XXX
-		// FIND_BOB(header);
-		// anim.object = Param;
+		
+		anim.object = _queenLogic->findBob(header);
 
-#if 0
 		// If fullscreen cutaway then clip to 199 down
 
 		// 21/9/94, Make sure that bobs are clipped on 150 screens
-		if(COMPANEL==2 && OBJ_CUT[6]<=0 && BDyres==200) bobs[Param].y2=199;
-		FIND_FRAME(J);
-		anim.originalFrame =Param;
-#endif
+		// XXX if(COMPANEL==2 && OBJ_CUT[6]<=0 && BDyres==200) bobs[Param].y2=199;
+
+		anim.originalFrame = _queenLogic->findFrame(header);
 	}
 
 	anim.unpackFrame = (int16)READ_BE_UINT16(ptr);
@@ -820,15 +825,15 @@
 		 If COPY_FROM Object images are greater than COPY_TO Object
 		 images then swap the objects around. */
 
-	int16* dummyObject = _queenLogic->objectData(dummyObjectIndex);
-	int16* realObject  = _queenLogic->objectData(realObjectIndex);
+	ObjectData *dummyObject = _queenLogic->objectData(dummyObjectIndex);
+	ObjectData *realObject  = _queenLogic->objectData(realObjectIndex);
 	
-	int fromState = (dummyObject[0] < 0) ? -1 : 0;
+	int fromState = (dummyObject->name < 0) ? -1 : 0;
 
 	int frameCountReal = 1;
 	int frameCountDummy = 1;
 
-	int graphic = realObject[7];
+	int graphic = realObject->image;
 	if (graphic > 0) {
 		if (graphic > 5000)
 			graphic -= 5000;
@@ -836,7 +841,7 @@
 		// XXX FIND_GRAPHIC(graphic)
 		// XXX if(EFRAME>0) frameCountReal=(EFRAME-SFRAME)+1;
 
-		graphic = dummyObject[7];
+		graphic = dummyObject->image;
 		if (graphic > 0) {
 			if (graphic > 5000)
 				graphic -= 5000;
@@ -847,18 +852,16 @@
 		}
 	}
 
-	for (int i = 0; i <= 7; i++) {
-		int16 temp = realObject[i];
-		realObject[i] = dummyObject[i];
-		
-		if (frameCountDummy > frameCountReal)
-			dummyObject[i] = temp;
-	}
+	ObjectData temp = *realObject;
+	*realObject = *dummyObject;
 
-	realObject[0] = abs(realObject[0]);
+	if (frameCountDummy > frameCountReal)
+		*dummyObject = temp;
+
+	realObject->name = abs(realObject->name);
 
 	if  (fromState == -1)
-		dummyObject[0] = -abs(dummyObject[0]);
+		dummyObject->name = -abs(dummyObject->name);
 
 	//  Make sure that WALK_OFF_DATA is copied too!
 
@@ -921,16 +924,15 @@
 			int16 room    = (int16)READ_BE_UINT16(ptr); ptr += 2;
 			/*int16 frame   = (int16)READ_BE_UINT16(ptr);*/ ptr += 2;
 
-			// XXX FIND_BOB(object)
-			// XXX int bob = Param;
+			// XXX int bob = _queenLogic->findBob(objectIndex);
 
 			if (from > 0) {
 				// XXX
 			}
 
-			int16* objectData = _queenLogic->objectData(objectIndex);
+			ObjectData *objectData = _queenLogic->objectData(objectIndex);
 
-			if (objectData[5] == room) {
+			if (objectData->room == room) {
 				// XXX
 			}
 		} // for()
@@ -984,16 +986,16 @@
 			// Show or hide an object
 
 			if (objectIndex > 0) {                    // Show the object
-				int16* objectData  = _queenLogic->objectData(objectIndex);
-				objectData[0]      = abs(objectData[0]);
+				ObjectData *objectData  = _queenLogic->objectData(objectIndex);
+				objectData->name        = abs(objectData->name);
 				if (fromObject > 0)
 					objectCopy(fromObject, objectIndex);
 				// XXX REDISP_OBJECT(objectIndex);
 			}
 			else if (objectIndex < 0) {               // Hide the object
-				objectIndex        = -objectIndex;
-				int16* objectData  = _queenLogic->objectData(objectIndex);
-				objectData[0]      = -abs(objectData[0]);
+				objectIndex             = -objectIndex;
+				ObjectData *objectData  = _queenLogic->objectData(objectIndex);
+				objectData->name        = -abs(objectData->name);
 				// XXX REDISP_OBJECT(objectIndex);
 			}
 

Index: cutaway.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/cutaway.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cutaway.h	2 Oct 2003 11:07:43 -0000	1.2
+++ cutaway.h	3 Oct 2003 12:55:11 -0000	1.3
@@ -69,23 +69,23 @@
 
 		//! Data for a cutaway object
 		struct CutawayObject {
-			int objectNumber;    // 0 = JOE, -1 = MESSAGE
-			int moveToX;
-			int moveToY;
-			int bank;             // 0 = PBOB, 13 = Joe Bank, else BANK NAMEstr()
-			int animList;
-			int execute;          // 1 Yes, 0 No
-			int limitBobX1;
-			int limitBobY1;
-			int limitBobX2;
-			int limitBobY2;
-			int specialMove;
-			int animType;        // 0 - Packet, 1 - Amal, 2 - Unpack
-			int fromObject;
-			int bobStartX;
-			int bobStartY;
-			int room;
-			int scale;
+			int16 objectNumber;    // 0 = JOE, -1 = MESSAGE
+			int16 moveToX;
+			int16 moveToY;
+			int16 bank;             // 0 = PBOB, 13 = Joe Bank, else BANK NAMEstr()
+			int16 animList;
+			int16 execute;          // 1 Yes, 0 No
+			int16 limitBobX1;
+			int16 limitBobY1;
+			int16 limitBobX2;
+			int16 limitBobY2;
+			int16 specialMove;
+			int16 animType;        // 0 - Packet, 1 - Amal, 2 - Unpack
+			int16 fromObject;
+			int16 bobStartX;
+			int16 bobStartY;
+			int16 room;
+			int16 scale;
 
 			// Variables derived from the variables above
 			int song;
@@ -114,8 +114,8 @@
 
 		struct ObjectDataBackup {
 			int index;
-			int16 value0;
-			int16 value7;
+			int16 name;
+			int16 image;
 		};
 
 		QueenLogic 		*_queenLogic;
@@ -230,6 +230,9 @@
 		//! Prepare for talk after cutaway
 		void talk(char *nextFilename);
 
+		//! Get CutawayAnim data from ptr and return new ptr
+		byte *getCutawayAnim(byte *ptr, int header, CutawayAnim &anim);
+
 		//! Read a string from ptr and return new ptr
 		static byte *getString(byte *ptr, char *str, int maxLength);
 
@@ -238,9 +241,6 @@
 
 		//! Dump a CutawayObject with debug()
 		static void dumpCutawayObject(int index, CutawayObject &object);
-
-		//! Get CutawayAnim data from ptr and return new ptr
-		static byte *getCutawayAnim(byte *ptr, int header, CutawayAnim &anim);
 
 		//! Dump CutawayAnum data with debug()
 		static void dumpCutawayAnim(CutawayAnim &anim);





More information about the Scummvm-git-logs mailing list