|
@@ -457,31 +457,36 @@ protected:
|
|
|
|
|
|
public:
|
|
|
/** Helper for pathfinders - get min/max speed on the m_old_tile/m_old_td */
|
|
|
int GetSpeedLimit(int *pmin_speed = nullptr) const
|
|
|
{
|
|
|
int min_speed = 0;
|
|
|
int max_speed = INT_MAX; // no limit
|
|
|
|
|
|
/* Check for on-bridge speed limit */
|
|
|
if (!IsWaterTT() && IsBridgeTile(m_old_tile)) {
|
|
|
int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed;
|
|
|
if (IsRoadTT()) spd *= 2;
|
|
|
if (max_speed > spd) max_speed = spd;
|
|
|
max_speed = std::min(max_speed, spd);
|
|
|
}
|
|
|
/* Check for speed limit imposed by railtype */
|
|
|
if (IsRailTT()) {
|
|
|
uint16 rail_speed = GetRailTypeInfo(GetRailType(m_old_tile))->max_speed;
|
|
|
if (rail_speed > 0) max_speed = std::min<int>(max_speed, rail_speed);
|
|
|
}
|
|
|
if (IsRoadTT()) {
|
|
|
/* max_speed is already in roadvehicle units, no need to further modify (divide by 2) */
|
|
|
uint16 road_speed = GetRoadTypeInfo(GetRoadType(m_old_tile, GetRoadTramType(RoadVehicle::From(m_veh)->roadtype)))->max_speed;
|
|
|
if (road_speed > 0) max_speed = std::min<int>(max_speed, road_speed);
|
|
|
}
|
|
|
|
|
|
/* if min speed was requested, return it */
|
|
|
if (pmin_speed != nullptr) *pmin_speed = min_speed;
|
|
|
return max_speed;
|
|
|
}
|
|
|
};
|
|
|
|
|
|
typedef CFollowTrackT<TRANSPORT_WATER, Ship, true > CFollowTrackWater;
|
|
|
typedef CFollowTrackT<TRANSPORT_ROAD, RoadVehicle, true > CFollowTrackRoad;
|
|
|
typedef CFollowTrackT<TRANSPORT_RAIL, Train, true > CFollowTrackRail;
|
|
|
|
|
|
typedef CFollowTrackT<TRANSPORT_RAIL, Train, false> CFollowTrackRailNo90;
|