OpenTTD Source 20241224-master-gee860a5c8e
waypoint.cpp
Go to the documentation of this file.
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 */
7
10#include "stdafx.h"
11
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"
17
18#include "safeguards.h"
19
28void DrawWaypointSprite(int x, int y, StationClassID station_class, uint16_t station_type, RailType railtype)
29{
30 if (!DrawStationTile(x, y, railtype, AXIS_X, station_class, station_type)) {
31 StationPickerDrawSprite(x, y, STATION_WAYPOINT, railtype, INVALID_ROADTYPE, AXIS_X);
32 }
33}
34
36{
37 switch (type) {
38 case STATION_WAYPOINT:
39 *ta = this->train_station;
40 return;
41
42 case STATION_ROADWAYPOINT:
43 *ta = this->road_waypoint_area;
44 return;
45
46 case STATION_BUOY:
47 ta->tile = this->xy;
48 ta->w = 1;
49 ta->h = 1;
50 break;
51
52 default: NOT_REACHED();
53 }
54}
55
56Waypoint::~Waypoint()
57{
58 if (CleaningPool()) return;
60 RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
61 if (this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index));
62}
void Remove(const T &element)
Remove a single element from the tree, if it exists.
Definition kdtree.hpp:417
@ AXIS_X
The X axis.
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
Header file for NewGRF stations.
StationClassID
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
Functions related to orders.
RailType
Enumeration for all possible railtypes.
Definition rail_type.h:27
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition road_type.h:30
A number of safeguards to prevent using unsafe methods.
StationType
Station types.
Definition of base types and functions in a cross-platform compatible way.
TileIndex xy
Base tile of the station.
TileArea train_station
Tile area the train 'station' part covers.
TrackedViewportSign sign
NOSAVE: Dimensions of sign.
Represents the covered area of e.g.
uint16_t w
The width of the area.
TileIndex tile
The base tile of the area.
uint16_t h
The height of the area.
Tindex index
Index of this pool item.
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
TileArea road_waypoint_area
Tile area the road waypoint part covers.
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition waypoint.cpp:35
void DrawWaypointSprite(int x, int y, StationClassID station_class, uint16_t station_type, RailType railtype)
Draw a waypoint.
Definition waypoint.cpp:28
Base of waypoints.
void CloseWindowById(WindowClass cls, WindowNumber number, bool force, int data)
Close a window by its class and window number (if it is open).
Definition window.cpp:1140
Window functions not directly related to making/drawing windows.
@ WC_WAYPOINT_VIEW
Waypoint view; Window numbers: