Changeset - r23763:b6c9aeb13a51
[Not reviewed]
master
0 1 0
peter1138 - 5 years ago 2019-03-11 13:52:47
peter1138@openttd.org
Change: Avoid caching end of ship path, to allow penalties to apply.
1 file changed with 5 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/pathfinder/yapf/yapf_ship.cpp
Show inline comments
 
@@ -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;
0 comments (0 inline, 0 general)