[Scummvm-cvs-logs] CVS: scummvm/queen graphics.cpp,1.69,1.70 logic.cpp,1.159,1.160 logic.h,1.102,1.103 structs.h,1.30,1.31

Gregory Montoir cyx at users.sourceforge.net
Tue Jan 6 12:01:05 CET 2004


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

Modified Files:
	graphics.cpp logic.cpp logic.h structs.h 
Log Message:
- minor cleanup in Person/Actor stuff
- minor tweak in Graphics::bobSetText()
from previous commit (message was erroneous) :
- moved config stuff to QueenEngine 
- added 3 Logic subclasses to handle the specific parts of each game version (demo, intv...)


Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.69
retrieving revision 1.70
diff -u -d -r1.69 -r1.70
--- graphics.cpp	6 Jan 2004 14:21:50 -0000	1.69
+++ graphics.cpp	6 Jan 2004 20:00:43 -0000	1.70
@@ -1026,7 +1026,7 @@
 		y = y - height - 16 - lineCount * 9;
 	}
 
-	// XXX x -= scrollx;
+	x -= _vm->display()->horizontalScroll();
 
 	if (y < 0) {
 		y = 0;

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.159
retrieving revision 1.160
diff -u -d -r1.159 -r1.160
--- logic.cpp	6 Jan 2004 16:53:35 -0000	1.159
+++ logic.cpp	6 Jan 2004 20:00:45 -0000	1.160
@@ -1002,20 +1002,16 @@
 }
 
 
