1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
7
8 /** @file station_map.h Maps accessors for stations. */
9
10 #ifndef STATION_MAP_H
11 #define STATION_MAP_H
12
13 #include "rail_map.h"
14 #include "road_map.h"
15 #include "water_map.h"
16 #include "station_func.h"
17 #include "rail.h"
18 #include "road.h"
19
20 typedef byte StationGfx; ///< Index of station graphics. @see _station_display_datas
21
22 /**
23 * Get StationID from a tile
24 * @param t Tile to query station ID from
25 * @pre IsTileType(t, MP_STATION)
26 * @return Station ID of the station at \a t
27 */
GetStationIndex(TileIndex t)28 static inline StationID GetStationIndex(TileIndex t)
29 {
30 assert(IsTileType(t, MP_STATION));
31 return (StationID)_m[t].m2;
32 }
33
34
35 static const int GFX_DOCK_BASE_WATER_PART = 4; ///< The offset for the water parts.
36 static const int GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET = 4; ///< The offset for the drive through parts.
37
38 /**
39 * Get the station type of this tile
40 * @param t the tile to query
41 * @pre IsTileType(t, MP_STATION)
42 * @return the station type
43 */
GetStationType(TileIndex t)44 static inline StationType GetStationType(TileIndex t)
45 {
46 assert(IsTileType(t, MP_STATION));
47 return (StationType)GB(_me[t].m6, 3, 3);
48 }
49
50 /**
51 * Get the road stop type of this tile
52 * @param t the tile to query
53 * @pre GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS
54 * @return the road stop type
55 */
GetRoadStopType(TileIndex t)56 static inline RoadStopType GetRoadStopType(TileIndex t)
57 {
58 assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
59 return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
60 }
61
62 /**
63 * Get the station graphics of this tile
64 * @param t the tile to query
65 * @pre IsTileType(t, MP_STATION)
66 * @return the station graphics
67 */
GetStationGfx(TileIndex t)68 static inline StationGfx GetStationGfx(TileIndex t)
69 {
70 assert(IsTileType(t, MP_STATION));
71 return _m[t].m5;
72 }
73
74 /**
75 * Set the station graphics of this tile
76 * @param t the tile to update
77 * @param gfx the new graphics
78 * @pre IsTileType(t, MP_STATION)
79 */
SetStationGfx(TileIndex t,StationGfx gfx)80 static inline void SetStationGfx(TileIndex t, StationGfx gfx)
81 {
82 assert(IsTileType(t, MP_STATION));
83 _m[t].m5 = gfx;
84 }
85
86 /**
87 * Is this station tile a rail station?
88 * @param t the tile to get the information from
89 * @pre IsTileType(t, MP_STATION)
90 * @return true if and only if the tile is a rail station
91 */
IsRailStation(TileIndex t)92 static inline bool IsRailStation(TileIndex t)
93 {
94 return GetStationType(t) == STATION_RAIL;
95 }
96
97 /**
98 * Is this tile a station tile and a rail station?
99 * @param t the tile to get the information from
100 * @return true if and only if the tile is a rail station
101 */
IsRailStationTile(TileIndex t)102 static inline bool IsRailStationTile(TileIndex t)
103 {
104 return IsTileType(t, MP_STATION) && IsRailStation(t);
105 }
106
107 /**
108 * Is this station tile a rail waypoint?
109 * @param t the tile to get the information from
110 * @pre IsTileType(t, MP_STATION)
111 * @return true if and only if the tile is a rail waypoint
112 */
IsRailWaypoint(TileIndex t)113 static inline bool IsRailWaypoint(TileIndex t)
114 {
115 return GetStationType(t) == STATION_WAYPOINT;
116 }
117
118 /**
119 * Is this tile a station tile and a rail waypoint?
120 * @param t the tile to get the information from
121 * @return true if and only if the tile is a rail waypoint
122 */
IsRailWaypointTile(TileIndex t)123 static inline bool IsRailWaypointTile(TileIndex t)
124 {
125 return IsTileType(t, MP_STATION) && IsRailWaypoint(t);
126 }
127
128 /**
129 * Has this station tile a rail? In other words, is this station
130 * tile a rail station or rail waypoint?
131 * @param t the tile to check
132 * @pre IsTileType(t, MP_STATION)
133 * @return true if and only if the tile has rail
134 */
HasStationRail(TileIndex t)135 static inline bool HasStationRail(TileIndex t)
136 {
137 return IsRailStation(t) || IsRailWaypoint(t);
138 }
139
140 /**
141 * Has this station tile a rail? In other words, is this station
142 * tile a rail station or rail waypoint?
143 * @param t the tile to check
144 * @return true if and only if the tile is a station tile and has rail
145 */
HasStationTileRail(TileIndex t)146 static inline bool HasStationTileRail(TileIndex t)
147 {
148 return IsTileType(t, MP_STATION) && HasStationRail(t);
149 }
150
151 /**
152 * Is this station tile an airport?
153 * @param t the tile to get the information from
154 * @pre IsTileType(t, MP_STATION)
155 * @return true if and only if the tile is an airport
156 */
IsAirport(TileIndex t)157 static inline bool IsAirport(TileIndex t)
158 {
159 return GetStationType(t) == STATION_AIRPORT;
160 }
161
162 /**
163 * Is this tile a station tile and an airport tile?
164 * @param t the tile to get the information from
165 * @return true if and only if the tile is an airport
166 */
IsAirportTile(TileIndex t)167 static inline bool IsAirportTile(TileIndex t)
168 {
169 return IsTileType(t, MP_STATION) && IsAirport(t);
170 }
171
172 bool IsHangar(TileIndex t);
173
174 /**
175 * Is the station at \a t a truck stop?
176 * @param t Tile to check
177 * @pre IsTileType(t, MP_STATION)
178 * @return \c true if station is a truck stop, \c false otherwise
179 */
IsTruckStop(TileIndex t)180 static inline bool IsTruckStop(TileIndex t)
181 {
182 return GetStationType(t) == STATION_TRUCK;
183 }
184
185 /**
186 * Is the station at \a t a bus stop?
187 * @param t Tile to check
188 * @pre IsTileType(t, MP_STATION)
189 * @return \c true if station is a bus stop, \c false otherwise
190 */
IsBusStop(TileIndex t)191 static inline bool IsBusStop(TileIndex t)
192 {
193 return GetStationType(t) == STATION_BUS;
194 }
195
196 /**
197 * Is the station at \a t a road station?
198 * @param t Tile to check
199 * @pre IsTileType(t, MP_STATION)
200 * @return \c true if station at the tile is a bus top or a truck stop, \c false otherwise
201 */
IsRoadStop(TileIndex t)202 static inline bool IsRoadStop(TileIndex t)
203 {
204 assert(IsTileType(t, MP_STATION));
205 return IsTruckStop(t) || IsBusStop(t);
206 }
207
208 /**
209 * Is tile \a t a road stop station?
210 * @param t Tile to check
211 * @return \c true if the tile is a station tile and a road stop
212 */
IsRoadStopTile(TileIndex t)213 static inline bool IsRoadStopTile(TileIndex t)
214 {
215 return IsTileType(t, MP_STATION) && IsRoadStop(t);
216 }
217
218 /**
219 * Is tile \a t a standard (non-drive through) road stop station?
220 * @param t Tile to check
221 * @return \c true if the tile is a station tile and a standard road stop
222 */
IsStandardRoadStopTile(TileIndex t)223 static inline bool IsStandardRoadStopTile(TileIndex t)
224 {
225 return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
226 }
227
228 /**
229 * Is tile \a t a drive through road stop station?
230 * @param t Tile to check
231 * @return \c true if the tile is a station tile and a drive through road stop
232 */
IsDriveThroughStopTile(TileIndex t)233 static inline bool IsDriveThroughStopTile(TileIndex t)
234 {
235 return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
236 }
237
238 /**
239 * Get the station graphics of this airport tile
240 * @param t the tile to query
241 * @pre IsAirport(t)
242 * @return the station graphics
243 */
GetAirportGfx(TileIndex t)244 static inline StationGfx GetAirportGfx(TileIndex t)
245 {
246 assert(IsAirport(t));
247 extern StationGfx GetTranslatedAirportTileID(StationGfx gfx);
248 return GetTranslatedAirportTileID(GetStationGfx(t));
249 }
250
251 /**
252 * Gets the direction the road stop entrance points towards.
253 * @param t the tile of the road stop
254 * @pre IsRoadStopTile(t)
255 * @return the direction of the entrance
256 */
GetRoadStopDir(TileIndex t)257 static inline DiagDirection GetRoadStopDir(TileIndex t)
258 {
259 StationGfx gfx = GetStationGfx(t);
260 assert(IsRoadStopTile(t));
261 if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
262 return (DiagDirection)(gfx);
263 } else {
264 return (DiagDirection)(gfx - GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET);
265 }
266 }
267
268 /**
269 * Is tile \a t part of an oilrig?
270 * @param t Tile to check
271 * @pre IsTileType(t, MP_STATION)
272 * @return \c true if the tile is an oilrig tile
273 */
IsOilRig(TileIndex t)274 static inline bool IsOilRig(TileIndex t)
275 {
276 return GetStationType(t) == STATION_OILRIG;
277 }
278
279 /**
280 * Is tile \a t a dock tile?
281 * @param t Tile to check
282 * @pre IsTileType(t, MP_STATION)
283 * @return \c true if the tile is a dock
284 */
IsDock(TileIndex t)285 static inline bool IsDock(TileIndex t)
286 {
287 return GetStationType(t) == STATION_DOCK;
288 }
289
290 /**
291 * Is tile \a t a dock tile?
292 * @param t Tile to check
293 * @return \c true if the tile is a dock
294 */
IsDockTile(TileIndex t)295 static inline bool IsDockTile(TileIndex t)
296 {
297 return IsTileType(t, MP_STATION) && GetStationType(t) == STATION_DOCK;
298 }
299
300 /**
301 * Is tile \a t a buoy tile?
302 * @param t Tile to check
303 * @pre IsTileType(t, MP_STATION)
304 * @return \c true if the tile is a buoy
305 */
IsBuoy(TileIndex t)306 static inline bool IsBuoy(TileIndex t)
307 {
308 return GetStationType(t) == STATION_BUOY;
309 }
310
311 /**
312 * Is tile \a t a buoy tile?
313 * @param t Tile to check
314 * @return \c true if the tile is a buoy
315 */
IsBuoyTile(TileIndex t)316 static inline bool IsBuoyTile(TileIndex t)
317 {
318 return IsTileType(t, MP_STATION) && IsBuoy(t);
319 }
320
321 /**
322 * Is tile \a t an hangar tile?
323 * @param t Tile to check
324 * @return \c true if the tile is an hangar
325 */
IsHangarTile(TileIndex t)326 static inline bool IsHangarTile(TileIndex t)
327 {
328 return IsTileType(t, MP_STATION) && IsHangar(t);
329 }
330
331 /**
332 * Get the rail direction of a rail station.
333 * @param t Tile to query
334 * @pre HasStationRail(t)
335 * @return The direction of the rails on tile \a t.
336 */
GetRailStationAxis(TileIndex t)337 static inline Axis GetRailStationAxis(TileIndex t)
338 {
339 assert(HasStationRail(t));
340 return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
341 }
342
343 /**
344 * Get the rail track of a rail station tile.
345 * @param t Tile to query
346 * @pre HasStationRail(t)
347 * @return The rail track of the rails on tile \a t.
348 */
GetRailStationTrack(TileIndex t)349 static inline Track GetRailStationTrack(TileIndex t)
350 {
351 return AxisToTrack(GetRailStationAxis(t));
352 }
353
354 /**
355 * Get the trackbits of a rail station tile.
356 * @param t Tile to query
357 * @pre HasStationRail(t)
358 * @return The trackbits of the rails on tile \a t.
359 */
GetRailStationTrackBits(TileIndex t)360 static inline TrackBits GetRailStationTrackBits(TileIndex t)
361 {
362 return AxisToTrackBits(GetRailStationAxis(t));
363 }
364
365 /**
366 * Check if a tile is a valid continuation to a railstation tile.
367 * The tile \a test_tile is a valid continuation to \a station_tile, if all of the following are true:
368 * \li \a test_tile is a rail station tile
369 * \li the railtype of \a test_tile is compatible with the railtype of \a station_tile
370 * \li the tracks on \a test_tile and \a station_tile are in the same direction
371 * \li both tiles belong to the same station
372 * \li \a test_tile is not blocked (@see IsStationTileBlocked)
373 * @param test_tile Tile to test
374 * @param station_tile Station tile to compare with
375 * @pre IsRailStationTile(station_tile)
376 * @return true if the two tiles are compatible
377 */
IsCompatibleTrainStationTile(TileIndex test_tile,TileIndex station_tile)378 static inline bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
379 {
380 assert(IsRailStationTile(station_tile));
381 return IsRailStationTile(test_tile) && IsCompatibleRail(GetRailType(test_tile), GetRailType(station_tile)) &&
382 GetRailStationAxis(test_tile) == GetRailStationAxis(station_tile) &&
383 GetStationIndex(test_tile) == GetStationIndex(station_tile) &&
384 !IsStationTileBlocked(test_tile);
385 }
386
387 /**
388 * Get the reservation state of the rail station
389 * @pre HasStationRail(t)
390 * @param t the station tile
391 * @return reservation state
392 */
HasStationReservation(TileIndex t)393 static inline bool HasStationReservation(TileIndex t)
394 {
395 assert(HasStationRail(t));
396 return HasBit(_me[t].m6, 2);
397 }
398
399 /**
400 * Set the reservation state of the rail station
401 * @pre HasStationRail(t)
402 * @param t the station tile
403 * @param b the reservation state
404 */
SetRailStationReservation(TileIndex t,bool b)405 static inline void SetRailStationReservation(TileIndex t, bool b)
406 {
407 assert(HasStationRail(t));
408 SB(_me[t].m6, 2, 1, b ? 1 : 0);
409 }
410
411 /**
412 * Get the reserved track bits for a waypoint
413 * @pre HasStationRail(t)
414 * @param t the tile
415 * @return reserved track bits
416 */
GetStationReservationTrackBits(TileIndex t)417 static inline TrackBits GetStationReservationTrackBits(TileIndex t)
418 {
419 return HasStationReservation(t) ? GetRailStationTrackBits(t) : TRACK_BIT_NONE;
420 }
421
422 /**
423 * Get the direction of a dock.
424 * @param t Tile to query
425 * @pre IsDock(t)
426 * @pre \a t is the land part of the dock
427 * @return The direction of the dock on tile \a t.
428 */
GetDockDirection(TileIndex t)429 static inline DiagDirection GetDockDirection(TileIndex t)
430 {
431 StationGfx gfx = GetStationGfx(t);
432 assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART);
433 return (DiagDirection)(gfx);
434 }
435
436 /**
437 * Get the tileoffset from this tile a ship should target to get to this dock.
438 * @param t Tile to query
439 * @pre IsTileType(t, MP_STATION)
440 * @pre IsBuoy(t) || IsOilRig(t) || IsDock(t)
441 * @return The offset from this tile that should be used as destination for ships.
442 */
GetDockOffset(TileIndex t)443 static inline TileIndexDiffC GetDockOffset(TileIndex t)
444 {
445 static const TileIndexDiffC buoy_offset = {0, 0};
446 static const TileIndexDiffC oilrig_offset = {2, 0};
447 static const TileIndexDiffC dock_offset[DIAGDIR_END] = {
448 {-2, 0},
449 { 0, 2},
450 { 2, 0},
451 { 0, -2},
452 };
453 assert(IsTileType(t, MP_STATION));
454
455 if (IsBuoy(t)) return buoy_offset;
456 if (IsOilRig(t)) return oilrig_offset;
457
458 assert(IsDock(t));
459
460 return dock_offset[GetDockDirection(t)];
461 }
462
463 /**
464 * Is there a custom rail station spec on this tile?
465 * @param t Tile to query
466 * @pre HasStationTileRail(t)
467 * @return True if this station is part of a newgrf station.
468 */
IsCustomStationSpecIndex(TileIndex t)469 static inline bool IsCustomStationSpecIndex(TileIndex t)
470 {
471 assert(HasStationTileRail(t));
472 return _m[t].m4 != 0;
473 }
474
475 /**
476 * Set the custom station spec for this tile.
477 * @param t Tile to set the stationspec of.
478 * @param specindex The new spec.
479 * @pre HasStationTileRail(t)
480 */
SetCustomStationSpecIndex(TileIndex t,byte specindex)481 static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
482 {
483 assert(HasStationTileRail(t));
484 _m[t].m4 = specindex;
485 }
486
487 /**
488 * Get the custom station spec for this tile.
489 * @param t Tile to query
490 * @pre HasStationTileRail(t)
491 * @return The custom station spec of this tile.
492 */
GetCustomStationSpecIndex(TileIndex t)493 static inline uint GetCustomStationSpecIndex(TileIndex t)
494 {
495 assert(HasStationTileRail(t));
496 return _m[t].m4;
497 }
498
499 /**
500 * Set the random bits for a station tile.
501 * @param t Tile to set random bits for.
502 * @param random_bits The random bits.
503 * @pre IsTileType(t, MP_STATION)
504 */
SetStationTileRandomBits(TileIndex t,byte random_bits)505 static inline void SetStationTileRandomBits(TileIndex t, byte random_bits)
506 {
507 assert(IsTileType(t, MP_STATION));
508 SB(_m[t].m3, 4, 4, random_bits);
509 }
510
511 /**
512 * Get the random bits of a station tile.
513 * @param t Tile to query
514 * @pre IsTileType(t, MP_STATION)
515 * @return The random bits for this station tile.
516 */
GetStationTileRandomBits(TileIndex t)517 static inline byte GetStationTileRandomBits(TileIndex t)
518 {
519 assert(IsTileType(t, MP_STATION));
520 return GB(_m[t].m3, 4, 4);
521 }
522
523 /**
524 * Make the given tile a station tile.
525 * @param t the tile to make a station tile
526 * @param o the owner of the station
527 * @param sid the station to which this tile belongs
528 * @param st the type this station tile
529 * @param section the StationGfx to be used for this tile
530 * @param wc The water class of the station
531 */
532 static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section, WaterClass wc = WATER_CLASS_INVALID)
533 {
534 SetTileType(t, MP_STATION);
535 SetTileOwner(t, o);
536 SetWaterClass(t, wc);
537 SetDockingTile(t, false);
538 _m[t].m2 = sid;
539 _m[t].m3 = 0;
540 _m[t].m4 = 0;
541 _m[t].m5 = section;
542 SB(_me[t].m6, 2, 1, 0);
543 SB(_me[t].m6, 3, 3, st);
544 _me[t].m7 = 0;
545 _me[t].m8 = 0;
546 }
547
548 /**
549 * Make the given tile a rail station tile.
550 * @param t the tile to make a rail station tile
551 * @param o the owner of the station
552 * @param sid the station to which this tile belongs
553 * @param a the axis of this tile
554 * @param section the StationGfx to be used for this tile
555 * @param rt the railtype of this tile
556 */
MakeRailStation(TileIndex t,Owner o,StationID sid,Axis a,byte section,RailType rt)557 static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
558 {
559 MakeStation(t, o, sid, STATION_RAIL, section + a);
560 SetRailType(t, rt);
561 SetRailStationReservation(t, false);
562 }
563
564 /**
565 * Make the given tile a rail waypoint tile.
566 * @param t the tile to make a rail waypoint
567 * @param o the owner of the waypoint
568 * @param sid the waypoint to which this tile belongs
569 * @param a the axis of this tile
570 * @param section the StationGfx to be used for this tile
571 * @param rt the railtype of this tile
572 */
MakeRailWaypoint(TileIndex t,Owner o,StationID sid,Axis a,byte section,RailType rt)573 static inline void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
574 {
575 MakeStation(t, o, sid, STATION_WAYPOINT, section + a);
576 SetRailType(t, rt);
577 SetRailStationReservation(t, false);
578 }
579
580 /**
581 * Make the given tile a roadstop tile.
582 * @param t the tile to make a roadstop
583 * @param o the owner of the roadstop
584 * @param sid the station to which this tile belongs
585 * @param rst the type of roadstop to make this tile
586 * @param road_rt the road roadtype on this tile
587 * @param tram_rt the tram roadtype on this tile
588 * @param d the direction of the roadstop
589 */
MakeRoadStop(TileIndex t,Owner o,StationID sid,RoadStopType rst,RoadType road_rt,RoadType tram_rt,DiagDirection d)590 static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
591 {
592 MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
593 SetRoadTypes(t, road_rt, tram_rt);
594 SetRoadOwner(t, RTT_ROAD, o);
595 SetRoadOwner(t, RTT_TRAM, o);
596 }
597
598 /**
599 * Make the given tile a drivethrough roadstop tile.
600 * @param t the tile to make a roadstop
601 * @param station the owner of the roadstop
602 * @param road the owner of the road
603 * @param tram the owner of the tram
604 * @param sid the station to which this tile belongs
605 * @param rst the type of roadstop to make this tile
606 * @param road_rt the road roadtype on this tile
607 * @param tram_rt the tram roadtype on this tile
608 * @param a the direction of the roadstop
609 */
MakeDriveThroughRoadStop(TileIndex t,Owner station,Owner road,Owner tram,StationID sid,RoadStopType rst,RoadType road_rt,RoadType tram_rt,Axis a)610 static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, Axis a)
611 {
612 MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
613 SetRoadTypes(t, road_rt, tram_rt);
614 SetRoadOwner(t, RTT_ROAD, road);
615 SetRoadOwner(t, RTT_TRAM, tram);
616 }
617
618 /**
619 * Make the given tile an airport tile.
620 * @param t the tile to make a airport
621 * @param o the owner of the airport
622 * @param sid the station to which this tile belongs
623 * @param section the StationGfx to be used for this tile
624 * @param wc the type of water on this tile
625 */
MakeAirport(TileIndex t,Owner o,StationID sid,byte section,WaterClass wc)626 static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section, WaterClass wc)
627 {
628 MakeStation(t, o, sid, STATION_AIRPORT, section, wc);
629 }
630
631 /**
632 * Make the given tile a buoy tile.
633 * @param t the tile to make a buoy
634 * @param sid the station to which this tile belongs
635 * @param wc the type of water on this tile
636 */
MakeBuoy(TileIndex t,StationID sid,WaterClass wc)637 static inline void MakeBuoy(TileIndex t, StationID sid, WaterClass wc)
638 {
639 /* Make the owner of the buoy tile the same as the current owner of the
640 * water tile. In this way, we can reset the owner of the water to its
641 * original state when the buoy gets removed. */
642 MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0, wc);
643 }
644
645 /**
646 * Make the given tile a dock tile.
647 * @param t the tile to make a dock
648 * @param o the owner of the dock
649 * @param sid the station to which this tile belongs
650 * @param d the direction of the dock
651 * @param wc the type of water on this tile
652 */
MakeDock(TileIndex t,Owner o,StationID sid,DiagDirection d,WaterClass wc)653 static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
654 {
655 MakeStation(t, o, sid, STATION_DOCK, d);
656 MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
657 }
658
659 /**
660 * Make the given tile an oilrig tile.
661 * @param t the tile to make an oilrig
662 * @param sid the station to which this tile belongs
663 * @param wc the type of water on this tile
664 */
MakeOilrig(TileIndex t,StationID sid,WaterClass wc)665 static inline void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
666 {
667 MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0, wc);
668 }
669
670 #endif /* STATION_MAP_H */
671