| 506 | |
| 507 | |
| 508 | void MicroPather::GoalReached( PathNode* node, cPosition* start, cPosition* end, MP_VECTOR< cPosition > *_path ) |
| 509 | { |
| 510 | MP_VECTOR< cPosition >& path = *_path; |
| 511 | path.clear(); |
| 512 | |
| 513 | // We have reached the goal. |
| 514 | // How long is the path? Used to allocate the vector which is returned. |
| 515 | int count = 1; |
| 516 | PathNode* it = node; |
| 517 | while( it->parent ) |
| 518 | { |
| 519 | ++count; |
| 520 | it = it->parent; |
| 521 | } |
| 522 | |
| 523 | // Now that the path has a known length, allocate |
| 524 | // and fill the vector that will be returned. |
| 525 | if ( count < 3 ) |
| 526 | { |
| 527 | // Handle the short, special case. |
| 528 | path.resize(2); |
| 529 | path[0] = *start; |
| 530 | path[1] = *end; |
| 531 | } |
| 532 | else |
| 533 | { |
| 534 | path.resize(count); |
| 535 | |
| 536 | path[0] = *start; |
| 537 | path[count-1] = *end; |
| 538 | count-=2; |
| 539 | it = node->parent; |
| 540 | |
| 541 | while ( it->parent ) |
| 542 | { |
| 543 | path[count] = it->state; |
| 544 | it = it->parent; |
| 545 | --count; |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | #ifdef DEBUG_PATH |
| 550 | printf( "Path: " ); |
| 551 | int counter=0; |
| 552 | #endif |
| 553 | for ( unsigned k=0; k<path.size(); ++k ) |
| 554 | { |
| 555 | #ifdef DEBUG_PATH |
| 556 | graph->PrintStateInfo( path[k] ); |
| 557 | printf( " " ); |
| 558 | ++counter; |
| 559 | if ( counter == 8 ) |
| 560 | { |
| 561 | printf( "\n" ); |
| 562 | counter = 0; |
| 563 | } |
| 564 | #endif |
| 565 | } |
nothing calls this directly
no test coverage detected