2009-02-19 07:40:08 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
/** @file script_waypoint.hpp Everything to query and build waypoints. */
|
2009-02-19 07:40:08 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#ifndef SCRIPT_WAYPOINT_HPP
|
|
|
|
#define SCRIPT_WAYPOINT_HPP
|
2009-02-19 07:40:08 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#include "script_basestation.hpp"
|
2009-02-19 07:40:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class that handles all waypoint related functions.
|
2011-11-29 23:27:26 +00:00
|
|
|
* @api ai
|
2009-02-19 07:40:08 +00:00
|
|
|
*/
|
2011-11-29 23:15:35 +00:00
|
|
|
class ScriptWaypoint : public ScriptBaseStation {
|
2009-02-19 07:40:08 +00:00
|
|
|
public:
|
2010-01-04 19:42:29 +00:00
|
|
|
/**
|
|
|
|
* Type of waypoints known in the game.
|
|
|
|
*/
|
|
|
|
enum WaypointType {
|
|
|
|
/* Values are important, as they represent the internal state of the game. */
|
2010-08-01 19:36:36 +00:00
|
|
|
WAYPOINT_RAIL = 0x01, ///< Rail waypoint
|
|
|
|
WAYPOINT_BUOY = 0x10, ///< Buoy
|
|
|
|
WAYPOINT_ANY = 0x11, ///< All waypoint types
|
2010-01-04 19:42:29 +00:00
|
|
|
};
|
|
|
|
|
2010-01-02 16:47:32 +00:00
|
|
|
/**
|
|
|
|
* All waypoint related error messages.
|
|
|
|
*/
|
|
|
|
enum ErrorMessages {
|
|
|
|
/** Base for waypoint related errors */
|
2011-11-29 23:15:35 +00:00
|
|
|
ERR_WAYPOINT_BASE = ScriptError::ERR_CAT_WAYPOINT << ScriptError::ERR_CAT_BIT_SIZE,
|
2010-01-02 16:47:32 +00:00
|
|
|
|
|
|
|
/** The waypoint is build too close to another waypoint */
|
|
|
|
ERR_WAYPOINT_TOO_CLOSE_TO_ANOTHER_WAYPOINT, // [STR_ERROR_TOO_CLOSE_TO_ANOTHER_WAYPOINT]
|
|
|
|
|
2010-05-09 18:13:36 +00:00
|
|
|
/** The waypoint would join more than one existing waypoint together. */
|
2010-01-02 16:47:32 +00:00
|
|
|
ERR_WAYPOINT_ADJOINS_MULTIPLE_WAYPOINTS, // [STR_ERROR_WAYPOINT_ADJOINS_MORE_THAN_ONE_EXISTING]
|
|
|
|
};
|
|
|
|
|
2009-02-19 07:40:08 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the given waypoint is valid and owned by you.
|
|
|
|
* @param waypoint_id The waypoint to check.
|
|
|
|
* @return True if and only if the waypoint is valid.
|
|
|
|
*/
|
2009-07-31 22:30:54 +00:00
|
|
|
static bool IsValidWaypoint(StationID waypoint_id);
|
2009-02-19 07:40:08 +00:00
|
|
|
|
|
|
|
/**
|
2009-07-31 22:30:54 +00:00
|
|
|
* Get the StationID of a tile.
|
|
|
|
* @param tile The tile to find the StationID of.
|
2011-11-29 23:15:35 +00:00
|
|
|
* @pre ScriptRail::IsRailWaypointTile(tile).
|
2009-07-31 22:30:54 +00:00
|
|
|
* @return StationID of the waypoint.
|
2009-02-19 07:40:08 +00:00
|
|
|
*/
|
2009-07-31 22:30:54 +00:00
|
|
|
static StationID GetWaypointID(TileIndex tile);
|
2010-01-04 19:42:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if any part of the waypoint contains a waypoint of the type waypoint_type
|
|
|
|
* @param waypoint_id The waypoint to look at.
|
|
|
|
* @param waypoint_type The WaypointType to look for.
|
|
|
|
* @return True if the waypoint has a waypoint part of the type waypoint_type.
|
|
|
|
*/
|
|
|
|
static bool HasWaypointType(StationID waypoint_id, WaypointType waypoint_type);
|
2009-02-19 07:40:08 +00:00
|
|
|
};
|
|
|
|
|
2011-11-29 23:15:35 +00:00
|
|
|
DECLARE_ENUM_AS_BIT_SET(ScriptWaypoint::WaypointType)
|
2010-01-04 19:42:29 +00:00
|
|
|
|
2011-11-29 23:07:38 +00:00
|
|
|
#endif /* SCRIPT_WAYPOINT_HPP */
|