[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.200,1.201 actor.h,1.97,1.98 sfuncs.cpp,1.175,1.176

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Tue Oct 11 11:12:44 CEST 2005


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3268

Modified Files:
	actor.cpp actor.h sfuncs.cpp 
Log Message:
This is an attempt to fix the actor frames in IHNM. It appears to be at
least partially successful.


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -d -r1.200 -r1.201
--- actor.cpp	11 Oct 2005 17:39:31 -0000	1.200
+++ actor.cpp	11 Oct 2005 18:11:58 -0000	1.201
@@ -603,7 +603,7 @@
 		if (hitZone->getFlags() & kHitZoneAutoWalk) {
 			actor->_currentAction = kActionWalkDir;
 			actor->_actionDirection = actor->_facingDirection = hitZone->getDirection();
-			actor->_walkFrameSequence = kFrameWalk;
+			actor->_walkFrameSequence = getFrameType(kFrameWalk);
 			return;
 		}
 	} else if (!(hitZone->getFlags() & kHitZoneAutoWalk)) {
@@ -849,17 +849,17 @@
 					tempLocation.x += delta.x;
 					tempLocation.y += delta.y;
 
-					if (validFollowerLocation( tempLocation)) {
+					if (validFollowerLocation(tempLocation)) {
 						possibleLocation = tempLocation;
 					} else {
 						tempLocation = possibleLocation;
 						tempLocation.x += delta.x;
-						if (validFollowerLocation( tempLocation)) {
+						if (validFollowerLocation(tempLocation)) {
 							possibleLocation = tempLocation;
 						} else {
 							tempLocation = possibleLocation;
 							tempLocation.y += delta.y;
-							if (validFollowerLocation( tempLocation)) {
+							if (validFollowerLocation(tempLocation)) {
 								possibleLocation = tempLocation;
 							} else {
 								break;
@@ -881,6 +881,27 @@
 	}
 }
 
+int Actor::getFrameType(int frameType) {
+	if (_vm->getGameType() == GType_ITE)
+		return frameType;
+
+	switch (frameType) {
+	case kFrameStand:
+		return kFrameIHNMStand;
+	case kFrameWalk:
+		return kFrameIHNMWalk;
+	case kFrameSpeak:
+		return kFrameIHNMSpeak;
+	case kFrameGesture:
+		return kFrameIHNMGesture;
+	case kFrameWait:
+		return kFrameIHNMWait;
+	default:
+		warning("Actor::getFrameType() unknown frame type %d", frameType);
+		return kFrameIHNMStand;
+	}
+}
+
 ActorFrameRange *Actor::getActorFrameRange(uint16 actorId, int frameType) {
 	ActorData *actor;
 	int fourDirection;
@@ -1084,7 +1105,7 @@
 			}
 
 			if (actor->_flags & kCycle) {
-				frameRange = getActorFrameRange(actor->_id, kFrameStand);
+				frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameStand));
 				if (frameRange->frameCount > 0) {
 					actor->_actionCycle++;
 					actor->_actionCycle = (actor->_actionCycle) % frameRange->frameCount;
@@ -1098,9 +1119,9 @@
 			if ((actor->_actionCycle & 3) == 0) {
 				actor->cycleWrap(100);
 
-				frameRange = getActorFrameRange(actor->_id, kFrameWait);
+				frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameWait));
 				if ((frameRange->frameCount < 1 || actor->_actionCycle > 33))
-					frameRange = getActorFrameRange(actor->_id, kFrameStand);
+					frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameStand));
 
 				if (frameRange->frameCount) {
 					actor->_frameNumber = frameRange->frameIndex + (uint16)_vm->_rnd.getRandomNumber(frameRange->frameCount - 1);
@@ -1149,7 +1170,7 @@
 				}
 
 				if (ABS(delta.v()) > ABS(delta.u())) {
-					addDelta.v() = clamp( -speed, delta.v(), speed );
+					addDelta.v() = clamp(-speed, delta.v(), speed);
 					if (addDelta.v() == delta.v()) {
 						addDelta.u() = delta.u();
 					} else {
@@ -1158,7 +1179,7 @@
 						addDelta.u() /= delta.v();
 					}
 				} else {
-					addDelta.u() = clamp( -speed, delta.u(), speed );
+					addDelta.u() = clamp(-speed, delta.u(), speed);
 					if (addDelta.u() == delta.u()) {
 						addDelta.v() = delta.v();
 					} else {
@@ -1266,16 +1287,16 @@
 			actor->_actionCycle++;
 			actor->cycleWrap(64);
 
-			frameRange = getActorFrameRange(actor->_id, kFrameGesture);
+			frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameGesture));
 			if (actor->_actionCycle >= frameRange->frameCount) {
 				if (actor->_actionCycle & 1)
 					break;
-				frameRange = getActorFrameRange(actor->_id, kFrameSpeak);
+				frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameSpeak));
 
 				state = (uint16)_vm->_rnd.getRandomNumber(frameRange->frameCount);
 
 				if (state == 0) {
-					frameRange = getActorFrameRange(actor->_id, kFrameStand);
+					frameRange = getActorFrameRange(actor->_id, getFrameType(kFrameStand));
 				} else {
 					state--;
 				}
@@ -1399,10 +1420,10 @@
 
 			if (hitZone != actor->_lastZone) {
 				if (actor->_lastZone)
-					stepZoneAction( actor, actor->_lastZone, true, false);
+					stepZoneAction(actor, actor->_lastZone, true, false);
 				actor->_lastZone = hitZone;
 				if (hitZone)
-					stepZoneAction( actor, hitZone, false, false);
+					stepZoneAction(actor, hitZone, false, false);
 			}
 		}
 	}
