Figured out the bug that was causing the animations to glitch

svn-id: r26856
This commit is contained in:
Vincent Hamm 2007-05-16 22:44:22 +00:00
parent f243227f09
commit 67ba6b1e40
8 changed files with 54 additions and 117 deletions

View File

@ -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 ((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 (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 >=

View File

@ -27,6 +27,8 @@
namespace Cruise {
cellStruct cellHead;
void resetPtr(cellStruct *ptr) {
ptr->next = NULL;
ptr->prev = NULL;

View File

@ -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;

View File

@ -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) {

View File

@ -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 {

View File

@ -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);
}

View File

@ -42,7 +42,7 @@ struct scriptInstanceStruct {
int16 scriptNumber;
int16 overlayNumber;
int16 sysKey;
int16 var12;
int16 freeze;
scriptTypeEnum type;
int16 var16;
int16 var18;

View File

@ -89,8 +89,6 @@ int16 bootOverlayNumber;
int16 initVar5[12];
cellStruct cellHead;
opcodeTypeFunction opcodeTypeTable[64];
int16 positionInStack;