diff options
author | rubidium <rubidium@openttd.org> | 2007-02-14 16:37:16 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-02-14 16:37:16 +0000 |
commit | 0e8f006dc18e8faff93382fe8044d046c36e86f4 (patch) | |
tree | 1a15ba2c92fafbb76de3d76a96583953c41b088b /src/yapf | |
parent | 39b73119cabcaa793856b441461fd77e37c491ef (diff) | |
download | openttd-0e8f006dc18e8faff93382fe8044d046c36e86f4.tar.xz |
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
Diffstat (limited to 'src/yapf')
-rw-r--r-- | src/yapf/follow_track.hpp | 8 | ||||
-rw-r--r-- | src/yapf/yapf_road.cpp | 9 | ||||
-rw-r--r-- | src/yapf/yapf_settings.h | 1 |
3 files changed, 13 insertions, 5 deletions
diff --git a/src/yapf/follow_track.hpp b/src/yapf/follow_track.hpp index 04ffecf5d..afae9b788 100644 --- a/src/yapf/follow_track.hpp +++ b/src/yapf/follow_track.hpp @@ -121,8 +121,8 @@ protected: /** return true if we can leave m_old_tile in m_exitdir */ FORCEINLINE bool CanExitOldTile() { - // road stop can be left at one direction only - if (IsRoadTT() && IsRoadStopTile(m_old_tile)) { + // road stop can be left at one direction only unless it's a drive-through stop + if (IsRoadTT() && IsStandardRoadStopTile(m_old_tile)) { DiagDirection exitdir = GetRoadStopDir(m_old_tile); if (exitdir != m_exitdir) return false; @@ -140,8 +140,8 @@ protected: /** return true if we can enter m_new_tile from m_exitdir */ FORCEINLINE bool CanEnterNewTile() { - if (IsRoadTT() && IsRoadStopTile(m_new_tile)) { - // road stop can be entered from one direction only + if (IsRoadTT() && IsStandardRoadStopTile(m_new_tile)) { + // road stop can be entered from one direction only unless it's a drive-through stop DiagDirection exitdir = GetRoadStopDir(m_new_tile); if (ReverseDiagDir(exitdir) != m_exitdir) return false; diff --git a/src/yapf/yapf_road.cpp b/src/yapf/yapf_road.cpp index 02b306b31..43d98716d 100644 --- a/src/yapf/yapf_road.cpp +++ b/src/yapf/yapf_road.cpp @@ -51,6 +51,10 @@ protected: if (IsLevelCrossing(tile)) cost += Yapf().PfGetSettings().road_crossing_penalty; break; + case MP_STATION: + if (IsDriveThroughStopTile(tile)) + cost += Yapf().PfGetSettings().road_stop_penalty; + break; default: break; @@ -76,6 +80,10 @@ public: // base tile cost depending on distance between edges segment_cost += Yapf().OneTileCost(tile, trackdir); + const Vehicle* v = Yapf().GetVehicle(); + // we have reached the vehicle's destination - segment should end here to avoid target skipping + if (v->current_order.type == OT_GOTO_STATION && tile == v->dest_tile) break; + // stop if we have just entered the depot if (IsTileDepotType(tile, TRANSPORT_ROAD) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) { // next time we will reverse and leave the depot @@ -103,7 +111,6 @@ public: // add min/max speed penalties int min_speed = 0; int max_speed = F.GetSpeedLimit(&min_speed); - const Vehicle* v = Yapf().GetVehicle(); if (max_speed < v->max_speed) segment_cost += 1 * (v->max_speed - max_speed); if (min_speed > v->max_speed) segment_cost += 10 * (min_speed - v->max_speed); diff --git a/src/yapf/yapf_settings.h b/src/yapf/yapf_settings.h index 193714dd1..f66b4b732 100644 --- a/src/yapf/yapf_settings.h +++ b/src/yapf/yapf_settings.h @@ -39,6 +39,7 @@ YS_DEF_BEGIN YS_DEF(uint32, road_slope_penalty) ///< penalty for up-hill slope YS_DEF(uint32, road_curve_penalty) ///< penalty for curves YS_DEF(uint32, road_crossing_penalty) ///< penalty for level crossing + YS_DEF(uint32, road_stop_penalty) ///< penalty for going through a drive-through road stop YS_DEF(bool , rail_firstred_twoway_eol) ///< treat first red two-way signal as dead end YS_DEF(uint32, rail_firstred_penalty) ///< penalty for first red signal YS_DEF(uint32, rail_firstred_exit_penalty) ///< penalty for first red exit signal |