int removeAnimation(actorStruct * pHead, int overlay, int objIdx, int objType) { actorStruct* pl; actorStruct* pl2; actorStruct* pl3; actorStruct* pl4; int dir = 0; pl = pHead; pl2 = pl; pl = pl2->next; while (pl) { pl2 = pl; if (((pl->overlayNumber == overlay) || (overlay == -1)) && ((pl->idx == objIdx) || (objIdx == -1)) && ((pl->type == objType) || (objType == -1))) { pl->type = -1; } pl = pl2->next; } pl = pHead; pl2 = pl; pl = pl2->next; while (pl) { if (pl->type == -1) { pl4 = pl->next; pl2->next = pl4; pl3 = pl4; if (pl3 == NULL) pl3 = pHead; pl3->prev = pl->prev; dir = pl->startDirection; if (pl->pathId >= 0) freePerso(pl->pathId); MemFree(pl); pl = pl4; } else { pl2 = pl; pl = pl2->next; } } return dir; }
void freeCTP() { for (unsigned long int i = 0; i < NUM_PERSONS; i++) { freePerso(i); } if (_vm->_polyStruct) { _vm->_polyStructNorm.clear(); _vm->_polyStructExp.clear(); _vm->_polyStruct = NULL; } ctpVar17 = NULL; _vm->_polyStruct = NULL; strcpy((char *)currentCtpName, ""); }
/** * Computes a path for an actor to walk between a given source and destination position */ int16 computePathfinding(MovementEntry &moveInfo, int16 x, int16 y, int16 destX, int16 destY, int16 stepX, int16 stepY, int16 oldPathId) { persoStruct *perso; int num; if (!_vm->_polyStruct) { moveInfo.x = -1; moveInfo.y = -1; return -1; } if (oldPathId >= 0) { if (persoTable[oldPathId]) { freePerso(oldPathId); } } if (!flagCt) { int i; int16 *ptr; for (i = 0; i < NUM_PERSONS; i++) { // 10 = num perso if (!persoTable[i]) { break; } } if (i == NUM_PERSONS) { moveInfo.x = -1; moveInfo.y = -1; return -1; } perso = persoTable[i] = (persoStruct *) MemAlloc(sizeof(persoStruct)); ptr = perso->solution[0]; perso->inc_jo1 = stepX; perso->inc_jo2 = stepY; *(ptr++) = x; *(ptr++) = y; *(ptr++) = moveInfo.x = destX; *(ptr++) = moveInfo.y = destY; *(ptr++) = -1; moveInfo.poly = numPoly; perso->inc_droite = 0; perso->inc_chemin = 0; return i; } nclick_noeud = 0; _vm->_polyStructs = &_vm->_polyStructNorm; flag_aff_chemin = 0; if (x == destX && y == destY) { moveInfo.x = -1; moveInfo.y = -1; return (-1); } /******* cherche le premier noeud ******/ getPixel(x, y); moveInfo.poly = numPoly; x_mouse = x; y_mouse = y; if (!flag_obstacle || (point_select = point_proche(ctp_routeCoords)) == -1) { moveInfo.x = -1; moveInfo.y = -1; return (-1); } valide_noeud(select_noeud, point_select, &nclick_noeud, NULL); flag_aff_chemin = 0; /******* cherche le deuxieme noeud ******/ num = 0; while (num < NUM_PERSONS && persoTable[num] != NULL) num++; if (num == NUM_PERSONS) { moveInfo.x = -1; moveInfo.y = -1; return (-1); } perso = persoTable[num] = (persoStruct *) MemAlloc(sizeof(persoStruct)); perso->inc_jo1 = stepX; perso->inc_jo2 = stepY; x_mouse = destX; y_mouse = destY; if ((point_select = point_proche(ctp_routeCoords)) != -1) 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]))) { moveInfo.x = -1; moveInfo.y = -1; freePerso(num); return (-1); } moveInfo.x = table_ptselect[1][0]; moveInfo.y = table_ptselect[1][1]; moveInfo.poly = numPoly; perso->inc_chemin = 0; perso->inc_droite = 0; return (num); }
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) { int u = 0; inc_jo = *inc_jo0; int i = *inc_chemin; if (!*inc_droite) { int x1 = solution0[i][0]; int y1 = solution0[i][1]; i++; if (solution0[i][0] != -1) { do { if (solution0[i][0] != -2) { int x2 = solution0[i][0]; int y2 = solution0[i][1]; if ((x1 == x2) && (y1 == y2)) { 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.direction = direction(x1, y1, x2, y2, *inc_jo1, *inc_jo2); *inc_jo0 = inc_jo; u = 1; } else i++; } while (solution0[i][0] != -1 && !u); } if (!u) { resx_y.x = -1; resx_y.y = -1; freePerso(num); return; } *inc_chemin = i; } 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.x, resx_y.y); resx_y.poly = numPoly; u = subOp23(resx_y.zoom, inc_jo); if (!u) u = 1; *inc_droite += u; if ((*inc_droite) >= (*inc_droite0)) { *inc_droite = 0; resx_y.x = solution0[*inc_chemin][0]; resx_y.y = solution0[*inc_chemin][1]; } }