Codefix: Documentation comment in IndustryDirectoryWindow (#13059)
[openttd-github.git] / src / waypoint.cpp
blob6ea1691d8dd697faa7a59a812fcc927d84827141
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.cpp Handling of waypoints. */
10 #include "stdafx.h"
12 #include "order_func.h"
13 #include "window_func.h"
14 #include "newgrf_station.h"
15 #include "waypoint_base.h"
16 #include "viewport_kdtree.h"
18 #include "safeguards.h"
20 /**
21 * Draw a waypoint
22 * @param x coordinate
23 * @param y coordinate
24 * @param station_class Station class.
25 * @param station_type Station type within class.
26 * @param railtype RailType to use for
28 void DrawWaypointSprite(int x, int y, StationClassID station_class, uint16_t station_type, RailType railtype)
30 if (!DrawStationTile(x, y, railtype, AXIS_X, station_class, station_type)) {
31 StationPickerDrawSprite(x, y, STATION_WAYPOINT, railtype, INVALID_ROADTYPE, AXIS_X);
35 void Waypoint::GetTileArea(TileArea *ta, StationType type) const
37 switch (type) {
38 case STATION_WAYPOINT:
39 *ta = this->train_station;
40 return;
42 case STATION_ROADWAYPOINT:
43 *ta = this->road_waypoint_area;
44 return;
46 case STATION_BUOY:
47 ta->tile = this->xy;
48 ta->w = 1;
49 ta->h = 1;
50 break;
52 default: NOT_REACHED();
56 Waypoint::~Waypoint()
58 if (CleaningPool()) return;
59 CloseWindowById(WC_WAYPOINT_VIEW, this->index);
60 RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
61 if (this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index));