diff --git a/source/simulation2/components/CCmpPathfinder.cpp b/source/simulation2/components/CCmpPathfinder.cpp
index a4097d0..87b0aa9 100644
a
|
b
|
void CCmpPathfinder::ProcessShortRequests(const std::vector<AsyncShortPathReques
|
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
632 | | void CCmpPathfinder::ProcessSameTurnMoves() |
| 632 | |
| 633 | template <class RequestType> void CCmpPathfinder::ProcessSameTurnMoves(std::vector<RequestType> &m_AsyncPathRequests, void (CCmpPathfinder::*ProcessRequests)(const std::vector<RequestType>&)) |
633 | 634 | { |
634 | | if (!m_AsyncLongPathRequests.empty()) |
| 635 | if (!m_AsyncPathRequests.empty()) |
635 | 636 | { |
636 | 637 | // Figure out how many moves we can do this time |
637 | 638 | i32 moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount; |
… |
… |
void CCmpPathfinder::ProcessSameTurnMoves()
|
640 | 641 | return; |
641 | 642 | |
642 | 643 | // Copy the long request elements we are going to process into a new array |
643 | | std::vector<AsyncLongPathRequest> longRequests; |
644 | | if ((i32)m_AsyncLongPathRequests.size() <= moveCount) |
| 644 | std::vector<RequestType> requests; |
| 645 | if ((i32)m_AsyncPathRequests.size() <= moveCount) |
645 | 646 | { |
646 | | m_AsyncLongPathRequests.swap(longRequests); |
647 | | moveCount = (i32)longRequests.size(); |
| 647 | m_AsyncPathRequests.swap(requests); |
| 648 | moveCount = (i32)requests.size(); |
648 | 649 | } |
649 | 650 | else |
650 | 651 | { |
651 | | longRequests.resize(moveCount); |
652 | | copy(m_AsyncLongPathRequests.begin(), m_AsyncLongPathRequests.begin() + moveCount, longRequests.begin()); |
653 | | m_AsyncLongPathRequests.erase(m_AsyncLongPathRequests.begin(), m_AsyncLongPathRequests.begin() + moveCount); |
| 652 | requests.resize(moveCount); |
| 653 | copy(m_AsyncPathRequests.begin(), m_AsyncPathRequests.begin() + moveCount, requests.begin()); |
| 654 | m_AsyncPathRequests.erase(m_AsyncPathRequests.begin(), m_AsyncPathRequests.begin() + moveCount); |
654 | 655 | } |
655 | 656 | |
656 | | ProcessLongRequests(longRequests); |
| 657 | (this->*ProcessRequests)(requests); |
657 | 658 | |
658 | 659 | m_SameTurnMovesCount = (u16)(m_SameTurnMovesCount + moveCount); |
659 | 660 | } |
660 | | |
661 | | if (!m_AsyncShortPathRequests.empty()) |
662 | | { |
663 | | // Figure out how many moves we can do now |
664 | | i32 moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount; |
| 661 | } |
665 | 662 | |
666 | | if (moveCount <= 0) |
667 | | return; |
668 | 663 | |
669 | | // Copy the short request elements we are going to process into a new array |
670 | | std::vector<AsyncShortPathRequest> shortRequests; |
671 | | if ((i32)m_AsyncShortPathRequests.size() <= moveCount) |
672 | | { |
673 | | m_AsyncShortPathRequests.swap(shortRequests); |
674 | | moveCount = (i32)shortRequests.size(); |
675 | | } |
676 | | else |
677 | | { |
678 | | shortRequests.resize(moveCount); |
679 | | copy(m_AsyncShortPathRequests.begin(), m_AsyncShortPathRequests.begin() + moveCount, shortRequests.begin()); |
680 | | m_AsyncShortPathRequests.erase(m_AsyncShortPathRequests.begin(), m_AsyncShortPathRequests.begin() + moveCount); |
681 | | } |
| 664 | void CCmpPathfinder::ProcessSameTurnMoves() |
| 665 | { |
| 666 | ProcessSameTurnMoves(m_AsyncLongPathRequests, &CCmpPathfinder::ProcessLongRequests); |
| 667 | ProcessSameTurnMoves(m_AsyncShortPathRequests, &CCmpPathfinder::ProcessShortRequests); |
| 668 | } |
682 | 669 | |
683 | | ProcessShortRequests(shortRequests); |
684 | 670 | |
685 | | m_SameTurnMovesCount = (u16)(m_SameTurnMovesCount + moveCount); |
686 | | } |
687 | | } |
688 | 671 | |
689 | 672 | ////////////////////////////////////////////////////////// |
690 | 673 | |
diff --git a/source/simulation2/components/CCmpPathfinder_Common.h b/source/simulation2/components/CCmpPathfinder_Common.h
index 9f39729..9555437 100644
a
|
b
|
public:
|
394 | 394 | void ProcessShortRequests(const std::vector<AsyncShortPathRequest>& shortRequests); |
395 | 395 | |
396 | 396 | virtual void ProcessSameTurnMoves(); |
| 397 | template <class RequestType> void ProcessSameTurnMoves(std::vector<RequestType> &m_AsyncPathRequests, void (CCmpPathfinder::*ProcessRequests)(const std::vector<RequestType>&)); |
397 | 398 | |
398 | 399 | /** |
399 | 400 | * Compute the navcell indexes on the grid nearest to a given point |