2005-07-24 16:12:37 +02:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 22:21:05 +02: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/>.
|
|
|
|
*/
|
|
|
|
|
2009-07-22 12:18:19 +02:00
|
|
|
/** @file waypoint_base.h Base of waypoints. */
|
2007-04-06 06:10:19 +02:00
|
|
|
|
2010-12-22 12:46:41 +01:00
|
|
|
#ifndef WAYPOINT_BASE_H
|
|
|
|
#define WAYPOINT_BASE_H
|
2005-03-24 18:03:37 +01:00
|
|
|
|
2009-07-22 13:35:35 +02:00
|
|
|
#include "base_station_base.h"
|
2005-03-24 18:03:37 +01:00
|
|
|
|
2011-05-01 21:14:12 +02:00
|
|
|
/** Representation of a waypoint. */
|
2009-07-22 10:59:57 +02:00
|
|
|
struct Waypoint : SpecializedStation<Waypoint, true> {
|
2010-09-16 18:31:57 +02:00
|
|
|
uint16 town_cn; ///< The N-1th waypoint for this town (consecutive number)
|
2005-03-24 18:03:37 +01:00
|
|
|
|
2011-05-01 21:14:12 +02:00
|
|
|
/**
|
|
|
|
* Create a waypoint at the given tile.
|
|
|
|
* @param tile The location of the waypoint.
|
|
|
|
*/
|
2009-07-18 20:39:17 +02:00
|
|
|
Waypoint(TileIndex tile = INVALID_TILE) : SpecializedStation<Waypoint, true>(tile) { }
|
2007-08-02 14:22:40 +02:00
|
|
|
~Waypoint();
|
2009-07-14 00:33:25 +02:00
|
|
|
|
|
|
|
void UpdateVirtCoord();
|
2009-07-17 22:21:24 +02:00
|
|
|
|
2009-07-17 23:06:06 +02:00
|
|
|
/* virtual */ FORCEINLINE bool TileBelongsToRailStation(TileIndex tile) const
|
|
|
|
{
|
2009-07-22 10:59:57 +02:00
|
|
|
return IsRailWaypointTile(tile) && GetStationIndex(tile) == this->index;
|
2009-07-17 23:06:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ uint32 GetNewGRFVariable(const struct ResolverObject *object, byte variable, byte parameter, bool *available) const;
|
|
|
|
|
2009-07-21 13:11:05 +02:00
|
|
|
/* virtual */ void GetTileArea(TileArea *ta, StationType type) const;
|
2009-07-24 17:18:25 +02:00
|
|
|
|
|
|
|
/* virtual */ uint GetPlatformLength(TileIndex tile, DiagDirection dir) const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */ uint GetPlatformLength(TileIndex tile) const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2010-02-16 00:55:04 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is this a single tile waypoint?
|
|
|
|
* @return true if it is.
|
|
|
|
*/
|
|
|
|
FORCEINLINE bool IsSingleTile() const
|
|
|
|
{
|
|
|
|
return (this->facilities & FACIL_TRAIN) != 0 && this->train_station.w == 1 && this->train_station.h == 1;
|
|
|
|
}
|
2010-05-12 20:31:39 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Is the "type" of waypoint the same as the given waypoint,
|
|
|
|
* i.e. are both a rail waypoint or are both a buoy?
|
|
|
|
* @param wp The waypoint to compare to.
|
|
|
|
* @return true iff their types are equal.
|
|
|
|
*/
|
|
|
|
FORCEINLINE bool IsOfType(const Waypoint *wp) const
|
|
|
|
{
|
|
|
|
return this->string_id == wp->string_id;
|
|
|
|
}
|
2007-08-02 14:22:40 +02:00
|
|
|
};
|
2006-08-22 17:33:35 +02:00
|
|
|
|
2011-05-01 21:14:12 +02:00
|
|
|
/**
|
|
|
|
* Iterate over all waypoints.
|
|
|
|
* @param var The variable used for iteration.
|
|
|
|
*/
|
2009-07-22 10:59:57 +02:00
|
|
|
#define FOR_ALL_WAYPOINTS(var) FOR_ALL_BASE_STATIONS_OF_TYPE(Waypoint, var)
|
2005-03-24 18:03:37 +01:00
|
|
|
|
2010-12-22 12:46:41 +01:00
|
|
|
#endif /* WAYPOINT_BASE_H */
|