[Scummvm-cvs-logs] SF.net SVN: scummvm:[39063] scummvm/trunk/engines/cruise

dreammaster at users.sourceforge.net dreammaster at users.sourceforge.net
Mon Mar 2 09:32:39 CET 2009


Revision: 39063
          http://scummvm.svn.sourceforge.net/scummvm/?rev=39063&view=rev
Author:   dreammaster
Date:     2009-03-02 08:32:38 +0000 (Mon, 02 Mar 2009)

Log Message:
-----------
Formatting fixes, and added extra constants and function name corrections

Modified Paths:
--------------
    scummvm/trunk/engines/cruise/actor.cpp
    scummvm/trunk/engines/cruise/actor.h
    scummvm/trunk/engines/cruise/cell.cpp
    scummvm/trunk/engines/cruise/cruise_main.cpp
    scummvm/trunk/engines/cruise/function.cpp

Modified: scummvm/trunk/engines/cruise/actor.cpp
===================================================================
--- scummvm/trunk/engines/cruise/actor.cpp	2009-03-02 06:14:25 UTC (rev 39062)
+++ scummvm/trunk/engines/cruise/actor.cpp	2009-03-02 08:32:38 UTC (rev 39063)
@@ -28,15 +28,21 @@
 
 namespace Cruise {
 
-int16 mainProc13(int overlayIdx, int param1, actorStruct *pStartEntry, int param2) {
+enum AnimPathIds {
+	ANIM_WAIT	= -1,
+	ANIM_FINISH = -2,
+	ANIM_STATIC = -3
+};
+
+bool isAnimFinished(int overlayIdx, int idx, actorStruct *pStartEntry, int objType) {
 	actorStruct *pCurrentEntry = pStartEntry->next;
 
 	while (pCurrentEntry) {
 		if ((pCurrentEntry->overlayNumber == overlayIdx || overlayIdx == -1) &&
-		        (pCurrentEntry->idx == param1 || param1 == -1) &&
-		        (pCurrentEntry->type == param2 || param2 == -1)) {
-			if (pCurrentEntry->pathId != -2) {
-				return 0;
+		        (pCurrentEntry->idx == idx || idx == -1) &&
+		        (pCurrentEntry->type == objType || objType == ANIM_WAIT)) {
+			if (pCurrentEntry->pathId != ANIM_FINISH) {
+				return false;
 			}
 		}
 
@@ -732,23 +738,23 @@
 				if (!animationStart) {
 					aniX = currentActor->x_dest;
 					aniY = currentActor->y_dest;
-
 					currentActor->x_dest = -1;
 					currentActor->y_dest = -1;
 
 					currentActor->flag = 1;
 				}
 
-				currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, aniX, aniY, currentActor->stepX, currentActor->stepY, currentActor->pathId);
+				currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, 
+					aniX, aniY, currentActor->stepX, currentActor->stepY, currentActor->pathId);
 
-				if (currentActor->pathId == -1) {
+				if (currentActor->pathId == ANIM_WAIT) {
 					if ((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection)) {
 						currentActor->phase = ANIM_PHASE_STATIC_END;
 						currentActor->nextDirection = currentActor->endDirection;
 						currentActor->endDirection = -1;
 						currentActor->counter = 0;
 					} else {
-						currentActor->pathId = -2;
+						currentActor->pathId = ANIM_FINISH;
 						currentActor->flag = 0;
 						currentActor->endDirection = -1;
 						currentActor->phase = ANIM_PHASE_WAIT;
@@ -765,7 +771,7 @@
 					currentActor->x_dest = -1;
 					currentActor->y_dest = -1;
 
-					if (currentActor->pathId == -1) {
+					if (currentActor->pathId == ANIM_WAIT) {
 						if ((currentActor->endDirection != -1) && (currentActor->endDirection != currentActor->startDirection)) {
 							currentActor->phase = ANIM_PHASE_STATIC_END;
 							currentActor->nextDirection = currentActor->endDirection;
@@ -787,13 +793,15 @@
 
 			if ((currentActor->pathId >= 0) || (currentActor->phase == ANIM_PHASE_STATIC_END)) {
 				switch (currentActor->phase) {
+				// In-place (on the spot) animationos
 				case ANIM_PHASE_STATIC_END:
-				case ANIM_PHASE_STATIC: {
+				case ANIM_PHASE_STATIC: 
+				{
 					if ((currentActor->counter == -1) && (currentActor->phase == ANIM_PHASE_STATIC)) {
 						affiche_chemin(currentActor->pathId, returnVar2);
 
 						if (returnVar2[0] == -1) {
-							currentActor->pathId = -2;
+							currentActor->pathId = ANIM_FINISH;
 							currentActor->flag = 0;
 							currentActor->endDirection = -1;
 							currentActor->phase = ANIM_PHASE_WAIT;
@@ -824,207 +832,92 @@
 							inc = -1;
 
 						if (inc > 0)
-							newA =
-							    actor_stat
-							    [currentActor->
-							     startDirection]
-							    [currentActor->
-							     counter++];
+							newA = actor_stat[currentActor->startDirection][currentActor->counter++];
 						else
-							newA =
-							    actor_invstat
-							    [currentActor->
-							     startDirection]
-							    [currentActor->
-							     counter++];
+							newA = actor_invstat[currentActor->startDirection][currentActor->counter++];
 
 						if (newA == 0) {
-							currentActor->
-							startDirection
-							=
-							    currentActor->
-							    startDirection
-							    + inc;
+							currentActor->startDirection = currentActor->startDirection + inc;
 
 							if (currentActor->startDirection > 3)
-								currentActor->
-								startDirection
-								=
-								    0;
+								currentActor->startDirection = 0;
 
 							if (currentActor->startDirection < 0)
-								currentActor->
-								startDirection
-								=
-								    3;
+								currentActor-> startDirection = 3;
 
-							currentActor->
-							counter =
-							    0;
+							currentActor->counter = 0;
 
 							if (currentActor->startDirection == currentActor->nextDirection) {
 								if (currentActor->phase == ANIM_PHASE_STATIC)
-									currentActor->
-									phase
-									=
-									    ANIM_PHASE_MOVE;
+									currentActor->phase = ANIM_PHASE_MOVE;
 								else
-									currentActor->
-									phase
-									=
-									    ANIM_PHASE_END;
+									currentActor->phase = ANIM_PHASE_END;
 							} else {
-								newA =
-								    actor_stat
-								    [currentActor->
-								     startDirection]
-								    [currentActor->
-								     counter++];
+								newA = actor_stat[currentActor->startDirection][currentActor->counter++];
 
-								if (inc
-								        ==
-								        -1)
+								if (inc == -1)
 									newA = -newA;
 
-								set_anim
-								(currentActor->
-								 overlayNumber,
-								 currentActor->
-								 idx,
-								 currentActor->
-								 start,
-								 params.
-								 X,
-								 params.
-								 Y,
-								 newA,
-								 currentActor->
-								 poly);
+								set_anim(currentActor->overlayNumber, currentActor->idx,
+									currentActor->start, params.X, params.Y, newA, currentActor->poly);
 								break;
 							}
 						} else {
-							set_anim
-							(currentActor->
-							 overlayNumber,
-							 currentActor->
-							 idx,
-							 currentActor->
-							 start,
-							 params.X,
-							 params.Y,
-							 newA,
-							 currentActor->
-							 poly);
+							set_anim(currentActor->overlayNumber,currentActor->idx, currentActor->start,
+								params.X, params.Y, newA, currentActor->poly);
 							break;
 						}
 					}
 					break;
 				}
+
+				// Walk animations
 				case ANIM_PHASE_MOVE: {
 					if (currentActor->counter >= 1) {
-						affiche_chemin
-						(currentActor->
-						 pathId,
-						 returnVar2);
-						if (returnVar2[0] ==
-						        -1) {
+						affiche_chemin(currentActor->pathId, returnVar2);
+
+						if (returnVar2[0] == -1) {
 							if ((currentActor->endDirection == -1) || (currentActor->endDirection == currentActor->nextDirection)) {
-								currentActor->
-								phase
-								=
-								    ANIM_PHASE_END;
+								currentActor->phase = ANIM_PHASE_END;
 							} else {
-								currentActor->
-								phase
-								=
-								    ANIM_PHASE_STATIC_END;
-								currentActor->
-								nextDirection
-								=
-								    currentActor->
-								    endDirection;
+								currentActor->phase = ANIM_PHASE_STATIC_END;
+								currentActor->nextDirection = currentActor->endDirection;
 							}
-							currentActor->
-							counter =
-							    0;
+							currentActor->counter = 0;
 							break;
 						} else {
-							currentActor->
-							x =
-							    returnVar2
-							    [0];
-							currentActor->
-							y =
-							    returnVar2
-							    [1];
-							currentActor->
-							nextDirection
-							=
-							    returnVar2
-							    [2];
-							currentActor->
-							poly =
-							    returnVar2
-							    [4];
-
-							/*
-							 * if (pl->next_dir!=pl->start_dir)
-							 * {
-							 * pl->phase=PHASE_STATIC;
-							 * pl->cnt=0;
-							 * break;
-							 * }
-							 */
+							currentActor->x = returnVar2[0];
+							currentActor->y = returnVar2[1];
+							currentActor->nextDirection = returnVar2[2];
+							currentActor->poly = returnVar2[4];
 						}
 					}
 
-					if (currentActor->phase ==
-					        ANIM_PHASE_MOVE) {
+					if (currentActor->phase == ANIM_PHASE_MOVE) {
 						int newA;
 
-						currentActor->
-						startDirection =
-						    currentActor->
-						    nextDirection;
+						currentActor->startDirection = currentActor->nextDirection;
 
-						newA =
-						    actor_move
-						    [currentActor->
-						     startDirection]
-						    [currentActor->
-						     counter++];
+						newA = actor_move[currentActor->startDirection][currentActor->counter++];
 						if (!newA) {
-							currentActor->
-							counter =
-							    0;
-							newA =
-							    actor_move
-							    [currentActor->
-							     startDirection]
-							    [currentActor->
-							     counter++];
+							currentActor->counter = 0;
+							newA = actor_move[currentActor->startDirection][currentActor->counter++];
 						}
-						set_anim(currentActor->
-						         overlayNumber,
-						         currentActor->idx,
-						         currentActor->
-						         start,
-						         currentActor->x,
-						         currentActor->y,
-						         newA,
-						         currentActor->
-						         poly);
+						set_anim(currentActor->overlayNumber, currentActor->idx, currentActor->start,
+							currentActor->x, currentActor->y, newA, currentActor->poly);
 						break;
 					}
 
 					break;
 				}
-				case ANIM_PHASE_END: {
+				case ANIM_PHASE_END:
+				{
 					int newA = actor_end[currentActor->startDirection][0];
 
-					set_anim(currentActor->overlayNumber, currentActor->idx, currentActor->start, currentActor->x, currentActor->y, newA, currentActor->poly);
+					set_anim(currentActor->overlayNumber, currentActor->idx, currentActor->start,
+						currentActor->x, currentActor->y, newA, currentActor->poly);
 
-					currentActor->pathId = -2;
+					currentActor->pathId = ANIM_FINISH;
 					currentActor->phase = ANIM_PHASE_WAIT;
 					currentActor->flag = 0;
 					currentActor->endDirection = -1;

Modified: scummvm/trunk/engines/cruise/actor.h
===================================================================
--- scummvm/trunk/engines/cruise/actor.h	2009-03-02 06:14:25 UTC (rev 39062)
+++ scummvm/trunk/engines/cruise/actor.h	2009-03-02 08:32:38 UTC (rev 39063)
@@ -61,7 +61,7 @@
 	int16 freeze;
 };
 
-int16 mainProc13(int overlayIdx, int param1, actorStruct * pStartEntry, int param2);
+bool isAnimFinished(int overlayIdx, int idx, actorStruct *pStartEntry, int objType);
 actorStruct *findActor(actorStruct *pStartEntry, int overlayIdx, int objIdx, int type);
 void processAnimation(void);
 void getPixel(int x, int y);

Modified: scummvm/trunk/engines/cruise/cell.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cell.cpp	2009-03-02 06:14:25 UTC (rev 39062)
+++ scummvm/trunk/engines/cruise/cell.cpp	2009-03-02 08:32:38 UTC (rev 39063)
@@ -144,12 +144,13 @@
 	var_2 = si;
 
 	pNewElement = (cellStruct *) malloc(sizeof(cellStruct));
+	memset(pNewElement, 0, sizeof(cellStruct));
 
 	pNewElement->next = pObject->next;
 	pObject->next = pNewElement;
 
 	pNewElement->idx = messageIdx;
-	pNewElement->type = 5;
+	pNewElement->type = OBJ_TYPE_MSG;
 	pNewElement->backgroundPlane = backgroundPlane;
 	pNewElement->overlay = overlayIdx;
 	pNewElement->x = x;

Modified: scummvm/trunk/engines/cruise/cruise_main.cpp
===================================================================
--- scummvm/trunk/engines/cruise/cruise_main.cpp	2009-03-02 06:14:25 UTC (rev 39062)
+++ scummvm/trunk/engines/cruise/cruise_main.cpp	2009-03-02 08:32:38 UTC (rev 39063)
@@ -1702,8 +1702,7 @@
 	main21 = 0;
 	main22 = 0;
 	userWait = 0;
-	autoTrack = 0;
-	autoTrack = 0;
+	autoTrack = false;
 
 	initAllData();
 
@@ -1830,7 +1829,7 @@
 
 				// wait for character to finish auto track
 				if (autoTrack) {
-					if (mainProc13(narratorOvl, narratorIdx, &actorHead, 0)) {
+					if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, 0)) {
 						if (autoMsg != -1) {
 							freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0);
 
@@ -1841,7 +1840,7 @@
 						}
 
 						changeScriptParamInList(-1, -1, &relHead, 9998, 0);
-						autoTrack = 0;
+						autoTrack = false;
 						enableUser = 1;
 					} else {
 						userEnabled = false;

Modified: scummvm/trunk/engines/cruise/function.cpp
===================================================================
--- scummvm/trunk/engines/cruise/function.cpp	2009-03-02 06:14:25 UTC (rev 39062)
+++ scummvm/trunk/engines/cruise/function.cpp	2009-03-02 08:32:38 UTC (rev 39063)
@@ -745,7 +745,7 @@
 	if (!overlay)
 		overlay = currentScriptPtr->overlayNumber;
 
-	return mainProc13(overlay, param2, &actorHead, param1);
+	return isAnimFinished(overlay, param2, &actorHead, param1);
 }
 
 int16 Op_Protect(void) {


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