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/>.
|
|
|
|
*/
|
|
|
|
|
2009-07-22 10:18:19 +00:00
|
|
|
/** @file waypoint_base.h Base of waypoints. */
|
2007-04-06 04:10:19 +00:00
|
|
|
|
2010-12-22 11:46:41 +00:00
|
|
|
#ifndef WAYPOINT_BASE_H
|
|
|
|
#define WAYPOINT_BASE_H
|
2005-03-24 17:03:37 +00:00
|
|
|
|
2009-07-22 11:35:35 +00:00
|
|
|
#include "base_station_base.h"
|
2005-03-24 17:03:37 +00:00
|
|
|
|
2022-01-21 23:37:53 +00:00
|
|
|
/**
|
|
|
|
* Enum to handle waypoint flags.
|
|
|
|
*/
|
|
|
|
enum WaypointFlags {
|
|
|
|
WPF_HIDE_LABEL = 0, ///< Hide waypoint label
|
2022-01-25 22:02:32 +00:00
|
|
|
WPF_ROAD = 1, ///< This is a road waypoint
|
2022-01-21 23:37:53 +00:00
|
|
|
};
|
|
|
|
|
2011-05-01 19:14:12 +00:00
|
|
|
/** Representation of a waypoint. */
|
2024-01-31 20:03:17 +00:00
|
|
|
struct Waypoint final : SpecializedStation<Waypoint, true> {
|
2024-01-07 16:41:53 +00:00
|
|
|
uint16_t town_cn; ///< The N-1th waypoint for this town (consecutive number)
|
|
|
|
uint16_t waypoint_flags; ///< Waypoint flags, see WaypointFlags
|
2005-03-24 17:03:37 +00:00
|
|
|
|
2022-01-25 22:02:32 +00:00
|
|
|
TileArea road_waypoint_area; ///< Tile area the road waypoint part covers
|
|
|
|
|
2011-05-01 19:14:12 +00:00
|
|
|
/**
|
|
|
|
* Create a waypoint at the given tile.
|
|
|
|
* @param tile The location of the waypoint.
|
|
|
|
*/
|
2022-01-21 23:37:53 +00:00
|
|
|
Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile), waypoint_flags(0) { }
|
2007-08-02 12:22:40 +00:00
|
|
|
~Waypoint();
|
2009-07-13 22:33:25 +00:00
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
void UpdateVirtCoord() override;
|
2009-07-17 20:21:24 +00:00
|
|
|
|
2019-07-07 17:44:08 +00:00
|
|
|
void MoveSign(TileIndex new_xy) override;
|
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
inline bool TileBelongsToRailStation(TileIndex tile) const override
|
2009-07-17 21:06:06 +00:00
|
|
|
{
|
2009-07-22 08:59:57 +00:00
|
|
|
return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
|
2009-07-17 21:06:06 +00:00
|
|
|
}
|
|
|
|
|
2024-01-07 16:41:53 +00:00
|
|
|
uint32_t GetNewGRFVariable(const struct ResolverObject &object, uint16_t variable, byte parameter, bool *available) const override;
|
2009-07-17 21:06:06 +00:00
|
|
|
|
2019-03-03 22:25:13 +00:00
|
|
|
void GetTileArea(TileArea *ta, StationType type) const override;
|
2009-07-24 15:18:25 +00:00
|
|
|
|
2023-09-16 20:20:53 +00:00
|
|
|
uint GetPlatformLength(TileIndex, DiagDirection) const override
|
2009-07-24 15:18:25 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2023-09-16 20:20:53 +00:00
|
|
|
uint GetPlatformLength(TileIndex) const override
|
2009-07-24 15:18:25 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2010-02-15 23:55:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is this a single tile waypoint?
|
|
|
|
* @return true if it is.
|
|
|
|
*/
|
2011-12-20 17:57:56 +00:00
|
|
|
inline bool IsSingleTile() const
|
2010-02-15 23:55:04 +00:00
|
|
|
{
|
|
|
|
return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
|
|
|
|
}
|
2010-05-12 18:31:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the "type" of waypoint the same as the given waypoint,
|
|
|
|
* i.e. are both a rail waypoint or are both a buoy?
|
|
|
|
* @param wp The waypoint to compare to.
|
|
|
|
* @return true iff their types are equal.
|
|
|
|
*/
|
2011-12-20 17:57:56 +00:00
|
|
|
inline bool IsOfType(const Waypoint *wp) const
|
2010-05-12 18:31:39 +00:00
|
|
|
{
|
|
|
|
return this->string_id == wp->string_id;
|
|
|
|
}
|
2007-08-02 12:22:40 +00:00
|
|
|
};
|
2006-08-22 15:33:35 +00:00
|
|
|
|
2010-12-22 11:46:41 +00:00
|
|
|
#endif /* WAYPOINT_BASE_H */
|