OpenTTD Source: src/road_map.h Source File

OpenTTD Source 15.0-RC2

road_map.h
Go to the documentation of this file.
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 <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
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#include "road_type.h"
19
20
22 enum class RoadTileType : uint8_t {
23 Normal = 0,
24 Crossing = 1,
25 Depot = 2,
26};
27
28bool MayHaveRoad(Tile t);
29
36[[debug_inline]] inline static RoadTileType GetRoadTileType(Tile t)
37{
38 assert(IsTileType(t, MP_ROAD));
39 return static_cast<RoadTileType>(GB(t.m5(), 6, 2));
40}
41
48[[debug_inline]] inline static bool IsNormalRoad(Tile t)
49{
50 return GetRoadTileType(t) == RoadTileType::Normal;
51}
52
58[[debug_inline]] inline static bool IsNormalRoadTile(Tile t)
59{
60 return IsTileType(t, MP_ROAD) && IsNormalRoad(t);
61}
62
69 inline bool IsLevelCrossing(Tile t)
70{
71 return GetRoadTileType(t) == RoadTileType::Crossing;
72}
73
79 inline bool IsLevelCrossingTile(Tile t)
80{
81 return IsTileType(t, MP_ROAD) && IsLevelCrossing(t);
82}
83
90[[debug_inline]] inline static bool IsRoadDepot(Tile t)
91{
92 return GetRoadTileType(t) == RoadTileType::Depot;
93}
94
100[[debug_inline]] inline static bool IsRoadDepotTile(Tile t)
101{
102 return IsTileType(t, MP_ROAD) && IsRoadDepot(t);
103}
104
112 inline RoadBits GetRoadBits(Tile t, RoadTramType rtt)
113{
114 assert(IsNormalRoad(t));
115 if (rtt == RTT_TRAM) return (RoadBits)GB(t.m3(), 0, 4);
116 return (RoadBits)GB(t.m5(), 0, 4);
117}
118
125 inline RoadBits GetAllRoadBits(Tile tile)
126{
127 return GetRoadBits(tile, RTT_ROAD) | GetRoadBits(tile, RTT_TRAM);
128}
129
137 inline void SetRoadBits(Tile t, RoadBits r, RoadTramType rtt)
138{
139 assert(IsNormalRoad(t)); // XXX incomplete
140 if (rtt == RTT_TRAM) {
141 SB(t.m3(), 0, 4, r);
142 } else {
143 SB(t.m5(), 0, 4, r);
144 }
145}
146
147inline RoadType GetRoadTypeRoad(Tile t)
148{
149 assert(MayHaveRoad(t));
150 return (RoadType)GB(t.m4(), 0, 6);
151}
152
153inline RoadType GetRoadTypeTram(Tile t)
154{
155 assert(MayHaveRoad(t));
156 return (RoadType)GB(t.m8(), 6, 6);
157}
158
159inline RoadType GetRoadType(Tile t, RoadTramType rtt)
160{
161 return (rtt == RTT_TRAM) ? GetRoadTypeTram(t) : GetRoadTypeRoad(t);
162}
163
169 inline RoadTypes GetPresentRoadTypes(Tile t)
170{
171 RoadTypes result{};
172 if (MayHaveRoad(t)) {
173 if (GetRoadTypeRoad(t) != INVALID_ROADTYPE) result.Set(GetRoadTypeRoad(t));
174 if (GetRoadTypeTram(t) != INVALID_ROADTYPE) result.Set(GetRoadTypeTram(t));
175 }
176 return result;
177}
178
179inline bool HasRoadTypeRoad(Tile t)
180{
181 return GetRoadTypeRoad(t) != INVALID_ROADTYPE;
182}
183
184inline bool HasRoadTypeTram(Tile t)
185{
186 return GetRoadTypeTram(t) != INVALID_ROADTYPE;
187}
188
195 inline bool HasTileRoadType(Tile t, RoadTramType rtt)
196{
197 return GetRoadType(t, rtt) != INVALID_ROADTYPE;
198}
199
206 inline bool HasTileAnyRoadType(Tile t, RoadTypes rts)
207{
208 if (!MayHaveRoad(t)) return false;
209 return GetPresentRoadTypes(t).Any(rts);
210}
211
218 inline Owner GetRoadOwner(Tile t, RoadTramType rtt)
219{
220 assert(MayHaveRoad(t));
221 if (rtt == RTT_ROAD) return (Owner)GB(IsNormalRoadTile(t) ? t.m1() : t.m7(), 0, 5);
222
223 /* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
224 * to OWNER_TOWN makes it use one bit less */
225 Owner o = (Owner)GB(t.m3(), 4, 4);
226 return o == OWNER_TOWN ? OWNER_NONE : o;
227}
228
235 inline void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
236{
237 if (rtt == RTT_ROAD) {
238 SB(IsNormalRoadTile(t) ? t.m1() : t.m7(), 0, 5, o.base());
239 } else {
240 SB(t.m3(), 4, 4, (o == OWNER_NONE ? OWNER_TOWN : o).base());
241 }
242}
243
252 inline bool IsRoadOwner(Tile t, RoadTramType rtt, Owner o)
253{
254 assert(HasTileRoadType(t, rtt));
255 return (GetRoadOwner(t, rtt) == o);
256}
257
264 inline bool HasTownOwnedRoad(Tile t)
265{
266 return HasTileRoadType(t, RTT_ROAD) && IsRoadOwner(t, RTT_ROAD, OWNER_TOWN);
267}
268
275 inline bool IsValidDisallowedRoadDirections(DisallowedRoadDirections drt)
276{
277 return drt < DRD_END;
278}
279
285 inline DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
286{
287 assert(IsNormalRoad(t));
288 return (DisallowedRoadDirections)GB(t.m5(), 4, 2);
289}
290
296 inline void SetDisallowedRoadDirections(Tile t, DisallowedRoadDirections drd)
297{
298 assert(IsNormalRoad(t));
299 assert(drd < DRD_END);
300 SB(t.m5(), 4, 2, drd);
301}
302
309 inline Axis GetCrossingRoadAxis(Tile t)
310{
311 assert(IsLevelCrossing(t));
312 return (Axis)GB(t.m5(), 0, 1);
313}
314
321 inline Axis GetCrossingRailAxis(Tile t)
322{
323 assert(IsLevelCrossing(t));
324 return OtherAxis((Axis)GetCrossingRoadAxis(t));
325}
326
332 inline RoadBits GetCrossingRoadBits(Tile tile)
333{
334 return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
335}
336
342 inline Track GetCrossingRailTrack(Tile tile)
343{
344 return AxisToTrack(GetCrossingRailAxis(tile));
345}
346
352 inline TrackBits GetCrossingRailBits(Tile tile)
353{
354 return AxisToTrackBits(GetCrossingRailAxis(tile));
355}
356
357
364 inline bool HasCrossingReservation(Tile t)
365{
366 assert(IsLevelCrossingTile(t));
367 return HasBit(t.m5(), 4);
368}
369
377 inline void SetCrossingReservation(Tile t, bool b)
378{
379 assert(IsLevelCrossingTile(t));
380 AssignBit(t.m5(), 4, b);
381}
382
389 inline TrackBits GetCrossingReservationTrackBits(Tile t)
390{
391 return HasCrossingReservation(t) ? GetCrossingRailBits(t) : TRACK_BIT_NONE;
392}
393
400 inline bool IsCrossingBarred(Tile t)
401{
402 assert(IsLevelCrossing(t));
403 return HasBit(t.m5(), 5);
404}
405
412 inline void SetCrossingBarred(Tile t, bool barred)
413{
414 assert(IsLevelCrossing(t));
415 AssignBit(t.m5(), 5, barred);
416}
417
422 inline void UnbarCrossing(Tile t)
423{
424 SetCrossingBarred(t, false);
425}
426
431 inline void BarCrossing(Tile t)
432{
433 SetCrossingBarred(t, true);
434}
435
441 inline bool IsOnSnowOrDesert(Tile t)
442{
443 return HasBit(t.m7(), 5);
444}
445
450 inline void ToggleSnowOrDesert(Tile t)
451{
452 ToggleBit(t.m7(), 5);
453}
454
455
457 enum class Roadside : uint8_t {
458 Barren = 0,
459 Grass = 1,
460 Paved = 2,
461 StreetLights = 3,
462 /* 4 is unused for historical reasons */
463 Trees = 5,
464 GrassRoadWorks = 6,
465 PavedRoadWorks = 7,
466};
467
473 inline Roadside GetRoadside(Tile tile)
474{
475 return static_cast<Roadside>(GB(tile.m6(), 3, 3));
476}
477
483 inline void SetRoadside(Tile tile, Roadside s)
484{
485 SB(tile.m6(), 3, 3, to_underlying(s));
486}
487
493 inline bool HasRoadWorks(Tile t)
494{
495 return GetRoadside(t) >= Roadside::GrassRoadWorks;
496}
497
503 inline bool IncreaseRoadWorksCounter(Tile t)
504{
505 AB(t.m7(), 0, 4, 1);
506
507 return GB(t.m7(), 0, 4) == 15;
508}
509
515 inline void StartRoadWorks(Tile t)
516{
517 assert(!HasRoadWorks(t));
518 /* Remove any trees or lamps in case or roadwork */
519 switch (GetRoadside(t)) {
520 case Roadside::Barren:
521 case Roadside::Grass:
522 SetRoadside(t, Roadside::GrassRoadWorks);
523 break;
524
525 default:
526 SetRoadside(t, Roadside::PavedRoadWorks);
527 break;
528 }
529}
530
536 inline void TerminateRoadWorks(Tile t)
537{
538 assert(HasRoadWorks(t));
539 SetRoadside(t, GetRoadside(t) == Roadside::GrassRoadWorks ? Roadside::Grass : Roadside::Paved);
540 /* Stop the counter */
541 SB(t.m7(), 0, 4, 0);
542}
543
544
550 inline DiagDirection GetRoadDepotDirection(Tile t)
551{
552 assert(IsRoadDepot(t));
553 return (DiagDirection)GB(t.m5(), 0, 2);
554}
555
556
557 RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance = false);
558
564 inline void SetRoadTypeRoad(Tile t, RoadType rt)
565{
566 assert(MayHaveRoad(t));
567 assert(rt == INVALID_ROADTYPE || RoadTypeIsRoad(rt));
568 SB(t.m4(), 0, 6, rt);
569}
570
576 inline void SetRoadTypeTram(Tile t, RoadType rt)
577{
578 assert(MayHaveRoad(t));
579 assert(rt == INVALID_ROADTYPE || RoadTypeIsTram(rt));
580 SB(t.m8(), 6, 6, rt);
581}
582
589 inline void SetRoadType(Tile t, RoadTramType rtt, RoadType rt)
590{
591 if (rtt == RTT_TRAM) {
592 SetRoadTypeTram(t, rt);
593 } else {
594 SetRoadTypeRoad(t, rt);
595 }
596}
597
604 inline void SetRoadTypes(Tile t, RoadType road_rt, RoadType tram_rt)
605{
606 SetRoadTypeRoad(t, road_rt);
607 SetRoadTypeTram(t, tram_rt);
608}
609
620 inline void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
621{
622 SetTileType(t, MP_ROAD);
623 SetTileOwner(t, road);
624 t.m2() = town.base();
625 t.m3() = (tram_rt != INVALID_ROADTYPE ? bits : 0);
626 t.m5() = (road_rt != INVALID_ROADTYPE ? bits : 0) | to_underlying(RoadTileType::Normal) << 6;
627 SB(t.m6(), 2, 6, 0);
628 t.m7() = 0;
629 t.m8() = 0;
630 SetRoadTypes(t, road_rt, tram_rt);
631 SetRoadOwner(t, RTT_TRAM, tram);
632}
633
646 inline void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, TownID town)
647{
648 SetTileType(t, MP_ROAD);
649 SetTileOwner(t, rail);
650 t.m2() = town.base();
651 t.m3() = 0;
652 t.m4() = INVALID_ROADTYPE;
653 t.m5() = to_underlying(RoadTileType::Crossing) << 6 | roaddir;
654 SB(t.m6(), 2, 6, 0);
655 t.m7() = road.base();
656 t.m8() = INVALID_ROADTYPE << 6 | rat;
657 SetRoadTypes(t, road_rt, tram_rt);
658 SetRoadOwner(t, RTT_TRAM, tram);
659}
660
666 inline void SetRoadDepotExitDirection(Tile tile, DiagDirection dir)
667{
668 assert(IsRoadDepotTile(tile));
669 SB(tile.m5(), 0, 2, dir);
670}
671
680 inline void MakeRoadDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RoadType rt)
681{
682 SetTileType(tile, MP_ROAD);
683 SetTileOwner(tile, owner);
684 tile.m2() = depot_id.base();
685 tile.m3() = 0;
686 tile.m4() = INVALID_ROADTYPE;
687 tile.m5() = to_underlying(RoadTileType::Depot) << 6 | dir;
688 SB(tile.m6(), 2, 6, 0);
689 tile.m7() = owner.base();
690 tile.m8() = INVALID_ROADTYPE << 6;
691 SetRoadType(tile, GetRoadTramType(rt), rt);
692 SetRoadOwner(tile, RTT_TRAM, owner);
693}
694
695#endif /* ROAD_MAP_H */
AssignBit
constexpr T AssignBit(T &x, const uint8_t y, bool value)
Assigns a bit in a variable.
Definition bitmath_func.hpp:176
SB
constexpr T SB(T &x, const uint8_t s, const uint8_t n, const U d)
Set n bits in x starting at bit s to d.
Definition bitmath_func.hpp:58
GB
static constexpr uint GB(const T x, const uint8_t s, const uint8_t n)
Fetch n bits from x, started at bit s.
Definition bitmath_func.hpp:32
HasBit
constexpr bool HasBit(const T x, const uint8_t y)
Checks if a bit in a value is set.
Definition bitmath_func.hpp:103
AB
constexpr T AB(T &x, const uint8_t s, const uint8_t n, const U i)
Add i to n bits of x starting at bit s.
Definition bitmath_func.hpp:83
ToggleBit
constexpr T ToggleBit(T &x, const uint8_t y)
Toggles a bit in a variable.
Definition bitmath_func.hpp:157
BaseBitSet::Set
constexpr Timpl & Set()
Set all bits.
Definition base_bitset_type.hpp:40
BaseBitSet::Any
constexpr bool Any(const Timpl &other) const
Test if any of the given values are set.
Definition base_bitset_type.hpp:170
EnumBitSet< RoadType, uint64_t >
Tile
Wrapper class to abstract away the way the tiles are stored.
Definition map_func.h:25
Tile::m5
uint8_t & m5()
General purpose.
Definition map_func.h:161
Tile::m1
uint8_t & m1()
Primarily used for ownership information.
Definition map_func.h:113
Tile::m4
uint8_t & m4()
General purpose.
Definition map_func.h:149
Tile::m6
uint8_t & m6()
General purpose.
Definition map_func.h:173
Tile::m7
uint8_t & m7()
Primarily used for newgrf support.
Definition map_func.h:185
Tile::m3
uint8_t & m3()
General purpose.
Definition map_func.h:137
Tile::m8
uint16_t & m8()
General purpose.
Definition map_func.h:197
Tile::m2
uint16_t & m2()
Primarily used for indices to towns, industries and stations.
Definition map_func.h:125
OWNER_TOWN
static constexpr Owner OWNER_TOWN
A town owns the tile, or a town is expanding.
Definition company_type.h:25
OWNER_NONE
static constexpr Owner OWNER_NONE
The tile has no ownership.
Definition company_type.h:26
depot_type.h
Header files for depots (not hangars)
OtherAxis
Axis OtherAxis(Axis a)
Select the other axis as provided.
Definition direction_func.h:197
Axis
Axis
Allow incrementing of DiagDirDiff variables.
Definition direction_type.h:123
AXIS_X
@ AXIS_X
The X axis.
Definition direction_type.h:124
DiagDirection
DiagDirection
Enumeration for diagonal directions.
Definition direction_type.h:78
to_underlying
constexpr std::underlying_type_t< enum_type > to_underlying(enum_type e)
Implementation of std::to_underlying (from C++23)
Definition enum_type.hpp:17
rail_type.h
The different types of rail.
RailType
RailType
Enumeration for all possible railtypes.
Definition rail_type.h:25
road_func.h
Functions related to roads.
SetRoadOwner
void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
Set the owner of a specific road type.
Definition road_map.h:235
HasCrossingReservation
bool HasCrossingReservation(Tile t)
Get the reservation state of the rail crossing.
Definition road_map.h:364
GetRoadTileType
static RoadTileType GetRoadTileType(Tile t)
Get the type of the road tile.
Definition road_map.h:36
HasTownOwnedRoad
bool HasTownOwnedRoad(Tile t)
Checks if given tile has town owned road.
Definition road_map.h:264
SetRoadDepotExitDirection
void SetRoadDepotExitDirection(Tile tile, DiagDirection dir)
Sets the exit direction of a road depot.
Definition road_map.h:666
GetPresentRoadTypes
RoadTypes GetPresentRoadTypes(Tile t)
Get the present road types of a tile.
Definition road_map.h:169
SetRoadTypeRoad
void SetRoadTypeRoad(Tile t, RoadType rt)
Set the road road type of a tile.
Definition road_map.h:564
SetRoadTypeTram
void SetRoadTypeTram(Tile t, RoadType rt)
Set the tram road type of a tile.
Definition road_map.h:576
GetAnyRoadBits
RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance=false)
Returns the RoadBits on an arbitrary tile Special behaviour:
Definition road_map.cpp:54
IsLevelCrossingTile
bool IsLevelCrossingTile(Tile t)
Return whether a tile is a level crossing tile.
Definition road_map.h:79
IncreaseRoadWorksCounter
bool IncreaseRoadWorksCounter(Tile t)
Increase the progress counter of road works.
Definition road_map.h:503
GetRoadBits
RoadBits GetRoadBits(Tile t, RoadTramType rtt)
Get the present road bits for a specific road type.
Definition road_map.h:112
MayHaveRoad
bool MayHaveRoad(Tile t)
Test whether a tile can have road/tram types.
Definition road_map.cpp:21
IsRoadDepotTile
static bool IsRoadDepotTile(Tile t)
Return whether a tile is a road depot tile.
Definition road_map.h:100
HasTileAnyRoadType
bool HasTileAnyRoadType(Tile t, RoadTypes rts)
Check if a tile has one of the specified road types.
Definition road_map.h:206
IsValidDisallowedRoadDirections
bool IsValidDisallowedRoadDirections(DisallowedRoadDirections drt)
Checks if a DisallowedRoadDirections is valid.
Definition road_map.h:275
GetCrossingRoadAxis
Axis GetCrossingRoadAxis(Tile t)
Get the road axis of a level crossing.
Definition road_map.h:309
GetCrossingRailBits
TrackBits GetCrossingRailBits(Tile tile)
Get the rail track bits of a level crossing.
Definition road_map.h:352
SetDisallowedRoadDirections
void SetDisallowedRoadDirections(Tile t, DisallowedRoadDirections drd)
Sets the disallowed directions.
Definition road_map.h:296
GetCrossingRailTrack
Track GetCrossingRailTrack(Tile tile)
Get the rail track of a level crossing.
Definition road_map.h:342
StartRoadWorks
void StartRoadWorks(Tile t)
Start road works on a tile.
Definition road_map.h:515
SetCrossingBarred
void SetCrossingBarred(Tile t, bool barred)
Set the bar state of a level crossing.
Definition road_map.h:412
GetDisallowedRoadDirections
DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
Gets the disallowed directions.
Definition road_map.h:285
SetRoadTypes
void SetRoadTypes(Tile t, RoadType road_rt, RoadType tram_rt)
Set the present road types of a tile.
Definition road_map.h:604
HasTileRoadType
bool HasTileRoadType(Tile t, RoadTramType rtt)
Check if a tile has a road or a tram road type.
Definition road_map.h:195
GetRoadDepotDirection
DiagDirection GetRoadDepotDirection(Tile t)
Get the direction of the exit of a road depot.
Definition road_map.h:550
IsRoadDepot
static bool IsRoadDepot(Tile t)
Return whether a tile is a road depot.
Definition road_map.h:90
BarCrossing
void BarCrossing(Tile t)
Bar a level crossing.
Definition road_map.h:431
MakeRoadNormal
void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
Make a normal road tile.
Definition road_map.h:620
GetRoadside
Roadside GetRoadside(Tile tile)
Get the decorations of a road.
Definition road_map.h:473
RoadTileType
RoadTileType
The different types of road tiles.
Definition road_map.h:22
RoadTileType::Normal
@ Normal
Normal road.
RoadTileType::Depot
@ Depot
Depot (one entrance)
RoadTileType::Crossing
@ Crossing
Level crossing.
MakeRoadCrossing
void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, TownID town)
Make a level crossing.
Definition road_map.h:646
ToggleSnowOrDesert
void ToggleSnowOrDesert(Tile t)
Toggle the snow/desert state of a road tile.
Definition road_map.h:450
GetAllRoadBits
RoadBits GetAllRoadBits(Tile tile)
Get all set RoadBits on the given tile.
Definition road_map.h:125
GetCrossingRailAxis
Axis GetCrossingRailAxis(Tile t)
Get the rail axis of a level crossing.
Definition road_map.h:321
GetCrossingReservationTrackBits
TrackBits GetCrossingReservationTrackBits(Tile t)
Get the reserved track bits for a rail crossing.
Definition road_map.h:389
IsNormalRoadTile
static bool IsNormalRoadTile(Tile t)
Return whether a tile is a normal road tile.
Definition road_map.h:58
TerminateRoadWorks
void TerminateRoadWorks(Tile t)
Terminate road works on a tile.
Definition road_map.h:536
GetCrossingRoadBits
RoadBits GetCrossingRoadBits(Tile tile)
Get the road bits of a level crossing.
Definition road_map.h:332
SetRoadType
void SetRoadType(Tile t, RoadTramType rtt, RoadType rt)
Set the road type of a tile.
Definition road_map.h:589
GetRoadOwner
Owner GetRoadOwner(Tile t, RoadTramType rtt)
Get the owner of a specific road type.
Definition road_map.h:218
IsCrossingBarred
bool IsCrossingBarred(Tile t)
Check if the level crossing is barred.
Definition road_map.h:400
SetRoadside
void SetRoadside(Tile tile, Roadside s)
Set the decorations of a road.
Definition road_map.h:483
UnbarCrossing
void UnbarCrossing(Tile t)
Unbar a level crossing.
Definition road_map.h:422
IsRoadOwner
bool IsRoadOwner(Tile t, RoadTramType rtt, Owner o)
Check if a specific road type is owned by an owner.
Definition road_map.h:252
MakeRoadDepot
void MakeRoadDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RoadType rt)
Make a road depot.
Definition road_map.h:680
SetCrossingReservation
void SetCrossingReservation(Tile t, bool b)
Set the reservation state of the rail crossing.
Definition road_map.h:377
SetRoadBits
void SetRoadBits(Tile t, RoadBits r, RoadTramType rtt)
Set the present road bits for a specific road type.
Definition road_map.h:137
Roadside
Roadside
The possible road side decorations.
Definition road_map.h:457
Roadside::Paved
@ Paved
Road with paved sidewalks.
Roadside::Barren
@ Barren
Road on barren land.
Roadside::GrassRoadWorks
@ GrassRoadWorks
Road on grass with road works.
Roadside::StreetLights
@ StreetLights
Road with street lights on paved sidewalks.
Roadside::Trees
@ Trees
Road with trees on paved sidewalks.
Roadside::Grass
@ Grass
Road on grass.
Roadside::PavedRoadWorks
@ PavedRoadWorks
Road with sidewalks and road works.
IsLevelCrossing
bool IsLevelCrossing(Tile t)
Return whether a tile is a level crossing.
Definition road_map.h:69
IsNormalRoad
static bool IsNormalRoad(Tile t)
Return whether a tile is a normal road.
Definition road_map.h:48
IsOnSnowOrDesert
bool IsOnSnowOrDesert(Tile t)
Check if a road tile has snow/desert.
Definition road_map.h:441
HasRoadWorks
bool HasRoadWorks(Tile t)
Check if a tile has road works.
Definition road_map.h:493
road_type.h
Enums and other types related to roads.
RoadBits
RoadBits
Enumeration for the road parts on a tile.
Definition road_type.h:56
ROAD_Y
@ ROAD_Y
Full road along the y-axis (north-west + south-east)
Definition road_type.h:63
ROAD_X
@ ROAD_X
Full road along the x-axis (south-west + north-east)
Definition road_type.h:62
RoadTramType
RoadTramType
The different types of road type.
Definition road_type.h:37
RTT_ROAD
@ RTT_ROAD
Road road type.
Definition road_type.h:38
RTT_TRAM
@ RTT_TRAM
Tram road type.
Definition road_type.h:39
RoadType
RoadType
The different roadtypes we support.
Definition road_type.h:23
INVALID_ROADTYPE
@ INVALID_ROADTYPE
flag for invalid roadtype
Definition road_type.h:28
DisallowedRoadDirections
DisallowedRoadDirections
Which directions are disallowed ?
Definition road_type.h:77
DRD_END
@ DRD_END
Sentinel.
Definition road_type.h:82
Depot
Definition depot_base.h:20
PoolID< uint8_t, struct CompanyIDTag, 0xF, 0xFF >
tile_map.h
Map writing/reading functions for tiles.
IsTileType
static bool IsTileType(Tile tile, TileType type)
Checks if a tile is a given tiletype.
Definition tile_map.h:150
SetTileType
void SetTileType(Tile tile, TileType type)
Set the type of a tile.
Definition tile_map.h:131
SetTileOwner
void SetTileOwner(Tile tile, Owner owner)
Sets the owner of a tile.
Definition tile_map.h:198
MP_ROAD
@ MP_ROAD
A tile with road (or tram tracks)
Definition tile_type.h:50
track_func.h
Different conversion functions from one kind of track to another.
AxisToTrackBits
TrackBits AxisToTrackBits(Axis a)
Maps an Axis to the corresponding TrackBits value.
Definition track_func.h:88
AxisToTrack
Track AxisToTrack(Axis a)
Convert an Axis to the corresponding Track AXIS_X -> TRACK_X AXIS_Y -> TRACK_Y Uses the fact that the...
Definition track_func.h:66
TrackBits
TrackBits
Allow incrementing of Track variables.
Definition track_type.h:35
TRACK_BIT_NONE
@ TRACK_BIT_NONE
No track.
Definition track_type.h:36
Track
Track
These are used to specify a single track.
Definition track_type.h:19