src/station.h
author KUDr
Sat, 21 Apr 2007 08:23:57 +0000
branchcpp_gui
changeset 6308 646711c5feaa
parent 6307 f40e88cff863
permissions -rw-r--r--
(svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2154
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2154
diff changeset
     2
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
     3
/** @file station.h */
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
     4
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
#ifndef STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     6
#define STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     7
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
     8
#include "airport.h"
2154
63a6b880b4c0 (svn r2664) Remove depedency on player.h from variables.h
tron
parents: 2049
diff changeset
     9
#include "player.h"
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 4981
diff changeset
    10
#include "oldpool.h"
405
6830ae7a0d5d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 403
diff changeset
    11
#include "sprite.h"
1247
01711347f9ac (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
    12
#include "tile.h"
2963
6645da0a5b4a (svn r3525) - Rename station_newgrf.[ch] to newgrf_station.[ch], and update project files.
peter1138
parents: 2817
diff changeset
    13
#include "newgrf_station.h"
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6307
diff changeset
    14
#include <list>
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
5921
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    16
static const StationID INVALID_STATION = 0xFFFF;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    17
static const byte INITIAL_STATION_RATING = 175;
5921
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    18
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    19
struct GoodsEntry {
5921
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    20
	GoodsEntry() :
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    21
		waiting_acceptance(0),
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
    22
		unload_pending(0),
5921
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    23
		days_since_pickup(0),
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    24
		rating(INITIAL_STATION_RATING),
5921
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    25
		enroute_from(INVALID_STATION),
5934
9f91cc4e2b17 (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar
parents: 5927
diff changeset
    26
		enroute_from_xy(INVALID_TILE),
5921
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    27
		last_speed(0),
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    28
		last_age(255),
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    29
		feeder_profit(0)
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    30
	{}
51fa3124c16a (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5916
diff changeset
    31
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	uint16 waiting_acceptance;
6285
187e3ef04cc9 (svn r9004) [cpp_gui] -Sync with trunk (r8900..r9003)
KUDr
parents: 6268
diff changeset
    33
	uint16 unload_pending;        ///< records how much cargo is awaiting transfer during gradual loading to allow correct fee calc
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	byte days_since_pickup;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    35
	byte rating;
3347
d5d8ace1bb13 (svn r4131) - CodeChange: Add proper semantics for StationID for such variables instead of using the general uint16-type. StationID was added for depots, waypoints and stations where necessary. We probably need to change GetDepot(), IsDepotIndex(), IsStationIndex(), GetWaypoint() and IsWaypointIndex() as well to use StationID.
Darkvater
parents: 3333
diff changeset
    36
	StationID enroute_from;
5934
9f91cc4e2b17 (svn r8144) -Fix: [FS#163] When a station is removed, vehicles do not get excessive payment any longer, as the origin TILE is now stored as long as the origin STATION for the transported cargos. Basically this is only a temporary fix until cargopackets are implemented, but it fixes one of the oldest known bugs (Special Thanks to Darkvater for lots of testing)
celestar
parents: 5927
diff changeset
    37
	TileIndex enroute_from_xy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    38
	byte enroute_time;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    39
	byte last_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    40
	byte last_age;
1935
f43f062c9498 (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1802
diff changeset
    41
	int32 feeder_profit;
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    42
};
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    43
6087
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    44
/** A Stop for a Road Vehicle */
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    45
struct RoadStop {
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    46
	/** Types of RoadStops */
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    47
	enum Type {
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    48
		BUS,                                ///< A standard stop for buses
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    49
		TRUCK                               ///< A standard stop for trucks
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    50
	};
5959
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    51
6088
c11f7acc18bd (svn r8403) -Fix (r8402): Forgot to remove an enum
celestar
parents: 6087
diff changeset
    52
	static const int  cDebugCtorLevel =  3;  ///< Debug level on which Contructor / Destructor messages are printed
c11f7acc18bd (svn r8403) -Fix (r8402): Forgot to remove an enum
celestar
parents: 6087
diff changeset
    53
	static const uint LIMIT           = 16;  ///< The maximum amount of roadstops that are allowed at a single station
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    54
	static const uint MAX_BAY_COUNT   =  2;  ///< The maximum number of loading bays
6087
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    55
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    56
	TileIndex        xy;                    ///< Position on the map
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    57
	RoadStopID       index;                 ///< Global (i.e. pool-wide) index
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    58
	byte             status;                ///< Current status of the Stop. Like which spot is taken. Access using *Bay and *Busy functions.
6087
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    59
	byte             num_vehicles;          ///< Number of vehicles currently slotted to this stop
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    60
	struct RoadStop  *next;                 ///< Next stop of the given type at this station
5959
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    61
5967
d862ebaf5035 (svn r8207) -Fix
tron
parents: 5964
diff changeset
    62
	RoadStop(TileIndex tile);
5959
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    63
	~RoadStop();
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    64
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    65
	void *operator new (size_t size);
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    66
	void operator delete(void *rs);
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    67
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    68
	/* For loading games */
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    69
	void *operator new (size_t size, int index);
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    70
	void operator delete(void *rs, int index);
6a4c261987c3 (svn r8185) -Codechange: Equipped Roadstops with new/delete operators and gave them proper constructors/destructors (Thanks to KUDr for a nice interactive C++ lesson)
celestar
parents: 5934
diff changeset
    71
6086
61742a8471f5 (svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents: 5972
diff changeset
    72
	bool IsValid() const;
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    73
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    74
	/* For accessing status */
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    75
	bool HasFreeBay() const;
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
    76
	bool IsFreeBay(uint nr) const;
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    77
	uint AllocateBay();
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
    78
	void AllocateDriveThroughBay(uint nr);
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    79
	void FreeBay(uint nr);
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    80
	bool IsEntranceBusy() const;
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
    81
	void SetEntranceBusy(bool busy);
6086
61742a8471f5 (svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents: 5972
diff changeset
    82
protected:
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    83
	static RoadStop *AllocateRaw();
6087
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
    84
};
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    85
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    86
struct StationSpecList {
3587
2eb52db0b872 (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    87
	const StationSpec *spec;
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
    88
	uint32 grfid;      ///< GRF ID of this custom station
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
    89
	uint8  localidx;   ///< Station ID within GRF of station
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
    90
};
3587
2eb52db0b872 (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    91
5927
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    92
/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    93
struct StationRect : public Rect {
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    94
	enum StationRectMode
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    95
	{
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    96
		ADD_TEST = 0,
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    97
		ADD_TRY,
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    98
		ADD_FORCE
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
    99
	};
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   100
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   101
	StationRect();
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   102
	void MakeEmpty();
6161
754debc55207 (svn r8536) -Fix (FS#577): Road Vehicles now can obtain a slot even if the station is very spread out
celestar
parents: 6147
diff changeset
   103
	bool PtInExtendedRect(int x, int y, int distance = 0) const;
5927
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   104
	bool IsEmpty() const;
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   105
	bool BeforeAddTile(TileIndex tile, StationRectMode mode);
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   106
	bool BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode);
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   107
	bool AfterRemoveTile(Station *st, TileIndex tile);
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   108
	bool AfterRemoveRect(Station *st, TileIndex tile, int w, int h);
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   109
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   110
	static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a);
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   111
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   112
	StationRect& operator = (Rect src);
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   113
};
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   114
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
struct Station {
6127
a256e61e86f9 (svn r8474) -Fix
tron
parents: 6118
diff changeset
   116
	public:
a256e61e86f9 (svn r8474) -Fix
tron
parents: 6118
diff changeset
   117
		RoadStop *GetPrimaryRoadStop(RoadStop::Type type) const
a256e61e86f9 (svn r8474) -Fix
tron
parents: 6118
diff changeset
   118
		{
a256e61e86f9 (svn r8474) -Fix
tron
parents: 6118
diff changeset
   119
			return type == RoadStop::BUS ? bus_stops : truck_stops;
a256e61e86f9 (svn r8474) -Fix
tron
parents: 6118
diff changeset
   120
		}
a256e61e86f9 (svn r8474) -Fix
tron
parents: 6118
diff changeset
   121
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
   122
		const AirportFTAClass *Airport() const
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
   123
		{
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
   124
			if (airport_tile == 0) return GetAirport(AT_DUMMY);
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
   125
			return GetAirport(airport_type);
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
   126
		}
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
   127
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
	TileIndex xy;
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   129
	RoadStop *bus_stops;
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   130
	RoadStop *truck_stops;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   131
	TileIndex train_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   132
	TileIndex airport_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   133
	TileIndex dock_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
	Town *town;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	uint16 string_id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   136
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   137
	ViewportSign sign;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   139
	uint16 had_vehicle_of_type;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 123
diff changeset
   140
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   141
	byte time_since_load;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   142
	byte time_since_unload;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   143
	byte delete_ctr;
5838
9c3129cb019b (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5726
diff changeset
   144
	PlayerByte owner;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   145
	byte facilities;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   146
	byte airport_type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   147
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
   148
	/* trainstation width/height */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   149
	byte trainst_w, trainst_h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   150
3587
2eb52db0b872 (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
   151
	/** List of custom stations (StationSpecs) allocated to the station */
3786
73784d02aa69 (svn r4782) - Newstations: fix issue with saving/loading games with newstations on big endian architectures.
peter1138
parents: 3765
diff changeset
   152
	uint8 num_specs;
3587
2eb52db0b872 (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
   153
	StationSpecList *speclist;
2eb52db0b872 (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
   154
4289
ff1b2b915cab (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4268
diff changeset
   155
	Date build_date;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   156
6307
f40e88cff863 (svn r9639) [cpp_gui] -Sync with trunk (r9476:9633)
KUDr
parents: 6298
diff changeset
   157
	uint64 airport_flags;   ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
1551
eb05e6a90e67 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
   158
	StationID index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   159
3580
607e4245d024 (svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents: 3574
diff changeset
   160
	byte last_vehicle_type;
6308
646711c5feaa (svn r9708) [cpp_gui] -Sync with trunk (r9633:9707)
KUDr
parents: 6307
diff changeset
   161
	std::list<Vehicle *> loading_vehicles;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   162
	GoodsEntry goods[NUM_CARGO];
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   163
3687
109ec5cdb932 (svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents: 3587
diff changeset
   164
	uint16 random_bits;
109ec5cdb932 (svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents: 3587
diff changeset
   165
	byte waiting_triggers;
109ec5cdb932 (svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents: 3587
diff changeset
   166
5927
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   167
	StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions
5916
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   168
5927
d740cab19ca0 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5921
diff changeset
   169
	static const int cDebugCtorLevel = 3;
5916
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   170
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   171
	Station(TileIndex tile = 0);
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   172
	~Station();
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   173
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   174
	/* normal new/delete operators. Used when building/removing station */
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   175
	void* operator new (size_t size);
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   176
	void operator delete(void *p);
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   177
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   178
	/* new/delete operators accepting station index. Used when loading station from savegame. */
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   179
	void* operator new (size_t size, int st_idx);
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   180
	void operator delete(void *p, int st_idx);
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   181
5972
564f98b055d1 (svn r8231) -Fix (r8125): MP desync caused by calling Random() from station constructor. This was wrong because station constructor is called also when loading savegame and when player tries to build station when it is not sure that it will succeed (thanks Rubidium)
KUDr
parents: 5969
diff changeset
   182
	void AddFacility(byte new_facility_bit, TileIndex facil_xy);
5916
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   183
	void MarkDirty() const;
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   184
	void MarkTilesDirty() const;
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   185
	bool TileBelongsToRailStation(TileIndex tile) const;
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
   186
	uint GetPlatformLength(TileIndex tile, DiagDirection dir) const;
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
   187
	uint GetPlatformLength(TileIndex tile) const;
6147
2345f00d2a33 (svn r8514) -Codechange: Turn IsBuoy into a method of stations
celestar
parents: 6135
diff changeset
   188
	bool IsBuoy() const;
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
   189
	bool IsValid() const;
5916
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   190
75c6d5cf1600 (svn r8125) -Codechange: Station is now constructed/destroyed using new/delete operators (don't worry, they still use the same memory pool). Few station related functions turned into Station::methods (just first step). All this new stuff moved from station_cmd.cpp to the new file (station.cpp).
KUDr
parents: 5852
diff changeset
   191
protected:
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   192
	static Station *AllocateRaw();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   193
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   194
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   195
enum {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   196
	FACIL_TRAIN      = 0x01,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   197
	FACIL_TRUCK_STOP = 0x02,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   198
	FACIL_BUS_STOP   = 0x04,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   199
	FACIL_AIRPORT    = 0x08,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   200
	FACIL_DOCK       = 0x10,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   203
enum {
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   204
//	HVOT_PENDING_DELETE = 1 << 0, // not needed anymore
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   205
	HVOT_TRAIN    = 1 << 1,
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   206
	HVOT_BUS      = 1 << 2,
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   207
	HVOT_TRUCK    = 1 << 3,
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   208
	HVOT_AIRCRAFT = 1 << 4,
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   209
	HVOT_SHIP     = 1 << 5,
1751
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   210
	/* This bit is used to mark stations. No, it does not belong here, but what
954dd2900ac9 (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   211
	 * can we do? ;-) */
3554
c16eadc2d060 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   212
	HVOT_BUOY     = 1 << 6
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   213
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   214
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   215
enum CatchmentArea {
5852
cb3f71b16e1a (svn r8055) -Codechange: Replace the different max, dmax, maxu whatever macros by a simple template function max(), that requires two arguments of the same type. While I'm at it change a variable called "max" to "maxval" in a function that calls max().
celestar
parents: 5838
diff changeset
   216
	CA_NONE            =  0,
4344
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   217
	CA_BUS             =  3,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   218
	CA_TRUCK           =  3,
5d0e40cd67b9 (svn r6045) -Cleanup: align all table-like structures using spaces, i.e. whitespace fixes only except for a few comments to make them uniform for the whole enum/struct.
rubidium
parents: 4289
diff changeset
   219
	CA_TRAIN           =  4,
6254
abc6ad7c035c (svn r8769) [cpp_gui] -Sync with trunk (r8730..r8768)
KUDr
parents: 6253
diff changeset
   220
	CA_DOCK            =  5
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   221
};
568
6eb7d394fb35 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   222
2498
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2488
diff changeset
   223
void ModifyStationRatingAround(TileIndex tile, PlayerID owner, int amount, uint radius);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   224
2498
befad2fe53d2 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2488
diff changeset
   225
void ShowStationViewWindow(StationID station);
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   226
void UpdateAllStationVirtCoord();
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   227
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3786
diff changeset
   228
/* sorter stuff */
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   229
void RebuildStationLists();
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   230
void ResortStationLists();
3812
d9b3041ee3d0 (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3786
diff changeset
   231
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 4981
diff changeset
   232
DECLARE_OLD_POOL(Station, Station, 6, 1000)
1272
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   233
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   234
static inline StationID GetMaxStationIndex()
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   235
{
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   236
	/* TODO - This isn't the real content of the function, but
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   237
	 *  with the new pool-system this will be replaced with one that
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5220
diff changeset
   238
	 *  _really_ returns the highest index. Now it just returns
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   239
	 *  the next safe value we are sure about everything is below.
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   240
	 */
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5220
diff changeset
   241
	return GetStationPoolSize() - 1;
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5220
diff changeset
   242
}
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5220
diff changeset
   243
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   244
static inline uint GetNumStations()
5247
c3eece01af11 (svn r7372) - CodeChange: Rename all GetXXXArraySize() functions to GetNumXXX() and add GetMaxXXXIndex() functions. This prepares for the new pool interface.
matthijs
parents: 5220
diff changeset
   245
{
4354
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   246
	return GetStationPoolSize();
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   247
}
684ab9249dae (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   248
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
   249
static inline bool IsValidStationID(StationID index)
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   250
{
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
   251
	return index < GetStationPoolSize() && GetStation(index)->IsValid();
4346
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   252
}
3f00094f2670 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   253
6253
23983700e3d7 (svn r8731) [cpp_gui] -Sync: r8730 from trunk
bjarni
parents: 6187
diff changeset
   254
#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())
1272
d3e09adb7736 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   255
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
919
b0d6c7642f99 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   256
1284
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   257
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   258
/* Stuff for ROADSTOPS */
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   259
5216
d581e4db95b6 (svn r7331) - Codechange: Rename all memory pool macro's and types to "old pool", so the new pool implementation can be committed alongside it.
matthijs
parents: 4981
diff changeset
   260
DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000)
1284
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   261
6086
61742a8471f5 (svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents: 5972
diff changeset
   262
#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())
1284
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   263
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   264
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   265
/* End of stuff for ROADSTOPS */
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   266
06a52178bf46 (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   267
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   268
void AfterLoadStations();
1424
c6d120592e98 (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents: 1368
diff changeset
   269
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad);
c6d120592e98 (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents: 1368
diff changeset
   270
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
384
bf1303e754ff (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   271
bf1303e754ff (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   272
3763
460bbb4a8154 (svn r4754) - Newstations: expose default station display data via a function so we can use it (rarely) in other places.
peter1138
parents: 3687
diff changeset
   273
const DrawTileSprites *GetStationTileLayout(byte gfx);
2520
75eb66d6e371 (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2498
diff changeset
   274
void StationPickerDrawSprite(int x, int y, RailType railtype, int image);
75eb66d6e371 (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2498
diff changeset
   275
6087
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
   276
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type);
b56c54f79335 (svn r8402) -Codechange: Move RoadStop-specific enums to the RoadStop class, and changed a one-member enum into a static const. Simplify their naming and add some doxygen-comments to RoadStop
celestar
parents: 6086
diff changeset
   277
uint GetNumRoadStops(const Station* st, RoadStop::Type type);
6298
c30fe89622df (svn r9119) [cpp_gui] -Sync with trunk (r9003:9100)
bjarni
parents: 6285
diff changeset
   278
RoadStop * AllocateRoadStop();
3123
a82dd124b3f2 (svn r3730) Multistop modifications:
celestar
parents: 3092
diff changeset
   279
void ClearSlot(Vehicle *v);
1217
ab9f02a224ab (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   280
6135
72fa67e22bc2 (svn r8485) -Fix
tron
parents: 6130
diff changeset
   281
void DeleteOilRig(TileIndex t);
72fa67e22bc2 (svn r8485) -Fix
tron
parents: 6130
diff changeset
   282
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   283
#endif /* STATION_H */