-void Logic::personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp) {
-	if (noun <= 0) {
-		warning("Logic::personSetData() - Invalid object number: %i", noun);
-	}
-
-	uint16 i;
+ActorData *Logic::findActor(uint16 noun, const char *name) {
 	uint16 obj = currentRoomData() + noun;
 	int16 img = _objectData[obj].image;
 	if (img != -3 && img != -4) {
-		warning("Logic::personSetData() - Object %d is not a person", obj);
-		return;
+		warning("Logic::findActor() - Object %d is not a person", obj);
+		return NULL;
 	}
 
 	// search Bob number for the person
+	uint16 i;
 	uint16 bobNum = 0;
 	for (i = currentRoomData() + 1; i <= obj; ++i) {
 		img = _objectData[i].image;
@@ -1025,40 +1021,38 @@
 	}
 
 	// search for a matching actor
-	uint16 actor = 0;
-	for (i = 1; i <= _numActors; ++i) {
-		ActorData *pad = &_actorData[i];
-		if (pad->room == _currentRoom) {
-			if (_gameState[pad->gameStateSlot] == pad->gameStateValue) {
-				if ((bobNum > 0 && bobNum == pad->bobNum) || strcmp(_aName[pad->name], actorName) == 0) {
-					actor = i;
-					break;
+	if (bobNum > 0) {
+		for (i = 1; i <= _numActors; ++i) {
+			ActorData *pad = &_actorData[i];
+			if (pad->room == _currentRoom && gameState(pad->gsSlot) == pad->gsValue) {
+				if (bobNum == pad->bobNum || (name && !strcmp(_aName[pad->name], name))) {
+					return pad;
 				}
 			}
 		}
 	}
+	return NULL;
+}
 
-	if (actor != 0) {
 
-		pp->actor = &_actorData[actor];
-		pp->name = _aName[pp->actor->name];
-		if (pp->actor->anim != 0) {
-			pp->anim = _aAnim[pp->actor->anim];
+void Logic::personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp) {
+	if (noun <= 0) {
+		warning("Person::setData() - Invalid object number: %i", noun);
+	}	
+	ActorData *pad = findActor(noun, actorName);
+	if (pad != NULL) {
+		pp->actor = pad;
+		pp->name = _aName[pad->name];
+		if (pad->anim != 0) {
+			pp->anim = _aAnim[pad->anim];
 		} else {
 			pp->anim = NULL;
 		}
-
-		debug(6, "Logic::personSetData() - name=%s n=%d", pp->name, actor);
-
-		if (loadBank) {
-			const char *actorFile = _aFile[pp->actor->actorFile];
-			if (actorFile) {
-				_vm->bankMan()->load(actorFile, pp->actor->bankNum);
-			}
-			// if actorFile is null, the person data is already loaded as
-			// it is contained in objects room bank (.bbk)
+		if (loadBank && pad->file != 0) {
+			_vm->bankMan()->load(_aFile[pad->file], pad->bankNum);
+			// if there is no valid actor file (ie pad->file is 0), the person 
+			// data is already loaded as it is contained in objects room bank (.bbk)
 		}
-
 		pp->bobFrame = 29 + FRAMES_JOE_XTRA + pp->actor->bobNum;
 	}
 }
@@ -1082,17 +1076,12 @@
 	}
 
 	_vm->bankMan()->unpack(pad->bobFrameStanding, p.bobFrame, p.actor->bankNum);
-	bool xflip = false;
-	uint16 person = currentRoomData() + noun;
-	if (_objectData[person].image == -3) {
-		// person is facing left
-		xflip = true;
-	}
+	uint16 obj = currentRoomData() + noun;
 	BobSlot *pbs = _vm->graphics()->bob(pad->bobNum);
 	pbs->curPos(pad->x, pad->y);
 	pbs->scale = scale;
 	pbs->frameNum = p.bobFrame;
-	pbs->xflip = xflip;
+	pbs->xflip = (_objectData[obj].image == -3); // person is facing left
 
 	debug(6, "Logic::personSetup(%d, %d) - bob = %d name = %s", noun, curImage, pad->bobNum, p.name);
 
@@ -1107,51 +1096,24 @@
 
 
 uint16 Logic::personAllocate(uint16 noun, uint16 curImage) {
-	uint16 i;
-	uint16 person = currentRoomData() + noun;
-
-	// search Bob number for the person
-	uint16 bobNum = 0;
-	for (i = currentRoomData() + 1; i <= person; ++i) {
-		int16 img = _objectData[i].image;
-		if (img == -3 || img == -4) {
-			++bobNum;
-		}
-	}
-
-	// search for a matching actor
-	uint16 actor = 0;
-	for (i = 1; i <= _numActors; ++i) {
-		ActorData *pad = &_actorData[i];
-		if (pad->room == _currentRoom) {
-			if (_gameState[pad->gameStateSlot] == pad->gameStateValue) {
-				if (bobNum > 0 && bobNum == pad->bobNum) {
-					actor = i;
-					break;
-				}
-			}
-		}
-	}
-
-	if (actor > 0) {
-		const char *animStr = _aAnim[_actorData[actor].anim];
-		if (animStr) {
-			bool allocatedFrames[256];
-			memset(allocatedFrames, 0, sizeof(allocatedFrames));
-			uint16 f1, f2;
-			do {
-				sscanf(animStr, "%3hu,%3hu", &f1, &f2);
-				animStr += 8;
-				allocatedFrames[f1] = true;
-			} while(f1 != 0);
-			for (i = 1; i <= 255; ++i) {
-				if (allocatedFrames[i]) {
-					++curImage;
-				}
+	ActorData *pad = findActor(noun);
+	if (pad != NULL && pad->anim != 0) {
+		const char *animStr = _aAnim[pad->anim];
+		bool allocatedFrames[256];
+		memset(allocatedFrames, 0, sizeof(allocatedFrames));
+		uint16 f1, f2;
+		do {
+			sscanf(animStr, "%3hu,%3hu", &f1, &f2);
+			animStr += 8;
+			allocatedFrames[f1] = true;
+		} while(f1 != 0);
+		for (int i = 1; i <= 255; ++i) {
+			if (allocatedFrames[i]) {
+				++curImage;
 			}
-			// FIXME: shouldn't this line be executed BEFORE curImage is incremented ?
-			_personFrames[bobNum] = curImage + 1;
 		}
+		// FIXME: shouldn't this line be executed BEFORE curImage is incremented ?
+		_personFrames[pad->bobNum] = curImage + 1;
 	}
 	return curImage;
 }

Index: logic.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.h,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- logic.h	6 Jan 2004 16:53:35 -0000	1.102
+++ logic.h	6 Jan 2004 20:00:46 -0000	1.103
@@ -168,6 +168,7 @@
 
 	uint16 numFrames() const { return _numFrames; }
 
+	ActorData *findActor(uint16 noun, const char *name = NULL);
 	void personSetData(int16 noun, const char *actorName, bool loadBank, Person *pp);
 	uint16 personSetup(uint16 noun, uint16 curImage);
 	uint16 personAllocate(uint16 noun, uint16 curImage);

Index: structs.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/structs.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- structs.h	6 Jan 2004 12:45:29 -0000	1.30
+++ structs.h	6 Jan 2004 20:00:46 -0000	1.31
@@ -366,7 +366,7 @@
 	//! entry in ACTOR_NAME
 	uint16 name;
 	//! gamestate entry/value, actor is valid if GAMESTATE[slot] == value
-	int16 gameStateSlot, gameStateValue;
+	int16 gsSlot, gsValue;
 	//! spoken text color
 	uint16 color;
 	//! bank bobframe for standing position of the actor
@@ -378,25 +378,25 @@
 	//! bank to use to load the actor file
 	uint16 bankNum;
 	//! entry in ACTOR_FILE
-	uint16 actorFile;
+	uint16 file;
 
 	void readFromBE(byte *&ptr) {
 		room = (int16)READ_BE_UINT16(ptr); ptr += 2;
 		bobNum = (int16)READ_BE_UINT16(ptr); ptr += 2;
 		name = READ_BE_UINT16(ptr); ptr += 2;
-		gameStateSlot = (int16)READ_BE_UINT16(ptr); ptr += 2;
-		gameStateValue = (int16)READ_BE_UINT16(ptr); ptr += 2;
+		gsSlot = (int16)READ_BE_UINT16(ptr); ptr += 2;
+		gsValue = (int16)READ_BE_UINT16(ptr); ptr += 2;
 		color = READ_BE_UINT16(ptr); ptr += 2;
 		bobFrameStanding = READ_BE_UINT16(ptr); ptr += 2;
 		x = READ_BE_UINT16(ptr); ptr += 2;
 		y = READ_BE_UINT16(ptr); ptr += 2;
 		anim = READ_BE_UINT16(ptr); ptr += 2;
 		bankNum = READ_BE_UINT16(ptr); ptr += 2;
-		actorFile = READ_BE_UINT16(ptr); ptr += 2;
+		file = READ_BE_UINT16(ptr); ptr += 2;
 		// Fix the actor data (see queen.c - l.1518-1519). When there is no 
 		// valid actor file, we must load the data from the objects room bank.
 		// This bank has number 15 (not 10 as in the data files).
-		if (actorFile == 0) {
+		if (file == 0) {
 			bankNum = 15;
 		}
 	}





More information about the Scummvm-git-logs mailing list