src/waypoint.h
author miham
Fri, 02 Feb 2007 06:42:55 +0000
changeset 5904 17ba38dccdb3
parent 5475 2e6990a8c7c4
child 6182 7337aca829f1
permissions -rw-r--r--
(svn r8527) -Update: WebTranslator2 update to 2007-02-02 07:41:47
brazilian_portuguese - 6 fixed, 363 changed by fukumori (369)
bulgarian - 6 fixed by groupsky (6)
catalan - 6 fixed by arnaullv (6)
croatian - 54 fixed, 3 changed by tperic (57)
czech - 6 fixed by Hadez (6)
danish - 2 fixed, 1 changed by MiR (3)
dutch - 2 fixed by habell (2)
estonian - 6 fixed by kristjans (6)
french - 4 fixed by glx (4)
german - 6 fixed, 2 changed by Neonox (8)
hungarian - 2 fixed by miham (2)
italian - 6 fixed, 4 changed by lorenzodv (6), sidew (4)
japanese - 6 fixed by ickoonite (6)
polish - 4 fixed by meush (4)
simplified_chinese - 6 fixed by Fishingsnow (6)
slovenian - 39 fixed, 1 deleted, 2 changed by Necrolyte (42)
turkish - 6 fixed by jnmbk (6)
ukrainian - 41 fixed, 1 deleted, 22 changed by znikoz (1), mad (63)
/* $Id$ */

#ifndef WAYPOINT_H
#define WAYPOINT_H

#include "oldpool.h"
#include "rail_map.h"

struct Waypoint {
	TileIndex xy;      ///< Tile of waypoint
	WaypointID index;  ///< Index of waypoint

	TownID town_index; ///< Town associated with the waypoint
	byte town_cn;      ///< The Nth waypoint for this town (consecutive number)
	StringID string;   ///< If this is zero (i.e. no custom name), town + town_cn is used for naming

	ViewportSign sign; ///< Dimensions of sign (not saved)
	Date build_date;   ///< Date of construction

	byte stat_id;      ///< ID of waypoint within the waypoint class (not saved)
	uint32 grfid;      ///< ID of GRF file
	byte localidx;     ///< Index of station within GRF file

	byte deleted;      ///< Delete counter. If greater than 0 then it is decremented until it reaches 0; the waypoint is then is deleted.
};

DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000)

/**
 * Check if a Waypoint really exists.
 */
static inline bool IsValidWaypoint(const Waypoint *wp)
{
	return wp->xy != 0;
}

static inline bool IsValidWaypointID(WaypointID index)
{
	return index < GetWaypointPoolSize() && IsValidWaypoint(GetWaypoint(index));
}

void DestroyWaypoint(Waypoint *wp);

static inline void DeleteWaypoint(Waypoint *wp)
{
	DestroyWaypoint(wp);
	wp->xy = 0;
}

#define FOR_ALL_WAYPOINTS_FROM(wp, start) for (wp = GetWaypoint(start); wp != NULL; wp = (wp->index + 1U < GetWaypointPoolSize()) ? GetWaypoint(wp->index + 1U) : NULL) if (IsValidWaypoint(wp))
#define FOR_ALL_WAYPOINTS(wp) FOR_ALL_WAYPOINTS_FROM(wp, 0)


/**
 * Fetch a waypoint by tile
 * @param tile Tile of waypoint
 * @return Waypoint
 */
static inline Waypoint *GetWaypointByTile(TileIndex tile)
{
	assert(IsTileType(tile, MP_RAILWAY) && IsRailWaypoint(tile));
	return GetWaypoint(_m[tile].m2);
}

int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove);
Station *ComposeWaypointStation(TileIndex tile);
void ShowRenameWaypointWindow(const Waypoint *cp);
void DrawWaypointSprite(int x, int y, int image, RailType railtype);
void FixOldWaypoints(void);
void UpdateAllWaypointSigns(void);
void AfterLoadWaypoints(void);

#endif /* WAYPOINT_H */