22 DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000) |
22 DECLARE_OLD_POOL(RoadStop, RoadStop, 5, 2000) |
23 |
23 |
24 static const byte INITIAL_STATION_RATING = 175; |
24 static const byte INITIAL_STATION_RATING = 175; |
25 |
25 |
26 struct GoodsEntry { |
26 struct GoodsEntry { |
|
27 enum AcceptancePickup { |
|
28 ACCEPTANCE, |
|
29 PICKUP |
|
30 }; |
|
31 |
27 GoodsEntry() : |
32 GoodsEntry() : |
28 acceptance(false), |
33 acceptance_pickup(0), |
29 days_since_pickup(255), |
34 days_since_pickup(255), |
30 rating(INITIAL_STATION_RATING), |
35 rating(INITIAL_STATION_RATING), |
31 last_speed(0), |
36 last_speed(0), |
32 last_age(255) |
37 last_age(255) |
33 {} |
38 {} |
34 |
39 |
35 bool acceptance; |
40 byte acceptance_pickup; |
36 byte days_since_pickup; |
41 byte days_since_pickup; |
37 byte rating; |
42 byte rating; |
38 byte last_speed; |
43 byte last_speed; |
39 byte last_age; |
44 byte last_age; |
40 CargoList cargo; ///< The cargo packets of cargo waiting in this station |
45 CargoList cargo; ///< The cargo packets of cargo waiting in this station |
46 enum Type { |
51 enum Type { |
47 BUS, ///< A standard stop for buses |
52 BUS, ///< A standard stop for buses |
48 TRUCK ///< A standard stop for trucks |
53 TRUCK ///< A standard stop for trucks |
49 }; |
54 }; |
50 |
55 |
51 static const int cDebugCtorLevel = 3; ///< Debug level on which Contructor / Destructor messages are printed |
56 static const int cDebugCtorLevel = 5; ///< Debug level on which Contructor / Destructor messages are printed |
52 static const uint LIMIT = 16; ///< The maximum amount of roadstops that are allowed at a single station |
57 static const uint LIMIT = 16; ///< The maximum amount of roadstops that are allowed at a single station |
53 static const uint MAX_BAY_COUNT = 2; ///< The maximum number of loading bays |
58 static const uint MAX_BAY_COUNT = 2; ///< The maximum number of loading bays |
54 |
59 |
55 TileIndex xy; ///< Position on the map |
60 TileIndex xy; ///< Position on the map |
56 byte status; ///< Current status of the Stop. Like which spot is taken. Access using *Bay and *Busy functions. |
61 byte status; ///< Current status of the Stop. Like which spot is taken. Access using *Bay and *Busy functions. |
58 struct RoadStop *next; ///< Next stop of the given type at this station |
63 struct RoadStop *next; ///< Next stop of the given type at this station |
59 |
64 |
60 RoadStop(TileIndex tile = 0); |
65 RoadStop(TileIndex tile = 0); |
61 virtual ~RoadStop(); |
66 virtual ~RoadStop(); |
62 |
67 |
63 bool IsValid() const; |
68 /** |
|
69 * Determines whether a road stop exists |
|
70 * @return true if and only is the road stop exists |
|
71 */ |
|
72 inline bool IsValid() const { return this->xy != 0; } |
64 |
73 |
65 /* For accessing status */ |
74 /* For accessing status */ |
66 bool HasFreeBay() const; |
75 bool HasFreeBay() const; |
67 bool IsFreeBay(uint nr) const; |
76 bool IsFreeBay(uint nr) const; |
68 uint AllocateBay(); |
77 uint AllocateBay(); |
69 void AllocateDriveThroughBay(uint nr); |
78 void AllocateDriveThroughBay(uint nr); |
70 void FreeBay(uint nr); |
79 void FreeBay(uint nr); |
71 bool IsEntranceBusy() const; |
80 bool IsEntranceBusy() const; |
72 void SetEntranceBusy(bool busy); |
81 void SetEntranceBusy(bool busy); |
|
82 |
|
83 RoadStop *GetNextRoadStop(const Vehicle *v) const; |
73 }; |
84 }; |
74 |
85 |
75 struct StationSpecList { |
86 struct StationSpecList { |
76 const StationSpec *spec; |
87 const StationSpec *spec; |
77 uint32 grfid; ///< GRF ID of this custom station |
88 uint32 grfid; ///< GRF ID of this custom station |
100 |
111 |
101 StationRect& operator = (Rect src); |
112 StationRect& operator = (Rect src); |
102 }; |
113 }; |
103 |
114 |
104 struct Station : PoolItem<Station, StationID, &_Station_pool> { |
115 struct Station : PoolItem<Station, StationID, &_Station_pool> { |
105 public: |
116 public: |
106 RoadStop *GetPrimaryRoadStop(RoadStop::Type type) const |
117 RoadStop *GetPrimaryRoadStop(RoadStop::Type type) const |
107 { |
118 { |
108 return type == RoadStop::BUS ? bus_stops : truck_stops; |
119 return type == RoadStop::BUS ? bus_stops : truck_stops; |
109 } |
120 } |
110 |
121 |
111 const AirportFTAClass *Airport() const |
122 RoadStop *GetPrimaryRoadStop(const Vehicle *v) const; |
112 { |
123 |
113 if (airport_tile == 0) return GetAirport(AT_DUMMY); |
124 const AirportFTAClass *Airport() const |
114 return GetAirport(airport_type); |
125 { |
115 } |
126 if (airport_tile == 0) return GetAirport(AT_DUMMY); |
|
127 return GetAirport(airport_type); |
|
128 } |
116 |
129 |
117 TileIndex xy; |
130 TileIndex xy; |
118 RoadStop *bus_stops; |
131 RoadStop *bus_stops; |
119 RoadStop *truck_stops; |
132 RoadStop *truck_stops; |
120 TileIndex train_tile; |
133 TileIndex train_tile; |
152 uint16 random_bits; |
165 uint16 random_bits; |
153 byte waiting_triggers; |
166 byte waiting_triggers; |
154 |
167 |
155 StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions |
168 StationRect rect; ///< Station spread out rectangle (not saved) maintained by StationRect_xxx() functions |
156 |
169 |
157 static const int cDebugCtorLevel = 3; |
170 static const int cDebugCtorLevel = 5; |
158 |
171 |
159 Station(TileIndex tile = 0); |
172 Station(TileIndex tile = 0); |
160 virtual ~Station(); |
173 virtual ~Station(); |
161 |
|
162 void QuickFree(); |
|
163 |
174 |
164 void AddFacility(byte new_facility_bit, TileIndex facil_xy); |
175 void AddFacility(byte new_facility_bit, TileIndex facil_xy); |
165 void MarkDirty() const; |
176 void MarkDirty() const; |
166 void MarkTilesDirty(bool cargo_change) const; |
177 void MarkTilesDirty(bool cargo_change) const; |
167 bool TileBelongsToRailStation(TileIndex tile) const; |
178 bool TileBelongsToRailStation(TileIndex tile) const; |
168 uint GetPlatformLength(TileIndex tile, DiagDirection dir) const; |
179 uint GetPlatformLength(TileIndex tile, DiagDirection dir) const; |
169 uint GetPlatformLength(TileIndex tile) const; |
180 uint GetPlatformLength(TileIndex tile) const; |
170 bool IsBuoy() const; |
181 bool IsBuoy() const; |
171 bool IsValid() const; |
182 |
|
183 /** |
|
184 * Determines whether a station exists |
|
185 * @return true if and only is the station exists |
|
186 */ |
|
187 inline bool IsValid() const { return this->xy != 0; } |
172 }; |
188 }; |
173 |
189 |
174 enum StationType { |
190 enum StationType { |
175 STATION_RAIL, |
191 STATION_RAIL, |
176 STATION_AIRPORT, |
192 STATION_AIRPORT, |