Fix some daylength issues, possible division by zero in main menu.
[openttd-joker.git] / src / script / api / script_waypoint.hpp
blob455b8bcc9f612693ccd98dd3b031860002910e9b
1 /* $Id: script_waypoint.hpp 23770 2012-01-07 18:37:22Z smatz $ */
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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 */
10 /** @file script_waypoint.hpp Everything to query and build waypoints. */
12 #ifndef SCRIPT_WAYPOINT_HPP
13 #define SCRIPT_WAYPOINT_HPP
15 #include "script_basestation.hpp"
16 #include "script_error.hpp"
17 #include "../../station_type.h"
19 /**
20 * Class that handles all waypoint related functions.
21 * @api ai game
23 class ScriptWaypoint : public ScriptBaseStation {
24 public:
25 /**
26 * All waypoint related error messages.
28 enum ErrorMessages {
29 /** Base for waypoint related errors */
30 ERR_WAYPOINT_BASE = ScriptError::ERR_CAT_WAYPOINT << ScriptError::ERR_CAT_BIT_SIZE,
32 /** The waypoint is build too close to another waypoint */
33 ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT, // [STR_ERROR_TOO_CLOSE_TO_ANOTHER_WAYPOINT]
35 /** The waypoint would join more than one existing waypoint together. */
36 ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS, // [STR_ERROR_WAYPOINT_ADJOINS_MORE_THAN_ONE_EXISTING]
39 /**
40 * Type of waypoints known in the game.
42 enum WaypointType {
43 /* Note: these values represent part of the in-game StationFacility enum */
44 WAYPOINT_RAIL = (int)::FACIL_TRAIN, ///< Rail waypoint
45 WAYPOINT_BUOY = (int)::FACIL_DOCK, ///< Buoy
46 WAYPOINT_ANY = WAYPOINT_RAIL | WAYPOINT_BUOY, ///< All waypoint types
49 /**
50 * Checks whether the given waypoint is valid and owned by you.
51 * @param waypoint_id The waypoint to check.
52 * @return True if and only if the waypoint is valid.
54 static bool IsValidWaypoint(StationID waypoint_id);
56 /**
57 * Get the StationID of a tile.
58 * @param tile The tile to find the StationID of.
59 * @pre ScriptRail::IsRailWaypointTile(tile).
60 * @return StationID of the waypoint.
62 static StationID GetWaypointID(TileIndex tile);
64 /**
65 * Check if any part of the waypoint contains a waypoint of the type waypoint_type
66 * @param waypoint_id The waypoint to look at.
67 * @param waypoint_type The WaypointType to look for.
68 * @return True if the waypoint has a waypoint part of the type waypoint_type.
70 static bool HasWaypointType(StationID waypoint_id, WaypointType waypoint_type);
73 DECLARE_ENUM_AS_BIT_SET(ScriptWaypoint::WaypointType)
75 #endif /* SCRIPT_WAYPOINT_HPP */