2005-07-24 14:12:37 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file waypoint.cpp Handling of waypoints. */
|
2007-04-06 04:10:19 +00:00
|
|
|
|
2005-03-24 17:03:37 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
2009-07-22 10:18:19 +00:00
|
|
|
#include "order_func.h"
|
2007-12-25 11:26:07 +00:00
|
|
|
#include "window_func.h"
|
2008-03-31 06:42:26 +00:00
|
|
|
#include "newgrf_station.h"
|
2009-07-22 10:18:19 +00:00
|
|
|
#include "waypoint_base.h"
|
2019-02-22 16:57:28 +00:00
|
|
|
#include "viewport_kdtree.h"
|
2015-07-24 00:21:31 +00:00
|
|
|
#include "tracerestrict.h"
|
2005-03-24 17:03:37 +00:00
|
|
|
|
2014-04-23 20:13:33 +00:00
|
|
|
#include "safeguards.h"
|
|
|
|
|
2007-04-06 04:10:19 +00:00
|
|
|
/**
|
|
|
|
* Draw a waypoint
|
|
|
|
* @param x coordinate
|
|
|
|
* @param y coordinate
|
|
|
|
* @param stat_id station id
|
|
|
|
* @param railtype RailType to use for
|
|
|
|
*/
|
2005-10-16 09:13:04 +00:00
|
|
|
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
|
2005-03-24 17:03:37 +00:00
|
|
|
{
|
2006-05-06 20:48:40 +00:00
|
|
|
if (!DrawStationTile(x, y, railtype, AXIS_X, STAT_CLASS_WAYP, stat_id)) {
|
2009-07-18 10:01:31 +00:00
|
|
|
StationPickerDrawSprite(x, y, STATION_WAYPOINT, railtype, INVALID_ROADTYPE, AXIS_X);
|
2005-03-24 17:03:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-21 11:11:05 +00:00
|
|
|
void Waypoint::GetTileArea(TileArea *ta, StationType type) const
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case STATION_WAYPOINT:
|
2010-01-01 18:10:10 +00:00
|
|
|
*ta = this->train_station;
|
|
|
|
return;
|
|
|
|
|
|
|
|
case STATION_BUOY:
|
|
|
|
ta->tile = this->xy;
|
|
|
|
ta->w = 1;
|
|
|
|
ta->h = 1;
|
2009-07-21 11:11:05 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-08-02 12:22:40 +00:00
|
|
|
Waypoint::~Waypoint()
|
|
|
|
{
|
2007-08-05 21:20:55 +00:00
|
|
|
if (CleaningPool()) return;
|
2008-08-21 02:19:31 +00:00
|
|
|
DeleteWindowById(WC_WAYPOINT_VIEW, this->index);
|
2007-08-02 12:22:40 +00:00
|
|
|
RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, this->index);
|
2019-02-22 16:57:28 +00:00
|
|
|
_viewport_sign_kdtree.Remove(ViewportSignKdtreeItem::MakeWaypoint(this->index));
|
2015-07-24 00:21:31 +00:00
|
|
|
TraceRestrictRemoveDestinationID(TROCAF_WAYPOINT, this->index);
|
2007-08-02 12:22:40 +00:00
|
|
|
}
|