diff options
author | Paul Gilbert | 2009-03-03 10:10:35 +0000 |
---|---|---|
committer | Paul Gilbert | 2009-03-03 10:10:35 +0000 |
commit | f3a9274a4590b9310b10a9999f242f6f8a5eea38 (patch) | |
tree | 7af213ecf87a2157f31693731882549448ca7bef /engines | |
parent | 236b42bcffae68974abff22a6aaf8ea0eec35f50 (diff) | |
download | scummvm-rg350-f3a9274a4590b9310b10a9999f242f6f8a5eea38.tar.gz scummvm-rg350-f3a9274a4590b9310b10a9999f242f6f8a5eea38.tar.bz2 scummvm-rg350-f3a9274a4590b9310b10a9999f242f6f8a5eea38.zip |
Changed the int16[5] array used in pathfinding to a structure with explicitly named fields
svn-id: r39087
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cruise/actor.cpp | 70 | ||||
-rw-r--r-- | engines/cruise/cruise_main.cpp | 2 | ||||
-rw-r--r-- | engines/cruise/perso.cpp | 34 | ||||
-rw-r--r-- | engines/cruise/perso.h | 10 |
4 files changed, 62 insertions, 54 deletions
diff --git a/engines/cruise/actor.cpp b/engines/cruise/actor.cpp index 787248abcb..e63d8fde91 100644 --- a/engines/cruise/actor.cpp +++ b/engines/cruise/actor.cpp @@ -580,13 +580,13 @@ void valide_noeud(int16 table[], int16 p, int *nclick, int16 solution0[20 + 3][2 /** * Computes a path for an actor to walk between a given source and destination position */ -int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 destY, int16 stepX, int16 stepY, int16 oldPathId) { +int16 computePathfinding(MovementEntry &solution, int16 x, int16 y, int16 destX, int16 destY, int16 stepX, int16 stepY, int16 oldPathId) { persoStruct *perso; int num; if (!polyStruct) { - pSolution[0] = -1; - pSolution[1] = -1; + solution.x = -1; + solution.y = -1; return -1; } @@ -608,8 +608,8 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 } if (i == NUM_PERSONS) { - pSolution[0] = -1; - pSolution[1] = -1; + solution.x = -1; + solution.y = -1; return -1; } @@ -623,11 +623,11 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 *(ptr++) = x; *(ptr++) = y; - *(ptr++) = pSolution[0] = destX; - *(ptr++) = pSolution[1] = destY; + *(ptr++) = solution.x = destX; + *(ptr++) = solution.y = destY; *(ptr++) = -1; - pSolution[4] = computedVar14; + solution.poly = computedVar14; perso->inc_droite = 0; perso->inc_chemin = 0; @@ -640,8 +640,8 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 flag_aff_chemin = 0; if (x == destX && y == destY) { - pSolution[0] = -1; - pSolution[1] = -1; + solution.x = -1; + solution.y = -1; return (-1); } @@ -650,14 +650,14 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 getPixel(x, y); - pSolution[4] = computedVar14; + solution.poly = computedVar14; x_mouse = x; y_mouse = y; if (!flag_obstacle || (point_select = point_proche(ctp_routeCoords)) == -1) { - pSolution[0] = -1; - pSolution[1] = -1; + solution.x = -1; + solution.y = -1; return (-1); } @@ -673,8 +673,8 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 num++; if (num == NUM_PERSONS) { - pSolution[0] = -1; - pSolution[1] = -1; + solution.x = -1; + solution.y = -1; return (-1); } @@ -690,16 +690,16 @@ int16 computePathfinding(int16 *pSolution, int16 x, int16 y, int16 destX, int16 valide_noeud(select_noeud, point_select, &nclick_noeud, perso->solution); if ((!flag_aff_chemin) || ((table_ptselect[0][0] == table_ptselect[1][0]) && (table_ptselect[0][1] == table_ptselect[1][1]))) { - pSolution[0] = -1; - pSolution[1] = -1; + solution.x = -1; + solution.y = -1; freePerso(num); return (-1); } - pSolution[0] = table_ptselect[1][0]; - pSolution[1] = table_ptselect[1][1]; - pSolution[4] = computedVar14; + solution.x = table_ptselect[1][0]; + solution.y = table_ptselect[1][1]; + solution.poly = computedVar14; perso->inc_chemin = 0; perso->inc_droite = 0; @@ -728,7 +728,7 @@ void set_anim(int ovl, int obj, int start, int x, int y, int mat, int state) { */ void processAnimation(void) { objectParamsQuery params; - int16 returnVar2[5]; + MovementEntry moveInfo; actorStruct *currentActor = actorHead.next; actorStruct *nextActor; @@ -750,7 +750,7 @@ void processAnimation(void) { currentActor->flag = 1; } - currentActor->pathId = computePathfinding(returnVar2, params.X, params.Y, + currentActor->pathId = computePathfinding(moveInfo, params.X, params.Y, aniX, aniY, currentActor->stepX, currentActor->stepY, currentActor->pathId); if (currentActor->pathId == ANIM_WAIT) { @@ -772,7 +772,7 @@ void processAnimation(void) { } else 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(moveInfo, params.X, params.Y, currentActor->x_dest, currentActor->y_dest, currentActor->stepX, currentActor->stepY, currentActor->pathId); currentActor->x_dest = -1; currentActor->y_dest = -1; @@ -809,9 +809,9 @@ void processAnimation(void) { // In-place (on the spot) animationos if ((currentActor->counter == -1) && (currentActor->phase == ANIM_PHASE_STATIC)) { - affiche_chemin(currentActor->pathId, returnVar2); + affiche_chemin(currentActor->pathId, moveInfo); - if (returnVar2[0] == -1) { + if (moveInfo.x == -1) { currentActor->pathId = ANIM_FINISH; currentActor->flag = 0; currentActor->endDirection = -1; @@ -819,10 +819,10 @@ void processAnimation(void) { break; } - currentActor->x = returnVar2[0]; - currentActor->y = returnVar2[1]; - currentActor->nextDirection = returnVar2[2]; - currentActor->poly = returnVar2[4]; + currentActor->x = moveInfo.x; + currentActor->y = moveInfo.y; + currentActor->nextDirection = moveInfo.direction; + currentActor->poly = moveInfo.poly; currentActor->counter = 0; if (currentActor->startDirection == currentActor->nextDirection) @@ -886,9 +886,9 @@ void processAnimation(void) { // Walk animations if (currentActor->counter >= 1) { - affiche_chemin(currentActor->pathId, returnVar2); + affiche_chemin(currentActor->pathId, moveInfo); - if (returnVar2[0] == -1) { + if (moveInfo.x == -1) { if ((currentActor->endDirection == -1) || (currentActor->endDirection == currentActor->nextDirection)) { currentActor->phase = ANIM_PHASE_END; } else { @@ -898,10 +898,10 @@ void processAnimation(void) { currentActor->counter = 0; break; } else { - currentActor->x = returnVar2[0]; - currentActor->y = returnVar2[1]; - currentActor->nextDirection = returnVar2[2]; - currentActor->poly = returnVar2[4]; + currentActor->x = moveInfo.x; + currentActor->y = moveInfo.y; + currentActor->nextDirection = moveInfo.direction; + currentActor->poly = moveInfo.poly; } } diff --git a/engines/cruise/cruise_main.cpp b/engines/cruise/cruise_main.cpp index 010329352e..8f6736a34e 100644 --- a/engines/cruise/cruise_main.cpp +++ b/engines/cruise/cruise_main.cpp @@ -1829,7 +1829,7 @@ void mainLoop(void) { // wait for character to finish auto track if (autoTrack) { - if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, 0)) { + if (isAnimFinished(narratorOvl, narratorIdx, &actorHead, ATP_MOUSE)) { if (autoMsg != -1) { freezeCell(&cellHead, autoOvl, autoMsg, 5, -1, 9998, 0); diff --git a/engines/cruise/perso.cpp b/engines/cruise/perso.cpp index a172bb0cb8..9633a86e0b 100644 --- a/engines/cruise/perso.cpp +++ b/engines/cruise/perso.cpp @@ -168,7 +168,7 @@ int cor_droite(int x1, int y1, int x2, int y2, point* outputTable) { return numOutput; } -void processActorWalk(int16 resx_y[4], int16 *inc_droite, int16 *inc_droite0, +void processActorWalk(MovementEntry &resx_y, int16 *inc_droite, int16 *inc_droite0, int16 *inc_chemin, point* cor_joueur, int16 solution0[NUM_NODES + 3][2], int16 *inc_jo1, int16 *inc_jo2, int16 *dir_perso, int16 *inc_jo0, int16 num) { @@ -190,15 +190,15 @@ void processActorWalk(int16 resx_y[4], int16 *inc_droite, int16 *inc_droite0, x2 = solution0[i][0]; y2 = solution0[i][1]; if ((x1 == x2) && (y1 == y2)) { - resx_y[0] = -1; - resx_y[1] = -1; + resx_y.x = -1; + resx_y.y = -1; freePerso(num); return; } *inc_droite0 = cor_droite(x1, y1, x2, y2, cor_joueur); - *dir_perso = resx_y[2] = direction(x1, y1, x2, y2, *inc_jo1, *inc_jo2); + *dir_perso = resx_y.direction = direction(x1, y1, x2, y2, *inc_jo1, *inc_jo2); *inc_jo0 = inc_jo; u = 1; } else @@ -207,8 +207,8 @@ void processActorWalk(int16 resx_y[4], int16 *inc_droite, int16 *inc_droite0, } while (solution0[i][0] != -1 && !u); } if (!u) { - resx_y[0] = -1; - resx_y[1] = -1; + resx_y.x = -1; + resx_y.y = -1; freePerso(num); return; @@ -216,33 +216,33 @@ void processActorWalk(int16 resx_y[4], int16 *inc_droite, int16 *inc_droite0, *inc_chemin = i; } - resx_y[0] = cor_joueur[*inc_droite].x; - resx_y[1] = cor_joueur[*inc_droite].y; - resx_y[2] = *dir_perso; - resx_y[3] = computeZoom(resx_y[1]); + resx_y.x = cor_joueur[*inc_droite].x; + resx_y.y = cor_joueur[*inc_droite].y; + resx_y.direction = *dir_perso; + resx_y.zoom = computeZoom(resx_y.y); - getPixel(resx_y[0], resx_y[1]); - resx_y[4] = computedVar14; + getPixel(resx_y.x, resx_y.y); + resx_y.poly = computedVar14; - u = subOp23(resx_y[3], inc_jo); + u = subOp23(resx_y.zoom, inc_jo); if (!u) u = 1; *inc_droite += u; if ((*inc_droite) >= (*inc_droite0)) { *inc_droite = 0; - resx_y[0] = solution0[*inc_chemin][0]; - resx_y[1] = solution0[*inc_chemin][1]; + resx_y.x = solution0[*inc_chemin][0]; + resx_y.y = solution0[*inc_chemin][1]; } } -void affiche_chemin(int16 persoIdx, int16 *returnVar) { +void affiche_chemin(int16 persoIdx, MovementEntry &data) { persoStruct *pPerso = persoTable[persoIdx]; ASSERT(pPerso); - processActorWalk(returnVar, &pPerso->inc_droite, &pPerso->inc_droite0, + processActorWalk(data, &pPerso->inc_droite, &pPerso->inc_droite0, &pPerso->inc_chemin, pPerso->coordinates, pPerso->solution, &pPerso->inc_jo1, &pPerso->inc_jo2, &pPerso->dir_perso, &pPerso->inc_jo0, persoIdx); diff --git a/engines/cruise/perso.h b/engines/cruise/perso.h index d1cb9b2f98..a9864f6453 100644 --- a/engines/cruise/perso.h +++ b/engines/cruise/perso.h @@ -50,13 +50,21 @@ struct persoStruct { int16 inc_jo0; // 2 }; +struct MovementEntry { + int16 x; + int16 y; + int16 direction; + int16 zoom; + int16 poly; +}; + extern persoStruct *persoTable[NUM_PERSONS]; extern int16 computedVar14; int cor_droite(int x1, int y1, int x2, int y2, point* outputTable); void freePerso(int persoIdx); void freeCTP(void); -void affiche_chemin(int16 persoIdx, int16 * returnVar); +void affiche_chemin(int16 persoIdx, MovementEntry &data); int direction(int x1, int y1, int x2, int y2, int inc_jo1, int inc_jo2); } // End of namespace Cruise |