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