Fix: CmdSetAutoReplace didn't validate group type and engine type match (#9950)
[openttd-github.git] / src / waypoint_base.h
blob2c7cc530f656105c8b0defc92ff0eb09eb535c63
1 /*
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/>.
6 */
8 /** @file waypoint_base.h Base of waypoints. */
10 #ifndef WAYPOINT_BASE_H
11 #define WAYPOINT_BASE_H
13 #include "base_station_base.h"
15 /** Representation of a waypoint. */
16 struct Waypoint FINAL : SpecializedStation<Waypoint, true> {
17 uint16 town_cn; ///< The N-1th waypoint for this town (consecutive number)
19 /**
20 * Create a waypoint at the given tile.
21 * @param tile The location of the waypoint.
23 Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile) { }
24 ~Waypoint();
26 void UpdateVirtCoord() override;
28 void MoveSign(TileIndex new_xy) override;
30 inline bool TileBelongsToRailStation(TileIndex tile) const override
32 return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
35 uint32 GetNewGRFVariable(const struct ResolverObject &object, byte variable, byte parameter, bool *available) const override;
37 void GetTileArea(TileArea *ta, StationType type) const override;
39 uint GetPlatformLength(TileIndex tile, DiagDirection dir) const override
41 return 1;
44 uint GetPlatformLength(TileIndex tile) const override
46 return 1;
49 /**
50 * Is this a single tile waypoint?
51 * @return true if it is.
53 inline bool IsSingleTile() const
55 return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
58 /**
59 * Is the "type" of waypoint the same as the given waypoint,
60 * i.e. are both a rail waypoint or are both a buoy?
61 * @param wp The waypoint to compare to.
62 * @return true iff their types are equal.
64 inline bool IsOfType(const Waypoint *wp) const
66 return this->string_id == wp->string_id;
70 #endif /* WAYPOINT_BASE_H */