@@ -1637,8 +1658,8 @@
 			actor = getActor(_activeSpeech.actorIds[i]);
 			calcScreenPosition(actor);
 
-			textPoint.x = clamp( 10, actor->_screenPosition.x - width / 2, _vm->getDisplayWidth() - 10 - width);
-			textPoint.y = clamp( 10, actor->_screenPosition.y - 58, _vm->_scene->getHeight() - 10 - height);
+			textPoint.x = clamp(10, actor->_screenPosition.x - width / 2, _vm->getDisplayWidth() - 10 - width);
+			textPoint.y = clamp(10, actor->_screenPosition.y - 58, _vm->_scene->getHeight() - 10 - height);
 
 			_vm->_font->textDraw(font, backBuffer, _activeSpeech.strings[0], textPoint,
 				_activeSpeech.speechColor[i], _activeSpeech.outlineColor[i], _activeSpeech.getFontFlags(i));
@@ -1692,8 +1713,8 @@
 			prefU /= 2;
 			prefV /= 2;
 
-			newU = clamp( -prefU, delta.u(), prefU ) + protagonistLocation.u();
-			newV = clamp( -prefV, delta.v(), prefV ) + protagonistLocation.v();
+			newU = clamp(-prefU, delta.u(), prefU) + protagonistLocation.u();
+			newV = clamp(-prefV, delta.v(), prefV) + protagonistLocation.v();
 
 			newLocation.u() = newU + _vm->_rnd.getRandomNumber(prefU - 1) - prefU / 2;
 			newLocation.v() = newV + _vm->_rnd.getRandomNumber(prefV - 1) - prefV / 2;
@@ -1860,9 +1881,9 @@
 		actor->_walkStepIndex = 0;
 		if (_vm->_isoMap->nextTileTarget(actor)) {
 			actor->_currentAction = kActionWalkToPoint;
-			actor->_walkFrameSequence = kFrameWalk;
+			actor->_walkFrameSequence = getFrameType(kFrameWalk);
 		} else {
-			actorEndWalk( actorId, false);
+			actorEndWalk(actorId, false);
 			return false;
 		}
 	} else {
@@ -1918,9 +1939,10 @@
 
 				for (i = 0; (i < _actorsCount) && (_barrierCount < ACTOR_BARRIERS_MAX); i++) {
 					anotherActor = _actors[i];
-					if (!anotherActor->_inScene) continue;
-					if (anotherActor == actor ) continue;
-
+					if (!anotherActor->_inScene)
+						continue;
+					if (anotherActor == actor)
+						continue;
 
 					anotherActorScreenPosition = anotherActor->_screenPosition;
 					testBox.left = (anotherActorScreenPosition.x - collision.x) & ~1;
@@ -2006,9 +2028,8 @@
 				_actors[2]->_actorFlags &= ~kActorNoFollow;
 			}
 			actor->_currentAction = (actor->_walkStepsCount >= ACTOR_MAX_STEPS_COUNT) ? kActionWalkToLink : kActionWalkToPoint;
-			actor->_walkFrameSequence = kFrameWalk;
+			actor->_walkFrameSequence = getFrameType(kFrameWalk);
 		}
