diff options
author | peter1138 <peter1138@openttd.org> | 2019-03-11 13:52:47 +0000 |
---|---|---|
committer | Niels Martin Hansen <nielsm@indvikleren.dk> | 2019-06-30 16:46:32 +0200 |
commit | 0db31ae27f391f83f8f2f5272506adaa245c0962 (patch) | |
tree | 5a428fc22f031bbb2eae12337c24936278568e84 /src/pathfinder | |
parent | 31db4f8d5ef61e49e006b39864e38584fc2f485d (diff) | |
download | openttd-0db31ae27f391f83f8f2f5272506adaa245c0962.tar.xz |
Change: Avoid caching end of ship path, to allow penalties to apply.
Diffstat (limited to 'src/pathfinder')
-rw-r--r-- | src/pathfinder/yapf/yapf_ship.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pathfinder/yapf/yapf_ship.cpp b/src/pathfinder/yapf/yapf_ship.cpp index 6e0775505..731ae2f84 100644 --- a/src/pathfinder/yapf/yapf_ship.cpp +++ b/src/pathfinder/yapf/yapf_ship.cpp @@ -174,12 +174,16 @@ public: if (pNode != nullptr) { 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; /* walk through the path back to the origin */ Node *pPrevNode = nullptr; while (pNode->m_parent != nullptr) { steps--; - if (steps > 0 && steps < YAPF_SHIP_PATH_CACHE_LENGTH) { + /* Skip tiles at end of path near destination. */ + if (skip > 0) skip--; + if (skip == 0 && steps > 0 && steps < YAPF_SHIP_PATH_CACHE_LENGTH) { path_cache.push_front(pNode->GetTrackdir()); } pPrevNode = pNode; |