aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorVincent Hamm2007-05-16 22:44:22 +0000
committerVincent Hamm2007-05-16 22:44:22 +0000
commit67ba6b1e4064de28b27a5979ccf88086aecdaced (patch)
tree340134789d7a00279f5ed585774366efa1689911 /engines
parentf243227f098824a74eae078531ccf6af539dfbcb (diff)
downloadscummvm-rg350-67ba6b1e4064de28b27a5979ccf88086aecdaced.tar.gz
scummvm-rg350-67ba6b1e4064de28b27a5979ccf88086aecdaced.tar.bz2
scummvm-rg350-67ba6b1e4064de28b27a5979ccf88086aecdaced.zip
Figured out the bug that was causing the animations to glitch
svn-id: r26856
Diffstat (limited to 'engines')
-rw-r--r--engines/cruise/actor.cpp113
-rw-r--r--engines/cruise/cell.cpp2
-rw-r--r--engines/cruise/cruise_main.cpp12
-rw-r--r--engines/cruise/function.cpp9
-rw-r--r--engines/cruise/mainDraw.cpp28
-rw-r--r--engines/cruise/script.cpp5
-rw-r--r--engines/cruise/script.h2
-rw-r--r--engines/cruise/vars.cpp2
8 files changed, 55 insertions, 118 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp
index 3b430fae1a..cf7ef4b176 100644
--- a/engines/cruise/actor.cpp
+++ b/engines/cruise/actor.cpp
@@ -788,122 +788,73 @@ void processAnimation(void) {
currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, var34, var35, currentActor->stepX, currentActor->stepY, currentActor->pathId);
if (currentActor->pathId == -1) {
- if ((currentActor->endDirection != -1)
- && (currentActor->endDirection !=
- currentActor->
- startDirection)) {
- currentActor->phase =
- ANIM_PHASE_STATIC_END;
- currentActor->nextDirection =
- currentActor->endDirection;
- currentActor->endDirection =
- -1;
+ 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->flag = 0;
- currentActor->endDirection =
- -1;
- currentActor->phase =
- ANIM_PHASE_WAIT;
+ currentActor->endDirection = -1;
+ currentActor->phase = ANIM_PHASE_WAIT;
}
} else {
- currentActor->phase =
- ANIM_PHASE_STATIC;
+ currentActor->phase = ANIM_PHASE_STATIC;
currentActor->counter = -1;
}
} else
- if ((currentActor->type == 1)
- && (currentActor->x_dest != -1)
- && (currentActor->y_dest != -1)) {
+ if ((currentActor->type == 1) && (currentActor->x_dest != -1) && (currentActor->y_dest != -1)) {
// track animation
- currentActor->pathId =
- computePathfinding(returnVar2, params.X,
- params.Y, currentActor->x_dest,
- currentActor->y_dest, currentActor->stepX,
- currentActor->stepY, currentActor->pathId);
+ currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, currentActor->x_dest, currentActor->y_dest, currentActor->stepX, currentActor->stepY, currentActor->pathId);
currentActor->x_dest = -1;
currentActor->y_dest = -1;
if (currentActor->pathId == -1) {
- if ((currentActor->endDirection != -1)
- && (currentActor->endDirection !=
- currentActor->
- startDirection)) {
- currentActor->phase =
- ANIM_PHASE_STATIC_END;
- currentActor->nextDirection =
- currentActor->endDirection;
- currentActor->endDirection =
- -1;
+ 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->flag = 0;
- currentActor->endDirection =
- -1;
- currentActor->phase =
- ANIM_PHASE_WAIT;
+ currentActor->endDirection = -1;
+ currentActor->phase = ANIM_PHASE_WAIT;
}
} else {
- currentActor->phase =
- ANIM_PHASE_STATIC;
+ currentActor->phase = ANIM_PHASE_STATIC;
currentActor->counter = -1;
}
}
animationStart = false;
- if (currentActor->pathId >= 0
- || currentActor->phase == ANIM_PHASE_STATIC_END) {
+ if ((currentActor->pathId >= 0) || (currentActor->phase == ANIM_PHASE_STATIC_END)) {
switch (currentActor->phase) {
case ANIM_PHASE_STATIC_END:
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->
- flag = 0;
- currentActor->
- endDirection
- = -1;
- currentActor->
- phase =
- ANIM_PHASE_WAIT;
+ if ((currentActor->counter == -1) && (currentActor->phase == ANIM_PHASE_STATIC)) {
+ affiche_chemin(currentActor->pathId, returnVar2);
+
+ if (returnVar2[0] == -1) {
+ currentActor->pathId = -2;
+ currentActor->flag = 0;
+ currentActor->endDirection = -1;
+ currentActor->phase = ANIM_PHASE_WAIT;
break;
}
- currentActor->x =
- returnVar2[0];
- currentActor->y =
- returnVar2[1];
- currentActor->
- nextDirection =
- returnVar2[2];
- currentActor->poly =
- returnVar2[4];
- currentActor->counter =
- 0;
+ currentActor->x = returnVar2[0];
+ currentActor->y = returnVar2[1];
+ currentActor->nextDirection = returnVar2[2];
+ currentActor->poly = returnVar2[4];
+ currentActor->counter = 0;
- if (currentActor->
- startDirection ==
- currentActor->
- nextDirection)
- currentActor->
- phase =
- ANIM_PHASE_MOVE;
+ if (currentActor->startDirection == currentActor->nextDirection)
+ currentActor->phase = ANIM_PHASE_MOVE;
}
if ((currentActor->counter >=
diff --git a/engines/cruise/cell.cpp b/engines/cruise/cell.cpp
index ff0570f194..2c9589f744 100644
--- a/engines/cruise/cell.cpp
+++ b/engines/cruise/cell.cpp
@@ -27,6 +27,8 @@
namespace Cruise {
+cellStruct cellHead;
+
void resetPtr(cellStruct *ptr) {
ptr->next = NULL;
ptr->prev = NULL;
diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp
index f24e1f1cd7..1f3c1f2f6a 100644
--- a/engines/cruise/cruise_main.cpp
+++ b/engines/cruise/cruise_main.cpp
@@ -162,15 +162,13 @@ int getProcParam(int overlayIdx, int param2, uint8 *name) {
return 0;
}
-void changeScriptParamInList(int param1, int param2,
- scriptInstanceStruct *pScriptInstance, int newValue, int param3) {
+void changeScriptParamInList(int param1, int param2, scriptInstanceStruct *pScriptInstance, int newValue, int param3) {
pScriptInstance = pScriptInstance->nextScriptPtr;
while (pScriptInstance) {
- if ((pScriptInstance->overlayNumber == param1 || param1 == -1)
- && (pScriptInstance->scriptNumber == param2
- || param2 == -1)
- && (pScriptInstance->var12 == param3 || param3 == -1)) {
- pScriptInstance->var12 = newValue;
+ if ((pScriptInstance->overlayNumber == param1) || (param1 == -1))
+ if ((pScriptInstance->scriptNumber == param2) || (param2 == -1))
+ if ((pScriptInstance->freeze == param3) || (param3 == -1)) {
+ pScriptInstance->freeze = newValue;
}
pScriptInstance = pScriptInstance->nextScriptPtr;
diff --git a/engines/cruise/function.cpp b/engines/cruise/function.cpp
index 5971d191fa..73e1bd9084 100644
--- a/engines/cruise/function.cpp
+++ b/engines/cruise/function.cpp
@@ -102,10 +102,7 @@ int16 Op_startScript(void) {
ovlIdx = currentScriptPtr->overlayNumber;
}
- ptr =
- attacheNewScriptToTail(ovlIdx, &procHead, scriptIdx,
- currentScriptPtr->type, currentScriptPtr->scriptNumber,
- currentScriptPtr->overlayNumber, scriptType_MinusPROC);
+ ptr = attacheNewScriptToTail(ovlIdx, &procHead, scriptIdx, currentScriptPtr->type, currentScriptPtr->scriptNumber, currentScriptPtr->overlayNumber, scriptType_MinusPROC);
if (!ptr)
return (0);
@@ -194,7 +191,7 @@ int16 Op_rand(void) { // TODO: implement
if (var < 2) {
return (0);
}
-// return(8);
+
return (rand() % var);
}
@@ -797,7 +794,7 @@ int16 Op_66(void) {
getMultipleObjectParam(overlay, index, &params);
- return params.var7;
+ return params.var7 - 1;
}
int16 Op_SetActiveBackgroundPlane(void) {
diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp
index 8210f6d404..3d9064cf59 100644
--- a/engines/cruise/mainDraw.cpp
+++ b/engines/cruise/mainDraw.cpp
@@ -865,8 +865,7 @@ void mainDraw(int16 param) {
bgPtr = backgroundPtrtable[currentActiveBackgroundPlane];
if (bgPtr) {
- gfxModuleData_gfxCopyScreen((char *)bgPtr,
- (char *)gfxModuleData.pPage10);
+ gfxModuleData_gfxCopyScreen((char *)bgPtr, (char *)gfxModuleData.pPage10);
}
autoCellHead.next = NULL;
@@ -881,24 +880,16 @@ void mainDraw(int16 param) {
//-------------------------------------------------- PROCESS SPRITES -----------------------------------------//
while (currentObjPtr) {
- if ((currentActiveBackgroundPlane ==
- currentObjPtr->backgroundPlane)
- && (currentObjPtr->freeze == 0)
- && (currentObjPtr->type == OBJ_SPRITE)) {
+ if ((currentActiveBackgroundPlane == currentObjPtr->backgroundPlane) && (currentObjPtr->freeze == 0) && (currentObjPtr->type == OBJ_SPRITE)) {
objectParamsQuery params;
currentObjIdx = currentObjPtr->idx;
- if ((currentObjPtr->followObjectOverlayIdx !=
- currentObjPtr->overlay)
- || (currentObjPtr->followObjectIdx !=
- currentObjPtr->idx)) {
+ if ((currentObjPtr->followObjectOverlayIdx != currentObjPtr->overlay) || (currentObjPtr->followObjectIdx != currentObjPtr->idx)) {
// Declaring this twice ?
// objectParamsQuery params;
- getMultipleObjectParam(currentObjPtr->
- followObjectOverlayIdx,
- currentObjPtr->followObjectIdx, &params);
+ getMultipleObjectParam(currentObjPtr->followObjectOverlayIdx, currentObjPtr->followObjectIdx, &params);
objX1 = params.X;
objY1 = params.Y;
@@ -940,18 +931,20 @@ void mainDraw(int16 param) {
}
}
- if ((currentObjPtr->animStep != 0) && (param == 0)) {
+ // automatic animation process
+ if (currentObjPtr->animStep && !param) {
if (currentObjPtr->animCounter <= 0) {
- int newVal;
+
bool change = true;
- newVal = getValueFromObjectQuerry(&params, currentObjPtr->animChange) + currentObjPtr->animStep;
+ int newVal = getValueFromObjectQuerry(&params, currentObjPtr->animChange) + currentObjPtr->animStep;
if (currentObjPtr->animStep > 0) {
if (newVal > currentObjPtr->animEnd) {
if (currentObjPtr->animLoop) {
newVal = currentObjPtr->animStart;
- currentObjPtr->animLoop--;
+ if(currentObjPtr->animLoop>0)
+ currentObjPtr->animLoop--;
} else {
int16 data2;
data2 = currentObjPtr->animStart;
@@ -968,7 +961,6 @@ void mainDraw(int16 param) {
changeScriptParamInList(currentObjPtr->parentOverlay, currentObjPtr->parent, &relHead, 0, -1);
}
}
- newVal = data2;
}
}
} else {
diff --git a/engines/cruise/script.cpp b/engines/cruise/script.cpp
index 9751ce4adb..f690530a09 100644
--- a/engines/cruise/script.cpp
+++ b/engines/cruise/script.cpp
@@ -666,7 +666,7 @@ uint8 *attacheNewScriptToTail(int16 overlayNumber,
tempPtr->sysKey = 1;
}
- tempPtr->var12 = 0;
+ tempPtr->freeze = 0;
tempPtr->type = scriptType;
tempPtr->var18 = arg2;
tempPtr->var16 = arg1;
@@ -753,8 +753,7 @@ void manageScripts(scriptInstanceStruct *scriptHandle) {
if (ptr) {
do {
if (!overlayTable[ptr->overlayNumber].executeScripts) {
- if (ptr->scriptNumber != -1 && ptr->var12 == 0
- && ptr->sysKey != 0) {
+ if ((ptr->scriptNumber != -1) && (ptr->freeze == 0) && (ptr->sysKey != 0)) {
executeScripts(ptr);
}
diff --git a/engines/cruise/script.h b/engines/cruise/script.h
index 5b938b92b1..668fcaae74 100644
--- a/engines/cruise/script.h
+++ b/engines/cruise/script.h
@@ -42,7 +42,7 @@ struct scriptInstanceStruct {
int16 scriptNumber;
int16 overlayNumber;
int16 sysKey;
- int16 var12;
+ int16 freeze;
scriptTypeEnum type;
int16 var16;
int16 var18;
diff --git a/engines/cruise/vars.cpp b/engines/cruise/vars.cpp
index daee27e2d1..c6cb068306 100644
--- a/engines/cruise/vars.cpp
+++ b/engines/cruise/vars.cpp
@@ -89,8 +89,6 @@ int16 bootOverlayNumber;
int16 initVar5[12];
-cellStruct cellHead;
-
opcodeTypeFunction opcodeTypeTable[64];
int16 positionInStack;