Posted to tcl by hypnotoad at Mon Dec 08 22:03:15 GMT 2014view raw

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