annotate src/road_map.h @ 12411:9fdbb4594b82 draft

(svn r16845) -Codechange: Introduction of constants for describing the bits in a WWT_MATRIX data field.
author alberth <alberth@openttd.org>
date Thu, 16 Jul 2009 16:22:23 +0000
parents ac52bf3742f4
children 299da608443d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
1 /* $Id$ */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
2
9111
d48433370037 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium <rubidium@openttd.org>
parents: 8744
diff changeset
3 /** @file road_map.h Map accessors for roads. */
6393
ffd35446c110 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas <belugas@openttd.org>
parents: 6390
diff changeset
4
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
5 #ifndef ROAD_MAP_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
6 #define ROAD_MAP_H
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
7
8101
b222582555cb (svn r11662) -Codechange: move some rail types/related functions around.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
8 #include "track_func.h"
b222582555cb (svn r11662) -Codechange: move some rail types/related functions around.
rubidium <rubidium@openttd.org>
parents: 7932
diff changeset
9 #include "rail_type.h"
8213
87c85bb42d6f (svn r11776) -Codechange: more header splittings to reduce the dependencies.
rubidium <rubidium@openttd.org>
parents: 8113
diff changeset
10 #include "town_type.h"
8102
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
11 #include "road_func.h"
8108
4faab45e2603 (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents: 8102
diff changeset
12 #include "tile_map.h"
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
13
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
14
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6172
diff changeset
15 enum RoadTileType {
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
16 ROAD_TILE_NORMAL,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
17 ROAD_TILE_CROSSING,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
18 ROAD_TILE_DEPOT
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6172
diff changeset
19 };
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
20
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
21 static inline RoadTileType GetRoadTileType(TileIndex t)
8529
6a75c42267d1 (svn r12104) -Fix (r12103): remember loading indicators transparency settings and make in switchable by Ctrl+9
smatz <smatz@openttd.org>
parents: 8344
diff changeset
22 {
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 6778
diff changeset
23 assert(IsTileType(t, MP_ROAD));
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
24 return (RoadTileType)GB(_m[t].m5, 6, 2);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
25 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
26
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
27 static inline bool IsNormalRoad(TileIndex t)
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
28 {
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
29 return GetRoadTileType(t) == ROAD_TILE_NORMAL;
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
30 }
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
31
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
32 static inline bool IsNormalRoadTile(TileIndex t)
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
33 {
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
34 return IsTileType(t, MP_ROAD) && IsNormalRoad(t);
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
35 }
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
36
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
37 static inline bool IsLevelCrossing(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
38 {
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
39 return GetRoadTileType(t) == ROAD_TILE_CROSSING;
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
40 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
41
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
42 static inline bool IsLevelCrossingTile(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
43 {
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 6778
diff changeset
44 return IsTileType(t, MP_ROAD) && IsLevelCrossing(t);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
45 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
46
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
47 static inline bool IsRoadDepot(TileIndex t)
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
48 {
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
49 return GetRoadTileType(t) == ROAD_TILE_DEPOT;
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
50 }
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
51
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
52 static inline bool IsRoadDepotTile(TileIndex t)
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
53 {
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
54 return IsTileType(t, MP_ROAD) && IsRoadDepot(t);
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
55 }
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
56
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
57 static inline RoadBits GetRoadBits(TileIndex t, RoadType rt)
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
58 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
59 assert(IsNormalRoad(t));
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
60 switch (rt) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
61 default: NOT_REACHED();
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
62 case ROADTYPE_ROAD: return (RoadBits)GB(_m[t].m5, 0, 4);
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
63 case ROADTYPE_TRAM: return (RoadBits)GB(_m[t].m3, 0, 4);
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
64 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
65 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
66
8734
c370e9d5f5c4 (svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents: 8716
diff changeset
67 /**
8744
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
68 * Get all RoadBits set on a tile except from the given RoadType
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
69 *
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
70 * @param t The tile from which we want to get the RoadBits
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
71 * @param rt The RoadType which we exclude from the querry
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
72 * @return all set RoadBits of the tile which are not from the given RoadType
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
73 */
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
74 static inline RoadBits GetOtherRoadBits(TileIndex t, RoadType rt)
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
75 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
76 return GetRoadBits(t, rt == ROADTYPE_ROAD ? ROADTYPE_TRAM : ROADTYPE_ROAD);
8744
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
77 }
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
78
bcc06c9be6ef (svn r12440) -Fix [FS#1694]: Make the road building and road removing conditions more union
skidd13 <skidd13@openttd.org>
parents: 8734
diff changeset
79 /**
8734
c370e9d5f5c4 (svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents: 8716
diff changeset
80 * Get all set RoadBits on the given tile
c370e9d5f5c4 (svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents: 8716
diff changeset
81 *
c370e9d5f5c4 (svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents: 8716
diff changeset
82 * @param tile The tile from which we want to get the RoadBits
c370e9d5f5c4 (svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents: 8716
diff changeset
83 * @return all set RoadBits of the tile
c370e9d5f5c4 (svn r12419) -Cleanup: of the internal road-piece building and removing.
skidd13 <skidd13@openttd.org>
parents: 8716
diff changeset
84 */
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
85 static inline RoadBits GetAllRoadBits(TileIndex tile)
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
86 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
87 return GetRoadBits(tile, ROADTYPE_ROAD) | GetRoadBits(tile, ROADTYPE_TRAM);
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
88 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
89
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
90 static inline void SetRoadBits(TileIndex t, RoadBits r, RoadType rt)
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
91 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
92 assert(IsNormalRoad(t)); // XXX incomplete
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
93 switch (rt) {
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
94 default: NOT_REACHED();
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
95 case ROADTYPE_ROAD: SB(_m[t].m5, 0, 4, r); break;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
96 case ROADTYPE_TRAM: SB(_m[t].m3, 0, 4, r); break;
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
97 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
98 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
99
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
100 static inline RoadTypes GetRoadTypes(TileIndex t)
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
101 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
102 return (RoadTypes)GB(_me[t].m7, 6, 2);
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
103 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
104
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
105 static inline void SetRoadTypes(TileIndex t, RoadTypes rt)
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
106 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
107 assert(IsTileType(t, MP_ROAD) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
108 SB(_me[t].m7, 6, 2, rt);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
109 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
110
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
111 static inline bool HasTileRoadType(TileIndex t, RoadType rt)
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
112 {
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
113 return HasBit(GetRoadTypes(t), rt);
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
114 }
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
115
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
116 static inline Owner GetRoadOwner(TileIndex t, RoadType rt)
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
117 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
118 switch (rt) {
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
119 default: NOT_REACHED();
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
120 case ROADTYPE_ROAD: return (Owner)GB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5);
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
121 case ROADTYPE_TRAM: {
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
122 /* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
11361
02313cc6114e (svn r15711) -Codechange: lots of whitespace cleanup/fixes
rubidium <rubidium@openttd.org>
parents: 11294
diff changeset
123 * to OWNER_TOWN makes it use one bit less */
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
124 Owner o = (Owner)GB(_m[t].m3, 4, 4);
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
125 return o == OWNER_TOWN ? OWNER_NONE : o;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
126 }
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
127 }
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
128 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
129
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
130 static inline void SetRoadOwner(TileIndex t, RoadType rt, Owner o)
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
131 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
132 switch (rt) {
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
133 default: NOT_REACHED();
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
134 case ROADTYPE_ROAD: SB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5, o); break;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
135 case ROADTYPE_TRAM: SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o); break;
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
136 }
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
137 }
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
138
9341
98ef22a4841d (svn r13233) -Fix: Replace some (incorrect) evaluations of TileOwner by RoadOwner.
frosch <frosch@openttd.org>
parents: 9111
diff changeset
139 static inline bool IsRoadOwner(TileIndex t, RoadType rt, Owner o)
98ef22a4841d (svn r13233) -Fix: Replace some (incorrect) evaluations of TileOwner by RoadOwner.
frosch <frosch@openttd.org>
parents: 9111
diff changeset
140 {
10340
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
141 assert(HasTileRoadType(t, rt));
9341
98ef22a4841d (svn r13233) -Fix: Replace some (incorrect) evaluations of TileOwner by RoadOwner.
frosch <frosch@openttd.org>
parents: 9111
diff changeset
142 return (GetRoadOwner(t, rt) == o);
98ef22a4841d (svn r13233) -Fix: Replace some (incorrect) evaluations of TileOwner by RoadOwner.
frosch <frosch@openttd.org>
parents: 9111
diff changeset
143 }
98ef22a4841d (svn r13233) -Fix: Replace some (incorrect) evaluations of TileOwner by RoadOwner.
frosch <frosch@openttd.org>
parents: 9111
diff changeset
144
10340
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
145 /** Checks if given tile has town owned road
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
146 * @param t tile to check
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
147 * @return true iff tile has road and the road is owned by a town
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
148 * @pre IsTileType(t, MP_ROAD)
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
149 */
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
150 static inline bool HasTownOwnedRoad(TileIndex t)
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
151 {
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
152 return HasTileRoadType(t, ROADTYPE_ROAD) && IsRoadOwner(t, ROADTYPE_ROAD, OWNER_TOWN);
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
153 }
e3f0f062c7c3 (svn r14591) -Fix [FS#2388](r14528): cached nearest town could be invalid after importing older savegame and during town generation
smatz <smatz@openttd.org>
parents: 10289
diff changeset
154
6764
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
155 /** Which directions are disallowed ? */
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
156 enum DisallowedRoadDirections {
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
157 DRD_NONE, ///< None of the directions are disallowed
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
158 DRD_SOUTHBOUND, ///< All southbound traffic is disallowed
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
159 DRD_NORTHBOUND, ///< All northbound traffic is disallowed
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
160 DRD_BOTH, ///< All directions are disallowed
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
161 DRD_END
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
162 };
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
163 DECLARE_ENUM_AS_BIT_SET(DisallowedRoadDirections);
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
164
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
165 /**
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
166 * Gets the disallowed directions
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
167 * @param t the tile to get the directions from
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
168 * @return the disallowed directions
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
169 */
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
170 static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
171 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
172 assert(IsNormalRoad(t));
6764
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
173 return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
174 }
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
175
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
176 /**
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
177 * Sets the disallowed directions
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
178 * @param t the tile to set the directions for
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
179 * @param drd the disallowed directions
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
180 */
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
181 static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
182 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
183 assert(IsNormalRoad(t));
6764
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
184 assert(drd < DRD_END);
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
185 SB(_m[t].m5, 4, 2, drd);
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
186 }
6ce333c8fd7e (svn r9999) -Feature: make it possible to disallow busses and lorries to go a specific way on straight pieces of road.
rubidium <rubidium@openttd.org>
parents: 6662
diff changeset
187
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
188 static inline Axis GetCrossingRoadAxis(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
189 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
190 assert(IsLevelCrossing(t));
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
191 return (Axis)GB(_m[t].m5, 0, 1);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
192 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
193
8598
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
194 static inline Axis GetCrossingRailAxis(TileIndex t)
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
195 {
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
196 assert(IsLevelCrossing(t));
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
197 return OtherAxis((Axis)GetCrossingRoadAxis(t));
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
198 }
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
199
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
200 static inline RoadBits GetCrossingRoadBits(TileIndex tile)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
201 {
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
202 return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
203 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
204
8598
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
205 static inline Track GetCrossingRailTrack(TileIndex tile)
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
206 {
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
207 return AxisToTrack(GetCrossingRailAxis(tile));
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
208 }
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
209
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
210 static inline TrackBits GetCrossingRailBits(TileIndex tile)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
211 {
8598
ef2c93a9589d (svn r12179) -Codechange: use GetCrossingRailTrack() and GetCrossingRailAxis() to improve code readability
smatz <smatz@openttd.org>
parents: 8563
diff changeset
212 return AxisToTrackBits(GetCrossingRailAxis(tile));
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
213 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
214
9784
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
215
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
216 /**
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
217 * Get the reservation state of the rail crossing
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
218 * @pre IsLevelCrossingTile(t)
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
219 * @param t the crossing tile
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
220 * @return reservation state
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
221 */
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
222 static inline bool GetCrossingReservation(TileIndex t)
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
223 {
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
224 assert(IsLevelCrossingTile(t));
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
225 return HasBit(_m[t].m5, 4);
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
226 }
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
227
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
228 /**
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
229 * Set the reservation state of the rail crossing
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
230 * @note Works for both waypoints and rail depots
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
231 * @pre IsLevelCrossingTile(t)
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
232 * @param t the crossing tile
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
233 * @param b the reservation state
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
234 */
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
235 static inline void SetCrossingReservation(TileIndex t, bool b)
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
236 {
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
237 assert(IsLevelCrossingTile(t));
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
238 SB(_m[t].m5, 4, 1, b ? 1 : 0);
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
239 }
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
240
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
241 /**
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
242 * Get the reserved track bits for a rail crossing
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
243 * @pre IsLevelCrossingTile(t)
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
244 * @param t the tile
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
245 * @return reserved track bits
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
246 */
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
247 static inline TrackBits GetRailCrossingReservation(TileIndex t)
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
248 {
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
249 return GetCrossingReservation(t) ? GetCrossingRailBits(t) : TRACK_BIT_NONE;
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
250 }
a2ae4bee49e1 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium <rubidium@openttd.org>
parents: 9341
diff changeset
251
8344
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
252 static inline bool IsCrossingBarred(TileIndex t)
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
253 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
254 assert(IsLevelCrossing(t));
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
255 return HasBit(_m[t].m5, 5);
8344
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
256 }
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
257
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
258 static inline void SetCrossingBarred(TileIndex t, bool barred)
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
259 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
260 assert(IsLevelCrossing(t));
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
261 SB(_m[t].m5, 5, 1, barred ? 1 : 0);
8344
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
262 }
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
263
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
264 static inline void UnbarCrossing(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
265 {
8344
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
266 SetCrossingBarred(t, false);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
267 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
268
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
269 static inline void BarCrossing(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
270 {
8344
6312fafcfe47 (svn r11910) -Fix: play 'ding-ding' crossing sound in more cases (except gameload and crossing construction)
smatz <smatz@openttd.org>
parents: 8213
diff changeset
271 SetCrossingBarred(t, true);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
272 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
273
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
274 #define IsOnDesert IsOnSnow
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
275 static inline bool IsOnSnow(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
276 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
277 return HasBit(_me[t].m7, 5);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
278 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
279
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
280 #define ToggleDesert ToggleSnow
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
281 static inline void ToggleSnow(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
282 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
283 ToggleBit(_me[t].m7, 5);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
284 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
285
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
286
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6172
diff changeset
287 enum Roadside {
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
288 ROADSIDE_BARREN = 0,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
289 ROADSIDE_GRASS = 1,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
290 ROADSIDE_PAVED = 2,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
291 ROADSIDE_STREET_LIGHTS = 3,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
292 ROADSIDE_TREES = 5,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
293 ROADSIDE_GRASS_ROAD_WORKS = 6,
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
294 ROADSIDE_PAVED_ROAD_WORKS = 7
6248
0789677a15a0 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium <rubidium@openttd.org>
parents: 6172
diff changeset
295 };
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
296
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
297 static inline Roadside GetRoadside(TileIndex tile)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
298 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
299 return (Roadside)GB(_m[tile].m6, 3, 3);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
300 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
301
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
302 static inline void SetRoadside(TileIndex tile, Roadside s)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
303 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
304 SB(_m[tile].m6, 3, 3, s);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
305 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
306
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
307 static inline bool HasRoadWorks(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
308 {
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
309 return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
310 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
311
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
312 static inline bool IncreaseRoadWorksCounter(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
313 {
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
314 AB(_me[t].m7, 0, 4, 1);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
315
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
316 return GB(_me[t].m7, 0, 4) == 15;
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
317 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
318
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
319 static inline void StartRoadWorks(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
320 {
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
321 assert(!HasRoadWorks(t));
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
322 /* Remove any trees or lamps in case or roadwork */
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
323 switch (GetRoadside(t)) {
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
324 case ROADSIDE_BARREN:
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
325 case ROADSIDE_GRASS: SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break;
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
326 default: SetRoadside(t, ROADSIDE_PAVED_ROAD_WORKS); break;
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
327 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
328 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
329
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
330 static inline void TerminateRoadWorks(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
331 {
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
332 assert(HasRoadWorks(t));
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
333 SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
334 /* Stop the counter */
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
335 SB(_me[t].m7, 0, 4, 0);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
336 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
337
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
338
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
339 static inline DiagDirection GetRoadDepotDirection(TileIndex t)
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
340 {
8563
992fa65afba1 (svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch <frosch@openttd.org>
parents: 8529
diff changeset
341 assert(IsRoadDepot(t));
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
342 return (DiagDirection)GB(_m[t].m5, 0, 2);
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
343 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
344
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
345
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
346 /**
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
347 * Returns the RoadBits on an arbitrary tile
6390
a6b14274ee2e (svn r9520) -Codechange: Add the notion of Industry behaviour. It means what an industry can do (plant fields, cut trees, do not change production), what can be done to it (disasters like mine subsidence, jet/chopper attack), when it can be built etc...
belugas <belugas@openttd.org>
parents: 6248
diff changeset
348 * Special behaviour:
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
349 * - road depots: entrance is treated as road piece
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
350 * - road tunnels: entrance is treated as road piece
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
351 * - bridge ramps: start of the ramp is treated as road piece
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
352 * - bridge middle parts: bridge itself is ignored
8716
eba39ab6a0ab (svn r12390) -Fix [FS#1851]: trams failing to turn on bridge heads/tunnel entrances.
rubidium <rubidium@openttd.org>
parents: 8598
diff changeset
353 *
eba39ab6a0ab (svn r12390) -Fix [FS#1851]: trams failing to turn on bridge heads/tunnel entrances.
rubidium <rubidium@openttd.org>
parents: 8598
diff changeset
354 * If straight_tunnel_bridge_entrance is set a ROAD_X or ROAD_Y
eba39ab6a0ab (svn r12390) -Fix [FS#1851]: trams failing to turn on bridge heads/tunnel entrances.
rubidium <rubidium@openttd.org>
parents: 8598
diff changeset
355 * for bridge ramps and tunnel entrances is returned depending
eba39ab6a0ab (svn r12390) -Fix [FS#1851]: trams failing to turn on bridge heads/tunnel entrances.
rubidium <rubidium@openttd.org>
parents: 8598
diff changeset
356 * on the orientation of the tunnel or bridge.
6418
c8862595d06b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium <rubidium@openttd.org>
parents: 6393
diff changeset
357 * @param tile the tile to get the road bits for
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
358 * @param rt the road type to get the road bits form
8716
eba39ab6a0ab (svn r12390) -Fix [FS#1851]: trams failing to turn on bridge heads/tunnel entrances.
rubidium <rubidium@openttd.org>
parents: 8598
diff changeset
359 * @param stbe whether to return straight road bits for tunnels/bridges.
6418
c8862595d06b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium <rubidium@openttd.org>
parents: 6393
diff changeset
360 * @return the road bits of the given tile
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
361 */
8716
eba39ab6a0ab (svn r12390) -Fix [FS#1851]: trams failing to turn on bridge heads/tunnel entrances.
rubidium <rubidium@openttd.org>
parents: 8598
diff changeset
362 RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance = false);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
363
6418
c8862595d06b (svn r9554) -Documentation: add documentation to some map accessors.
rubidium <rubidium@openttd.org>
parents: 6393
diff changeset
364 /**
8102
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
365 * Return if the tile is a valid tile for a crossing.
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
366 *
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
367 * @note function is overloaded
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
368 * @param tile the curent tile
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
369 * @param ax the axis of the road over the rail
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
370 * @return true if it is a valid tile
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
371 */
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
372 bool IsPossibleCrossing(const TileIndex tile, Axis ax);
afb4c7da91df (svn r11663) -Codechange: moving of the road related types and functions.
rubidium <rubidium@openttd.org>
parents: 8101
diff changeset
373
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
374
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
375 static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
376 {
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 6778
diff changeset
377 SetTileType(t, MP_ROAD);
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
378 SetTileOwner(t, road);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
379 _m[t].m2 = town;
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
380 _m[t].m3 = (HasBit(rot, ROADTYPE_TRAM) ? bits : 0);
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
381 _m[t].m4 = 0;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
382 _m[t].m5 = (HasBit(rot, ROADTYPE_ROAD) ? bits : 0) | ROAD_TILE_NORMAL << 6;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
383 SB(_m[t].m6, 2, 4, 0);
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
384 _me[t].m7 = rot << 6;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
385 SetRoadOwner(t, ROADTYPE_TRAM, tram);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
386 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
387
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
388
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
389 static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadTypes rot, uint town)
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
390 {
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 6778
diff changeset
391 SetTileType(t, MP_ROAD);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
392 SetTileOwner(t, rail);
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
393 _m[t].m2 = town;
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
394 _m[t].m3 = rat;
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
395 _m[t].m4 = 0;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
396 _m[t].m5 = ROAD_TILE_CROSSING << 6 | roaddir;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
397 SB(_m[t].m6, 2, 4, 0);
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
398 _me[t].m7 = rot << 6 | road;
6778
3b713d300215 (svn r10014) -Fix: roads became automatically one way in the scenario editor.
rubidium <rubidium@openttd.org>
parents: 6764
diff changeset
399 SetRoadOwner(t, ROADTYPE_TRAM, tram);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
400 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
401
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
402
10289
5f3f0d0a6e07 (svn r14528) -Codechange: cache the closest town for all road tiles instead of only roads owned by tiles. This replaces a O(n) search over all towns from the road's tileloop with a O(1) lookup (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 9784
diff changeset
403 static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir, RoadType rt, TownID town)
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
404 {
7370
fba35a9abf79 (svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium <rubidium@openttd.org>
parents: 6778
diff changeset
405 SetTileType(t, MP_ROAD);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
406 SetTileOwner(t, owner);
10289
5f3f0d0a6e07 (svn r14528) -Codechange: cache the closest town for all road tiles instead of only roads owned by tiles. This replaces a O(n) search over all towns from the road's tileloop with a O(1) lookup (PhilSophus)
rubidium <rubidium@openttd.org>
parents: 9784
diff changeset
407 _m[t].m2 = town;
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
408 _m[t].m3 = 0;
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
409 _m[t].m4 = 0;
6661
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
410 _m[t].m5 = ROAD_TILE_DEPOT << 6 | dir;
5850ac8865e8 (svn r9892) -Codechange: lots of ground work for allowing multiple types of "road" with multiple owners on a single tile.
rubidium <rubidium@openttd.org>
parents: 6418
diff changeset
411 SB(_m[t].m6, 2, 4, 0);
11252
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
412 _me[t].m7 = RoadTypeToRoadTypes(rt) << 6 | owner;
f7b6f8f03e5e (svn r15601) -Fix [FS#2615]: bridges/tunnels don't store tram owner making it possible to remove someone's tram tracks.
rubidium <rubidium@openttd.org>
parents: 10340
diff changeset
413 SetRoadOwner(t, ROADTYPE_TRAM, owner);
5475
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
414 }
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
415
eabf4b86aed6 (svn r7759) -Merge: makefile rewrite. This merge features:
rubidium <rubidium@openttd.org>
parents:
diff changeset
416 #endif /* ROAD_MAP_H */