Mercurial > hg > openttd
annotate road_cmd.c @ 534:6de858608a45 draft
(svn r901) Small step in the process to clean up the DPARAM mess:
- reduce to 2 sizes (*DParam64 for 64bit values, *DParam for the rest)
- use inline functions instead of macros
- add assert()s to check for buffer overruns
author | tron <tron@openttd.org> |
---|---|
date | Thu, 02 Dec 2004 22:53:07 +0000 |
parents | 9dcc34b8887e |
children | facaef10d233 |
rev | line source |
---|---|
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1 #include "stdafx.h" |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
2 #include "ttd.h" |
507
9dcc34b8887e
(svn r815) Include strings.h only in the files which need it.
tron <tron@openttd.org>
parents:
497
diff
changeset
|
3 #include "table/strings.h" |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
4 #include "vehicle.h" |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
5 #include "viewport.h" |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
6 #include "command.h" |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
7 #include "player.h" |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
8 #include "town.h" |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
9 #include "gfx.h" |
159
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
10 #include "table/directions.h" |
337
c88b35750799
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron <tron@openttd.org>
parents:
241
diff
changeset
|
11 #include "sound.h" |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
12 |
22
7a15e52a1c8f
(svn r23) -Some omments on the code (blathijs)
darkvater <darkvater@openttd.org>
parents:
13
diff
changeset
|
13 /* When true, GetTrackStatus for roads will treat roads under reconstruction |
7a15e52a1c8f
(svn r23) -Some omments on the code (blathijs)
darkvater <darkvater@openttd.org>
parents:
13
diff
changeset
|
14 * as normal roads instead of impassable. This is used when detecting whether |
7a15e52a1c8f
(svn r23) -Some omments on the code (blathijs)
darkvater <darkvater@openttd.org>
parents:
13
diff
changeset
|
15 * a road can be removed. This is of course ugly, but I don't know a better |
7a15e52a1c8f
(svn r23) -Some omments on the code (blathijs)
darkvater <darkvater@openttd.org>
parents:
13
diff
changeset
|
16 * solution just like that... */ |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
17 static bool _road_special_gettrackstatus; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
18 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
19 void RoadVehEnterDepot(Vehicle *v); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
20 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
21 |
84
784a9e9bb932
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight <truelight@openttd.org>
parents:
72
diff
changeset
|
22 bool HasTileRoadAt(uint tile, int i) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
23 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
24 int mask; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
25 byte b; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
26 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
27 switch(GET_TILETYPE(tile)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
28 case MP_STREET: |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
29 b = _map5[tile]; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
30 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
31 if ((b & 0xF0) == 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
32 } else if ((b & 0xF0) == 0x10) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
33 b = (b&8)?5:10; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
34 } else if ((b & 0xF0) == 0x20) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
35 return (~b & 3) == i; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
36 } else |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
37 return false; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
38 break; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
39 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
40 case MP_STATION: |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
41 b = _map5[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
42 if (!IS_BYTE_INSIDE(b, 0x43, 0x43+8)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
43 return false; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
44 return ((~(b - 0x43) & 3) == i); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
45 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
46 case MP_TUNNELBRIDGE: |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
47 mask = GetRoadBitsByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
48 b = 10; if (mask & 1) break; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
49 b = 5; if (mask & 2) break; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
50 return false; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
51 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
52 default: |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
53 return false; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
54 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
55 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
56 return HASBIT(b, i); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
57 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
58 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
59 static bool CheckAllowRemoveRoad(uint tile, uint br, bool *edge_road) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
60 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
61 int blocks; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
62 byte owner; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
63 uint n; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
64 *edge_road = true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
65 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
66 if (_game_mode == GM_EDITOR) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
67 return true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
68 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
69 blocks = GetRoadBitsByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
70 if (blocks == 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
71 return true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
72 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
73 // Only do the special processing for actual players. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
74 if (_current_player >= MAX_PLAYERS) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
75 return true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
76 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
77 // A railway crossing has the road owner in the map3_lo byte. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
78 if (IS_TILETYPE(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
79 owner = _map3_lo[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
80 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
81 owner = _map_owner[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
82 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
83 // Only do the special processing if the road is owned |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
84 // by a town |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
85 if (owner != OWNER_TOWN) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
86 return owner == OWNER_NONE || CheckOwnership(owner); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
87 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
88 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
89 if (_cheats.magic_bulldozer.value) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
90 return true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
91 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
92 // Get a bitmask of which neighbouring roads has a tile |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
93 n = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
94 if (blocks&0x25 && HasTileRoadAt(TILE_ADDXY(tile,-1, 0), 1)) n |= 8; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
95 if (blocks&0x2A && HasTileRoadAt(TILE_ADDXY(tile, 0, 1), 0)) n |= 4; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
96 if (blocks&0x19 && HasTileRoadAt(TILE_ADDXY(tile, 1, 0), 3)) n |= 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
97 if (blocks&0x16 && HasTileRoadAt(TILE_ADDXY(tile, 0,-1), 2)) n |= 1; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
98 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
99 // If 0 or 1 bits are set in n, or if no bits that match the bits to remove, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
100 // then allow it |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
101 if ((n & (n-1)) != 0 && (n & br) != 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
102 Town *t; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
103 *edge_road = false; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
104 // you can remove all kind of roads with extra dynamite |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
105 if (_patches.extra_dynamite) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
106 return true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
107 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
108 t = ClosestTownFromTile(tile, (uint)-1); |
534
6de858608a45
(svn r901) Small step in the process to clean up the DPARAM mess:
tron <tron@openttd.org>
parents:
507
diff
changeset
|
109 SetDParam(0, t->index); |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
110 _error_message = STR_2009_LOCAL_AUTHORITY_REFUSES; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
111 return false; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
112 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
113 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
114 return true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
115 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
116 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
117 bool IsRoadDepotTile(TileIndex tile) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
118 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
119 return IS_TILETYPE(tile, MP_STREET) && |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
120 (_map5[tile] & 0xF0) == 0x20; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
121 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
122 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
123 uint GetRoadBitsByTile(TileIndex tile) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
124 { |
159
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
125 uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD); |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
126 return (byte)(r | (r >> 8)); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
127 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
128 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
129 // cost for removing inner/edge -roads |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
130 static const uint16 _road_remove_cost[2] = {50, 18}; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
131 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
132 /* Delete a piece of road |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
133 * p1 = piece type |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
134 */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
135 int32 CmdRemoveRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
136 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
137 TileInfo ti; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
138 int32 cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
139 uint tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
140 Town *t; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
141 /* true if the roadpiece was always removeable, |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
142 false if it was a center piece. Affects town ratings drop |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
143 */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
144 bool edge_road; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
145 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
146 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
147 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
148 FindLandscapeHeight(&ti, x, y); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
149 tile = ti.tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
150 t = ClosestTownFromTile(tile, (uint)-1); // needed for town rating penalty |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
151 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
152 // allow deleting road under bridge |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
153 if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
154 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
155 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
156 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
157 bool b; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
158 _road_special_gettrackstatus = true; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
159 b = CheckAllowRemoveRoad(tile, p1, &edge_road); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
160 _road_special_gettrackstatus = false; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
161 if (!b) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
162 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
163 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
164 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
165 if (ti.type == MP_TUNNELBRIDGE) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
166 if (!EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile))) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
167 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
168 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
169 if ((ti.map5 & 0xE9) == 0xE8) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
170 if (p1 & 10) goto return_error; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
171 } else if ((ti.map5 & 0xE9) == 0xE9) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
172 if (p1 & 5) goto return_error; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
173 } else |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
174 goto return_error; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
175 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
176 cost = _price.remove_road * 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
177 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
178 if (flags & DC_EXEC) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
179 _map5[tile] = ti.map5 & 0xC7; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
180 _map_owner[tile] = OWNER_NONE; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
181 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
182 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
183 return cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
184 } else if (ti.type == MP_STREET) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
185 if (!(ti.map5 & 0xF0)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
186 uint c = p1, t2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
187 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
188 if (ti.tileh != 0 && (ti.map5 == 5 || ti.map5 == 10)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
189 c |= (c & 0xC) >> 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
190 c |= (c & 0x3) << 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
191 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
192 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
193 // limit the bits to delete to the existing bits. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
194 if ((c &= ti.map5) == 0) goto return_error; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
195 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
196 // calculate the cost |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
197 t2 = c; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
198 cost = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
199 do { |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
200 if (t2&1) cost += _price.remove_road; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
201 } while(t2>>=1); |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
202 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
203 // check if you're allowed to remove the street owned by a town |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
204 // removal allowance depends on difficulty setting |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
205 if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) { |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
206 if (!CheckforTownRating(tile, flags, t, ROAD_REMOVE)) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
207 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
208 } |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
209 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
210 if (flags & DC_EXEC) { |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
211 // checks if the owner is town than decrease town rating by 50 until you have |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
212 // a "Poor" town rating |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
213 if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
214 ChangeTownRating(t, -_road_remove_cost[(byte)edge_road], -100); |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
215 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
216 _map5[tile] ^= c; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
217 if ((_map5[tile]&0xF) == 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
218 DoClearSquare(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
219 else |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
220 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
221 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
222 } |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
223 return cost; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
224 } else if (!(ti.map5 & 0xE0)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
225 byte c; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
226 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
227 if (!(ti.map5 & 8)) { |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
228 c = 2; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
229 if (p1 & 5) goto return_error; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
230 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
231 c = 1; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
232 if (p1 & 10) goto return_error; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
233 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
234 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
235 cost = _price.remove_road * 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
236 if (flags & DC_EXEC) { |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
237 ModifyTile(tile, |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
238 MP_SETTYPE(MP_RAILWAY) | |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
239 MP_MAP2_CLEAR | MP_MAP3LO | MP_MAP3HI_CLEAR | MP_MAP5, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
240 _map3_hi[tile] & 0xF, /* map3_lo */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
241 c /* map5 */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
242 ); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
243 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
244 return cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
245 } else |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
246 goto return_error; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
247 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
248 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
249 return_error:; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
250 return_cmd_error(INVALID_STRING_ID); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
251 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
252 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
253 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
254 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
255 enum { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
256 ROAD_NW = 1, // NW road track |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
257 ROAD_SW = 2, // SW road track |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
258 ROAD_SE = 4, // SE road track |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
259 ROAD_NE = 8, // NE road track |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
260 ROAD_ALL = (ROAD_NW | ROAD_SW | ROAD_SE | ROAD_NE) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
261 }; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
262 |
13
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
263 static const byte _valid_tileh_slopes_road[3][15] = { |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
264 // set of normal ones |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
265 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
266 ROAD_ALL, 0, 0, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
267 ROAD_SW | ROAD_NE, 0, 0, // 3, 4, 5 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
268 ROAD_NW | ROAD_SE, 0, 0, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
269 ROAD_NW | ROAD_SE, 0, 0, // 9, 10, 11 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
270 ROAD_SW | ROAD_NE, 0, 0 |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
271 }, |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
272 // allowed road for an evenly raised platform |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
273 { |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
274 0, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
275 ROAD_SW | ROAD_NW, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
276 ROAD_SW | ROAD_SE, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
277 ROAD_NW | ROAD_SE | ROAD_SW, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
278 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
279 ROAD_SE | ROAD_NE, // 4 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
280 ROAD_ALL, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
281 ROAD_SW | ROAD_NE | ROAD_SE, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
282 ROAD_ALL, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
283 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
284 ROAD_NW | ROAD_NE, // 8 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
285 ROAD_SW | ROAD_NE | ROAD_NW, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
286 ROAD_ALL, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
287 ROAD_ALL, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
288 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
289 ROAD_NW | ROAD_SE | ROAD_NE, // 12 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
290 ROAD_ALL, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
291 ROAD_ALL |
13
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
292 }, |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
293 // valid railway crossings on slopes |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
294 { |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
295 1, 0, 0, // 0, 1, 2 |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
296 0, 0, 1, // 3, 4, 5 |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
297 0, 1, 0, // 6, 7, 8 |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
298 0, 1, 1, // 9, 10, 11 |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
299 0, 1, 1, // 12, 13, 14 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
300 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
301 }; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
302 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
303 |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
304 static uint32 CheckRoadSlope(int tileh, byte *pieces, byte existing) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
305 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
306 if (!(tileh & 0x10)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
307 byte road_bits = *pieces | existing; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
308 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
309 // no special foundation |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
310 if ((~_valid_tileh_slopes_road[0][tileh] & road_bits) == 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
311 // force that all bits are set when we have slopes |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
312 if (tileh != 0) *pieces |= _valid_tileh_slopes_road[0][tileh]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
313 return 0; // no extra cost |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
314 } |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
315 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
316 // foundation is used. Whole tile is leveled up |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
317 if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) { |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
318 return existing ? 0 : _price.terraform; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
319 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
320 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
321 // partly leveled up tile, only if there's no road on that tile |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
322 if ( !existing && (tileh == 1 || tileh == 2 || tileh == 4 || tileh == 8) ) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
323 // force full pieces. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
324 *pieces |= (*pieces & 0xC) >> 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
325 *pieces |= (*pieces & 0x3) << 2; |
72
0ecf460b53fc
(svn r73) -Fix: Wrong building of road-slopes for a future AI/Town
darkvater <darkvater@openttd.org>
parents:
39
diff
changeset
|
326 return (*pieces == (ROAD_NE|ROAD_SW) || *pieces == (ROAD_SE|ROAD_NW)) ? _price.terraform : CMD_ERROR; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
327 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
328 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
329 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
330 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
331 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
332 /* Build a piece of road |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
333 * p1 = piece flags |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
334 */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
335 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
336 int32 CmdBuildRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
337 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
338 TileInfo ti; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
339 int32 cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
340 byte pieces = (byte)p1, existing = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
341 uint tile; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
342 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
343 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
344 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
345 FindLandscapeHeight(&ti, x, y); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
346 tile = ti.tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
347 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
348 // allow building road under bridge |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
349 if (ti.type != MP_TUNNELBRIDGE && !EnsureNoVehicle(tile)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
350 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
351 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
352 if (ti.type == MP_STREET) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
353 if (!(ti.map5 & 0xF0)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
354 if ( ((pieces) & (byte)(ti.map5)) == (pieces)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
355 return_cmd_error(STR_1007_ALREADY_BUILT); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
356 existing = ti.map5; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
357 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
358 if (!(ti.map5 & 0xE0) && pieces != ((ti.map5 & 8) ? 5 : 10)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
359 return_cmd_error(STR_1007_ALREADY_BUILT); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
360 goto do_clear; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
361 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
362 } else if (ti.type == MP_RAILWAY) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
363 byte m5; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
364 |
13
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
365 if (ti.tileh & 0x10) // very steep tile |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
366 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
367 |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
368 if(!_valid_tileh_slopes_road[2][ti.tileh]) // prevent certain slopes |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
369 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
370 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
371 if (ti.map5 == 2) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
372 if (pieces & 5) goto do_clear; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
373 m5 = 0x10; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
374 } else if (ti.map5 == 1) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
375 if (pieces & 10) goto do_clear; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
376 m5 = 0x18; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
377 } else |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
378 goto do_clear; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
379 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
380 if (flags & DC_EXEC) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
381 ModifyTile(tile, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
382 MP_SETTYPE(MP_STREET) | |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
383 MP_MAP2_CLEAR | MP_MAP3LO | MP_MAP3HI | MP_MAP5, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
384 _current_player, /* map3_lo */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
385 _map3_lo[tile] & 0xF, /* map3_hi */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
386 m5 /* map5 */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
387 ); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
388 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
389 return _price.build_road * 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
390 } else if (ti.type == MP_TUNNELBRIDGE) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
391 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
392 /* check for flat land */ |
13
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
393 if (ti.tileh & 0x10) // very steep tile |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
394 return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
395 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
396 /* is this middle part of a bridge? */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
397 if ((ti.map5 & 0xC0) != 0xC0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
398 goto do_clear; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
399 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
400 /* only allow roads pertendicular to bridge */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
401 if ((pieces & 5) == (ti.map5 & 0x01)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
402 goto do_clear; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
403 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
404 /* check if clear land under bridge */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
405 if ((ti.map5 & 0xF8) == 0xE8) /* road under bridge */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
406 return_cmd_error(STR_1007_ALREADY_BUILT); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
407 else if ((ti.map5 & 0xE0) == 0xE0) /* other transport route under bridge */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
408 return_cmd_error(STR_1008_MUST_REMOVE_RAILROAD_TRACK); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
409 else if ((ti.map5 & 0xF8) == 0xC8) /* water under bridge */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
410 return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
411 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
412 /* all checked, can build road now! */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
413 cost = _price.build_road * 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
414 if (flags & DC_EXEC) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
415 ModifyTile(tile, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
416 MP_MAPOWNER_CURRENT | MP_MAP5, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
417 (ti.map5 & 0xC7) | 0x28 // map5 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
418 ); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
419 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
420 return cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
421 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
422 do_clear:; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
423 if (DoCommandByTile(tile, 0, 0, flags & ~DC_EXEC, CMD_LANDSCAPE_CLEAR) == CMD_ERROR) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
424 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
425 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
426 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
427 cost = CheckRoadSlope(ti.tileh, &pieces, existing); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
428 if (cost == CMD_ERROR) return_cmd_error(STR_1800_LAND_SLOPED_IN_WRONG_DIRECTION); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
429 |
84
784a9e9bb932
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight <truelight@openttd.org>
parents:
72
diff
changeset
|
430 if (cost && (!_patches.build_on_slopes || (!_patches.ainew_active && _is_ai_player))) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
431 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
432 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
433 if (!(ti.type == MP_STREET && (ti.map5 & 0xF0) == 0)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
434 cost += DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
435 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
436 // Don't put the pieces that already exist |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
437 pieces &= ~ti.map5; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
438 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
439 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
440 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
441 byte t = pieces; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
442 while (t) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
443 if (t & 1) cost += _price.build_road; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
444 t >>= 1; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
445 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
446 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
447 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
448 if (flags & DC_EXEC) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
449 if (ti.type != MP_STREET) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
450 _map_type_and_height[tile] &= 0xF; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
451 _map_type_and_height[tile] |= MP_STREET << 4; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
452 _map5[tile] = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
453 _map_owner[tile] = _current_player; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
454 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
455 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
456 _map5[tile] |= (byte)pieces; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
457 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
458 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
459 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
460 return cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
461 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
462 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
463 int32 DoConvertStreetRail(uint tile, uint totype, bool exec) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
464 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
465 // not a railroad crossing? |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
466 if ((_map5[tile] & 0xF0) != 0x10) return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
467 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
468 // not owned by me? |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
469 if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
470 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
471 // tile is already of requested type? |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
472 if ( (uint)(_map3_hi[tile] & 0xF) == totype) return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
473 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
474 if (exec) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
475 // change type. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
476 _map3_hi[tile] = (_map3_hi[tile] & 0xF0) + totype; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
477 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
478 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
479 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
480 return _price.build_rail >> 1; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
481 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
482 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
483 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
484 // Build a long piece of road. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
485 // x,y = end tile |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
486 // p1 = start tile |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
487 // p2&1 = start tile starts in the 2nd half |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
488 // p2&2 = end tile starts in the 2nd half |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
489 // p2&4 = direction (0 = along x, 1=along y) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
490 int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
491 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
492 uint start_tile, end_tile, tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
493 int mode; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
494 int32 cost,ret; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
495 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
496 start_tile = p1; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
497 end_tile = TILE_FROM_XY(x, y); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
498 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
499 if (start_tile > end_tile || (start_tile == end_tile && (p2&1))) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
500 uint t = start_tile; start_tile = end_tile; end_tile = t; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
501 p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
502 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
503 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
504 cost = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
505 tile = start_tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
506 // Start tile is the small number. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
507 for(;;) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
508 mode = (p2&4) ? 5 : 10; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
509 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
510 if (tile == start_tile && (p2&1)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
511 mode &= (4+2); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
512 else if (tile == end_tile && !(p2&2)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
513 mode &= (1+8); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
514 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
515 ret = DoCommandByTile(tile, mode, 0, flags, CMD_BUILD_ROAD); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
516 if (ret == CMD_ERROR) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
517 if (_error_message != STR_1007_ALREADY_BUILT) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
518 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
519 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
520 cost += ret; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
521 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
522 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
523 if (tile == end_tile) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
524 break; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
525 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
526 tile += (p2&4)?TILE_XY(0,1):TILE_XY(1,0); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
527 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
528 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
529 // already built? |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
530 if (cost == 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
531 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
532 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
533 return cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
534 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
535 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
536 // Remove a long piece of road. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
537 // x,y = end tile |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
538 // p1 = start tile |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
539 // p2&1 = start tile starts in the 2nd half |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
540 // p2&2 = end tile starts in the 2nd half |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
541 // p2&4 = direction (0 = along x, 1=along y) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
542 int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
543 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
544 uint start_tile, end_tile, tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
545 int32 cost,ret; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
546 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
547 start_tile = p1; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
548 end_tile = TILE_FROM_XY(x, y); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
549 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
550 if (start_tile > end_tile || (start_tile == end_tile && (p2&1))) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
551 uint t = start_tile; start_tile = end_tile; end_tile = t; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
552 p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
553 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
554 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
555 cost = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
556 tile = start_tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
557 // Start tile is the small number. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
558 for(;;) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
559 uint bits = (p2 & 4) ? ROAD_SE | ROAD_NW : ROAD_SW | ROAD_NE; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
560 if (tile == end_tile && !(p2&2)) bits &= ROAD_NW | ROAD_NE; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
561 if (tile == start_tile && (p2&1)) bits &= ROAD_SE | ROAD_SW; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
562 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
563 // try to remove the halves. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
564 if (bits) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
565 ret = DoCommandByTile(tile, bits, 0, flags, CMD_REMOVE_ROAD); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
566 if (ret != CMD_ERROR) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
567 cost += ret; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
568 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
569 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
570 if (tile == end_tile) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
571 break; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
572 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
573 tile += (p2&4)?TILE_XY(0,1):TILE_XY(1,0); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
574 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
575 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
576 // already built? |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
577 if (cost == 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
578 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
579 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
580 return cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
581 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
582 |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
583 /* Build a road depot |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
584 * p1 - direction (0-3) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
585 * p2 - unused |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
586 */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
587 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
588 int32 CmdBuildRoadDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
589 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
590 TileInfo ti; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
591 int32 cost; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
592 Depot *dep; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
593 uint tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
594 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
595 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
596 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
597 FindLandscapeHeight(&ti, x, y); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
598 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
599 tile = ti.tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
600 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
601 if (!EnsureNoVehicle(tile)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
602 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
603 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
604 if (ti.tileh != 0) { |
84
784a9e9bb932
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight <truelight@openttd.org>
parents:
72
diff
changeset
|
605 if (!_patches.build_on_slopes || (ti.tileh & 0x10 || !((0x4C >> p1) & ti.tileh) )) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
606 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
607 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
608 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
609 cost = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
610 if (cost == CMD_ERROR) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
611 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
612 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
613 dep = AllocateDepot(); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
614 if (dep == NULL) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
615 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
616 |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
617 if (flags & DC_EXEC) { |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
618 if (_current_player == _local_player) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
619 _last_built_road_depot_tile = (TileIndex)tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
620 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
621 dep->xy = tile; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
622 dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
623 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
624 ModifyTile(tile, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
625 MP_SETTYPE(MP_STREET) | |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
626 MP_MAPOWNER_CURRENT | MP_MAP5, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
627 (p1 | 0x20) /* map5 */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
628 ); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
629 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
630 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
631 return cost + _price.build_road_depot; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
632 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
633 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
634 static int32 RemoveRoadDepot(uint tile, uint32 flags) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
635 { |
149
811875caee5f
(svn r150) -Fix: [1010833] Turning on the magic bulldozer removes oil rigs
darkvater <darkvater@openttd.org>
parents:
84
diff
changeset
|
636 if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
637 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
638 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
639 if (!EnsureNoVehicle(tile)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
640 return CMD_ERROR; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
641 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
642 if (flags & DC_EXEC) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
643 DoDeleteDepot(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
644 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
645 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
646 return _price.remove_road_depot; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
647 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
648 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
649 #define M(x) (1<<(x)) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
650 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
651 static int32 ClearTile_Road(uint tile, byte flags) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
652 int32 ret; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
653 byte m5 = _map5[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
654 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
655 if ( (m5 & 0xF0) == 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
656 byte b = m5 & 0xF; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
657 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
658 if (! ((1 << b) & (M(1)|M(2)|M(4)|M(8))) ) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
659 if ( (!(flags & DC_AI_BUILDING) || _map_owner[tile]!=OWNER_TOWN) && flags&DC_AUTO) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
660 return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
661 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
662 return DoCommandByTile(tile, b, 0, flags, CMD_REMOVE_ROAD); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
663 } else if ( (m5 & 0xE0) == 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
664 if (flags & DC_AUTO) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
665 return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
666 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
667 ret = DoCommandByTile(tile, (m5&8)?5:10, 0, flags, CMD_REMOVE_ROAD); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
668 if (ret == CMD_ERROR) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
669 return CMD_ERROR; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
670 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
671 if (flags & DC_EXEC) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
672 DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
673 } |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
674 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
675 return ret; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
676 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
677 if (flags & DC_AUTO) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
678 return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
679 return RemoveRoadDepot(tile,flags); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
680 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
681 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
682 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
683 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
684 typedef struct DrawRoadTileStruct { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
685 uint16 image; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
686 byte subcoord_x; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
687 byte subcoord_y; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
688 } DrawRoadTileStruct; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
689 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
690 typedef struct DrawRoadSeqStruct { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
691 uint32 image; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
692 byte subcoord_x; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
693 byte subcoord_y; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
694 byte width; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
695 byte height; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
696 } DrawRoadSeqStruct; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
697 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
698 #include "table/road_land.h" |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
699 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
700 |
84
784a9e9bb932
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight <truelight@openttd.org>
parents:
72
diff
changeset
|
701 uint GetRoadFoundation(uint tileh, uint bits) { |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
702 int i; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
703 // normal level sloped building |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
704 if ((~_valid_tileh_slopes_road[1][tileh] & bits) == 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
705 return tileh; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
706 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
707 // inclined sloped building |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
708 if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
709 ((bits == (ROAD_SW | ROAD_NE)) || (i++, bits == (ROAD_NW | ROAD_SE)))) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
710 return i + 15; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
711 |
13
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
712 // rail crossing |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
713 if ((bits & 0x10) && _valid_tileh_slopes_road[2][tileh]) |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
714 return tileh; |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
715 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
716 return 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
717 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
718 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
719 const byte _road_sloped_sprites[14] = { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
720 0, 0, 2, 0, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
721 0, 1, 0, 0, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
722 3, 0, 0, 0, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
723 0, 0 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
724 }; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
725 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
726 static void DrawTile_Road(TileInfo *ti) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
727 { |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
728 uint32 image; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
729 byte m2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
730 const byte *s; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
731 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
732 if ( (ti->map5 & 0xF0) == 0) { // if it is a road the upper 4 bits are 0 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
733 const DrawRoadTileStruct *drts; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
734 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
735 if (ti->tileh != 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
736 int f = GetRoadFoundation(ti->tileh, ti->map5 & 0xF); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
737 if (f) DrawFoundation(ti, f); |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
738 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
739 // default sloped sprites.. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
740 if (ti->tileh != 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
741 image = _road_sloped_sprites[ti->tileh - 1] + 0x53F; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
742 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
743 image = _road_tile_sprites_1[ti->map5 & 0xF]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
744 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
745 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
746 image = _road_tile_sprites_1[ti->map5 & 0xF]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
747 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
748 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
749 m2 = _map2[ti->tile] & 7; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
750 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
751 if (m2 == 0) image |= 0x3178000; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
752 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
753 if (_map3_hi[ti->tile] & 0x80) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
754 image += 19; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
755 } else if (m2 > 1 && m2 != 6) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
756 image -= 19; /* pavement along the road? */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
757 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
758 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
759 DrawGroundSprite(image); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
760 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
761 if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
762 return; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
763 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
764 if (m2 >= 6) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
765 // roadwork |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
766 DrawGroundSprite(0x586 + ((ti->map5&8)!=0 ? 0 : 1)); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
767 return; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
768 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
769 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
770 drts = (const DrawRoadTileStruct*)_road_display_table[m2][ti->map5 & 0xF]; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
771 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
772 while ((image = drts->image) != 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
773 int x = ti->x | drts->subcoord_x; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
774 int y = ti->y | drts->subcoord_y; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
775 byte z = ti->z; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
776 if (ti->tileh != 0) z = GetSlopeZ(x, y); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
777 AddSortableSpriteToDraw(image, x, y, 2, 2, 0x10, z); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
778 drts++; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
779 } |
13
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
780 } else if ( (ti->map5 & 0xE0) == 0) { // railroad crossing |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
781 int f = GetRoadFoundation(ti->tileh, ti->map5 & 0xF); |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
782 if (f) DrawFoundation(ti, f); |
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
783 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
784 image = 0x55B; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
785 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
786 if ( (ti->map5 & 8) != 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
787 image--; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
788 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
789 if ( (ti->map5 & 4) != 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
790 image += 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
791 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
792 if ( _map3_hi[ti->tile] & 0x80) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
793 image += 8; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
794 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
795 m2 = _map2[ti->tile] & 7; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
796 if (m2 == 0) image |= 0x3178000; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
797 if (m2 > 1) image += 4; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
798 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
799 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
800 DrawGroundSprite(image + (_map3_hi[ti->tile] & 0xF) * 12); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
801 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
802 uint32 ormod; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
803 int player; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
804 const DrawRoadSeqStruct *drss; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
805 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
806 if (ti->tileh != 0) { DrawFoundation(ti, ti->tileh); } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
807 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
808 ormod = 0x315; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
809 player = _map_owner[ti->tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
810 if (player < MAX_PLAYERS) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
811 ormod = PLAYER_SPRITE_COLOR(player); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
812 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
813 s = _road_display_datas[ti->map5 & 0xF]; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
814 |
222
d1b097f4593b
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater <darkvater@openttd.org>
parents:
204
diff
changeset
|
815 DrawGroundSprite(*(const uint32*)s); |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
816 s += sizeof(uint32); |
222
d1b097f4593b
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater <darkvater@openttd.org>
parents:
204
diff
changeset
|
817 drss = (const DrawRoadSeqStruct*)s; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
818 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
819 while ((image=drss->image) != 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
820 if (image & 0x8000) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
821 image |= ormod; |
497
5ac8ae8585fa
(svn r787) Invert the sense of the DO_TRANS_BUILDINGS flag to be consistent with its own name and all other DO_* flags.
tron <tron@openttd.org>
parents:
473
diff
changeset
|
822 if (_display_opt & DO_TRANS_BUILDINGS) // show transparent depots |
204
6b6352ec7434
(svn r205) -Fix: [1026271] Vehicle depots not transparent with transparent buildings.
darkvater <darkvater@openttd.org>
parents:
201
diff
changeset
|
823 image = (image & 0x3FFF) | 0x3224000; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
824 |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
825 AddSortableSpriteToDraw(image, ti->x | drss->subcoord_x, |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
826 ti->y | drss->subcoord_y, drss->width, drss->height, 0x14, ti->z); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
827 drss++; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
828 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
829 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
830 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
831 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
832 void DrawRoadDepotSprite(int x, int y, int image) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
833 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
834 uint32 ormod; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
835 const DrawRoadSeqStruct *dtss; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
836 const byte *t; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
837 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
838 ormod = PLAYER_SPRITE_COLOR(_local_player); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
839 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
840 t = _road_display_datas[image]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
841 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
842 x+=33; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
843 y+=17; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
844 |
222
d1b097f4593b
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater <darkvater@openttd.org>
parents:
204
diff
changeset
|
845 DrawSprite(*(const uint32*)t, x, y); |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
846 t += sizeof(uint32); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
847 |
222
d1b097f4593b
(svn r223) -Fix: Const correctness and miscellaneous fixes. Thank you Tron for your diligent fixing of warnings (and some possibly bugs) (Tron)
darkvater <darkvater@openttd.org>
parents:
204
diff
changeset
|
848 for(dtss = (const DrawRoadSeqStruct *)t; dtss->image != 0; dtss++) { |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
849 Point pt = RemapCoords(dtss->subcoord_x, dtss->subcoord_y, 0); |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
850 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
851 image = dtss->image; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
852 if (image & 0x8000) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
853 image |= ormod; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
854 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
855 DrawSprite(image, x + pt.x, y + pt.y); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
856 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
857 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
858 |
410
e165d1275350
(svn r607) -Patch: [ 985102 ] static cleanup
tron <tron@openttd.org>
parents:
337
diff
changeset
|
859 static uint GetSlopeZ_Road(TileInfo *ti) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
860 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
861 uint z = ti->z; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
862 int th = ti->tileh; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
863 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
864 // check if it's a foundation |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
865 if (ti->tileh != 0) { |
13
c8795721b2d5
(svn r14) Fix: railroad crossings on slopes are now possible
dominik <dominik@openttd.org>
parents:
0
diff
changeset
|
866 if ((ti->map5 & 0xE0) == 0) { /* road or crossing */ |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
867 uint f = GetRoadFoundation(ti->tileh, ti->map5 & 0x3F); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
868 if (f != 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
869 if (f < 15) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
870 // leveled foundation |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
871 return z + 8; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
872 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
873 // inclined foundation |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
874 th = _inclined_tileh[f - 15]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
875 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
876 } else if ((ti->map5 & 0xF0) == 0x20) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
877 // depot |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
878 return z + 8; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
879 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
880 return GetPartialZ(ti->x&0xF, ti->y&0xF, th) + z; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
881 } |
39
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
882 return z; // normal Z if no slope |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
883 } |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
884 |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
885 uint GetSlopeTileh_Road(TileInfo *ti) |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
886 { |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
887 // check if it's a foundation |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
888 if (ti->tileh != 0) { |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
889 if ((ti->map5 & 0xE0) == 0) { /* road or crossing */ |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
890 uint f = GetRoadFoundation(ti->tileh, ti->map5 & 0x3F); |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
891 if (f != 0) { |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
892 if (f < 15) { |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
893 // leveled foundation |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
894 return 0; |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
895 } |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
896 // inclined foundation |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
897 return _inclined_tileh[f - 15]; |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
898 } |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
899 } else if ((ti->map5 & 0xF0) == 0x20) { |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
900 // depot |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
901 return 0; |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
902 } |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
903 } |
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
904 return ti->tileh; |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
905 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
906 |
473
b2908e7209e4
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron <tron@openttd.org>
parents:
410
diff
changeset
|
907 static void GetAcceptedCargo_Road(uint tile, AcceptedCargo ac) |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
908 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
909 /* not used */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
910 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
911 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
912 static void AnimateTile_Road(uint tile) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
913 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
914 if ((_map5[tile] & 0xF0) == 0x10) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
915 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
916 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
917 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
918 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
919 static const byte _town_road_types[5][2] = { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
920 {1,1}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
921 {2,2}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
922 {2,2}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
923 {5,5}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
924 {3,2}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
925 }; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
926 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
927 static const byte _town_road_types_2[5][2] = { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
928 {1,1}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
929 {2,2}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
930 {3,2}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
931 {3,2}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
932 {3,2}, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
933 }; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
934 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
935 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
936 static void TileLoop_Road(uint tile) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
937 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
938 Town *t; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
939 int grp; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
940 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
941 if (_opt.landscape == LT_HILLY) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
942 // Fix snow style if the road is above the snowline |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
943 if ((_map3_hi[tile] & 0x80) != ((GetTileZ(tile) > _opt.snow_line) ? 0x80 : 0x00)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
944 _map3_hi[tile] ^= 0x80; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
945 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
946 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
947 } else if (_opt.landscape == LT_DESERT) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
948 // Fix desert style |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
949 if (GetMapExtraBits(tile) == 1 && !(_map3_hi[tile] & 0x80)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
950 _map3_hi[tile] |= 0x80; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
951 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
952 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
953 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
954 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
955 if (_map5[tile] & 0xE0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
956 return; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
957 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
958 if ((_map2[tile] & 7) < 6) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
959 t = ClosestTownFromTile(tile, (uint)-1); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
960 grp = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
961 if (t != NULL) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
962 // If in the scenario editor, set the owner to a town. |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
963 if (_game_mode == GM_EDITOR) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
964 _map_owner[tile] = OWNER_TOWN; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
965 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
966 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
967 grp = GetTownRadiusGroup(t, tile); |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
968 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
969 // Show an animation to indicate road work |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
970 if (t->road_build_months != 0 && |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
971 !(GetTileDist(t->xy, tile) >= 8 && grp==0) && |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
972 (_map5[tile]==5 || _map5[tile]==10)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
973 if (GetTileSlope(tile, NULL) == 0 && EnsureNoVehicle(tile) && CHANCE16(1,20)) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
974 _map2[tile] = ((_map2[tile]&7) <= 1) ? 6 : 7; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
975 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
976 SndPlayTileFx(0x1F,tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
977 CreateEffectVehicleAbove( |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
978 GET_TILE_X(tile) * 16 + 7, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
979 GET_TILE_Y(tile) * 16 + 7, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
980 0, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
981 EV_ROADWORK); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
982 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
983 return; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
984 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
985 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
986 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
987 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
988 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
989 const byte *p = (_opt.landscape == LT_CANDY) ? _town_road_types_2[grp] : _town_road_types[grp]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
990 byte b = _map2[tile] & 7; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
991 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
992 if (b == p[0]) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
993 return; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
994 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
995 if (b == p[1]) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
996 b = p[0]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
997 } else if (b == 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
998 b = p[1]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
999 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1000 b = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1001 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1002 _map2[tile] = (_map2[tile] & ~7) | b; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1003 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1004 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1005 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1006 // Handle road work |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
1007 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1008 byte b = _map2[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1009 if (b < 0x80) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1010 _map2[tile] = b + 8; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1011 return; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1012 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1013 _map2[tile] = ((b&7) == 6) ? 1 : 2; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1014 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1015 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1016 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1017 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1018 void ShowRoadDepotWindow(uint tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1019 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1020 static void ClickTile_Road(uint tile) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1021 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1022 if ((_map5[tile] & 0xF0) == 0x20) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1023 ShowRoadDepotWindow(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1024 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1025 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1026 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1027 static const byte _road_trackbits[16] = { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1028 0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1029 }; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1030 |
159
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
1031 static uint32 GetTileTrackStatus_Road(uint tile, TransportType mode) { |
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
1032 if (mode == TRANSPORT_RAIL) { |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1033 if ((_map5[tile] & 0xF0) != 0x10) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1034 return 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1035 return _map5[tile] & 8 ? 0x101 : 0x202; |
159
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
1036 } else if (mode == TRANSPORT_ROAD) { |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1037 byte b = _map5[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1038 if ((b & 0xF0) == 0) { |
159
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
1039 /* Ordinary road */ |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1040 if (!_road_special_gettrackstatus && (_map2[tile]&7) >= 6) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1041 return 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1042 return _road_trackbits[b&0xF] * 0x101; |
159
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
1043 } else if ((b&0xF0) == 0x10) { |
a4e15430335b
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight <truelight@openttd.org>
parents:
149
diff
changeset
|
1044 /* Crossing */ |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1045 uint32 r = 0x101; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1046 if (b&8) r <<= 1; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
1047 |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1048 if (b&4) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1049 r *= 0x10001; |
201
f2b49b0674c6
(svn r202) -Codechange: I missed some files with trailing spaces.. this should be
truelight <truelight@openttd.org>
parents:
159
diff
changeset
|
1050 } |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1051 return r; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1052 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1053 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1054 return 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1055 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1056 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1057 static const StringID _road_tile_strings[] = { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1058 STR_1818_ROAD_RAIL_LEVEL_CROSSING, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1059 STR_1817_ROAD_VEHICLE_DEPOT, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1060 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1061 STR_1814_ROAD, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1062 STR_1814_ROAD, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1063 STR_1814_ROAD, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1064 STR_1815_ROAD_WITH_STREETLIGHTS, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1065 STR_1814_ROAD, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1066 STR_1816_TREE_LINED_ROAD, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1067 STR_1814_ROAD, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1068 STR_1814_ROAD, |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1069 }; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1070 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1071 static void GetTileDesc_Road(uint tile, TileDesc *td) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1072 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1073 int i = (_map5[tile] >> 4); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1074 if (i == 0) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1075 i = (_map2[tile] & 7) + 3; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1076 td->str = _road_tile_strings[i - 1]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1077 td->owner = _map_owner[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1078 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1079 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1080 static const byte _roadveh_enter_depot_unk0[4] = { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1081 8, 9, 0, 1 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1082 }; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1083 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1084 static uint32 VehicleEnter_Road(Vehicle *v, uint tile, int x, int y) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1085 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1086 if ((_map5[tile] & 0xF0) == 0x10) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1087 if (v->type == VEH_Train && (_map5[tile] & 4) == 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1088 /* train crossing a road */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1089 SndPlayVehicleFx(12, v); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1090 _map5[tile] |= 4; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1091 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1092 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1093 } else if ((_map5[tile]&0xF0) == 0x20){ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1094 if (v->type == VEH_Road && v->u.road.frame == 11) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1095 if (_roadveh_enter_depot_unk0[_map5[tile]&3] == v->u.road.state) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1096 RoadVehEnterDepot(v); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1097 return 4; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1098 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1099 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1100 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1101 return 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1102 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1103 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1104 static void VehicleLeave_Road(Vehicle *v, uint tile, int x, int y) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1105 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1106 if ((_map5[tile] & 0xF0) == 0x10 && v->type == VEH_Train && v->next == NULL) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1107 _map5[tile] &= ~4; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1108 MarkTileDirtyByTile(tile); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1109 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1110 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1111 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1112 static void ChangeTileOwner_Road(uint tile, byte old_player, byte new_player) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1113 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1114 byte b; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1115 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1116 // road/rail crossing where the road is owned by the current player? |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1117 if (old_player == _map3_lo[tile] && (_map5[tile]&0xF0) == 0x10) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1118 _map3_lo[tile] = (new_player == 0xFF) ? OWNER_NONE : new_player; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1119 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1120 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1121 if (_map_owner[tile] != old_player) |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1122 return; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1123 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1124 if (new_player != 255) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1125 _map_owner[tile] = new_player; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1126 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1127 b = _map5[tile]&0xF0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1128 if (b == 0) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1129 _map_owner[tile] = OWNER_NONE; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1130 } else if (b == 0x10) { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1131 _map5[tile] = (_map5[tile]&8) ? 0x5 : 0xA; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1132 _map_owner[tile] = _map3_lo[tile]; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1133 _map3_lo[tile] = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1134 _map3_hi[tile] &= 0x80; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1135 } else { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1136 DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1137 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1138 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1139 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1140 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1141 void InitializeRoad() |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1142 { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1143 _last_built_road_depot_tile = 0; |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1144 } |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1145 |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1146 const TileTypeProcs _tile_type_road_procs = { |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1147 DrawTile_Road, /* draw_tile_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1148 GetSlopeZ_Road, /* get_slope_z_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1149 ClearTile_Road, /* clear_tile_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1150 GetAcceptedCargo_Road, /* get_accepted_cargo_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1151 GetTileDesc_Road, /* get_tile_desc_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1152 GetTileTrackStatus_Road, /* get_tile_track_status_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1153 ClickTile_Road, /* click_tile_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1154 AnimateTile_Road, /* animate_tile_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1155 TileLoop_Road, /* tile_loop_clear */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1156 ChangeTileOwner_Road, /* change_tile_owner_clear */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1157 NULL, /* get_produced_cargo_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1158 VehicleEnter_Road, /* vehicle_enter_tile_proc */ |
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1159 VehicleLeave_Road, /* vehicle_leave_tile_proc */ |
39
927ba896b4a5
(svn r40) Final slope graphics fix
dominik <dominik@openttd.org>
parents:
22
diff
changeset
|
1160 GetSlopeTileh_Road, /* get_slope_tileh_proc */ |
0
fa6ee4d75c8a
(svn r1) Import of revision 975 of old (crashed) SVN
truelight <truelight@openttd.org>
parents:
diff
changeset
|
1161 }; |