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 road_map.h Map accessors for roads. */
9 
10 #ifndef ROAD_MAP_H
11 #define ROAD_MAP_H
12 
13 #include "track_func.h"
14 #include "depot_type.h"
15 #include "rail_type.h"
16 #include "road_func.h"
17 #include "tile_map.h"
18 
19 
20 /** The different types of road tiles. */
21 enum RoadTileType {
22 	ROAD_TILE_NORMAL,   ///< Normal road
23 	ROAD_TILE_CROSSING, ///< Level crossing
24 	ROAD_TILE_DEPOT,    ///< Depot (one entrance)
25 };
26 
27 /**
28  * Test whether a tile can have road/tram types.
29  * @param t Tile to query.
30  * @return true if tile can be queried about road/tram types.
31  */
MayHaveRoad(TileIndex t)32 static inline bool MayHaveRoad(TileIndex t)
33 {
34 	switch (GetTileType(t)) {
35 		case MP_ROAD:
36 		case MP_STATION:
37 		case MP_TUNNELBRIDGE:
38 			return true;
39 
40 		default:
41 			return false;
42 	}
43 }
44 
45 /**
46  * Get the type of the road tile.
47  * @param t Tile to query.
48  * @pre IsTileType(t, MP_ROAD)
49  * @return The road tile type.
50  */
GetRoadTileType(TileIndex t)51 static inline RoadTileType GetRoadTileType(TileIndex t)
52 {
53 	assert(IsTileType(t, MP_ROAD));
54 	return (RoadTileType)GB(_m[t].m5, 6, 2);
55 }
56 
57 /**
58  * Return whether a tile is a normal road.
59  * @param t Tile to query.
60  * @pre IsTileType(t, MP_ROAD)
61  * @return True if normal road.
62  */
IsNormalRoad(TileIndex t)63 static inline bool IsNormalRoad(TileIndex t)
64 {
65 	return GetRoadTileType(t) == ROAD_TILE_NORMAL;
66 }
67 
68 /**
69  * Return whether a tile is a normal road tile.
70  * @param t Tile to query.
71  * @return True if normal road tile.
72  */
IsNormalRoadTile(TileIndex t)73 static inline bool IsNormalRoadTile(TileIndex t)
74 {
75 	return IsTileType(t, MP_ROAD) && IsNormalRoad(t);
76 }
77 
78 /**
79  * Return whether a tile is a level crossing.
80  * @param t Tile to query.
81  * @pre IsTileType(t, MP_ROAD)
82  * @return True if level crossing.
83  */
IsLevelCrossing(TileIndex t)84 static inline bool IsLevelCrossing(TileIndex t)
85 {
86 	return GetRoadTileType(t) == ROAD_TILE_CROSSING;
87 }
88 
89 /**
90  * Return whether a tile is a level crossing tile.
91  * @param t Tile to query.
92  * @return True if level crossing tile.
93  */
IsLevelCrossingTile(TileIndex t)94 static inline bool IsLevelCrossingTile(TileIndex t)
95 {
96 	return IsTileType(t, MP_ROAD) && IsLevelCrossing(t);
97 }
98 
99 /**
100  * Return whether a tile is a road depot.
101  * @param t Tile to query.
102  * @pre IsTileType(t, MP_ROAD)
103  * @return True if road depot.
104  */
IsRoadDepot(TileIndex t)105 static inline bool IsRoadDepot(TileIndex t)
106 {
107 	return GetRoadTileType(t) == ROAD_TILE_DEPOT;
108 }
109 
110 /**
111  * Return whether a tile is a road depot tile.
112  * @param t Tile to query.
113  * @return True if road depot tile.
114  */
IsRoadDepotTile(TileIndex t)115 static inline bool IsRoadDepotTile(TileIndex t)
116 {
117 	return IsTileType(t, MP_ROAD) && IsRoadDepot(t);
118 }
119 
120 /**
121  * Get the present road bits for a specific road type.
122  * @param t  The tile to query.
123  * @param rt Road type.
124  * @pre IsNormalRoad(t)
125  * @return The present road bits for the road type.
126  */
GetRoadBits(TileIndex t,RoadTramType rtt)127 static inline RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
128 {
129 	assert(IsNormalRoad(t));
130 	if (rtt == RTT_TRAM) return (RoadBits)GB(_m[t].m3, 0, 4);
131 	return (RoadBits)GB(_m[t].m5, 0, 4);
132 }
133 
134 /**
135  * Get all set RoadBits on the given tile
136  *
137  * @param tile The tile from which we want to get the RoadBits
138  * @return all set RoadBits of the tile
139  */
GetAllRoadBits(TileIndex tile)140 static inline RoadBits GetAllRoadBits(TileIndex tile)
141 {
142 	return GetRoadBits(tile, RTT_ROAD) | GetRoadBits(tile, RTT_TRAM);
143 }
144 
145 /**
146  * Set the present road bits for a specific road type.
147  * @param t  The tile to change.
148  * @param r  The new road bits.
149  * @param rt Road type.
150  * @pre IsNormalRoad(t)
151  */
SetRoadBits(TileIndex t,RoadBits r,RoadTramType rtt)152 static inline void SetRoadBits(TileIndex t, RoadBits r, RoadTramType rtt)
153 {
154 	assert(IsNormalRoad(t)); // XXX incomplete
155 	if (rtt == RTT_TRAM) {
156 		SB(_m[t].m3, 0, 4, r);
157 	} else {
158 		SB(_m[t].m5, 0, 4, r);
159 	}
160 }
161 
GetRoadTypeRoad(TileIndex t)162 static inline RoadType GetRoadTypeRoad(TileIndex t)
163 {
164 	assert(MayHaveRoad(t));
165 	return (RoadType)GB(_m[t].m4, 0, 6);
166 }
167 
GetRoadTypeTram(TileIndex t)168 static inline RoadType GetRoadTypeTram(TileIndex t)
169 {
170 	assert(MayHaveRoad(t));
171 	return (RoadType)GB(_me[t].m8, 6, 6);
172 }
173 
GetRoadType(TileIndex t,RoadTramType rtt)174 static inline RoadType GetRoadType(TileIndex t, RoadTramType rtt)
175 {
176 	return (rtt == RTT_TRAM) ? GetRoadTypeTram(t) : GetRoadTypeRoad(t);
177 }
178 
179 /**
180  * Get the present road types of a tile.
181  * @param t The tile to query.
182  * @return Present road types.
183  */
GetPresentRoadTypes(TileIndex t)184 static inline RoadTypes GetPresentRoadTypes(TileIndex t)
185 {
186 	RoadTypes result = ROADTYPES_NONE;
187 	if (MayHaveRoad(t)) {
188 		if (GetRoadTypeRoad(t) != INVALID_ROADTYPE) SetBit(result, GetRoadTypeRoad(t));
189 		if (GetRoadTypeTram(t) != INVALID_ROADTYPE) SetBit(result, GetRoadTypeTram(t));
190 	}
191 	return result;
192 }
193 
HasRoadTypeRoad(TileIndex t)194 static inline bool HasRoadTypeRoad(TileIndex t)
195 {
196 	return GetRoadTypeRoad(t) != INVALID_ROADTYPE;
197 }
198 
HasRoadTypeTram(TileIndex t)199 static inline bool HasRoadTypeTram(TileIndex t)
200 {
201 	return GetRoadTypeTram(t) != INVALID_ROADTYPE;
202 }
203 
204 /**
205  * Check if a tile has a road or a tram road type.
206  * @param t  The tile to check.
207  * @param tram True to check tram, false to check road.
208  * @return True if the tile has the specified road type.
209  */
HasTileRoadType(TileIndex t,RoadTramType rtt)210 static inline bool HasTileRoadType(TileIndex t, RoadTramType rtt)
211 {
212 	return GetRoadType(t, rtt) != INVALID_ROADTYPE;
213 }
214 
215 /**
216  * Check if a tile has one of the specified road types.
217  * @param t  The tile to check.
218  * @param rts Allowed road types.
219  * @return True if the tile has one of the specified road types.
220  */
HasTileAnyRoadType(TileIndex t,RoadTypes rts)221 static inline bool HasTileAnyRoadType(TileIndex t, RoadTypes rts)
222 {
223 	if (!MayHaveRoad(t)) return false;
224 	return (GetPresentRoadTypes(t) & rts);
225 }
226 
227 /**
228  * Get the owner of a specific road type.
229  * @param t  The tile to query.
230  * @param rtt RoadTramType.
231  * @return Owner of the given road type.
232  */
GetRoadOwner(TileIndex t,RoadTramType rtt)233 static inline Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
234 {
235 	assert(MayHaveRoad(t));
236 	if (rtt == RTT_ROAD) return (Owner)GB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5);
237 
238 	/* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
239 	 * to OWNER_TOWN makes it use one bit less */
240 	Owner o = (Owner)GB(_m[t].m3, 4, 4);
241 	return o == OWNER_TOWN ? OWNER_NONE : o;
242 }
243 
244 /**
245  * Set the owner of a specific road type.
246  * @param t  The tile to change.
247  * @param rtt RoadTramType.
248  * @param o  New owner of the given road type.
249  */
SetRoadOwner(TileIndex t,RoadTramType rtt,Owner o)250 static inline void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
251 {
252 	if (rtt == RTT_ROAD) {
253 		SB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5, o);
254 	} else {
255 		SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o);
256 	}
257 }
258 
259 /**
260  * Check if a specific road type is owned by an owner.
261  * @param t  The tile to query.
262  * @param tram True to check tram, false to check road.
263  * @param o  Owner to compare with.
264  * @pre HasTileRoadType(t, rt)
265  * @return True if the road type is owned by the given owner.
266  */
IsRoadOwner(TileIndex t,RoadTramType rtt,Owner o)267 static inline bool IsRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
268 {
269 	assert(HasTileRoadType(t, rtt));
270 	return (GetRoadOwner(t, rtt) == o);
271 }
272 
273 /**
274  * Checks if given tile has town owned road
275  * @param t tile to check
276  * @pre IsTileType(t, MP_ROAD)
277  * @return true iff tile has road and the road is owned by a town
278  */
HasTownOwnedRoad(TileIndex t)279 static inline bool HasTownOwnedRoad(TileIndex t)
280 {
281 	return HasTileRoadType(t, RTT_ROAD) && IsRoadOwner(t, RTT_ROAD, OWNER_TOWN);
282 }
283 
284 /** Which directions are disallowed ? */
285 enum DisallowedRoadDirections {
286 	DRD_NONE,       ///< None of the directions are disallowed
287 	DRD_SOUTHBOUND, ///< All southbound traffic is disallowed
288 	DRD_NORTHBOUND, ///< All northbound traffic is disallowed
289 	DRD_BOTH,       ///< All directions are disallowed
290 	DRD_END,        ///< Sentinel
291 };
292 DECLARE_ENUM_AS_BIT_SET(DisallowedRoadDirections)
293 /** Helper information for extract tool. */
294 template <> struct EnumPropsT<DisallowedRoadDirections> : MakeEnumPropsT<DisallowedRoadDirections, byte, DRD_NONE, DRD_END, DRD_END, 2> {};
295 
296 /**
297  * Gets the disallowed directions
298  * @param t the tile to get the directions from
299  * @return the disallowed directions
300  */
301 static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
302 {
303 	assert(IsNormalRoad(t));
304 	return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
305 }
306 
307 /**
308  * Sets the disallowed directions
309  * @param t   the tile to set the directions for
310  * @param drd the disallowed directions
311  */
312 static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
313 {
314 	assert(IsNormalRoad(t));
315 	assert(drd < DRD_END);
316 	SB(_m[t].m5, 4, 2, drd);
317 }
318 
319 /**
320  * Get the road axis of a level crossing.
321  * @param t The tile to query.
322  * @pre IsLevelCrossing(t)
323  * @return The axis of the road.
324  */
325 static inline Axis GetCrossingRoadAxis(TileIndex t)
326 {
327 	assert(IsLevelCrossing(t));
328 	return (Axis)GB(_m[t].m5, 0, 1);
329 }
330 
331 /**
332  * Get the rail axis of a level crossing.
333  * @param t The tile to query.
334  * @pre IsLevelCrossing(t)
335  * @return The axis of the rail.
336  */
337 static inline Axis GetCrossingRailAxis(TileIndex t)
338 {
339 	assert(IsLevelCrossing(t));
340 	return OtherAxis((Axis)GetCrossingRoadAxis(t));
341 }
342 
343 /**
344  * Get the road bits of a level crossing.
345  * @param tile The tile to query.
346  * @return The present road bits.
347  */
348 static inline RoadBits GetCrossingRoadBits(TileIndex tile)
349 {
350 	return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
351 }
352 
353 /**
354  * Get the rail track of a level crossing.
355  * @param tile The tile to query.
356  * @return The rail track.
357  */
358 static inline Track GetCrossingRailTrack(TileIndex tile)
359 {
360 	return AxisToTrack(GetCrossingRailAxis(tile));
361 }
362 
363 /**
364  * Get the rail track bits of a level crossing.
365  * @param tile The tile to query.
366  * @return The rail track bits.
367  */
368 static inline TrackBits GetCrossingRailBits(TileIndex tile)
369 {
370 	return AxisToTrackBits(GetCrossingRailAxis(tile));
371 }
372 
373 
374 /**
375  * Get the reservation state of the rail crossing
376  * @param t the crossing tile
377  * @return reservation state
378  * @pre IsLevelCrossingTile(t)
379  */
380 static inline bool HasCrossingReservation(TileIndex t)
381 {
382 	assert(IsLevelCrossingTile(t));
383 	return HasBit(_m[t].m5, 4);
384 }
385 
386 /**
387  * Set the reservation state of the rail crossing
388  * @note Works for both waypoints and rail depots
389  * @param t the crossing tile
390  * @param b the reservation state
391  * @pre IsLevelCrossingTile(t)
392  */
393 static inline void SetCrossingReservation(TileIndex t, bool b)
394 {
395 	assert(IsLevelCrossingTile(t));
396 	SB(_m[t].m5, 4, 1, b ? 1 : 0);
397 }
398 
399 /**
400  * Get the reserved track bits for a rail crossing
401  * @param t the tile
402  * @pre IsLevelCrossingTile(t)
403  * @return reserved track bits
404  */
405 static inline TrackBits GetCrossingReservationTrackBits(TileIndex t)
406 {
407 	return HasCrossingReservation(t) ? GetCrossingRailBits(t) : TRACK_BIT_NONE;
408 }
409 
410 /**
411  * Check if the level crossing is barred.
412  * @param t The tile to query.
413  * @pre IsLevelCrossing(t)
414  * @return True if the level crossing is barred.
415  */
416 static inline bool IsCrossingBarred(TileIndex t)
417 {
418 	assert(IsLevelCrossing(t));
419 	return HasBit(_m[t].m5, 5);
420 }
421 
422 /**
423  * Set the bar state of a level crossing.
424  * @param t The tile to modify.
425  * @param barred True if the crossing should be barred, false otherwise.
426  * @pre IsLevelCrossing(t)
427  */
428 static inline void SetCrossingBarred(TileIndex t, bool barred)
429 {
430 	assert(IsLevelCrossing(t));
431 	SB(_m[t].m5, 5, 1, barred ? 1 : 0);
432 }
433 
434 /**
435  * Unbar a level crossing.
436  * @param t The tile to change.
437  */
438 static inline void UnbarCrossing(TileIndex t)
439 {
440 	SetCrossingBarred(t, false);
441 }
442 
443 /**
444  * Bar a level crossing.
445  * @param t The tile to change.
446  */
447 static inline void BarCrossing(TileIndex t)
448 {
449 	SetCrossingBarred(t, true);
450 }
451 
452 /** Check if a road tile has snow/desert. */
453 #define IsOnDesert IsOnSnow
454 /**
455  * Check if a road tile has snow/desert.
456  * @param t The tile to query.
457  * @return True if the tile has snow/desert.
458  */
459 static inline bool IsOnSnow(TileIndex t)
460 {
461 	return HasBit(_me[t].m7, 5);
462 }
463 
464 /** Toggle the snow/desert state of a road tile. */
465 #define ToggleDesert ToggleSnow
466 /**
467  * Toggle the snow/desert state of a road tile.
468  * @param t The tile to change.
469  */
470 static inline void ToggleSnow(TileIndex t)
471 {
472 	ToggleBit(_me[t].m7, 5);
473 }
474 
475 
476 /** The possible road side decorations. */
477 enum Roadside {
478 	ROADSIDE_BARREN           = 0, ///< Road on barren land
479 	ROADSIDE_GRASS            = 1, ///< Road on grass
480 	ROADSIDE_PAVED            = 2, ///< Road with paved sidewalks
481 	ROADSIDE_STREET_LIGHTS    = 3, ///< Road with street lights on paved sidewalks
482 	// 4 is unused for historical reasons
483 	ROADSIDE_TREES            = 5, ///< Road with trees on paved sidewalks
484 	ROADSIDE_GRASS_ROAD_WORKS = 6, ///< Road on grass with road works
485 	ROADSIDE_PAVED_ROAD_WORKS = 7, ///< Road with sidewalks and road works
486 };
487 
488 /**
489  * Get the decorations of a road.
490  * @param tile The tile to query.
491  * @return The road decoration of the tile.
492  */
493 static inline Roadside GetRoadside(TileIndex tile)
494 {
495 	return (Roadside)GB(_me[tile].m6, 3, 3);
496 }
497 
498 /**
499  * Set the decorations of a road.
500  * @param tile The tile to change.
501  * @param s    The new road decoration of the tile.
502  */
503 static inline void SetRoadside(TileIndex tile, Roadside s)
504 {
505 	SB(_me[tile].m6, 3, 3, s);
506 }
507 
508 /**
509  * Check if a tile has road works.
510  * @param t The tile to check.
511  * @return True if the tile has road works in progress.
512  */
513 static inline bool HasRoadWorks(TileIndex t)
514 {
515 	return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
516 }
517 
518 /**
519  * Increase the progress counter of road works.
520  * @param t The tile to modify.
521  * @return True if the road works are in the last stage.
522  */
523 static inline bool IncreaseRoadWorksCounter(TileIndex t)
524 {
525 	AB(_me[t].m7, 0, 4, 1);
526 
527 	return GB(_me[t].m7, 0, 4) == 15;
528 }
529 
530 /**
531  * Start road works on a tile.
532  * @param t The tile to start the work on.
533  * @pre !HasRoadWorks(t)
534  */
535 static inline void StartRoadWorks(TileIndex t)
536 {
537 	assert(!HasRoadWorks(t));
538 	/* Remove any trees or lamps in case or roadwork */
539 	switch (GetRoadside(t)) {
540 		case ROADSIDE_BARREN:
541 		case ROADSIDE_GRASS:  SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break;
542 		default:              SetRoadside(t, ROADSIDE_PAVED_ROAD_WORKS); break;
543 	}
544 }
545 
546 /**
547  * Terminate road works on a tile.
548  * @param t Tile to stop the road works on.
549  * @pre HasRoadWorks(t)
550  */
551 static inline void TerminateRoadWorks(TileIndex t)
552 {
553 	assert(HasRoadWorks(t));
554 	SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
555 	/* Stop the counter */
556 	SB(_me[t].m7, 0, 4, 0);
557 }
558 
559 
560 /**
561  * Get the direction of the exit of a road depot.
562  * @param t The tile to query.
563  * @return Diagonal direction of the depot exit.
564  */
565 static inline DiagDirection GetRoadDepotDirection(TileIndex t)
566 {
567 	assert(IsRoadDepot(t));
568 	return (DiagDirection)GB(_m[t].m5, 0, 2);
569 }
570 
571 
572 RoadBits GetAnyRoadBits(TileIndex tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance = false);
573 
574 /**
575  * Set the road road type of a tile.
576  * @param t The tile to change.
577  * @param rt The road type to set.
578  */
579 static inline void SetRoadTypeRoad(TileIndex t, RoadType rt)
580 {
581 	assert(MayHaveRoad(t));
582 	assert(rt == INVALID_ROADTYPE || RoadTypeIsRoad(rt));
583 	SB(_m[t].m4, 0, 6, rt);
584 }
585 
586 /**
587  * Set the tram road type of a tile.
588  * @param t The tile to change.
589  * @param rt The road type to set.
590  */
591 static inline void SetRoadTypeTram(TileIndex t, RoadType rt)
592 {
593 	assert(MayHaveRoad(t));
594 	assert(rt == INVALID_ROADTYPE || RoadTypeIsTram(rt));
595 	SB(_me[t].m8, 6, 6, rt);
596 }
597 
598 /**
599  * Set the road type of a tile.
600  * @param t The tile to change.
601  * @param rtt Set road or tram type.
602  * @param rt The road type to set.
603  */
604 static inline void SetRoadType(TileIndex t, RoadTramType rtt, RoadType rt)
605 {
606 	if (rtt == RTT_TRAM) {
607 		SetRoadTypeTram(t, rt);
608 	} else {
609 		SetRoadTypeRoad(t, rt);
610 	}
611 }
612 
613 /**
614  * Set the present road types of a tile.
615  * @param t  The tile to change.
616  * @param road_rt The road roadtype to set for the tile.
617  * @param tram_rt The tram roadtype to set for the tile.
618  */
619 static inline void SetRoadTypes(TileIndex t, RoadType road_rt, RoadType tram_rt)
620 {
621 	SetRoadTypeRoad(t, road_rt);
622 	SetRoadTypeTram(t, tram_rt);
623 }
624 
625 /**
626  * Make a normal road tile.
627  * @param t       Tile to make a normal road.
628  * @param bits    Road bits to set for all present road types.
629  * @param road_rt The road roadtype to set for the tile.
630  * @param tram_rt The tram roadtype to set for the tile.
631  * @param town    Town ID if the road is a town-owned road.
632  * @param road    New owner of road.
633  * @param tram    New owner of tram tracks.
634  */
635 static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
636 {
637 	SetTileType(t, MP_ROAD);
638 	SetTileOwner(t, road);
639 	_m[t].m2 = town;
640 	_m[t].m3 = (tram_rt != INVALID_ROADTYPE ? bits : 0);
641 	_m[t].m5 = (road_rt != INVALID_ROADTYPE ? bits : 0) | ROAD_TILE_NORMAL << 6;
642 	SB(_me[t].m6, 2, 4, 0);
643 	_me[t].m7 = 0;
644 	SetRoadTypes(t, road_rt, tram_rt);
645 	SetRoadOwner(t, RTT_TRAM, tram);
646 }
647 
648 /**
649  * Make a level crossing.
650  * @param t       Tile to make a level crossing.
651  * @param road    New owner of road.
652  * @param tram    New owner of tram tracks.
653  * @param rail    New owner of the rail track.
654  * @param roaddir Axis of the road.
655  * @param rat     New rail type.
656  * @param road_rt The road roadtype to set for the tile.
657  * @param tram_rt The tram roadtype to set for the tile.
658  * @param town    Town ID if the road is a town-owned road.
659  */
660 static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
661 {
662 	SetTileType(t, MP_ROAD);
663 	SetTileOwner(t, rail);
664 	_m[t].m2 = town;
665 	_m[t].m3 = 0;
666 	_m[t].m4 = INVALID_ROADTYPE;
667 	_m[t].m5 = ROAD_TILE_CROSSING << 6 | roaddir;
668 	SB(_me[t].m6, 2, 4, 0);
669 	_me[t].m7 = road;
670 	_me[t].m8 = INVALID_ROADTYPE << 6 | rat;
671 	SetRoadTypes(t, road_rt, tram_rt);
672 	SetRoadOwner(t, RTT_TRAM, tram);
673 }
674 
675 /**
676  * Make a road depot.
677  * @param t     Tile to make a level crossing.
678  * @param owner New owner of the depot.
679  * @param did   New depot ID.
680  * @param dir   Direction of the depot exit.*
681  * @param rt    Road type of the depot.
682  */
683 static inline void MakeRoadDepot(TileIndex t, Owner owner, DepotID did, DiagDirection dir, RoadType rt)
684 {
685 	SetTileType(t, MP_ROAD);
686 	SetTileOwner(t, owner);
687 	_m[t].m2 = did;
688 	_m[t].m3 = 0;
689 	_m[t].m4 = INVALID_ROADTYPE;
690 	_m[t].m5 = ROAD_TILE_DEPOT << 6 | dir;
691 	SB(_me[t].m6, 2, 4, 0);
692 	_me[t].m7 = owner;
693 	_me[t].m8 = INVALID_ROADTYPE << 6;
694 	SetRoadType(t, GetRoadTramType(rt), rt);
695 	SetRoadOwner(t, RTT_TRAM, owner);
696 }
697 
698 #endif /* ROAD_MAP_H */
699