summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pathfinder/yapf/yapf_costrail.hpp4
-rw-r--r--src/pathfinder/yapf/yapf_destrail.hpp11
-rw-r--r--src/waypoint_base.h9
3 files changed, 22 insertions, 2 deletions
diff --git a/src/pathfinder/yapf/yapf_costrail.hpp b/src/pathfinder/yapf/yapf_costrail.hpp
index 57820af1e..6c4603c68 100644
--- a/src/pathfinder/yapf/yapf_costrail.hpp
+++ b/src/pathfinder/yapf/yapf_costrail.hpp
@@ -410,7 +410,9 @@ no_entry_cost: // jump here at the beginning if the node has no parent (it is th
end_segment_reason |= ESRB_DEPOT;
} else if (cur.tile_type == MP_STATION && IsRailWaypoint(cur.tile)) {
- if (v->current_order.IsType(OT_GOTO_WAYPOINT) && GetStationIndex(cur.tile) == v->current_order.GetDestination()) {
+ if (v->current_order.IsType(OT_GOTO_WAYPOINT) &&
+ GetStationIndex(cur.tile) == v->current_order.GetDestination() &&
+ !Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) {
/* This waypoint is our destination; maybe this isn't an unreserved
* one, so check that and if so see that as the last signal being
* red. This way waypoints near stations should work better. */
diff --git a/src/pathfinder/yapf/yapf_destrail.hpp b/src/pathfinder/yapf/yapf_destrail.hpp
index da360b474..c7594df6c 100644
--- a/src/pathfinder/yapf/yapf_destrail.hpp
+++ b/src/pathfinder/yapf/yapf_destrail.hpp
@@ -135,8 +135,17 @@ public:
void SetDestination(const Train *v)
{
switch (v->current_order.GetType()) {
- case OT_GOTO_STATION:
case OT_GOTO_WAYPOINT:
+ if (!Waypoint::Get(v->current_order.GetDestination())->IsSingleTile()) {
+ /* In case of 'complex' waypoints we need to do a look
+ * ahead. This look ahead messes a bit about, which
+ * means that it 'corrupts' the cache. To prevent this
+ * we disable caching when we're looking for a complex
+ * waypoint. */
+ Yapf().DisableCache(true);
+ }
+ /* FALL THROUGH */
+ case OT_GOTO_STATION:
m_destTile = CalcClosestStationTile(v->current_order.GetDestination(), v->tile, v->current_order.IsType(OT_GOTO_STATION) ? STATION_RAIL : STATION_WAYPOINT);
m_dest_station_id = v->current_order.GetDestination();
m_destTrackdirs = INVALID_TRACKDIR_BIT;
diff --git a/src/waypoint_base.h b/src/waypoint_base.h
index eb8074900..3f8a48db9 100644
--- a/src/waypoint_base.h
+++ b/src/waypoint_base.h
@@ -40,6 +40,15 @@ struct Waypoint : SpecializedStation<Waypoint, true> {
{
return 1;
}
+
+ /**
+ * Is this a single tile waypoint?
+ * @return true if it is.
+ */
+ FORCEINLINE bool IsSingleTile() const
+ {
+ return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
+ }
};
#define FOR_ALL_WAYPOINTS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Waypoint, var)