Posted to tcl by hypnotoad at Mon Dec 08 22:41:47 GMT 2014view raw

  1. /*
  2. ** The step counter has just changed. Initialize the Crew structure
  3. ** accordingly.
  4. **
  5. ** pCrew has finished with its current path step. Advance it to the
  6. ** next step. Or if it has reached its final destination, halt it.
  7. */
  8. static inline void gotoNextStep(Crew *pCrew){
  9. Waypoint *pW, *pWPrev=NULL;
  10. int i;
  11. pCrew->iStep++;
  12. if( pCrew->iStep>=pCrew->nStep ){
  13. Crew_Halt(pCrew,CREW_OPERATION_ARRIVED);
  14. return;
  15. }
  16.  
  17. /* Waypoint we are approaching */
  18. pW = &pCrew->aStep[pCrew->iStep];
  19. if( pCrew->iStep>0 ){
  20. /* Waypoint we are leaving */
  21. pWPrev = &pCrew->aStep[pCrew->iStep-1];
  22. pCrew->public_compartment = pWPrev->cid;
  23. }
  24. if(pW->cid != pCrew->public_compartment) {
  25. pCrew->public_compartment_entering = pW->cid;
  26. } else {
  27. pCrew->public_compartment_entering = 0;
  28. }
  29. insertIntoCidList(pCrew);
  30.  
  31. pCrew->nextPid = 0;
  32.  
  33. pCrew->public_operation = CREW_OPERATION_MOVE;
  34. pCrew->fx = pCrew->tx;
  35. pCrew->tx = pW->x;
  36. pCrew->fy = pCrew->ty;
  37. pCrew->ty = pW->y;
  38.  
  39. /* Calculate our next portal */
  40. for(i=pCrew->iStep;i<pCrew->nStep;i++) {
  41. Waypoint *pWNext=&pCrew->aStep[i];
  42. if(pWNext->pid) {
  43. pCrew->nextPid=pWNext->pid;
  44. }
  45. }
  46. }
  47.