Change ship path cache to be optional and use a ring buffer
This commit is contained in:
@@ -38,9 +38,6 @@ static const int YAPF_TILE_CORNER_LENGTH = 71;
|
||||
*/
|
||||
static const int YAPF_INFINITE_PENALTY = 1000 * YAPF_TILE_LENGTH;
|
||||
|
||||
/** Maximum length of ship path cache */
|
||||
static const int YAPF_SHIP_PATH_CACHE_LENGTH = 32;
|
||||
|
||||
/** Distance from destination road stops to not cache any further */
|
||||
static const int YAPF_ROADVEH_PATH_CACHE_DESTINATION_LIMIT = 8;
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ public:
|
||||
uint steps = 0;
|
||||
for (Node *n = pNode; n->m_parent != nullptr; n = n->m_parent) steps++;
|
||||
uint skip = 0;
|
||||
if (path_found) skip = YAPF_SHIP_PATH_CACHE_LENGTH / 2;
|
||||
if (path_found) skip = SHIP_PATH_CACHE_LENGTH / 2;
|
||||
|
||||
/* walk through the path back to the origin */
|
||||
Node *pPrevNode = nullptr;
|
||||
@@ -181,7 +181,7 @@ public:
|
||||
steps--;
|
||||
/* Skip tiles at end of path near destination. */
|
||||
if (skip > 0) skip--;
|
||||
if (skip == 0 && steps > 0 && steps < YAPF_SHIP_PATH_CACHE_LENGTH) {
|
||||
if (skip == 0 && steps > 0 && steps < SHIP_PATH_CACHE_LENGTH) {
|
||||
path_cache.push_front(pNode->GetTrackdir());
|
||||
}
|
||||
pPrevNode = pNode;
|
||||
|
||||
Reference in New Issue
Block a user