src/station.h
author rubidium
Thu, 01 Feb 2007 15:49:12 +0000
changeset 5893 7e431a4abebb
parent 5884 0c9a9c61ca76
child 5896 a9f7bdd841d4
permissions -rw-r--r--
(svn r8511) -Codechange: make WindowClass an enumerated value.
2186
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2154
diff changeset
     1
/* $Id$ */
db48cf29b983 (svn r2701) Insert Id tags into all source files
tron
parents: 2154
diff changeset
     2
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     3
#ifndef STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     4
#define STATION_H
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
5665
d6b5c720ad67 (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: 5601
diff changeset
     6
#include <deque>
2154
f86c59e73a16 (svn r2664) Remove depedency on player.h from variables.h
tron
parents: 2049
diff changeset
     7
#include "player.h"
5216
8bd14ee39af2 (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
     8
#include "oldpool.h"
405
415546028e8d (svn r602) -newgrf: Move DrawTileSeqStruct & co and struct SpriteGroup to sprite.h (pasky)
darkvater
parents: 403
diff changeset
     9
#include "sprite.h"
1247
3851739bfd09 (svn r1751) - Feature: New PathFinder (NPF).
matthijs
parents: 1217
diff changeset
    10
#include "tile.h"
2963
f28ce0549513 (svn r3525) - Rename station_newgrf.[ch] to newgrf_station.[ch], and update project files.
peter1138
parents: 2817
diff changeset
    11
#include "newgrf_station.h"
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    12
5670
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    13
static const StationID INVALID_STATION = 0xFFFF;
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    14
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    15
typedef struct GoodsEntry {
5670
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    16
	GoodsEntry() :
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    17
		waiting_acceptance(0),
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    18
		days_since_pickup(0),
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    19
		rating(175),
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    20
		enroute_from(INVALID_STATION),
5683
b027e5d5b4cd (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: 5676
diff changeset
    21
		enroute_from_xy(INVALID_TILE),
5670
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    22
		last_speed(0),
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    23
		last_age(255),
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    24
		feeder_profit(0)
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    25
	{}
1e0f505996dc (svn r8130) Provide struct GoodsEntry with a constructor
tron
parents: 5665
diff changeset
    26
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    27
	uint16 waiting_acceptance;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
	byte days_since_pickup;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    29
	byte rating;
3347
0ddacd451b81 (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
    30
	StationID enroute_from;
5683
b027e5d5b4cd (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: 5676
diff changeset
    31
	TileIndex enroute_from_xy;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    32
	byte enroute_time;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    33
	byte last_speed;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    34
	byte last_age;
1935
164d58b9137c (svn r2441) -Feature: You can now give transfer order to set up feeder systems
celestar
parents: 1802
diff changeset
    35
	int32 feeder_profit;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    36
} GoodsEntry;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    37
5836
a60d2114780e (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: 5835
diff changeset
    38
/** A Stop for a Road Vehicle */
a60d2114780e (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: 5835
diff changeset
    39
struct RoadStop {
a60d2114780e (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: 5835
diff changeset
    40
	/** Types of RoadStops */
a60d2114780e (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: 5835
diff changeset
    41
	enum Type {
a60d2114780e (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: 5835
diff changeset
    42
		BUS,                                ///< A standard stop for buses
a60d2114780e (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: 5835
diff changeset
    43
		TRUCK                               ///< A standard stop for trucks
a60d2114780e (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: 5835
diff changeset
    44
	};
5708
4c4c5ec2bed6 (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: 5683
diff changeset
    45
5837
e9c21cf7c7d9 (svn r8403) -Fix (r8402): Forgot to remove an enum
celestar
parents: 5836
diff changeset
    46
	static const int  cDebugCtorLevel =  3;  ///< Debug level on which Contructor / Destructor messages are printed
e9c21cf7c7d9 (svn r8403) -Fix (r8402): Forgot to remove an enum
celestar
parents: 5836
diff changeset
    47
	static const uint LIMIT           = 16;  ///< The maximum amount of roadstops that are allowed at a single station
5836
a60d2114780e (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: 5835
diff changeset
    48
a60d2114780e (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: 5835
diff changeset
    49
	TileIndex        xy;                    ///< Position on the map
a60d2114780e (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: 5835
diff changeset
    50
	RoadStopID       index;                 ///< Global (i.e. pool-wide) index
a60d2114780e (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: 5835
diff changeset
    51
	byte             status;                ///< Current status of the Stop. Like which spot is taken. TODO - enumify this
a60d2114780e (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: 5835
diff changeset
    52
	byte             num_vehicles;          ///< Number of vehicles currently slotted to this stop
a60d2114780e (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: 5835
diff changeset
    53
	struct RoadStop  *next;                 ///< Next stop of the given type at this station
5708
4c4c5ec2bed6 (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: 5683
diff changeset
    54
5716
7176379debd0 (svn r8207) -Fix
tron
parents: 5713
diff changeset
    55
	RoadStop(TileIndex tile);
5708
4c4c5ec2bed6 (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: 5683
diff changeset
    56
	~RoadStop();
4c4c5ec2bed6 (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: 5683
diff changeset
    57
4c4c5ec2bed6 (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: 5683
diff changeset
    58
	void *operator new (size_t size);
4c4c5ec2bed6 (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: 5683
diff changeset
    59
	void operator delete(void *rs);
4c4c5ec2bed6 (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: 5683
diff changeset
    60
4c4c5ec2bed6 (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: 5683
diff changeset
    61
	/* For loading games */
4c4c5ec2bed6 (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: 5683
diff changeset
    62
	void *operator new (size_t size, int index);
4c4c5ec2bed6 (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: 5683
diff changeset
    63
	void operator delete(void *rs, int index);
4c4c5ec2bed6 (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: 5683
diff changeset
    64
5835
7ef65a4a70ef (svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents: 5721
diff changeset
    65
	bool IsValid() const;
7ef65a4a70ef (svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents: 5721
diff changeset
    66
protected:
5713
979dc0617902 (svn r8203) -Fix:
tron
parents: 5708
diff changeset
    67
	static RoadStop *AllocateRaw(void);
5836
a60d2114780e (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: 5835
diff changeset
    68
};
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
    69
3587
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    70
typedef struct StationSpecList {
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    71
	const StationSpec *spec;
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    72
	uint32 grfid;      /// GRF ID of this custom station
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    73
	uint8  localidx;   /// Station ID within GRF of station
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    74
} StationSpecList;
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
    75
5676
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    76
/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    77
struct StationRect : public Rect {
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    78
	enum StationRectMode
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    79
	{
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    80
		ADD_TEST = 0,
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    81
		ADD_TRY,
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    82
		ADD_FORCE
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    83
	};
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    84
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    85
	StationRect();
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    86
	void MakeEmpty();
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    87
	bool PtInRectXY(int x, int y) const;
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    88
	bool IsEmpty() const;
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    89
	bool BeforeAddTile(TileIndex tile, StationRectMode mode);
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    90
	bool BeforeAddRect(TileIndex tile, int w, int h, StationRectMode mode);
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    91
	bool AfterRemoveTile(Station *st, TileIndex tile);
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    92
	bool AfterRemoveRect(Station *st, TileIndex tile, int w, int h);
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    93
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    94
	static bool ScanForStationTiles(StationID st_id, int left_a, int top_a, int right_a, int bottom_a);
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    95
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    96
	StationRect& operator = (Rect src);
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    97
};
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
    98
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
struct Station {
5876
01bdebe2e50b (svn r8474) -Fix
tron
parents: 5867
diff changeset
   100
	public:
01bdebe2e50b (svn r8474) -Fix
tron
parents: 5867
diff changeset
   101
		RoadStop *GetPrimaryRoadStop(RoadStop::Type type) const
01bdebe2e50b (svn r8474) -Fix
tron
parents: 5867
diff changeset
   102
		{
01bdebe2e50b (svn r8474) -Fix
tron
parents: 5867
diff changeset
   103
			return type == RoadStop::BUS ? bus_stops : truck_stops;
01bdebe2e50b (svn r8474) -Fix
tron
parents: 5867
diff changeset
   104
		}
01bdebe2e50b (svn r8474) -Fix
tron
parents: 5867
diff changeset
   105
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   106
	TileIndex xy;
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   107
	RoadStop *bus_stops;
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   108
	RoadStop *truck_stops;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   109
	TileIndex train_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   110
	TileIndex airport_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   111
	TileIndex dock_tile;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   112
	Town *town;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   113
	uint16 string_id;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   114
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   115
	ViewportSign sign;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   116
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   117
	uint16 had_vehicle_of_type;
193
0a7025304867 (svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents: 123
diff changeset
   118
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   119
	byte time_since_load;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   120
	byte time_since_unload;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
	byte delete_ctr;
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   122
	PlayerByte owner;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   123
	byte facilities;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   124
	byte airport_type;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   125
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   126
	// trainstation width/height
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   127
	byte trainst_w, trainst_h;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   128
3587
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
   129
	/** List of custom stations (StationSpecs) allocated to the station */
3786
ac7ff031ff5f (svn r4782) - Newstations: fix issue with saving/loading games with newstations on big endian architectures.
peter1138
parents: 3765
diff changeset
   130
	uint8 num_specs;
3587
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
   131
	StationSpecList *speclist;
c434d5c3dcaa (svn r4473) - Newstations:
peter1138
parents: 3580
diff changeset
   132
4289
8981ce44336d (svn r5919) -Cleanup: use the type Date when the variable really is a date
rubidium
parents: 4268
diff changeset
   133
	Date build_date;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   134
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   135
	//uint16 airport_flags;
393
e1128b94f3fb (svn r585) -newgrf: GUI for selecting custom waypoint graphics to use. Patch by dominik81 and pasky.
darkvater
parents: 389
diff changeset
   136
	uint32 airport_flags;
1551
b1c7df6daa63 (svn r2055) -CodeChange: Begun introducting StationID
celestar
parents: 1550
diff changeset
   137
	StationID index;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   138
3580
14bf6e7715c8 (svn r4466) -Fix: (FS#71) Game no longer crashes when the last vehicle serving a station has been deleted.
celestar
parents: 3574
diff changeset
   139
	byte last_vehicle_type;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   140
	GoodsEntry goods[NUM_CARGO];
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   141
3687
f421ffcfeb00 (svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents: 3587
diff changeset
   142
	uint16 random_bits;
f421ffcfeb00 (svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents: 3587
diff changeset
   143
	byte waiting_triggers;
f421ffcfeb00 (svn r4612) - NewStations: add random bits (for graphic variation) to stations
peter1138
parents: 3587
diff changeset
   144
5676
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
   145
	StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions
5665
d6b5c720ad67 (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: 5601
diff changeset
   146
5676
7a641ebbc080 (svn r8136) -Codechange: Station spread rectangle manipulators turned into StationRect::methods.
KUDr
parents: 5670
diff changeset
   147
	static const int cDebugCtorLevel = 3;
5665
d6b5c720ad67 (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: 5601
diff changeset
   148
d6b5c720ad67 (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: 5601
diff changeset
   149
	Station(TileIndex tile = 0);
d6b5c720ad67 (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: 5601
diff changeset
   150
	~Station();
d6b5c720ad67 (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: 5601
diff changeset
   151
d6b5c720ad67 (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: 5601
diff changeset
   152
	/* normal new/delete operators. Used when building/removing station */
d6b5c720ad67 (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: 5601
diff changeset
   153
	void* operator new (size_t size);
d6b5c720ad67 (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: 5601
diff changeset
   154
	void operator delete(void *p);
d6b5c720ad67 (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: 5601
diff changeset
   155
d6b5c720ad67 (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: 5601
diff changeset
   156
	/* new/delete operators accepting station index. Used when loading station from savegame. */
d6b5c720ad67 (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: 5601
diff changeset
   157
	void* operator new (size_t size, int st_idx);
d6b5c720ad67 (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: 5601
diff changeset
   158
	void operator delete(void *p, int st_idx);
d6b5c720ad67 (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: 5601
diff changeset
   159
5721
fa4e587f59f5 (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: 5718
diff changeset
   160
	void AddFacility(byte new_facility_bit, TileIndex facil_xy);
5665
d6b5c720ad67 (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: 5601
diff changeset
   161
	void MarkDirty() const;
d6b5c720ad67 (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: 5601
diff changeset
   162
	void MarkTilesDirty() const;
d6b5c720ad67 (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: 5601
diff changeset
   163
	bool TileBelongsToRailStation(TileIndex tile) const;
d6b5c720ad67 (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: 5601
diff changeset
   164
d6b5c720ad67 (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: 5601
diff changeset
   165
protected:
d6b5c720ad67 (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: 5601
diff changeset
   166
	static Station *AllocateRaw(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   167
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   168
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   169
enum {
4344
7e123fec5b0b (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
   170
	FACIL_TRAIN      = 0x01,
7e123fec5b0b (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
   171
	FACIL_TRUCK_STOP = 0x02,
7e123fec5b0b (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
   172
	FACIL_BUS_STOP   = 0x04,
7e123fec5b0b (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
   173
	FACIL_AIRPORT    = 0x08,
7e123fec5b0b (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
   174
	FACIL_DOCK       = 0x10,
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   175
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   176
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   177
enum {
4344
7e123fec5b0b (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
   178
//	HVOT_PENDING_DELETE = 1 << 0, // not needed anymore
3554
86230061c3e7 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   179
	HVOT_TRAIN    = 1 << 1,
86230061c3e7 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   180
	HVOT_BUS      = 1 << 2,
86230061c3e7 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   181
	HVOT_TRUCK    = 1 << 3,
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   182
	HVOT_AIRCRAFT = 1 << 4,
3554
86230061c3e7 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   183
	HVOT_SHIP     = 1 << 5,
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   184
	/* This bit is used to mark stations. No, it does not belong here, but what
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   185
	 * can we do? ;-) */
3554
86230061c3e7 (svn r4426) Code Cleaning : replacing tabs with spaces, removing obvious comments, aligning arrays etc...
belugas
parents: 3479
diff changeset
   186
	HVOT_BUOY     = 1 << 6
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   187
};
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   188
5601
d58f82901b2f (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: 5587
diff changeset
   189
typedef enum CatchmentAeras {
d58f82901b2f (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: 5587
diff changeset
   190
	CA_NONE            =  0,
4344
7e123fec5b0b (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
   191
	CA_BUS             =  3,
7e123fec5b0b (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
   192
	CA_TRUCK           =  3,
7e123fec5b0b (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
   193
	CA_AIR_OILPAD      =  3,
7e123fec5b0b (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
   194
	CA_TRAIN           =  4,
7e123fec5b0b (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
   195
	CA_AIR_HELIPORT    =  4,
7e123fec5b0b (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
	CA_AIR_SMALL       =  4,
7e123fec5b0b (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
	CA_AIR_LARGE       =  5,
7e123fec5b0b (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
	CA_DOCK            =  5,
7e123fec5b0b (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
	CA_AIR_METRO       =  6,
7e123fec5b0b (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
	CA_AIR_INTER       =  8,
7e123fec5b0b (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
   201
	CA_AIR_COMMUTER    =  4,
7e123fec5b0b (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
   202
	CA_AIR_HELIDEPOT   =  4,
4059
b1e1c1193f0a (svn r5346) - Feature: Add 4 new airports. 2 for aircraft, 2 for helicopters.
richk
parents: 3928
diff changeset
   203
	CA_AIR_INTERCON    = 10,
4344
7e123fec5b0b (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
	CA_AIR_HELISTATION =  4,
5601
d58f82901b2f (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: 5587
diff changeset
   205
} CatchmentAera;
568
b0d0df062880 (svn r979) Allow more realistically sized catchment areas
Celestar
parents: 449
diff changeset
   206
2498
3ed05caa4449 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2488
diff changeset
   207
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
   208
2498
3ed05caa4449 (svn r3024) -Codechange: Another batch of replacements of int/uint/int16/byte/-1 with proper types and constants
tron
parents: 2488
diff changeset
   209
void ShowStationViewWindow(StationID station);
1093
4fdc46eaf423 (svn r1594) Convert all undefined parameter lists to (void) and add the appropriate warning flags in the Makefile
tron
parents: 1024
diff changeset
   210
void UpdateAllStationVirtCoord(void);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
3812
e6fc916c17ab (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3786
diff changeset
   212
/* sorter stuff */
e6fc916c17ab (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3786
diff changeset
   213
void RebuildStationLists(void);
e6fc916c17ab (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3786
diff changeset
   214
void ResortStationLists(void);
e6fc916c17ab (svn r4822) -Feature: Station List View can now be sorted and filtered (by waiting cargo type and facilities)
celestar
parents: 3786
diff changeset
   215
5216
8bd14ee39af2 (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
   216
DECLARE_OLD_POOL(Station, Station, 6, 1000)
1272
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   217
5247
1f982de55b88 (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
   218
static inline StationID GetMaxStationIndex(void)
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   219
{
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   220
	/* TODO - This isn't the real content of the function, but
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   221
	 *  with the new pool-system this will be replaced with one that
5247
1f982de55b88 (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
   222
	 *  _really_ returns the highest index. Now it just returns
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   223
	 *  the next safe value we are sure about everything is below.
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   224
	 */
5247
1f982de55b88 (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
   225
	return GetStationPoolSize() - 1;
1f982de55b88 (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
   226
}
1f982de55b88 (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
   227
1f982de55b88 (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
   228
static inline uint GetNumStations(void)
1f982de55b88 (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
   229
{
4354
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   230
	return GetStationPoolSize();
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   231
}
10f4ce894eb1 (svn r6055) -Codechange: added GetXXXArraySize, which returns HighestID + 1 (or, will do that).
truelight
parents: 4352
diff changeset
   232
4346
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   233
/**
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   234
 * Check if a station really exists.
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   235
 */
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   236
static inline bool IsValidStation(const Station *st)
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   237
{
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   238
	return st->xy != 0;
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   239
}
66105d4f6e83 (svn r6047) -Codechange: FOR_ALL now _only_ loops valid items, and skips invalid ones
truelight
parents: 4344
diff changeset
   240
4352
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   241
static inline bool IsValidStationID(StationID index)
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   242
{
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   243
	return index < GetStationPoolSize() && IsValidStation(GetStation(index));
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   244
}
6703cd8d39e0 (svn r6053) -Codechange: renamed all IsXXXIndex to IsValidXXXID
truelight
parents: 4346
diff changeset
   245
4980
1e1cb22b3d27 (svn r6983) Use the pool macros for the Station pool
tron
parents: 4440
diff changeset
   246
#define FOR_ALL_STATIONS_FROM(st, start) for (st = GetStation(start); st != NULL; st = (st->index + 1U < GetStationPoolSize()) ? GetStation(st->index + 1U) : NULL) if (IsValidStation(st))
1272
9aa073c64fc7 (svn r1776) -Add: Dynamic stations. You can now have up to 64k of stations
truelight
parents: 1266
diff changeset
   247
#define FOR_ALL_STATIONS(st) FOR_ALL_STATIONS_FROM(st, 0)
919
544f374ee392 (svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
truelight
parents: 915
diff changeset
   248
1284
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   249
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   250
/* Stuff for ROADSTOPS */
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   251
5216
8bd14ee39af2 (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
   252
DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000)
1284
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   253
5835
7ef65a4a70ef (svn r8401) -Codechange: Make 'IsValidRoadStop' a method of RoadStop and rename it to 'IsValid'
celestar
parents: 5721
diff changeset
   254
#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
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   255
#define FOR_ALL_ROADSTOPS(rs) FOR_ALL_ROADSTOPS_FROM(rs, 0)
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   256
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   257
/* End of stuff for ROADSTOPS */
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   258
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   259
3765
a4ddbff73f9f (svn r4757) - Newstations: add saveload support for custom station speclists
peter1138
parents: 3763
diff changeset
   260
void AfterLoadStations(void);
1424
38b76de179c9 (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents: 1368
diff changeset
   261
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, int w, int h, int rad);
38b76de179c9 (svn r1928) Miscellaneous cleanups (data types, whitespace, const correctness)
tron
parents: 1368
diff changeset
   262
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile, int w, int h, int rad);
2436
7d5df545bd5d (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2186
diff changeset
   263
uint GetStationPlatforms(const Station *st, TileIndex tile);
3928
53fe96558353 (svn r5063) -Codechange: Add a function to determine the length of a platform (request by KUDr)
celestar
parents: 3900
diff changeset
   264
uint GetPlatformLength(TileIndex tile, DiagDirection dir);
384
809833b4068d (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   265
809833b4068d (svn r576) -newgrf: Cleanup horrible table/(station|unmovable)_land.h DrawTileSeqStruct hacks needed for custom station supports (pasky)
darkvater
parents: 243
diff changeset
   266
3763
7098c393c172 (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
   267
const DrawTileSprites *GetStationTileLayout(byte gfx);
2520
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2498
diff changeset
   268
void StationPickerDrawSprite(int x, int y, RailType railtype, int image);
8a52362c4ada (svn r3049) Replace byte/int/uint by RailType where appropriate
tron
parents: 2498
diff changeset
   269
5836
a60d2114780e (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: 5835
diff changeset
   270
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type);
a60d2114780e (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: 5835
diff changeset
   271
uint GetNumRoadStops(const Station* st, RoadStop::Type type);
1284
e1969eb0227b (svn r1788) -Add: Made RoadStops dynamic. You can now create up to 64k roadstops.
truelight
parents: 1272
diff changeset
   272
RoadStop * AllocateRoadStop( void );
3123
ad1ec737e974 (svn r3730) Multistop modifications:
celestar
parents: 3092
diff changeset
   273
void ClearSlot(Vehicle *v);
1217
59c024cfaf54 (svn r1721) -Feature: It is now possible to build multiple road stations (up to 8) on
celestar
parents: 1093
diff changeset
   274
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   275
static inline bool IsBuoy(const Station* st)
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   276
{
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3812
diff changeset
   277
	return (st->had_vehicle_of_type & HVOT_BUOY) != 0; /* XXX: We should really ditch this ugly coding and switch to something sane... */
1751
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   278
}
009a240d035a (svn r2255) - Fix: [ 9680363 ] [NPF] Broken buoy handling for ships
matthijs
parents: 1742
diff changeset
   279
5884
0c9a9c61ca76 (svn r8485) -Fix
tron
parents: 5879
diff changeset
   280
void DeleteOilRig(TileIndex t);
0c9a9c61ca76 (svn r8485) -Fix
tron
parents: 5879
diff changeset
   281
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
#endif /* STATION_H */