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_basestation.hpp Base for stations/waypoint handling. */
10 #ifndef SCRIPT_BASESTATION_HPP
11 #define SCRIPT_BASESTATION_HPP
13 #include "script_text.hpp"
14 #include "script_date.hpp"
17 * Base class for stations and waypoints.
20 class ScriptBaseStation
: public ScriptObject
{
23 * Special station IDs for building adjacent/new stations when
24 * the adjacent/distant join features are enabled.
26 enum SpecialStationIDs
{
27 STATION_NEW
= 0xFFFD, ///< Build a new station
28 STATION_JOIN_ADJACENT
= 0xFFFE, ///< Join an neighbouring station if one exists
29 STATION_INVALID
= 0xFFFF, ///< Invalid station id.
33 * Checks whether the given basestation is valid and owned by you.
34 * @param station_id The station to check.
35 * @return True if and only if the basestation is valid.
36 * @note IsValidBaseStation == (IsValidStation || IsValidWaypoint).
38 static bool IsValidBaseStation(StationID station_id
);
41 * Get the name of a basestation.
42 * @param station_id The basestation to get the name of.
43 * @pre IsValidBaseStation(station_id).
44 * @return The name of the station.
46 static std::optional
<std::string
> GetName(StationID station_id
);
49 * Set the name this basestation.
50 * @param station_id The basestation to set the name of.
51 * @param name The new name of the station (can be either a raw string, or a ScriptText object).
52 * @pre IsValidBaseStation(station_id).
53 * @pre name != null && len(name) != 0.
54 * @game @pre ScriptCompanyMode::IsValid().
55 * @exception ScriptError::ERR_NAME_IS_NOT_UNIQUE
56 * @return True if the name was changed.
58 static bool SetName(StationID station_id
, Text
*name
);
61 * Get the current location of a basestation.
62 * @param station_id The basestation to get the location of.
63 * @pre IsValidBaseStation(station_id).
64 * @return The tile the basestation sign above it.
65 * @note The tile is not necessarily a station tile (and if it is, it could also belong to another station).
66 * @see ScriptTileList_StationType.
68 static TileIndex
GetLocation(StationID station_id
);
71 * Get the last calendar-date a station part was added to this station.
72 * @param station_id The station to look at.
73 * @return The last calendar-date some part of this station was build.
74 * @see \ref ScriptCalendarTime
76 static ScriptDate::Date
GetConstructionDate(StationID station_id
);
79 #endif /* SCRIPT_BASESTATION_HPP */