OpenTTD Source: src/waypoint.cpp Source File

OpenTTD Source 12.0-beta1

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
27 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
28 {
29 if (!DrawStationTile(x, y, railtype, AXIS_X, STAT_CLASS_WAYP, stat_id)) {
30 StationPickerDrawSprite(x, y, STATION_WAYPOINT, railtype, INVALID_ROADTYPE, AXIS_X);
31 }
32 }
33
34 void Waypoint::GetTileArea(TileArea *ta, StationType type) const
35 {
36 switch (type) {
37 case STATION_WAYPOINT:
38 *ta = this->train_station;
39 return;
40
41 case STATION_BUOY:
42 ta->tile = this->xy;
43 ta->w = 1;
44 ta->h = 1;
45 break;
46
47 default: NOT_REACHED();
48 }
49 }
50
51 Waypoint::~Waypoint()
52 {
53 if (CleaningPool()) return;
54 CloseWindowById(WC_WAYPOINT_VIEW, this->index);
55 RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
56 if (this->sign.kdtree_valid) _viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index));
57 }
newgrf_station.h
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
Pool::PoolItem<&_station_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:235
Waypoint::GetTileArea
void GetTileArea(TileArea *ta, StationType type) const override
Get the tile area for a given station type.
Definition: waypoint.cpp:34
Kdtree::Remove
void Remove(const T &element)
Remove a single element from the tree, if it exists.
Definition: kdtree.hpp:419
StationType
StationType
Station types.
Definition: station_type.h:32
BaseStation::sign
TrackedViewportSign sign
NOSAVE: Dimensions of sign.
Definition: base_station_base.h:54
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:27
STAT_CLASS_WAYP
@ STAT_CLASS_WAYP
Waypoint class.
Definition: newgrf_station.h:86
BaseStation::train_station
TileArea train_station
Tile area the train 'station' part covers.
Definition: base_station_base.h:75
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
safeguards.h
WC_WAYPOINT_VIEW
@ WC_WAYPOINT_VIEW
Waypoint view; Window numbers:
Definition: window_type.h:349
stdafx.h
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
RemoveOrderFromAllVehicles
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination, bool hangar)
Removes an order from all vehicles.
Definition: order_cmd.cpp:1805
Pool::PoolItem<&_station_pool >::CleaningPool
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
Definition: pool_type.hpp:316
waypoint_base.h
TrackedViewportSign::kdtree_valid
bool kdtree_valid
Are the sign data valid for use with the _viewport_sign_kdtree?
Definition: viewport_type.h:58
BaseStation::xy
TileIndex xy
Base tile of the station.
Definition: base_station_base.h:53
window_func.h
CloseWindowById
void CloseWindowById(WindowClass cls, WindowNumber number, bool force)
Close a window by its class and window number (if it is open).
Definition: window.cpp:1176
DrawStationTile
bool DrawStationTile(int x, int y, RailType railtype, Axis axis, StationClassID sclass, uint station)
Draw representation of a station tile for GUI purposes.
Definition: newgrf_station.cpp:780
DrawWaypointSprite
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
Draw a waypoint.
Definition: waypoint.cpp:27
order_func.h
AXIS_X
@ AXIS_X
The X axis.
Definition: direction_type.h:124