OpenTTD

waypoint.cpp
Go to the documentation of this file.
1 /* $Id: waypoint.cpp 26482 2014-04-23 20:13:33Z rubidium $ */
2
3 /*
4 * This file is part of OpenTTD.
5 * 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.
6 * 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.
7 * 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/>.
8 */
9
12 #include "stdafx.h"
13
14 #include "order_func.h"
15 #include "window_func.h"
16 #include "newgrf_station.h"
17 #include "waypoint_base.h"
18
19 #include "safeguards.h"
20
28 void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
29 {
30 if (!DrawStationTile(x, y, railtype, AXIS_X, STAT_CLASS_WAYP, stat_id)) {
31 StationPickerDrawSprite(x, y, STATION_WAYPOINT, railtype, INVALID_ROADTYPE, AXIS_X);
32 }
33 }
34
35 void Waypoint::GetTileArea(TileArea *ta, StationType type) const
36 {
37 switch (type) {
38 case STATION_WAYPOINT:
39 *ta = this->train_station;
40 return;
41
42 case STATION_BUOY:
43 ta->tile = this->xy;
44 ta->w = 1;
45 ta->h = 1;
46 break;
47
48 default: NOT_REACHED();
49 }
50 }
51
52 Waypoint::~Waypoint()
53 {
54 if (CleaningPool()) return;
55 DeleteWindowById(WC_WAYPOINT_VIEW, this->index);
56 RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
57 }
RailType
RailType
Enumeration for all possible railtypes.
Definition: rail_type.h:29
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:763
BaseStation::train_station
TileArea train_station
Tile area the train &#39;station&#39; part covers.
Definition: base_station_base.h:76
Pool::PoolItem<&_station_pool >::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:147
order_func.h
Functions related to orders.
INVALID_ROADTYPE
flag for invalid roadtype
Definition: road_type.h:27
OrthogonalTileArea::w
uint16 w
The width of the area.
Definition: tilearea_type.h:20
STAT_CLASS_WAYP
Waypoint class.
Definition: newgrf_station.h:85
WC_WAYPOINT_VIEW
Waypoint view; Window numbers:
Definition: window_type.h:352
RemoveOrderFromAllVehicles
void RemoveOrderFromAllVehicles(OrderType type, DestinationID destination)
Removes an order from all vehicles.
Definition: order_cmd.cpp:1837
stdafx.h
Definition of base types and functions in a cross-platform compatible way.
safeguards.h
A number of safeguards to prevent using unsafe methods.
waypoint_base.h
Base of waypoints.
OrthogonalTileArea
Represents the covered area of e.g.
Definition: tilearea_type.h:18
OrthogonalTileArea::tile
TileIndex tile
The base tile of the area.
Definition: tilearea_type.h:19
AXIS_X
The X axis.
Definition: direction_type.h:128
DeleteWindowById
void DeleteWindowById(WindowClass cls, WindowNumber number, bool force)
Delete a window by its class and window number (if it is open).
Definition: window.cpp:1137
Pool::PoolItem<&_station_pool >::CleaningPool
static bool CleaningPool()
Returns current state of pool cleaning - yes or no.
Definition: pool_type.hpp:225
StationType
StationType
Station types.
Definition: station_type.h:35
newgrf_station.h
Header file for NewGRF stations.
BaseStation::xy
TileIndex xy
Base tile of the station.
Definition: base_station_base.h:55
Waypoint::GetTileArea
void GetTileArea(TileArea *ta, StationType type) const
Get the tile area for a given station type.
Definition: waypoint.cpp:35
window_func.h
Window functions not directly related to making/drawing windows.
DrawWaypointSprite
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
Draw a waypoint.
Definition: waypoint.cpp:28
OrthogonalTileArea::h
uint16 h
The height of the area.
Definition: tilearea_type.h:21