-
 	}
 	return true;
 }
@@ -2034,8 +2055,8 @@
 	_activeSpeech.playing = false;
 	_activeSpeech.slowModeCharIndex = 0;
 
-	dist = MIN(actor->_screenPosition.x - 10, _vm->getDisplayWidth() - 10 - actor->_screenPosition.x );
-	dist = clamp( 60, dist, 150 );
+	dist = MIN(actor->_screenPosition.x - 10, _vm->getDisplayWidth() - 10 - actor->_screenPosition.x);
+	dist = clamp(60, dist, 150);
 
 	_activeSpeech.speechBox.left = actor->_screenPosition.x - dist;
 	_activeSpeech.speechBox.right = actor->_screenPosition.x + dist;
@@ -2561,7 +2582,7 @@
 	addPathListPoint(toPoint);
 	nextPoint = toPoint;
 
-	while ( !(nextPoint == fromPoint)) {
+	while (!(nextPoint == fromPoint)) {
 		direction = getPathCell(nextPoint);
 		if ((direction < 0) || (direction >= 8)) {
 			error("Actor::setActorPath error direction 0x%X", direction);
@@ -2756,7 +2777,7 @@
 		if (iNode->point.x == PATH_NODE_EMPTY) {
 			j = i + 1;
 			jNode = iNode + 1;
-			while ( jNode->point.x == PATH_NODE_EMPTY ) {
+			while (jNode->point.x == PATH_NODE_EMPTY) {
 				j++;
 				jNode++;
 			}

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -d -r1.97 -r1.98
--- actor.h	9 Oct 2005 01:43:08 -0000	1.97
+++ actor.h	11 Oct 2005 18:11:58 -0000	1.98
@@ -104,8 +104,16 @@
 	kFrameGesture = 4,
 	kFrameWait = 5,
 	kFramePickUp = 6,
-	kFrameLook = 7
+	kFrameLook = 7,
 //...some special
+
+	// TODO: Verify that these are correct for IHNM
+	kFrameIHNMStand = 0,
+	kFrameIHNMSpeak = 1,
+	kFrameIHNMWait = 2,
+	kFrameIHNMGesture = 3,
+	kFrameIHNMWalkDiag = 4,
+	kFrameIHNMWalk = 5
 };
 
 enum ActorFlagsEx {
@@ -558,6 +566,7 @@
 	void takeExit(uint16 actorId, const HitZone *hitZone);
 	bool actorEndWalk(uint16 actorId, bool recurse);
 	bool actorWalkTo(uint16 actorId, const Location &toLocation);
+	int getFrameType(int frameType);
 	ActorFrameRange *getActorFrameRange(uint16 actorId, int frameType);
 	void actorFaceTowardsPoint(uint16 actorId, const Location &toLocation);
 	void actorFaceTowardsObject(uint16 actorId, uint16 objectId);

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.175
retrieving revision 1.176
diff -u -d -r1.175 -r1.176
--- sfuncs.cpp	11 Oct 2005 17:39:31 -0000	1.175
+++ sfuncs.cpp	11 Oct 2005 18:11:58 -0000	1.176
@@ -981,11 +981,10 @@
 		actor->_actorFlags |= kActorBackwards;
 	}
 
-	actor->_cycleFrameSequence	= cycleFrameSequence;
+	actor->_cycleFrameSequence = cycleFrameSequence;
 	actor->_cycleTimeCount = 0;
 	actor->_cycleDelay = cycleDelay;
 	actor->_actionCycle = 0;
-
 }
 
 // Script function #38 (0x26) nonblocking





More information about the Scummvm-git-logs mailing list