src/station_base.h
author rubidium
Thu, 18 Dec 2008 12:23:08 +0000
changeset 10436 8d3a9fbe8f19
parent 10347 6da2d30f2fe8
permissions -rw-r--r--
(svn r14689) -Change: make configure die on commonly made user mistakes, like not having SDL development files or zlib headers installed; you can still compile a dedicated server or a binary without zlib, but you have to explicitly force it.
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     1
/* $Id$ */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     2
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     3
/** @file station_base.h Base classes/functions for stations. */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     4
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     5
#ifndef STATION_BASE_H
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     6
#define STATION_BASE_H
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     7
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     8
#include "station_type.h"
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
     9
#include "airport.h"
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    10
#include "oldpool.h"
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    11
#include "cargopacket.h"
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    12
#include "cargo_type.h"
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    13
#include "town_type.h"
8787
41d9d5adbe87 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents: 8785
diff changeset
    14
#include "strings_type.h"
41d9d5adbe87 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents: 8785
diff changeset
    15
#include "date_type.h"
41d9d5adbe87 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents: 8785
diff changeset
    16
#include "vehicle_type.h"
10208
72c00af5c95d (svn r14422) -Codechange: also reflect the changes of r14421 in the filenames.
rubidium
parents: 10207
diff changeset
    17
#include "company_type.h"
10347
6da2d30f2fe8 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium
parents: 10290
diff changeset
    18
#include "industry_type.h"
8787
41d9d5adbe87 (svn r12495) -Codechange: reduce the dependency on newgrf_station.h (especially because newgrf_station.h includes a lot of stuff).
rubidium
parents: 8785
diff changeset
    19
#include "core/geometry_type.hpp"
9127
14f21c5954ee (svn r12987) -Codechange: split viewport and tile selection.
rubidium
parents: 9003
diff changeset
    20
