2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file script_rail.hpp Everything to query and build rails. */
10 #ifndef SCRIPT_RAIL_HPP
11 #define SCRIPT_RAIL_HPP
13 #include "script_tile.hpp"
14 #include "../../signal_type.h"
15 #include "../../track_type.h"
18 * Class that handles all rail related functions.
21 class ScriptRail
: public ScriptObject
{
24 * All rail related error messages.
26 * @see ScriptErrorType
29 /** Base for rail building / maintaining errors */
30 ERR_RAIL_BASE
= ScriptError::ERR_CAT_RAIL
<< ScriptError::ERR_CAT_BIT_SIZE
,
32 /** One-way roads cannot have crossings */
33 ERR_CROSSING_ON_ONEWAY_ROAD
, // [STR_ERROR_CROSSING_ON_ONEWAY_ROAD]
35 /** No suitable track could be found */
36 ERR_UNSUITABLE_TRACK
, // [STR_ERROR_NO_SUITABLE_RAILROAD_TRACK, STR_ERROR_THERE_IS_NO_RAILROAD_TRACK, STR_ERROR_THERE_ARE_NO_SIGNALS, STR_ERROR_THERE_IS_NO_STATION]
38 /** This railtype cannot have crossings */
39 ERR_RAILTYPE_DISALLOWS_CROSSING
, // [STR_ERROR_CROSSING_DISALLOWED_RAIL]
43 * Types of rail known to the game.
45 enum RailType
: uint8_t {
46 /* Note: these values represent part of the in-game static values */
47 RAILTYPE_INVALID
= ::INVALID_RAILTYPE
, ///< Invalid RailType.
51 * A bitmap with all possible rail tracks on a tile.
54 /* Note: these values represent part of the in-game TrackBits enum */
55 RAILTRACK_NE_SW
= ::TRACK_BIT_X
, ///< Track along the x-axis (north-east to south-west).
56 RAILTRACK_NW_SE
= ::TRACK_BIT_Y
, ///< Track along the y-axis (north-west to south-east).
57 RAILTRACK_NW_NE
= ::TRACK_BIT_UPPER
, ///< Track in the upper corner of the tile (north).
58 RAILTRACK_SW_SE
= ::TRACK_BIT_LOWER
, ///< Track in the lower corner of the tile (south).
59 RAILTRACK_NW_SW
= ::TRACK_BIT_LEFT
, ///< Track in the left corner of the tile (west).
60 RAILTRACK_NE_SE
= ::TRACK_BIT_RIGHT
, ///< Track in the right corner of the tile (east).
61 RAILTRACK_INVALID
= ::INVALID_TRACK_BIT
, ///< Flag for an invalid track.
65 * Types of signal known to the game.
68 /* Note: these values represent part of the in-game SignalType enum */
69 SIGNALTYPE_NORMAL
= ::SIGTYPE_BLOCK
, ///< Block signal.
70 SIGNALTYPE_ENTRY
= ::SIGTYPE_ENTRY
, ///< Entry presignal.
71 SIGNALTYPE_EXIT
= ::SIGTYPE_EXIT
, ///< Exit signal.
72 SIGNALTYPE_COMBO
= ::SIGTYPE_COMBO
, ///< Combo signal.
73 SIGNALTYPE_PBS
= ::SIGTYPE_PBS
, ///< Normal PBS signal.
74 SIGNALTYPE_PBS_ONEWAY
= ::SIGTYPE_PBS_ONEWAY
, ///< No-entry PBS signal.
76 SIGNALTYPE_TWOWAY
= 8, ///< Bit mask for twoway signal.
77 SIGNALTYPE_NORMAL_TWOWAY
= SIGNALTYPE_NORMAL
| SIGNALTYPE_TWOWAY
, ///< Normal twoway signal.
78 SIGNALTYPE_ENTRY_TWOWAY
= SIGNALTYPE_ENTRY
| SIGNALTYPE_TWOWAY
, ///< Entry twoway signal.
79 SIGNALTYPE_EXIT_TWOWAY
= SIGNALTYPE_EXIT
| SIGNALTYPE_TWOWAY
, ///< Exit twoway signal.
80 SIGNALTYPE_COMBO_TWOWAY
= SIGNALTYPE_COMBO
| SIGNALTYPE_TWOWAY
, ///< Combo twoway signal.
82 SIGNALTYPE_NONE
= 0xFF, ///< No signal.
86 * Types of rail-related objects in the game.
89 BT_TRACK
, ///< Build a track
90 BT_SIGNAL
, ///< Build a signal
91 BT_DEPOT
, ///< Build a depot
92 BT_STATION
, ///< Build a station
93 BT_WAYPOINT
, ///< Build a rail waypoint
97 * Get the name of a rail type.
98 * @param rail_type The rail type to get the name of.
99 * @pre IsRailTypeAvailable(rail_type).
100 * @return The name the rail type has.
101 * @note Since there is no string with only the name of the track, the text which
102 * is shown in the dropdown where you can chose a track type is returned. This
103 * means that the name could be something like "Maglev construction" instead
106 static std::optional
<std::string
> GetName(RailType rail_type
);
109 * Checks whether the given tile is actually a tile with rail that can be
110 * used to traverse a tile. This excludes rail depots but includes
111 * stations and waypoints.
112 * @param tile The tile to check.
113 * @pre ScriptMap::IsValidTile(tile).
114 * @return True if and only if the tile has rail.
116 static bool IsRailTile(TileIndex tile
);
119 * Checks whether there is a road / rail crossing on a tile.
120 * @param tile The tile to check.
121 * @return True if and only if there is a road / rail crossing.
123 static bool IsLevelCrossingTile(TileIndex tile
);
126 * Checks whether the given tile is actually a tile with a rail depot.
127 * @param tile The tile to check.
128 * @pre ScriptMap::IsValidTile(tile).
129 * @return True if and only if the tile has a rail depot.
131 static bool IsRailDepotTile(TileIndex tile
);
134 * Checks whether the given tile is actually a tile with a rail station.
135 * @param tile The tile to check.
136 * @pre ScriptMap::IsValidTile(tile).
137 * @return True if and only if the tile has a rail station.
139 static bool IsRailStationTile(TileIndex tile
);
142 * Checks whether the given tile is actually a tile with a rail waypoint.
143 * @param tile The tile to check.
144 * @pre ScriptMap::IsValidTile(tile).
145 * @return True if and only if the tile has a rail waypoint.
147 static bool IsRailWaypointTile(TileIndex tile
);
150 * Check if a given RailType is available.
151 * @param rail_type The RailType to check for.
152 * @return True if this RailType can be used.
154 static bool IsRailTypeAvailable(RailType rail_type
);
157 * Get the current RailType set for all ScriptRail functions.
158 * @return The RailType currently set.
160 static RailType
GetCurrentRailType();
163 * Set the RailType for all further ScriptRail functions.
164 * @param rail_type The RailType to set.
166 static void SetCurrentRailType(RailType rail_type
);
169 * Check if a train build for a rail type can run on another rail type.
170 * @param engine_rail_type The rail type the train is build for.
171 * @param track_rail_type The type you want to check.
172 * @pre ScriptRail::IsRailTypeAvailable(engine_rail_type).
173 * @pre ScriptRail::IsRailTypeAvailable(track_rail_type).
174 * @return Whether a train build for 'engine_rail_type' can run on 'track_rail_type'.
175 * @note Even if a train can run on a RailType that doesn't mean that it'll be
176 * able to power the train. Use TrainHasPowerOnRail for that.
178 static bool TrainCanRunOnRail(ScriptRail::RailType engine_rail_type
, ScriptRail::RailType track_rail_type
);
181 * Check if a train build for a rail type has power on another rail type.
182 * @param engine_rail_type The rail type the train is build for.
183 * @param track_rail_type The type you want to check.
184 * @pre ScriptRail::IsRailTypeAvailable(engine_rail_type).
185 * @pre ScriptRail::IsRailTypeAvailable(track_rail_type).
186 * @return Whether a train build for 'engine_rail_type' has power on 'track_rail_type'.
188 static bool TrainHasPowerOnRail(ScriptRail::RailType engine_rail_type
, ScriptRail::RailType track_rail_type
);
191 * Get the RailType that is used on a tile.
192 * @param tile The tile to check.
193 * @pre ScriptTile::HasTransportType(tile, ScriptTile.TRANSPORT_RAIL).
194 * @return The RailType that is used on a tile.
196 static RailType
GetRailType(TileIndex tile
);
199 * Convert the tracks on all tiles within a rectangle to another RailType.
200 * @param start_tile One corner of the rectangle.
201 * @param end_tile The opposite corner of the rectangle.
202 * @param convert_to The RailType you want to convert the rails to.
203 * @pre ScriptMap::IsValidTile(start_tile).
204 * @pre ScriptMap::IsValidTile(end_tile).
205 * @pre IsRailTypeAvailable(convert_to).
206 * @game @pre ScriptCompanyMode::IsValid().
207 * @exception ScriptRail::ERR_UNSUITABLE_TRACK
208 * @return Whether at least some rail has been converted successfully.
210 static bool ConvertRailType(TileIndex start_tile
, TileIndex end_tile
, ScriptRail::RailType convert_to
);
213 * Gets the tile in front of a rail depot.
214 * @param depot The rail depot tile.
215 * @pre IsRailDepotTile(depot).
216 * @return The tile in front of the depot.
218 static TileIndex
GetRailDepotFrontTile(TileIndex depot
);
221 * Gets the direction of a rail station tile.
222 * @param tile The rail station tile.
223 * @pre IsRailStationTile(tile).
224 * @return The direction of the station (either RAILTRACK_NE_SW or RAILTRACK_NW_SE).
226 static RailTrack
GetRailStationDirection(TileIndex tile
);
229 * Builds a rail depot.
230 * @param tile Place to build the depot.
231 * @param front The tile exactly in front of the depot.
232 * @pre ScriptMap::IsValidTile(tile).
233 * @pre ScriptMap::IsValidTile(front).
234 * @pre 'tile' is not equal to 'front', but in a straight line of it.
235 * @pre IsRailTypeAvailable(GetCurrentRailType()).
236 * @game @pre ScriptCompanyMode::IsValid().
237 * @exception ScriptError::ERR_FLAT_LAND_REQUIRED
238 * @exception ScriptError::ERR_AREA_NOT_CLEAR
239 * @return Whether the rail depot has been/can be build or not.
241 static bool BuildRailDepot(TileIndex tile
, TileIndex front
);
244 * Build a rail station.
245 * @param tile Place to build the station.
246 * @param direction The direction to build the station.
247 * @param num_platforms The number of platforms to build.
248 * @param platform_length The length of each platform.
249 * @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
250 * @pre IsRailTypeAvailable(GetCurrentRailType()).
251 * @pre ScriptMap::IsValidTile(tile).
252 * @pre direction == RAILTRACK_NW_SE || direction == RAILTRACK_NE_SW.
253 * @pre num_platforms > 0 && num_platforms <= 255.
254 * @pre platform_length > 0 && platform_length <= 255.
255 * @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
256 * @game @pre ScriptCompanyMode::IsValid().
257 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
258 * @exception ScriptError::ERR_AREA_NOT_CLEAR
259 * @exception ScriptError::ERR_FLAT_LAND_REQUIRED
260 * @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
261 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
262 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN
263 * @return Whether the station has been/can be build or not.
265 static bool BuildRailStation(TileIndex tile
, RailTrack direction
, SQInteger num_platforms
, SQInteger platform_length
, StationID station_id
);
268 * Build a NewGRF rail station. This calls callback 18 to let a NewGRF
269 * provide the station class / id to build, so we don't end up with
270 * only the default stations on the map.
271 * When no NewGRF provides a rail station, or an unbuildable rail station is
272 * returned by a NewGRF, this function will fall back to building a default
273 * non-NewGRF station as if ScriptRail::BuildRailStation was called.
274 * @param tile Place to build the station.
275 * @param direction The direction to build the station.
276 * @param num_platforms The number of platforms to build.
277 * @param platform_length The length of each platform.
278 * @param station_id The station to join, ScriptStation::STATION_NEW or ScriptStation::STATION_JOIN_ADJACENT.
279 * @param cargo_id The CargoID of the cargo that will be transported from / to this station.
280 * @param source_industry The IndustryType of the industry you'll transport goods from, ScriptIndustryType::INDUSTRYTYPE_UNKNOWN or ScriptIndustryType::INDUSTRYTYPE_TOWN.
281 * @param goal_industry The IndustryType of the industry you'll transport goods to, ScriptIndustryType::INDUSTRYTYPE_UNKNOWN or ScriptIndustryType::INDUSTRYTYPE_TOWN.
282 * @param distance The manhattan distance you'll transport the cargo over.
283 * @param source_station True if this is the source station, false otherwise.
284 * @pre IsRailTypeAvailable(GetCurrentRailType()).
285 * @pre ScriptMap::IsValidTile(tile).
286 * @pre direction == RAILTRACK_NW_SE || direction == RAILTRACK_NE_SW.
287 * @pre num_platforms > 0 && num_platforms <= 255.
288 * @pre platform_length > 0 && platform_length <= 255.
289 * @pre station_id == ScriptStation::STATION_NEW || station_id == ScriptStation::STATION_JOIN_ADJACENT || ScriptStation::IsValidStation(station_id).
290 * @pre ScriptCargo::IsValidCargo(cargo_type)
291 * @pre source_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(source_industry).
292 * @pre goal_industry == ScriptIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == ScriptIndustryType::INDUSTRYTYPE_TOWN || ScriptIndustryType::IsValidIndustryType(goal_industry).
293 * @game @pre ScriptCompanyMode::IsValid().
294 * @exception ScriptError::ERR_OWNED_BY_ANOTHER_COMPANY
295 * @exception ScriptError::ERR_AREA_NOT_CLEAR
296 * @exception ScriptError::ERR_FLAT_LAND_REQUIRED
297 * @exception ScriptStation::ERR_STATION_TOO_CLOSE_TO_ANOTHER_STATION
298 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS
299 * @exception ScriptStation::ERR_STATION_TOO_MANY_STATIONS_IN_TOWN
300 * @return Whether the station has been/can be build or not.
302 static bool BuildNewGRFRailStation(TileIndex tile
, RailTrack direction
, SQInteger num_platforms
, SQInteger platform_length
, StationID station_id
, CargoID cargo_id
, IndustryType source_industry
, IndustryType goal_industry
, SQInteger distance
, bool source_station
);
305 * Build a rail waypoint.
306 * @param tile Place to build the waypoint.
307 * @pre ScriptMap::IsValidTile(tile).
308 * @pre IsRailTile(tile).
309 * @pre GetRailTracks(tile) == RAILTRACK_NE_SW || GetRailTracks(tile) == RAILTRACK_NW_SE.
310 * @pre IsRailTypeAvailable(GetCurrentRailType()).
311 * @game @pre ScriptCompanyMode::IsValid().
312 * @exception ScriptError::ERR_FLAT_LAND_REQUIRED
313 * @return Whether the rail waypoint has been/can be build or not.
315 static bool BuildRailWaypoint(TileIndex tile
);
318 * Remove all rail waypoint pieces within a rectangle on the map.
319 * @param tile One corner of the rectangle to clear.
320 * @param tile2 The opposite corner.
321 * @param keep_rail Whether to keep the rail after removal.
322 * @pre IsValidTile(tile).
323 * @pre IsValidTile(tile2).
324 * @game @pre ScriptCompanyMode::IsValid().
325 * @exception ScriptRail::ERR_UNSUITABLE_TRACK
326 * @return Whether at least one tile has been/can be cleared or not.
328 static bool RemoveRailWaypointTileRectangle(TileIndex tile
, TileIndex tile2
, bool keep_rail
);
331 * Remove all rail station platform pieces within a rectangle on the map.
332 * @param tile One corner of the rectangle to clear.
333 * @param tile2 The opposite corner.
334 * @param keep_rail Whether to keep the rail after removal.
335 * @pre IsValidTile(tile).
336 * @pre IsValidTile(tile2).
337 * @game @pre ScriptCompanyMode::IsValid().
338 * @exception ScriptRail::ERR_UNSUITABLE_TRACK
339 * @return Whether at least one tile has been/can be cleared or not.
341 static bool RemoveRailStationTileRectangle(TileIndex tile
, TileIndex tile2
, bool keep_rail
);
344 * Get all RailTracks on the given tile.
345 * @note A depot has no railtracks.
346 * @param tile The tile to check.
347 * @pre IsRailTile(tile).
348 * @return A bitmask of RailTrack with all RailTracks on the tile.
350 static uint
GetRailTracks(TileIndex tile
);
353 * Build rail on the given tile.
354 * @param tile The tile to build on.
355 * @param rail_track The RailTrack to build.
356 * @pre ScriptMap::IsValidTile(tile).
357 * @pre IsRailTypeAvailable(GetCurrentRailType()).
358 * @game @pre ScriptCompanyMode::IsValid().
359 * @exception ScriptError::ERR_AREA_NOT_CLEAR
360 * @exception ScriptError::ERR_LAND_SLOPED_WRONG
361 * @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
362 * @exception ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD
363 * @exception ScriptError::ERR_ALREADY_BUILT
364 * @return Whether the rail has been/can be build or not.
365 * @note You can only build a single track with this function so do not
366 * use the values from RailTrack as bitmask.
368 static bool BuildRailTrack(TileIndex tile
, RailTrack rail_track
);
371 * Remove rail on the given tile.
372 * @param tile The tile to remove rail from.
373 * @param rail_track The RailTrack to remove.
374 * @pre ScriptMap::IsValidTile(tile).
375 * @pre (GetRailTracks(tile) & rail_track) != 0.
376 * @game @pre ScriptCompanyMode::IsValid().
377 * @exception ScriptRail::ERR_UNSUITABLE_TRACK
378 * @return Whether the rail has been/can be removed or not.
379 * @note You can only remove a single track with this function so do not
380 * use the values from RailTrack as bitmask.
382 static bool RemoveRailTrack(TileIndex tile
, RailTrack rail_track
);
385 * Check if a tile connects two adjacent tiles.
386 * @param from The first tile to connect.
387 * @param tile The tile that is checked.
388 * @param to The second tile to connect.
390 * @pre ScriptMap::DistanceManhattan(from, tile) == 1.
391 * @pre ScriptMap::DistanceManhattan(to, tile) == 1.
392 * @return True if 'tile' connects 'from' and 'to'.
394 static bool AreTilesConnected(TileIndex from
, TileIndex tile
, TileIndex to
);
397 * Build a rail connection between two tiles.
398 * @param from The tile just before the tile to build on.
399 * @param tile The first tile to build on.
400 * @param to The tile just after the last tile to build on.
402 * @pre ScriptMap::DistanceManhattan(from, tile) == 1.
403 * @pre ScriptMap::DistanceManhattan(to, tile) >= 1.
404 * @pre (abs(abs(ScriptMap::GetTileX(to) - ScriptMap::GetTileX(tile)) -
405 * abs(ScriptMap::GetTileY(to) - ScriptMap::GetTileY(tile))) <= 1) ||
406 * (ScriptMap::GetTileX(from) == ScriptMap::GetTileX(tile) && ScriptMap::GetTileX(tile) == ScriptMap::GetTileX(to)) ||
407 * (ScriptMap::GetTileY(from) == ScriptMap::GetTileY(tile) && ScriptMap::GetTileY(tile) == ScriptMap::GetTileY(to)).
408 * @pre IsRailTypeAvailable(GetCurrentRailType()).
409 * @game @pre ScriptCompanyMode::IsValid().
410 * @exception ScriptError::ERR_AREA_NOT_CLEAR
411 * @exception ScriptError::ERR_LAND_SLOPED_WRONG
412 * @exception ScriptRail::ERR_CROSSING_ON_ONEWAY_ROAD
413 * @exception ScriptRoad::ERR_ROAD_WORKS_IN_PROGRESS
414 * @exception ScriptError::ERR_ALREADY_BUILT
415 * @note Construction will fail if an obstacle is found between the start and end tiles.
416 * @return Whether the rail has been/can be build or not.
418 static bool BuildRail(TileIndex from
, TileIndex tile
, TileIndex to
);
421 * Remove a rail connection between two tiles.
422 * @param from The tile just before the tile to remove rail from.
423 * @param tile The first tile to remove rail from.
424 * @param to The tile just after the last tile to remove rail from.
426 * @pre ScriptMap::DistanceManhattan(from, tile) == 1.
427 * @pre ScriptMap::DistanceManhattan(to, tile) >= 1.
428 * @pre (abs(abs(ScriptMap::GetTileX(to) - ScriptMap::GetTileX(tile)) -
429 * abs(ScriptMap::GetTileY(to) - ScriptMap::GetTileY(tile))) <= 1) ||
430 * (ScriptMap::GetTileX(from) == ScriptMap::GetTileX(tile) && ScriptMap::GetTileX(tile) == ScriptMap::GetTileX(to)) ||
431 * (ScriptMap::GetTileY(from) == ScriptMap::GetTileY(tile) && ScriptMap::GetTileY(tile) == ScriptMap::GetTileY(to)).
432 * @game @pre ScriptCompanyMode::IsValid().
433 * @exception ScriptRail::ERR_UNSUITABLE_TRACK
434 * @return Whether the rail has been/can be removed or not.
436 static bool RemoveRail(TileIndex from
, TileIndex tile
, TileIndex to
);
439 * Get the SignalType of the signal on a tile or SIGNALTYPE_NONE if there is no signal.
440 * @pre ScriptMap::DistanceManhattan(tile, front) == 1.
441 * @param tile The tile that might have a signal.
442 * @param front The tile in front of 'tile'.
443 * @return The SignalType of the signal on 'tile' facing to 'front'.
445 static SignalType
GetSignalType(TileIndex tile
, TileIndex front
);
448 * Build a signal on a tile.
449 * @param tile The tile to build on.
450 * @param front The tile in front of the signal.
451 * @param signal The SignalType to build.
452 * @pre ScriptMap::DistanceManhattan(tile, front) == 1.
453 * @pre IsRailTile(tile) && !IsRailStationTile(tile) && !IsRailWaypointTile(tile).
454 * @game @pre ScriptCompanyMode::IsValid().
455 * @exception ScriptRail::ERR_UNSUITABLE_TRACK
456 * @return Whether the signal has been/can be build or not.
458 static bool BuildSignal(TileIndex tile
, TileIndex front
, SignalType signal
);
462 * @param tile The tile to remove the signal from.
463 * @param front The tile in front of the signal.
464 * @pre ScriptMap::DistanceManhattan(tile, front) == 1.
465 * @pre GetSignalType(tile, front) != SIGNALTYPE_NONE.
466 * @game @pre ScriptCompanyMode::IsValid().
467 * @exception ScriptRail::ERR_UNSUITABLE_TRACK
468 * @return Whether the signal has been/can be removed or not.
470 static bool RemoveSignal(TileIndex tile
, TileIndex front
);
473 * Get the baseprice of building a rail-related object.
474 * @param railtype the railtype that is build (on)
475 * @param build_type the type of object to build
476 * @pre IsRailTypeAvailable(railtype)
477 * @return The baseprice of building the given object.
479 static Money
GetBuildCost(RailType railtype
, BuildType build_type
);
482 * Get the maximum speed of trains running on this railtype.
483 * @param railtype The railtype to get the maximum speed of.
484 * @pre IsRailTypeAvailable(railtype)
485 * @return The maximum speed trains can run on this railtype
486 * or 0 if there is no limit.
487 * @note The speed is in OpenTTD's internal speed unit.
488 * This is mph / 1.6, which is roughly km/h.
489 * To get km/h multiply this number by 1.00584.
491 static SQInteger
GetMaxSpeed(RailType railtype
);
494 * Get the maintenance cost factor of a railtype.
495 * @param railtype The railtype to get the maintenance factor of.
496 * @pre IsRailTypeAvailable(railtype)
497 * @return Maintenance cost factor of the railtype.
499 static SQInteger
GetMaintenanceCostFactor(RailType railtype
);
502 #endif /* SCRIPT_RAIL_HPP */