#include "viewport_type.h"
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    21
#include <list>
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    22
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    23
DECLARE_OLD_POOL(Station, Station, 6, 1000)
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    24
DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000)
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    25
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    26
static const byte INITIAL_STATION_RATING = 175;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    27
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    28
struct GoodsEntry {
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    29
	enum AcceptancePickup {
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    30
		ACCEPTANCE,
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    31
		PICKUP
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    32
	};
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    33
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    34
	GoodsEntry() :
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    35
		acceptance_pickup(0),
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    36
		days_since_pickup(255),
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    37
		rating(INITIAL_STATION_RATING),
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    38
		last_speed(0),
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    39
		last_age(255)
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    40
	{}
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    41
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    42
	byte acceptance_pickup;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    43
	byte days_since_pickup;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    44
	byte rating;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    45
	byte last_speed;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    46
	byte last_age;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    47
	CargoList cargo; ///< The cargo packets of cargo waiting in this station
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    48
};
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    49
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    50
/** A Stop for a Road Vehicle */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    51
struct RoadStop : PoolItem<RoadStop, RoadStopID, &_RoadStop_pool> {
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    52
	static const int  cDebugCtorLevel =  5;  ///< Debug level on which Contructor / Destructor messages are printed
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    53
	static const uint LIMIT           = 16;  ///< The maximum amount of roadstops that are allowed at a single station
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    54
	static const uint MAX_BAY_COUNT   =  2;  ///< The maximum number of loading bays
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    55
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    56
	TileIndex        xy;                    ///< Position on the map
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    57
	byte             status;                ///< Current status of the Stop. Like which spot is taken. Access using *Bay and *Busy functions.
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    58
	byte             num_vehicles;          ///< Number of vehicles currently slotted to this stop
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    59
	struct RoadStop  *next;                 ///< Next stop of the given type at this station
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    60
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    61
	RoadStop(TileIndex tile = 0);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    62
	virtual ~RoadStop();
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    63
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    64
	/**
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    65
	 * Determines whether a road stop exists
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    66
	 * @return true if and only is the road stop exists
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    67
	 */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    68
	inline bool IsValid() const { return this->xy != 0; }
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    69
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    70
	/* For accessing status */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    71
	bool HasFreeBay() const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    72
	bool IsFreeBay(uint nr) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    73
	uint AllocateBay();
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    74
	void AllocateDriveThroughBay(uint nr);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    75
	void FreeBay(uint nr);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    76
	bool IsEntranceBusy() const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    77
	void SetEntranceBusy(bool busy);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    78
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    79
	RoadStop *GetNextRoadStop(const Vehicle *v) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    80
};
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    81
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    82
struct StationSpecList {
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    83
	const StationSpec *spec;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    84
	uint32 grfid;      ///< GRF ID of this custom station
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    85
	uint8  localidx;   ///< Station ID within GRF of station
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    86
};
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    87
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    88
/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    89
struct StationRect : public Rect {
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    90
	enum StationRectMode
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    91
	{
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    92
		ADD_TEST = 0,
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    93
		ADD_TRY,
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    94
		ADD_FORCE
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    95
	};
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    96
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    97
	StationRect();
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    98
	void MakeEmpty();
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
    99
	bool PtInExtendedRect(int x, int y, int distance = 0) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   100
	bool IsEmpty() const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   101
	bool BeforeAddTile(TileIndex tile, StationRectMode mode);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   102
	bool BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   103
	bool AfterRemoveTile(Station *st, TileIndex tile);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   104
	bool AfterRemoveRect(Station *st, TileIndex tile, int w, int h);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   105
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   106
	static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   107
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   108
	StationRect& operator = (Rect src);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   109
};
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   110
10260
c6ec6b3c1b18 (svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents: 10208
diff changeset
   111
/** Station data structure */
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   112
struct Station : PoolItem<Station, StationID, &_Station_pool> {
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   113
public:
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   114
	RoadStop *GetPrimaryRoadStop(RoadStopType type) const
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   115
	{
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   116
		return type == ROADSTOP_BUS ? bus_stops : truck_stops;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   117
	}
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   118
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   119
	RoadStop *GetPrimaryRoadStop(const Vehicle *v) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   120
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   121
	const AirportFTAClass *Airport() const
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   122
	{
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   123
		if (airport_tile == 0) return GetAirport(AT_DUMMY);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   124
		return GetAirport(airport_type);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   125
	}
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   126
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   127
	TileIndex xy;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   128
	RoadStop *bus_stops;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   129
	RoadStop *truck_stops;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   130
	TileIndex train_tile;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   131
	TileIndex airport_tile;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   132
	TileIndex dock_tile;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   133
	Town *town;
10347
6da2d30f2fe8 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium
parents: 10290
diff changeset
   134
6da2d30f2fe8 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium
parents: 10290
diff changeset
   135
	/* Place to get a name from, in order of importance: */
6da2d30f2fe8 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium
parents: 10290
diff changeset
   136
	char *name;             ///< Custom name
6da2d30f2fe8 (svn r14598) -Feature: Action0Industries property 24 (industry suuplies default name for nearby station).
rubidium
parents: 10290
diff changeset
   137
	IndustryType indtype;   ///< Industry type to get the name from
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   138
	StringID string_id;     ///< Default name (town area) of station
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   139
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   140
	ViewportSign sign;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   141
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   142
	uint16 had_vehicle_of_type;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   143
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   144
	byte time_since_load;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   145
	byte time_since_unload;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   146
	byte delete_ctr;
10207
c291a21b304e (svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium
parents: 9127
diff changeset
   147
	OwnerByte owner;
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   148
	byte facilities;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   149
	byte airport_type;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   150
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   151
	/* trainstation width/height */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   152
	byte trainst_w, trainst_h;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   153
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   154
	/** List of custom stations (StationSpecs) allocated to the station */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   155
	uint8 num_specs;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   156
	StationSpecList *speclist;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   157
10260
c6ec6b3c1b18 (svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents: 10208
diff changeset
   158
	Date build_date;  ///< Date of construction
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   159
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   160
	uint64 airport_flags;   ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   161
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   162
	byte last_vehicle_type;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   163
	std::list<Vehicle *> loading_vehicles;
10260
c6ec6b3c1b18 (svn r14491) -Documentation: updates/additions of doxygen docs (Alberth)
rubidium
parents: 10208
diff changeset
   164
	GoodsEntry goods[NUM_CARGO];  ///< Goods at this station
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   165
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   166
	uint16 random_bits;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   167
	byte waiting_triggers;
9003
7972fa66d9c9 (svn r12798) -Feature: Add some support for NewGRF station animation. (Thanks to mart3p for samples and fixes)
peter1138
parents: 8787
diff changeset
   168
	uint8 cached_anim_triggers; ///< Combined animation trigger bitmask, used to determine if trigger processing should happen.
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   169
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   170
	StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   171
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   172
	static const int cDebugCtorLevel = 5;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   173
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   174
	Station(TileIndex tile = 0);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   175
	virtual ~Station();
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   176
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   177
	void AddFacility(byte new_facility_bit, TileIndex facil_xy);
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   178
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   179
	/**
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   180
	 * Mark the sign of a station dirty for repaint.
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   181
	 *
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   182
	 * @ingroup dirty
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   183
	 */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   184
	void MarkDirty() const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   185
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   186
	/**
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   187
	 * Marks the tiles of the station as dirty.
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   188
	 *
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   189
	 * @ingroup dirty
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   190
	 */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   191
	void MarkTilesDirty(bool cargo_change) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   192
	bool TileBelongsToRailStation(TileIndex tile) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   193
	uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   194
	uint GetPlatformLength(TileIndex tile) const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   195
	bool IsBuoy() const;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   196
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   197
	/**
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   198
	 * Determines whether a station exists
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   199
	 * @return true if and only is the station exists
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   200
	 */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   201
	inline bool IsValid() const { return this->xy != 0; }
10290
56925f09d693 (svn r14529) -Codechange: Turn FindCatchmentRadius() into Station::GetCatchmentRadius().
frosch
parents: 10260
diff changeset
   202
56925f09d693 (svn r14529) -Codechange: Turn FindCatchmentRadius() into Station::GetCatchmentRadius().
frosch
parents: 10260
diff changeset
   203
	uint GetCatchmentRadius() const;
8785
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   204
};
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   205
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   206
static inline StationID GetMaxStationIndex()
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   207
{
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   208
	/* TODO - This isn't the real content of the function, but
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   209
	 *  with the new pool-system this will be replaced with one that
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   210
	 *  _really_ returns the highest index. Now it just returns
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   211
	 *  the next safe value we are sure about everything is below.
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   212
	 */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   213
	return GetStationPoolSize() - 1;
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   214
}
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   215
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   216
static inline uint GetNumStations()
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   217
{
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   218
	return GetStationPoolSize();
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   219
}
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   220
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   221
static inline bool IsValidStationID(StationID index)
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   222
{
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   223
	return index < GetStationPoolSize() && GetStation(index)->IsValid();
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   224
}
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   225
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   226
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) if (st->IsValid())
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   227
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   228
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   229
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   230
/* Stuff for ROADSTOPS */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   231
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   232
#define FOR_ALL_ROADSTOPS_FROM(rs, start) for (rs = GetRoadStop(start); rs != NULL; rs = (rs->index + 1U < GetRoadStopPoolSize()) ? GetRoadStop(rs->index + 1U) : NULL) if (rs->IsValid())
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   233
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   234
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   235
/* End of stuff for ROADSTOPS */
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   236
871586967963 (svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
diff changeset
   237
#endif /* STATION_BASE_H */