author | tron |
Sat, 04 Dec 2004 09:26:39 +0000 | |
changeset 541 | e1cd34389f79 |
parent 534 | 17ab2f22ff74 |
child 679 | e959706a3e4d |
permissions | -rw-r--r-- |
0 | 1 |
#include "stdafx.h" |
2 |
#include "ttd.h" |
|
507
8aa8100b0b22
(svn r815) Include strings.h only in the files which need it.
tron
parents:
497
diff
changeset
|
3 |
#include "table/strings.h" |
0 | 4 |
#include "vehicle.h" |
5 |
#include "viewport.h" |
|
6 |
#include "command.h" |
|
7 |
#include "player.h" |
|
8 |
#include "town.h" |
|
337
66647f97e7c0
(svn r513) Merge revisions 402, 416, 417, 478, 479, 511, 512 from map to trunk
tron
parents:
334
diff
changeset
|
9 |
#include "sound.h" |
0 | 10 |
|
11 |
extern void DrawCanalWater(uint tile); |
|
12 |
||
13 |
static const byte _bridge_available_year[MAX_BRIDGES] = { |
|
14 |
0, 0, 10, 0, 10, 10, 10, 10, 10, 10, 75, 85, 90 |
|
15 |
}; |
|
16 |
||
17 |
static const byte _bridge_minlen[MAX_BRIDGES] = { |
|
18 |
0, 0, 0, 2, 3, 3, 3, 3, 3, 0, 2, 2, 2 |
|
19 |
}; |
|
20 |
||
21 |
static const byte _bridge_maxlen[MAX_BRIDGES] = { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
22 |
16, 2, 5, 10, 16, 16, 7, 8, 9, 2, 16, 32, 32, |
0 | 23 |
}; |
24 |
||
25 |
const uint16 _bridge_type_price_mod[MAX_BRIDGES] = { |
|
26 |
80, 112, 144, 168, 185, 192, 224, 232, 248, 240, 255, 380, 510, |
|
27 |
}; |
|
28 |
||
29 |
const uint16 _bridge_speeds[MAX_BRIDGES] = { |
|
30 |
0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x0A0, 0x0D0, 0x0F0, 0x100, 0x140, 0x200, 0x260 |
|
31 |
}; |
|
32 |
||
33 |
const PalSpriteID _bridge_sprites[MAX_BRIDGES] = { |
|
34 |
0x0A24, 0x31E8A26, 0x0A25, 0x3208A22, |
|
35 |
0x0A22, 0x3218A22, 0x0A23, 0x31C8A23, |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
36 |
0x31E8A23, 0x0A27, 0x0A28, 0x3218A28, |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
37 |
0x3238A28, |
0 | 38 |
}; |
39 |
||
40 |
const StringID _bridge_material[MAX_BRIDGES] = { |
|
41 |
STR_5012_WOODEN, |
|
42 |
STR_5013_CONCRETE, |
|
43 |
STR_500F_GIRDER_STEEL, |
|
44 |
STR_5011_SUSPENSION_CONCRETE, |
|
45 |
STR_500E_SUSPENSION_STEEL, |
|
46 |
STR_500E_SUSPENSION_STEEL, |
|
47 |
STR_5010_CANTILEVER_STEEL, |
|
48 |
STR_5010_CANTILEVER_STEEL, |
|
49 |
STR_5010_CANTILEVER_STEEL, |
|
50 |
STR_500F_GIRDER_STEEL, |
|
51 |
STR_5014_TUBULAR_STEEL, |
|
52 |
STR_5014_TUBULAR_STEEL, |
|
53 |
STR_BRIDGE_TUBULAR_SILICON, |
|
54 |
}; |
|
55 |
||
56 |
// calculate the price factor for building a long bridge. |
|
57 |
// basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6, 7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8, |
|
58 |
int CalcBridgeLenCostFactor(int x) |
|
59 |
{ |
|
60 |
int n,r; |
|
61 |
if (x < 2) return x; |
|
62 |
x -= 2; |
|
63 |
for(n=0,r=2;;n++) { |
|
64 |
if (x <= n) return r + x * n; |
|
65 |
r += n * n; |
|
66 |
x -= n; |
|
67 |
} |
|
68 |
} |
|
69 |
||
70 |
enum { |
|
71 |
// foundation, whole tile is leveled up (tileh's 7, 11, 13, 14) --> 3 corners raised |
|
72 |
BRIDGE_FULL_LEVELED_FOUNDATION = 1 << 7 | 1 << 11 | 1 << 13 | 1 << 14, |
|
73 |
// foundation, tile is partly leveled up (tileh's 1, 2, 4, 8) --> 1 corner raised |
|
74 |
BRIDGE_PARTLY_LEVELED_FOUNDATION = 1 << 1 | 1 << 2 | 1 << 4 | 1 << 8, |
|
75 |
// no foundations (X,Y direction) (tileh's 0, 3, 6, 9, 12) |
|
76 |
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12, |
|
77 |
}; |
|
78 |
||
79 |
/* check if bridge can be built on slope |
|
80 |
* direction 0 = X-axis, direction 1 = Y-axis |
|
81 |
* is_start_tile = false <-- end tile |
|
82 |
* is_start_tile = true <-- start tile |
|
83 |
*/ |
|
84 |
static uint32 CheckBridgeSlope(uint direction, uint tileh, bool is_start_tile) |
|
85 |
{ |
|
86 |
if (!(tileh & 0x10)) { // disable building on very steep slopes |
|
87 |
||
88 |
if (is_start_tile) { |
|
89 |
/* check slope at start tile |
|
90 |
- no extra cost |
|
91 |
- direction X: tiles 0,12 |
|
92 |
- direction Y: tiles 0, 9 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
93 |
*/ |
0 | 94 |
if ((direction?0x201:0x1001) & (1 << tileh)) |
95 |
return 0; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
96 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
97 |
// disallow certain start tiles to avoid certain crooked bridges |
0 | 98 |
if (tileh == 2) |
99 |
return CMD_ERROR; |
|
100 |
||
101 |
} |
|
102 |
else { |
|
103 |
/* check slope at end tile |
|
104 |
- no extra cost |
|
105 |
- direction X: tiles 0, 3 |
|
106 |
- direction Y: tiles 0, 6 |
|
107 |
*/ |
|
108 |
if ((direction?0x41:0x9) & (1 << tileh)) |
|
109 |
return 0; |
|
110 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
111 |
// disallow certain end tiles to avoid certain crooked bridges |
0 | 112 |
if (tileh == 8) |
113 |
return CMD_ERROR; |
|
114 |
||
115 |
} |
|
116 |
||
117 |
/* disallow common start/end tiles to avoid certain crooked bridges e.g. |
|
118 |
* start-tile: X 2,1 Y 2,4 (2 was disabled before) |
|
119 |
* end-tile: X 8,4 Y 8,1 (8 was disabled before) |
|
120 |
*/ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
121 |
if ( (tileh == 1 && (is_start_tile != (bool)direction)) || |
0 | 122 |
(tileh == 4 && (is_start_tile == (bool)direction)) ) |
123 |
return CMD_ERROR; |
|
124 |
||
125 |
// slope foundations |
|
126 |
if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << tileh) || BRIDGE_PARTLY_LEVELED_FOUNDATION & (1 << tileh)) |
|
127 |
return _price.terraform; |
|
128 |
} |
|
129 |
||
130 |
return CMD_ERROR; |
|
131 |
} |
|
132 |
||
133 |
uint32 GetBridgeLength(TileIndex begin, TileIndex end) |
|
134 |
{ |
|
135 |
int x1, y1, x2, y2; // coordinates of starting and end tiles |
|
136 |
x1 = GET_TILE_X(begin); |
|
137 |
y1 = GET_TILE_Y(begin); |
|
138 |
x2 = GET_TILE_X(end); |
|
139 |
y2 = GET_TILE_Y(end); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
140 |
|
0 | 141 |
return abs((x2 + y2 - x1 - y1)) - 1; |
142 |
} |
|
143 |
||
144 |
bool CheckBridge_Stuff(byte bridge_type, int bridge_len) |
|
145 |
{ |
|
146 |
int max; // max possible length of a bridge (with patch 100) |
|
147 |
||
148 |
if (_bridge_available_year[bridge_type] > _cur_year) |
|
149 |
return false; |
|
150 |
||
151 |
max = _bridge_maxlen[bridge_type]; |
|
152 |
if (max >= 16 && _patches.longbridges) |
|
153 |
max = 100; |
|
154 |
||
155 |
if (bridge_len < _bridge_minlen[bridge_type] || bridge_len > max) |
|
156 |
return false; |
|
157 |
||
158 |
return true; |
|
159 |
} |
|
160 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
161 |
/* Build a Bridge |
0 | 162 |
* x,y - end tile coord |
163 |
* p1 - packed start tile coords (~ dx) |
|
164 |
* p2&0xFF - bridge type (hi bh) |
|
165 |
* p2>>8 - rail type. &0x80 means road bridge. |
|
166 |
*/ |
|
167 |
int32 CmdBuildBridge(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
168 |
{ |
|
169 |
int bridge_type; |
|
170 |
byte rail_or_road, railtype, m5; |
|
171 |
int sx,sy; |
|
172 |
TileInfo ti_start, ti_end, ti; /* OPT: only 2 of those are ever used */ |
|
173 |
int bridge_len, odd_middle_part; |
|
174 |
uint direction; |
|
175 |
int i; |
|
176 |
int32 cost, terraformcost, ret; |
|
177 |
||
178 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
179 |
|
0 | 180 |
/* unpack parameters */ |
181 |
bridge_type = p2 & 0xFF; |
|
182 |
railtype = (byte)(p2 >> 8); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
183 |
|
0 | 184 |
// type of bridge |
185 |
if (railtype & 0x80) { |
|
186 |
railtype = 0; |
|
187 |
rail_or_road = 2; |
|
188 |
} else { |
|
189 |
rail_or_road = 0; |
|
190 |
} |
|
191 |
||
192 |
sx = GET_TILE_X(p1) * 16; |
|
193 |
sy = GET_TILE_Y(p1) * 16; |
|
194 |
||
195 |
direction = 0; |
|
196 |
||
197 |
/* check if valid, and make sure that (x,y) are smaller than (sx,sy) */ |
|
198 |
if (x == sx) { |
|
199 |
if (y == sy) |
|
200 |
return_cmd_error(STR_5008_CANNOT_START_AND_END_ON); |
|
201 |
direction = 1; |
|
202 |
if (y > sy) { |
|
203 |
intswap(y,sy); |
|
204 |
intswap(x,sx); |
|
205 |
} |
|
206 |
} else if (y == sy) { |
|
207 |
if (x > sx) { |
|
208 |
intswap(y,sy); |
|
209 |
intswap(x,sx); |
|
210 |
} |
|
211 |
} else |
|
212 |
return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN); |
|
213 |
||
214 |
/* retrieve landscape height and ensure it's on land */ |
|
215 |
if ( |
|
216 |
((FindLandscapeHeight(&ti_end, sx, sy), |
|
217 |
ti_end.type == MP_WATER) && ti_end.map5 == 0) || |
|
218 |
((FindLandscapeHeight(&ti_start, x, y), |
|
219 |
ti_start.type == MP_WATER) && ti_start.map5 == 0)) |
|
220 |
return_cmd_error(STR_02A0_ENDS_OF_BRIDGE_MUST_BOTH); |
|
221 |
||
222 |
if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << ti_start.tileh)) { |
|
223 |
ti_start.z += 8; |
|
224 |
ti_start.tileh = 0; |
|
225 |
} |
|
226 |
||
227 |
if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << ti_end.tileh)) { |
|
228 |
ti_end.z += 8; |
|
229 |
ti_end.tileh = 0; |
|
230 |
} |
|
231 |
||
232 |
if (ti_start.z != ti_end.z) |
|
233 |
return_cmd_error(STR_5009_LEVEL_LAND_OR_WATER_REQUIRED); |
|
234 |
||
235 |
_error_message = STR_500C; |
|
236 |
||
237 |
/* try and clear the start landscape */ |
|
238 |
if ((ret=DoCommandByTile(ti_start.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)) == CMD_ERROR) |
|
239 |
return CMD_ERROR; |
|
240 |
cost = ret; |
|
241 |
||
242 |
terraformcost = CheckBridgeSlope(direction, ti_start.tileh, true); // true - bridge-start-tile, false - bridge-end-tile |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
243 |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
39
diff
changeset
|
244 |
// towns are not allowed to use bridges on slopes. |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
245 |
if (terraformcost == CMD_ERROR || |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
39
diff
changeset
|
246 |
(terraformcost && ((!_patches.ainew_active && _is_ai_player) || _current_player == OWNER_TOWN || !_patches.build_on_slopes))) |
0 | 247 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
248 |
||
249 |
cost += terraformcost; |
|
250 |
||
251 |
/* try and clear the end landscape */ |
|
252 |
if ((ret=DoCommandByTile(ti_end.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)) == CMD_ERROR) |
|
253 |
return CMD_ERROR; |
|
254 |
cost += ret; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
255 |
|
0 | 256 |
terraformcost = CheckBridgeSlope(direction, ti_end.tileh, false); // false - end tile slope check |
257 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
39
diff
changeset
|
258 |
// towns are not allowed to use bridges on slopes. |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
259 |
if (terraformcost == CMD_ERROR || |
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
39
diff
changeset
|
260 |
(terraformcost && ((!_patches.ainew_active && _is_ai_player) || _current_player == OWNER_TOWN || !_patches.build_on_slopes))) |
0 | 261 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
262 |
||
263 |
cost += terraformcost; |
|
264 |
||
265 |
/* do the drill? */ |
|
266 |
if (flags & DC_EXEC) { |
|
267 |
/* build the start tile */ |
|
268 |
ModifyTile(ti_start.tile, |
|
269 |
MP_SETTYPE(MP_TUNNELBRIDGE) | |
|
270 |
MP_MAP2 | MP_MAP3LO | MP_MAPOWNER_CURRENT | MP_MAP5, |
|
271 |
(bridge_type << 4), /* map2 */ |
|
272 |
railtype, /* map3_lo */ |
|
273 |
0x80 | direction | rail_or_road /* map5 */ |
|
274 |
); |
|
275 |
||
276 |
/* build the end tile */ |
|
277 |
ModifyTile(ti_end.tile, |
|
278 |
MP_SETTYPE(MP_TUNNELBRIDGE) | |
|
279 |
MP_MAP2 | MP_MAP3LO | MP_MAPOWNER_CURRENT | MP_MAP5, |
|
280 |
(bridge_type << 4), /* map2 */ |
|
281 |
railtype, /* map3_lo */ |
|
282 |
0x80 | 0x20 | direction | rail_or_road /* map5 */ |
|
283 |
); |
|
284 |
} |
|
285 |
||
286 |
/* set various params */ |
|
287 |
bridge_len = ((sx + sy - x - y) >> 4) - 1; |
|
288 |
||
289 |
//position of middle part of the odd bridge (larger than MAX(i) otherwise) |
|
290 |
odd_middle_part=(bridge_len%2)?(bridge_len/2):bridge_len; |
|
291 |
||
292 |
for(i = 0; i != bridge_len; i++) { |
|
293 |
if (direction != 0) |
|
294 |
y+=16; |
|
295 |
else |
|
296 |
x+=16; |
|
297 |
||
298 |
FindLandscapeHeight(&ti, x, y); |
|
299 |
||
300 |
_error_message = STR_5009_LEVEL_LAND_OR_WATER_REQUIRED; |
|
301 |
if (ti.tileh != 0 && ti.z >= ti_start.z) |
|
302 |
return CMD_ERROR; |
|
303 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
304 |
// Find ship below |
0 | 305 |
if ( ti.type == MP_WATER && !EnsureNoVehicle(ti.tile) ) |
306 |
{ |
|
307 |
_error_message = STR_980E_SHIP_IN_THE_WAY; |
|
308 |
return CMD_ERROR; |
|
309 |
} |
|
310 |
||
311 |
if (ti.type == MP_WATER) { |
|
312 |
if (ti.map5 != 0) goto not_valid_below; |
|
313 |
m5 = 0xC8; |
|
314 |
} else if (ti.type == MP_RAILWAY) { |
|
315 |
if (direction == 0) { |
|
316 |
if (ti.map5 != 2) goto not_valid_below; |
|
317 |
} else { |
|
318 |
if (ti.map5 != 1) goto not_valid_below; |
|
319 |
} |
|
320 |
m5 = 0xE0; |
|
321 |
} else if (ti.type == MP_STREET) { |
|
322 |
if (direction == 0) { |
|
323 |
if (ti.map5 != 5) goto not_valid_below; |
|
324 |
} else { |
|
325 |
if (ti.map5 != 10) goto not_valid_below; |
|
326 |
} |
|
327 |
m5 = 0xE8; |
|
328 |
} else { |
|
329 |
not_valid_below:; |
|
330 |
/* try and clear the middle landscape */ |
|
331 |
if ((ret=DoCommandByTile(ti.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR)) == CMD_ERROR) |
|
332 |
return CMD_ERROR; |
|
333 |
cost += ret; |
|
334 |
m5 = 0xC0; |
|
335 |
} |
|
336 |
||
337 |
/* do middle part of bridge */ |
|
338 |
if (flags & DC_EXEC) { |
|
339 |
_map5[ti.tile] = (byte)(m5 | direction | rail_or_road); |
|
340 |
_map_type_and_height[ti.tile] &= ~0xF0; |
|
341 |
_map_type_and_height[ti.tile] |= MP_TUNNELBRIDGE << 4; |
|
342 |
||
343 |
//bridges pieces sequence (middle parts) |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
344 |
// bridge len 1: 0 |
0 | 345 |
// bridge len 2: 0 1 |
346 |
// bridge len 3: 0 4 1 |
|
347 |
// bridge len 4: 0 2 3 1 |
|
348 |
// bridge len 5: 0 2 5 3 1 |
|
349 |
// bridge len 6: 0 2 3 2 3 1 |
|
350 |
// bridge len 7: 0 2 3 4 2 3 1 |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
351 |
// #0 - alwats as first, #1 - always as last (if len>1) |
0 | 352 |
// #2,#3 are to pair in order |
353 |
// for odd bridges: #5 is going in the bridge middle if on even position, #4 on odd (counting from 0) |
|
354 |
||
355 |
if(i==0) //first tile |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
356 |
m5 = 0; |
0 | 357 |
else if (i==bridge_len-1) //last tile |
358 |
m5 = 1; |
|
359 |
else if(i==odd_middle_part) //we are on the middle of odd bridge: #5 on even pos, #4 on odd |
|
360 |
m5 = 5 - (i%2); |
|
361 |
else { |
|
362 |
// generate #2 and #3 in turns [i%2==0], after the middle of odd bridge |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
363 |
// this sequence swaps [... XOR (i>odd_middle_part)], |
0 | 364 |
// for even bridges XOR does not apply as odd_middle_part==bridge_len |
365 |
m5 = 2 + ((i%2==0)^(i>odd_middle_part)); |
|
366 |
} |
|
367 |
||
368 |
_map2[ti.tile] = (bridge_type << 4) | m5; |
|
369 |
_map3_lo[ti.tile] &= 0xF; |
|
370 |
_map3_lo[ti.tile] |= (byte)(railtype << 4); |
|
371 |
||
372 |
MarkTileDirtyByTile(ti.tile); |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
SetSignalsOnBothDir(ti_start.tile, (direction&1) ? 1 : 0); |
|
377 |
||
378 |
/* for human player that builds the bridge he gets a selection to choose from bridges (DC_QUERY_COST) |
|
379 |
It's unnecessary to execute this command every time for every bridge. So it is done only |
|
380 |
and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated |
|
381 |
*/ |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
382 |
if (!(flags & DC_QUERY_COST)) { |
0 | 383 |
bridge_len += 2; // begin and end tiles/ramps |
384 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
39
diff
changeset
|
385 |
if (_current_player < MAX_PLAYERS && !(_is_ai_player && !_patches.ainew_active)) |
0 | 386 |
bridge_len = CalcBridgeLenCostFactor(bridge_len); |
387 |
||
203
d16d6e91bff8
(svn r204) -Fix: deleted unneeded casts (tnx Tron)
truelight
parents:
200
diff
changeset
|
388 |
cost += ((int64)bridge_len * _price.build_bridge * _bridge_type_price_mod[bridge_type]) >> 8; |
0 | 389 |
} |
390 |
||
391 |
return cost; |
|
392 |
} |
|
393 |
||
394 |
static bool DoCheckTunnelInWay(uint tile, uint z, uint dir) |
|
395 |
{ |
|
396 |
TileInfo ti; |
|
397 |
int delta; |
|
398 |
||
399 |
delta = _tileoffs_by_dir[dir]; |
|
400 |
||
401 |
do { |
|
402 |
tile -= delta; |
|
403 |
FindLandscapeHeightByTile(&ti, tile); |
|
404 |
} while (z < ti.z); |
|
405 |
||
406 |
if (z == ti.z && ti.type == MP_TUNNELBRIDGE && (ti.map5&0xF0) == 0 && (ti.map5&3) == dir) { |
|
407 |
_error_message = STR_5003_ANOTHER_TUNNEL_IN_THE_WAY; |
|
408 |
return false; |
|
409 |
} |
|
410 |
||
411 |
return true; |
|
412 |
} |
|
413 |
||
414 |
bool CheckTunnelInWay(uint tile, int z) |
|
415 |
{ |
|
416 |
return DoCheckTunnelInWay(tile,z,0) && |
|
417 |
DoCheckTunnelInWay(tile,z,1) && |
|
418 |
DoCheckTunnelInWay(tile,z,2) && |
|
419 |
DoCheckTunnelInWay(tile,z,3); |
|
420 |
} |
|
421 |
||
422 |
static byte _build_tunnel_bh; |
|
423 |
static byte _build_tunnel_railtype; |
|
424 |
||
425 |
static int32 DoBuildTunnel(int x, int y, int x2, int y2, uint32 flags, uint exc_tile) |
|
426 |
{ |
|
427 |
uint end_tile; |
|
428 |
int direction; |
|
429 |
int32 cost, ret; |
|
430 |
TileInfo ti; |
|
431 |
uint z; |
|
432 |
||
433 |
if ( (uint) x > TILE_X_MAX * 16 - 1 || (uint) y > TILE_X_MAX * 16 - 1) |
|
434 |
return CMD_ERROR; |
|
435 |
||
436 |
/* check if valid, and make sure that (x,y) is smaller than (x2,y2) */ |
|
437 |
direction = 0; |
|
438 |
if (x == x2) { |
|
439 |
if (y == y2) |
|
440 |
return_cmd_error(STR_5008_CANNOT_START_AND_END_ON); |
|
441 |
direction++; |
|
442 |
if (y > y2) { |
|
443 |
intswap(y,y2); |
|
444 |
intswap(x,x2); |
|
445 |
exc_tile|=2; |
|
446 |
} |
|
447 |
} else if (y == y2) { |
|
448 |
if (x > x2) { |
|
449 |
intswap(y,y2); |
|
450 |
intswap(x,x2); |
|
451 |
exc_tile|=2; |
|
452 |
} |
|
453 |
} else |
|
454 |
return_cmd_error(STR_500A_START_AND_END_MUST_BE_IN); |
|
455 |
||
456 |
cost = 0; |
|
457 |
||
458 |
FindLandscapeHeight(&ti, x2, y2); |
|
459 |
end_tile = ti.tile; |
|
460 |
z = ti.z; |
|
461 |
||
462 |
if (exc_tile != 3) { |
|
463 |
if ( (direction ? 9U : 12U) != ti.tileh) |
|
464 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
|
465 |
ret = DoCommandByTile(ti.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
|
466 |
if (ret == CMD_ERROR) |
|
467 |
return CMD_ERROR; |
|
468 |
cost += ret; |
|
469 |
} |
|
470 |
cost += _price.build_tunnel; |
|
471 |
||
472 |
for(;;) { |
|
473 |
if (direction) y2-=16; else x2-=16; |
|
474 |
||
475 |
if (x2 == x && y2 == y) |
|
476 |
break; |
|
477 |
||
478 |
FindLandscapeHeight(&ti, x2, y2); |
|
479 |
if (ti.z <= z) |
|
480 |
return_cmd_error(STR_5002); |
|
481 |
||
482 |
if (!_cheats.crossing_tunnels.value && !CheckTunnelInWay(ti.tile, z)) |
|
483 |
return CMD_ERROR; |
|
484 |
||
485 |
cost += _price.build_tunnel; |
|
486 |
cost += (cost >> 3); |
|
487 |
||
488 |
if (cost >= 400000000) |
|
489 |
cost = 400000000; |
|
490 |
} |
|
491 |
||
492 |
FindLandscapeHeight(&ti, x2, y2); |
|
493 |
if (ti.z != z) |
|
494 |
return_cmd_error(STR_5004); |
|
495 |
||
496 |
if (exc_tile != 1) { |
|
497 |
if ( (direction ? 6U : 3U) != ti.tileh) |
|
498 |
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION); |
|
499 |
||
500 |
ret = DoCommandByTile(ti.tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
|
501 |
if (ret == CMD_ERROR) |
|
502 |
return CMD_ERROR; |
|
503 |
cost += ret; |
|
504 |
} |
|
505 |
||
506 |
if (flags & DC_EXEC) { |
|
507 |
ModifyTile(ti.tile, |
|
508 |
MP_SETTYPE(MP_TUNNELBRIDGE) | |
|
509 |
MP_MAP3LO | MP_MAPOWNER_CURRENT | MP_MAP5, |
|
510 |
_build_tunnel_railtype, /* map3lo */ |
|
511 |
((_build_tunnel_bh << 1) | 2) - direction /* map5 */ |
|
512 |
); |
|
513 |
||
514 |
ModifyTile(end_tile, |
|
515 |
MP_SETTYPE(MP_TUNNELBRIDGE) | |
|
516 |
MP_MAP3LO | MP_MAPOWNER_CURRENT | MP_MAP5, |
|
517 |
_build_tunnel_railtype, /* map3lo */ |
|
518 |
(_build_tunnel_bh << 1) | (direction ? 3:0)/* map5 */ |
|
519 |
); |
|
520 |
||
521 |
UpdateSignalsOnSegment(end_tile, direction?7:1); |
|
522 |
} |
|
523 |
||
524 |
return cost + _price.build_tunnel; |
|
525 |
} |
|
526 |
||
527 |
/* Build Tunnel |
|
528 |
* x,y - start tile coord |
|
529 |
* p1 - railtype |
|
530 |
* p2 - ptr to uint that recieves end tile |
|
531 |
*/ |
|
532 |
int32 CmdBuildTunnel(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
|
533 |
{ |
|
534 |
TileInfo ti, tiorg; |
|
535 |
int direction; |
|
536 |
uint z; |
|
537 |
static const int8 _build_tunnel_coord_mod[4+1] = { -16, 0, 16, 0, -16 }; |
|
538 |
static const byte _build_tunnel_tileh[4] = {3, 9, 12, 6}; |
|
539 |
uint excavated_tile; |
|
540 |
||
541 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
542 |
||
543 |
_build_tunnel_railtype = (byte)(p1 & 0xFF); |
|
544 |
_build_tunnel_bh = (byte)(p1 >> 8); |
|
545 |
||
546 |
_build_tunnel_endtile = 0; |
|
547 |
excavated_tile = 0; |
|
548 |
||
549 |
FindLandscapeHeight(&tiorg, x, y); |
|
550 |
||
551 |
if (!EnsureNoVehicle(tiorg.tile)) |
|
552 |
return CMD_ERROR; |
|
553 |
||
554 |
if (!(direction=0, tiorg.tileh==12) && |
|
555 |
!(direction++, tiorg.tileh==6) && |
|
556 |
!(direction++, tiorg.tileh==3) && |
|
557 |
!(direction++, tiorg.tileh==9) ) |
|
558 |
return_cmd_error(STR_500B_SITE_UNSUITABLE_FOR_TUNNEL); |
|
559 |
||
560 |
z = tiorg.z; |
|
561 |
do { |
|
562 |
x += _build_tunnel_coord_mod[direction]; |
|
563 |
y += _build_tunnel_coord_mod[direction+1]; |
|
564 |
FindLandscapeHeight(&ti, x, y); |
|
565 |
} while (z != ti.z); |
|
566 |
_build_tunnel_endtile = ti.tile; |
|
567 |
||
568 |
||
569 |
if (!EnsureNoVehicle(ti.tile)) |
|
570 |
return CMD_ERROR; |
|
571 |
||
572 |
if (ti.tileh != _build_tunnel_tileh[direction]) { |
|
573 |
if (DoCommandByTile(ti.tile, ti.tileh & ~_build_tunnel_tileh[direction], 0, flags, CMD_TERRAFORM_LAND) == CMD_ERROR) |
|
574 |
return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND); |
|
575 |
excavated_tile = 1; |
|
576 |
} |
|
577 |
||
578 |
if (flags & DC_EXEC && DoBuildTunnel(x,y,tiorg.x,tiorg.y,flags&~DC_EXEC,excavated_tile) == CMD_ERROR) |
|
579 |
return CMD_ERROR; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
580 |
|
0 | 581 |
return DoBuildTunnel(x,y,tiorg.x, tiorg.y,flags,excavated_tile); |
582 |
} |
|
583 |
||
584 |
static const byte _updsignals_tunnel_dir[4] = { 5, 7, 1, 3}; |
|
585 |
||
98 | 586 |
uint CheckTunnelBusy(uint tile, int *length) |
0 | 587 |
{ |
588 |
int z = GetTileZ(tile); |
|
589 |
byte m5 = _map5[tile]; |
|
590 |
int delta = _tileoffs_by_dir[m5 & 3], len = 0; |
|
591 |
uint starttile = tile; |
|
592 |
Vehicle *v; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
593 |
|
0 | 594 |
do { tile += delta; len++; } while (!IS_TILETYPE(tile, MP_TUNNELBRIDGE) || _map5[tile]&0xF0 || (byte)(_map5[tile] ^ 2) != m5 || GetTileZ(tile) != z); |
595 |
||
596 |
if ((v=FindVehicleBetween(starttile, tile, z)) != NULL) { |
|
597 |
_error_message = v->type == VEH_Train ? STR_5000_TRAIN_IN_TUNNEL : STR_5001_ROAD_VEHICLE_IN_TUNNEL; |
|
598 |
return (uint)-1; |
|
599 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
600 |
|
0 | 601 |
if (length) *length = len; |
602 |
return tile; |
|
603 |
} |
|
604 |
||
605 |
static int32 DoClearTunnel(uint tile, uint32 flags) |
|
606 |
{ |
|
607 |
Town *t; |
|
608 |
uint endtile; |
|
609 |
int length; |
|
610 |
||
611 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
|
612 |
||
613 |
// in scenario editor you can always destroy tunnels |
|
614 |
if (_game_mode != GM_EDITOR && !CheckTileOwnership(tile)) { |
|
615 |
if (!(_patches.extra_dynamite || _cheats.magic_bulldozer.value) || _map_owner[tile] != OWNER_TOWN) |
|
616 |
return CMD_ERROR; |
|
617 |
} |
|
618 |
||
619 |
endtile = CheckTunnelBusy(tile, &length); |
|
620 |
if (endtile == (uint)-1) return CMD_ERROR; |
|
621 |
||
622 |
_build_tunnel_endtile = endtile; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
623 |
|
0 | 624 |
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty |
625 |
// check if you're allowed to remove the tunnel owned by a town |
|
626 |
// removal allowal depends on difficulty settings |
|
627 |
if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR ) { |
|
628 |
if (!CheckforTownRating(tile, flags, t, TUNNELBRIDGE_REMOVE)) { |
|
534
17ab2f22ff74
(svn r901) Small step in the process to clean up the DPARAM mess:
tron
parents:
511
diff
changeset
|
629 |
SetDParam(0, t->index); |
0 | 630 |
return_cmd_error(STR_2009_LOCAL_AUTHORITY_REFUSES); |
631 |
} |
|
632 |
} |
|
633 |
||
634 |
if (flags & DC_EXEC) { |
|
38
d20549a6ea13
(svn r39) -Fix [1008605] Signals not updated after ClearTunnel Bug [985920] (TrueLight)
darkvater
parents:
22
diff
changeset
|
635 |
// We first need to request the direction before calling DoClearSquare |
d20549a6ea13
(svn r39) -Fix [1008605] Signals not updated after ClearTunnel Bug [985920] (TrueLight)
darkvater
parents:
22
diff
changeset
|
636 |
// else the direction is always 0.. dah!! ;) |
d20549a6ea13
(svn r39) -Fix [1008605] Signals not updated after ClearTunnel Bug [985920] (TrueLight)
darkvater
parents:
22
diff
changeset
|
637 |
byte tile_dir = _map5[tile]&3; |
d20549a6ea13
(svn r39) -Fix [1008605] Signals not updated after ClearTunnel Bug [985920] (TrueLight)
darkvater
parents:
22
diff
changeset
|
638 |
byte endtile_dir = _map5[endtile]&3; |
0 | 639 |
DoClearSquare(tile); |
640 |
DoClearSquare(endtile); |
|
38
d20549a6ea13
(svn r39) -Fix [1008605] Signals not updated after ClearTunnel Bug [985920] (TrueLight)
darkvater
parents:
22
diff
changeset
|
641 |
UpdateSignalsOnSegment(tile, _updsignals_tunnel_dir[tile_dir]); |
d20549a6ea13
(svn r39) -Fix [1008605] Signals not updated after ClearTunnel Bug [985920] (TrueLight)
darkvater
parents:
22
diff
changeset
|
642 |
UpdateSignalsOnSegment(endtile, _updsignals_tunnel_dir[endtile_dir]); |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
643 |
if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) |
0 | 644 |
ChangeTownRating(t, -250, 0); |
645 |
} |
|
646 |
return _price.clear_tunnel * (length + 1); |
|
647 |
} |
|
648 |
||
649 |
static uint FindEdgesOfBridge(uint tile, uint *endtile) |
|
650 |
{ |
|
651 |
int direction = _map5[tile] & 1; |
|
652 |
uint start; |
|
653 |
||
654 |
// find start of bridge |
|
655 |
for(;;) { |
|
656 |
if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xE0) == 0x80) |
|
657 |
break; |
|
658 |
tile += direction ? TILE_XY(0,-1) : TILE_XY(-1,0); |
|
659 |
} |
|
660 |
||
661 |
start = tile; |
|
662 |
||
663 |
// find end of bridge |
|
664 |
for(;;) { |
|
665 |
if (IS_TILETYPE(tile, MP_TUNNELBRIDGE) && (_map5[tile] & 0xE0) == 0xA0) |
|
666 |
break; |
|
667 |
tile += direction ? TILE_XY(0,1) : TILE_XY(1,0); |
|
668 |
} |
|
669 |
||
670 |
*endtile = tile; |
|
671 |
||
672 |
return start; |
|
673 |
} |
|
674 |
||
675 |
static int32 DoClearBridge(uint tile, uint32 flags) |
|
676 |
{ |
|
677 |
uint endtile; |
|
678 |
Vehicle *v; |
|
679 |
Town *t; |
|
680 |
int direction; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
681 |
|
0 | 682 |
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
683 |
||
684 |
direction = _map5[tile]&1; |
|
685 |
||
686 |
/* delete stuff under the middle part if there's a transport route there..? */ |
|
687 |
if ((_map5[tile] & 0xE0) == 0xE0) { |
|
688 |
int32 cost; |
|
689 |
||
690 |
// check if we own the tile below the bridge.. |
|
691 |
if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)) )) |
|
692 |
return CMD_ERROR; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
693 |
|
0 | 694 |
cost = (_map5[tile] & 8) ? _price.remove_road * 2 : _price.remove_rail; |
695 |
||
696 |
if (flags & DC_EXEC) { |
|
697 |
_map5[tile] = _map5[tile] & ~0x38; |
|
698 |
_map_owner[tile] = OWNER_NONE; |
|
699 |
MarkTileDirtyByTile(tile); |
|
700 |
} |
|
701 |
return cost; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
702 |
|
0 | 703 |
/* delete canal under bridge */ |
704 |
} else if(_map5[tile]==0xC8 && GET_TILEHEIGHT(tile)!=0) { |
|
705 |
int32 cost; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
706 |
|
0 | 707 |
// check for vehicles under bridge |
708 |
if ( !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile)) ) |
|
709 |
return CMD_ERROR; |
|
710 |
cost = _price.clear_water; |
|
711 |
if (flags & DC_EXEC) { |
|
712 |
_map5[tile] = _map5[tile] & ~0x38; |
|
713 |
_map_owner[tile] = OWNER_NONE; |
|
714 |
MarkTileDirtyByTile(tile); |
|
715 |
} |
|
716 |
return cost; |
|
717 |
} |
|
718 |
||
719 |
tile = FindEdgesOfBridge(tile, &endtile); |
|
720 |
||
721 |
// floods, scenario editor can always destroy bridges |
|
722 |
if (_current_player != OWNER_WATER && _game_mode != GM_EDITOR && !CheckTileOwnership(tile)) { |
|
723 |
if (!(_patches.extra_dynamite || _cheats.magic_bulldozer.value) || _map_owner[tile] != OWNER_TOWN) |
|
724 |
return CMD_ERROR; |
|
725 |
} |
|
726 |
||
727 |
if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(endtile)) |
|
728 |
return CMD_ERROR; |
|
729 |
||
730 |
/* Make sure there's no vehicle on the bridge |
|
731 |
Omit tile and endtile, since these are already checked, thus solving the problem |
|
732 |
of bridges over water, or higher bridges, where z is not increased, eg level bridge |
|
733 |
*/ |
|
734 |
tile += direction ? TILE_XY(0, 1) : TILE_XY( 1,0); |
|
735 |
endtile -= direction ? TILE_XY(0, 1) : TILE_XY( 1,0); |
|
736 |
if ((v=FindVehicleBetween(tile, endtile, GET_TILEHEIGHT(tile) + 8)) != NULL) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
737 |
VehicleInTheWayErrMsg(v); |
0 | 738 |
return CMD_ERROR; |
739 |
} |
|
740 |
||
741 |
/* Put the tiles back to start/end position */ |
|
742 |
tile -= direction ? TILE_XY(0, 1) : TILE_XY( 1,0); |
|
743 |
endtile += direction ? TILE_XY(0, 1) : TILE_XY( 1,0); |
|
744 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
745 |
|
0 | 746 |
t = ClosestTownFromTile(tile, (uint)-1); //needed for town rating penalty |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
747 |
// check if you're allowed to remove the bridge owned by a town. |
0 | 748 |
// removal allowal depends on difficulty settings |
749 |
if(_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
750 |
if (!CheckforTownRating(tile, flags, t, TUNNELBRIDGE_REMOVE)) |
0 | 751 |
return CMD_ERROR; |
752 |
} |
|
753 |
||
754 |
if (flags & DC_EXEC) { |
|
755 |
byte m5; |
|
756 |
uint c = tile; |
|
757 |
uint16 new_data; |
|
758 |
||
759 |
//checks if the owner is town then decrease town rating by 250 until |
|
760 |
// you have a "Poor" (0) town rating |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
761 |
if (_map_owner[tile] == OWNER_TOWN && _game_mode != GM_EDITOR) |
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
762 |
ChangeTownRating(t, -250, 0); |
0 | 763 |
|
764 |
do { |
|
765 |
m5 = _map5[c]; |
|
766 |
||
767 |
if (m5 & 0x40) { |
|
768 |
if (m5 & 0x20) { |
|
769 |
static const uint16 _new_data_table[] = {0x1002, 0x1001, 0x2005, 0x200A, 0, 0, 0, 0}; |
|
770 |
new_data = _new_data_table[((m5 & 0x18) >> 2) | (m5&1)]; |
|
771 |
} else { |
|
772 |
if (!(m5 & 0x18)) goto clear_it; |
|
773 |
new_data = 0x6000; |
|
774 |
} |
|
775 |
||
776 |
_map_type_and_height[c] &= 0x0F; |
|
777 |
_map_type_and_height[c] |= new_data >> 8; |
|
778 |
_map5[c] = (byte)new_data; |
|
779 |
_map2[c] = 0; |
|
780 |
||
781 |
MarkTileDirtyByTile(c); |
|
782 |
||
783 |
} else { |
|
784 |
clear_it:; |
|
785 |
DoClearSquare(c); |
|
786 |
} |
|
787 |
c += direction ? TILE_XY(0,1) : TILE_XY(1,0); |
|
788 |
} while (c <= endtile); |
|
789 |
||
790 |
SetSignalsOnBothDir(tile, direction); |
|
791 |
SetSignalsOnBothDir(endtile, direction); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
792 |
|
0 | 793 |
} |
794 |
||
795 |
return ((((endtile - tile) >> (direction?8:0))&0xFF)+1) * _price.clear_bridge; |
|
796 |
} |
|
797 |
||
798 |
static int32 ClearTile_TunnelBridge(uint tile, byte flags) { |
|
799 |
int32 ret; |
|
800 |
byte m5 = _map5[tile]; |
|
801 |
||
802 |
if ((m5 & 0xF0) == 0) { |
|
803 |
if (flags & DC_AUTO) |
|
804 |
return_cmd_error(STR_5006_MUST_DEMOLISH_TUNNEL_FIRST); |
|
805 |
return DoClearTunnel(tile, flags); |
|
806 |
} else if (m5 & 0x80) { |
|
807 |
if (flags & DC_AUTO) |
|
808 |
return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST); |
|
809 |
||
810 |
ret = DoClearBridge(tile, flags); |
|
811 |
if (ret == CMD_ERROR) |
|
812 |
return CMD_ERROR; |
|
813 |
||
814 |
return ret; |
|
815 |
} else { |
|
816 |
return CMD_ERROR; |
|
817 |
} |
|
818 |
} |
|
819 |
||
820 |
int32 DoConvertTunnelBridgeRail(uint tile, uint totype, bool exec) |
|
821 |
{ |
|
822 |
uint endtile; |
|
823 |
int length; |
|
824 |
Vehicle *v; |
|
825 |
||
826 |
if ((_map5[tile] & 0xFC) == 0x00) { |
|
827 |
// railway tunnel |
|
828 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
|
829 |
||
830 |
if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
831 |
|
0 | 832 |
endtile = CheckTunnelBusy(tile, &length); |
833 |
if (endtile == (uint)-1) return CMD_ERROR; |
|
834 |
||
835 |
if (exec) { |
|
836 |
_map3_lo[tile] = (_map3_lo[tile] & 0xF0) + totype; |
|
837 |
_map3_lo[endtile] = (_map3_lo[endtile] & 0xF0) + totype; |
|
838 |
MarkTileDirtyByTile(tile); |
|
839 |
MarkTileDirtyByTile(endtile); |
|
840 |
} |
|
841 |
return (length + 1) * (_price.build_rail >> 1); |
|
842 |
} else if ((_map5[tile] & 0xF8) == 0xE0) { |
|
843 |
// bridge middle part with rail below |
|
844 |
// only check for train under bridge |
|
845 |
if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, GET_TILEHEIGHT(tile))) |
|
846 |
return CMD_ERROR; |
|
847 |
||
848 |
// tile is already of requested type? |
|
849 |
if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR; |
|
850 |
// change type. |
|
851 |
if (exec) { |
|
852 |
_map3_lo[tile] = (_map3_lo[tile] & 0xF0) + totype; |
|
853 |
MarkTileDirtyByTile(tile); |
|
854 |
} |
|
855 |
return _price.build_rail >> 1; |
|
856 |
} else if ((_map5[tile]&0xC6) == 0x80) { |
|
857 |
uint starttile; |
|
858 |
int32 cost; |
|
859 |
||
860 |
if (!CheckTileOwnership(tile)) return CMD_ERROR; |
|
861 |
||
862 |
// railway bridge |
|
863 |
starttile = tile = FindEdgesOfBridge(tile, &endtile); |
|
864 |
// Make sure there's no vehicle on the bridge |
|
865 |
if ((v=FindVehicleBetween(tile, endtile, 0xff)) != NULL) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
866 |
VehicleInTheWayErrMsg(v); |
0 | 867 |
return CMD_ERROR; |
868 |
} |
|
869 |
||
870 |
if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR; |
|
871 |
cost = 0; |
|
872 |
do { |
|
873 |
if (exec) { |
|
874 |
if (tile == starttile || tile == endtile) { |
|
875 |
_map3_lo[tile] = (_map3_lo[tile] & 0xF0) + totype; |
|
876 |
} else { |
|
877 |
_map3_lo[tile] = (_map3_lo[tile] & 0x0F) + (totype << 4); |
|
878 |
} |
|
879 |
MarkTileDirtyByTile(tile); |
|
880 |
} |
|
881 |
cost += (_price.build_rail>>1); |
|
882 |
tile += _map5[tile]&1 ? TILE_XY(0,1) : TILE_XY(1,0); |
|
883 |
} while (tile <= endtile); |
|
884 |
||
885 |
return cost; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
886 |
} else |
0 | 887 |
return CMD_ERROR; |
888 |
} |
|
889 |
||
890 |
||
891 |
// fast routine for getting the height of a middle bridge tile. 'tile' MUST be a middle bridge tile. |
|
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
39
diff
changeset
|
892 |
uint GetBridgeHeight(const TileInfo *ti) |
0 | 893 |
{ |
894 |
uint delta; |
|
895 |
TileInfo ti_end; |
|
896 |
uint tile = ti->tile; |
|
897 |
uint z_correction = 0; |
|
898 |
||
899 |
// find the end tile of the bridge. |
|
900 |
delta = (_map5[tile] & 1) ? TILE_XY(0,1) : TILE_XY(1,0); |
|
901 |
do { |
|
902 |
assert((_map5[tile] & 0xC0) == 0xC0); // bridge and middle part |
|
903 |
tile += delta; |
|
904 |
} while (_map5[tile] & 0x40); // while bridge middle parts |
|
905 |
||
906 |
// if the end of the bridge is on a tileh 7, the z coordinate is 1 tile too low |
|
907 |
// correct it. |
|
908 |
FindLandscapeHeightByTile(&ti_end, tile); |
|
909 |
if (HASBIT(1 << 7, ti_end.tileh)) |
|
910 |
z_correction += 8; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
911 |
|
0 | 912 |
// return the height there (the height of the NORTH CORNER) |
913 |
return GET_TILEHEIGHT(tile) + z_correction; |
|
914 |
} |
|
915 |
||
916 |
static const byte _bridge_foundations[2][16] = { |
|
917 |
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
918 |
{1,16,18,3,20,5,0,7,22,0,10,11,12,13,14}, |
|
919 |
{1,15,17,0,19,5,6,7,21,9,10,11, 0,13,14}, |
|
920 |
}; |
|
921 |
||
922 |
extern const byte _track_sloped_sprites[14]; |
|
923 |
extern const byte _road_sloped_sprites[14]; |
|
924 |
||
511
b86b13d2288b
(svn r826) Seperate all bridge related tables from tunnel_land.h into their own file
tron
parents:
507
diff
changeset
|
925 |
#include "table/bridge_land.h" |
0 | 926 |
#include "table/tunnel_land.h" |
927 |
||
928 |
static void DrawBridgePillars(TileInfo *ti, int x, int y, int z) |
|
929 |
{ |
|
930 |
const uint32 *b; |
|
931 |
uint32 image; |
|
932 |
int piece; |
|
933 |
||
934 |
b = _bridge_poles_table[_map2[ti->tile]>>4]; |
|
935 |
||
936 |
// Draw first piece |
|
937 |
// (necessary for cantilever bridges) |
|
938 |
image = b[12 + (ti->map5&0x01)]; |
|
939 |
piece = _map2[ti->tile]&0xF; |
|
333
6dee54ed9701
(svn r500) -Fix: Some bridge part isn't displayed transparent in transparent mode
tron
parents:
241
diff
changeset
|
940 |
if (image != 0 && piece != 0) { |
497
2d6d31173813
(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
|
941 |
if (_display_opt & DO_TRANS_BUILDINGS) image = (image & 0x3FFF) | 0x03224000; |
333
6dee54ed9701
(svn r500) -Fix: Some bridge part isn't displayed transparent in transparent mode
tron
parents:
241
diff
changeset
|
942 |
DrawGroundSpriteAt(image, x, y, z); |
6dee54ed9701
(svn r500) -Fix: Some bridge part isn't displayed transparent in transparent mode
tron
parents:
241
diff
changeset
|
943 |
} |
0 | 944 |
|
945 |
image = b[(ti->map5&0x01)*6 + piece]; |
|
946 |
||
947 |
if (image != 0) { |
|
948 |
int back_height, front_height, i=z; |
|
949 |
const byte *p; |
|
950 |
||
951 |
static const byte _tileh_bits[4][8] = { |
|
952 |
{2,1,8,4, 16,11,0,9}, |
|
953 |
{1,8,4,2, 11,16,9,0}, |
|
954 |
{4,8,1,2, 16,11,0,9}, |
|
955 |
{2,4,8,1, 11,16,9,0}, |
|
956 |
}; |
|
957 |
||
497
2d6d31173813
(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
|
958 |
if (_display_opt & DO_TRANS_BUILDINGS) image = (image & 0x3FFF) | 0x03224000; |
333
6dee54ed9701
(svn r500) -Fix: Some bridge part isn't displayed transparent in transparent mode
tron
parents:
241
diff
changeset
|
959 |
|
0 | 960 |
p = _tileh_bits[(image & 1) * 2 + (ti->map5&0x01)]; |
961 |
front_height = ti->z + ((ti->tileh & p[0])?8:0); |
|
962 |
back_height = ti->z + ((ti->tileh & p[1])?8:0); |
|
963 |
if (ti->tileh & 0x10) { |
|
964 |
if (!(ti->tileh & p[2])) front_height += 8; |
|
965 |
if (!(ti->tileh & p[3])) back_height += 8; |
|
966 |
} |
|
967 |
||
968 |
for(; z>=front_height || z>=back_height; z=z-8) { |
|
969 |
if (z>=front_height) AddSortableSpriteToDraw(image, x,y, p[4], p[5], 0x28, z); // front facing pillar |
|
970 |
if (z>=back_height && z<i-8) AddSortableSpriteToDraw(image, x - p[6], y - p[7], p[4], p[5], 0x28, z); // back facing pillar |
|
971 |
} |
|
972 |
} |
|
973 |
} |
|
974 |
||
84
1e0721c29bad
(svn r85) -Add: initial commit of new AI (enable in Patch menu)
truelight
parents:
39
diff
changeset
|
975 |
uint GetBridgeFoundation(uint tileh, byte direction) { |
0 | 976 |
int i; |
977 |
// normal level sloped building (7, 11, 13, 14) |
|
978 |
if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << tileh)) |
|
979 |
return tileh; |
|
980 |
||
981 |
// inclined sloped building |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
982 |
if ( ((i=0, tileh == 1) || (i+=2, tileh == 2) || (i+=2, tileh == 4) || (i+=2, tileh == 8)) && |
0 | 983 |
( direction == 0 || (i++, direction == 1)) ) |
984 |
return i + 15; |
|
985 |
||
986 |
return 0; |
|
987 |
} |
|
988 |
||
989 |
static void DrawTile_TunnelBridge(TileInfo *ti) |
|
990 |
{ |
|
991 |
uint32 image; |
|
992 |
uint tmp; |
|
993 |
const uint32 *b; |
|
994 |
bool ice = _map3_hi[ti->tile] & 0x80; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
995 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
996 |
// draw tunnel? |
0 | 997 |
if ( (byte)(ti->map5&0xF0) == 0) { |
998 |
/* railway type */ |
|
999 |
image = (_map3_lo[ti->tile] & 0xF) * 8; |
|
1000 |
||
1001 |
/* ice? */ |
|
1002 |
if (ice) |
|
1003 |
image += 32; |
|
1004 |
||
1005 |
image += _draw_tunnel_table_1[(ti->map5 >> 2) & 0x3]; |
|
1006 |
image += (ti->map5 & 3) << 1; |
|
1007 |
DrawGroundSprite(image); |
|
1008 |
||
1009 |
AddSortableSpriteToDraw(image+1, ti->x + 15, ti->y + 15, 1, 1, 8, (byte)ti->z); |
|
1010 |
// draw bridge? |
|
1011 |
} else if ((byte)ti->map5 & 0x80) { |
|
1012 |
// get type of track on the bridge. |
|
1013 |
tmp = _map3_lo[ti->tile]; |
|
1014 |
if (ti->map5 & 0x40) tmp >>= 4; |
|
1015 |
tmp &= 0xF; |
|
1016 |
||
1017 |
// 0 = rail bridge |
|
1018 |
// 1 = road bridge |
|
1019 |
// 2 = monorail bridge |
|
1020 |
// 3 = maglev bridge |
|
1021 |
||
1022 |
// add direction and fix stuff. |
|
1023 |
if (tmp != 0) tmp++; |
|
1024 |
tmp = (ti->map5&3) + (tmp*2); |
|
1025 |
||
1026 |
if (!(ti->map5 & 0x40)) { // bridge ramps |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1027 |
|
0 | 1028 |
if (!(BRIDGE_NO_FOUNDATION & (1 << ti->tileh))) { // no foundations for 0, 3, 6, 9, 12 |
1029 |
int f = GetBridgeFoundation(ti->tileh, ti->map5 & 0x1); // pass direction |
|
1030 |
if (f) DrawFoundation(ti, f); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1031 |
|
0 | 1032 |
// default sloped sprites.. |
1033 |
if (ti->tileh != 0) image = _track_sloped_sprites[ti->tileh - 1] + 0x3F3; |
|
1034 |
} |
|
1035 |
||
1036 |
// bridge ending. |
|
1037 |
b = _bridge_sprite_table[_map2[ti->tile]>>4][6]; |
|
1038 |
b += (tmp&(3<<1))*4; /* actually ((tmp>>2)&3)*8 */ |
|
1039 |
b += (tmp&1); // direction |
|
1040 |
if (ti->tileh == 0) b += 4; // sloped "entrance" ? |
|
1041 |
if (ti->map5 & 0x20) b += 2; // which side |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1042 |
|
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1043 |
image = *b; |
0 | 1044 |
|
1045 |
if (!ice) { |
|
1046 |
DrawClearLandTile(ti, 3); |
|
1047 |
} else { |
|
1048 |
DrawGroundSprite(0x11C6 + _tileh_to_sprite[ti->tileh]); |
|
1049 |
} |
|
1050 |
||
1051 |
// draw ramp |
|
497
2d6d31173813
(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
|
1052 |
if (_display_opt & DO_TRANS_BUILDINGS) image = (image & 0x3FFF) | 0x03224000; |
0 | 1053 |
AddSortableSpriteToDraw(image, ti->x, ti->y, 16, 16, 7, ti->z); |
1054 |
} else { |
|
1055 |
// bridge middle part. |
|
1056 |
uint z; |
|
1057 |
int x,y; |
|
1058 |
||
1059 |
image = (ti->map5 >> 3) & 3; // type of stuff under bridge (only defined for 0,1) |
|
1060 |
assert(image <= 1); |
|
1061 |
||
1062 |
if (!(ti->map5 & 0x20)) { |
|
1063 |
// draw land under bridge |
|
1064 |
if (ice) image += 2; // ice too? |
|
1065 |
DrawGroundSprite(_bridge_land_below[image] + _tileh_to_sprite[ti->tileh]); |
|
1066 |
||
1067 |
// draw canal water? |
|
1068 |
if (ti->map5 & 8 && ti->z != 0) DrawCanalWater(ti->tile); |
|
1069 |
} else { |
|
1070 |
// draw transport route under bridge |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1071 |
|
0 | 1072 |
// draw foundation? |
1073 |
if (ti->tileh) { |
|
1074 |
int f = _bridge_foundations[ti->map5&1][ti->tileh]; |
|
1075 |
if (f) DrawFoundation(ti, f); |
|
1076 |
} |
|
1077 |
||
1078 |
if (!(image&1)) { |
|
1079 |
// railway |
|
1080 |
image = 0x3F3 + (ti->map5 & 1); |
|
1081 |
if (ti->tileh != 0) image = _track_sloped_sprites[ti->tileh - 1] + 0x3F3; |
|
1082 |
image += (_map3_lo[ti->tile] & 0xF) * TRACKTYPE_SPRITE_PITCH; |
|
1083 |
if (ice) image += 26; // ice? |
|
1084 |
} else { |
|
1085 |
// road |
|
1086 |
image = 1332 + (ti->map5 & 1); |
|
1087 |
if (ti->tileh != 0) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F; |
|
1088 |
if (ice) image += 19; // ice? |
|
1089 |
} |
|
1090 |
DrawGroundSprite(image); |
|
1091 |
} |
|
1092 |
// get bridge sprites |
|
1093 |
b = _bridge_sprite_table[_map2[ti->tile]>>4][_map2[ti->tile]&0xF] + tmp * 4; |
|
1094 |
||
1095 |
z = GetBridgeHeight(ti) + 5; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1096 |
|
0 | 1097 |
// draw rail |
1098 |
image = b[0]; |
|
497
2d6d31173813
(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
|
1099 |
if (_display_opt & DO_TRANS_BUILDINGS) image = (image & 0x3FFF) | 0x03224000; |
0 | 1100 |
AddSortableSpriteToDraw(image, ti->x, ti->y, (ti->map5&1)?11:16, (ti->map5&1)?16:11, 1, z); |
1101 |
||
1102 |
x = ti->x; |
|
1103 |
y = ti->y; |
|
1104 |
image = b[1]; |
|
497
2d6d31173813
(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
|
1105 |
if (_display_opt & DO_TRANS_BUILDINGS) image = (image & 0x3FFF) | 0x03224000; |
0 | 1106 |
|
1107 |
// draw roof |
|
1108 |
if (ti->map5&1) { |
|
1109 |
x += 12; |
|
1110 |
if (image&0x3FFF) AddSortableSpriteToDraw(image, x,y, 1, 16, 0x28, z); |
|
1111 |
} else { |
|
1112 |
y += 12; |
|
1113 |
if (image&0x3FFF) AddSortableSpriteToDraw(image, x,y, 16, 1, 0x28, z); |
|
1114 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1115 |
|
0 | 1116 |
if (ti->z + 5 == z ) { |
1117 |
// draw poles below for small bridges |
|
1118 |
image = b[2]; |
|
1119 |
if (image) { |
|
497
2d6d31173813
(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
|
1120 |
if (_display_opt & DO_TRANS_BUILDINGS) image = (image & 0x3FFF) | 0x03224000; |
0 | 1121 |
DrawGroundSpriteAt(image, x, y, z); |
1122 |
} |
|
1123 |
} else if (_patches.bridge_pillars) { |
|
1124 |
// draw pillars below for high bridges |
|
1125 |
DrawBridgePillars(ti, x, y, z); |
|
1126 |
} |
|
1127 |
} |
|
1128 |
} |
|
1129 |
} |
|
1130 |
||
1131 |
static uint GetSlopeZ_TunnelBridge(TileInfo *ti) { |
|
1132 |
uint z = ti->z; |
|
1133 |
uint x = ti->x & 0xF; |
|
1134 |
uint y = ti->y & 0xF; |
|
1135 |
||
1136 |
// swap directions if Y tunnel/bridge to let the code handle the X case only. |
|
1137 |
if (ti->map5 & 1) intswap(x,y); |
|
1138 |
||
1139 |
// to the side of the tunnel/bridge? |
|
1140 |
if (IS_INT_INSIDE(y, 5, 10+1)) { |
|
1141 |
// tunnel? |
|
1142 |
if ( (ti->map5 & 0xF0) == 0) |
|
1143 |
return z; |
|
1144 |
||
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1145 |
// bridge? |
0 | 1146 |
if ( ti->map5 & 0x80 ) { |
1147 |
// bridge ending? |
|
1148 |
if (!(ti->map5 & 0x40)) { |
|
1149 |
if (BRIDGE_FULL_LEVELED_FOUNDATION & (1 << ti->tileh)) // 7, 11, 13, 14 |
|
1150 |
z += 8; |
|
1151 |
||
1152 |
// no ramp for bridge ending |
|
1153 |
if ((BRIDGE_PARTLY_LEVELED_FOUNDATION & (1 << ti->tileh) || BRIDGE_NO_FOUNDATION & (1 << ti->tileh)) && ti->tileh != 0) { |
|
1154 |
return z + 8; |
|
1155 |
||
1156 |
} else if (!(ti->map5 & 0x20)) { // northern / southern ending |
|
1157 |
// ramp |
|
1158 |
return (z + (x>>1) + 1); |
|
1159 |
} else { |
|
1160 |
// ramp in opposite dir |
|
1161 |
return (z + ((x^0xF)>>1)); |
|
1162 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1163 |
|
0 | 1164 |
// bridge middle part |
1165 |
} else { |
|
1166 |
// build on slopes? |
|
1167 |
if (ti->tileh) z+=8; |
|
1168 |
||
1169 |
// keep the same elevation because we're on the bridge? |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1170 |
if (_get_z_hint >= z + 8) |
0 | 1171 |
return _get_z_hint; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1172 |
|
0 | 1173 |
// actually on the bridge, but not yet in the shared area. |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1174 |
if (!IS_INT_INSIDE(x, 5, 10+1)) |
0 | 1175 |
return GetBridgeHeight(ti) + 8; |
1176 |
||
1177 |
// in the shared area, assume that we're below the bridge, cause otherwise the hint would've caught it. |
|
1178 |
// if rail or road below then it means it's possibly build on slope below the bridge. |
|
1179 |
if (ti->map5 & 0x20) { |
|
1180 |
uint f = _bridge_foundations[ti->map5&1][ti->tileh]; |
|
1181 |
// make sure that the slope is not inclined foundation |
|
1182 |
if (IS_BYTE_INSIDE(f, 1, 15)) return z; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1183 |
|
0 | 1184 |
// change foundation type? |
1185 |
if (f) ti->tileh = _inclined_tileh[f - 15]; |
|
1186 |
} |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1187 |
|
0 | 1188 |
// no transport route, fallback to default |
1189 |
} |
|
1190 |
} |
|
1191 |
} else { |
|
1192 |
// if it's a bridge middle with transport route below, then we need to compensate for build on slopes |
|
1193 |
if ( (ti->map5 & (0x80 + 0x40 + 0x20)) == (0x80 + 0x40 + 0x20)) { |
|
1194 |
uint f; |
|
1195 |
if (ti->tileh) z += 8; |
|
1196 |
f = _bridge_foundations[ti->map5&1][ti->tileh]; |
|
1197 |
if (IS_BYTE_INSIDE(f, 1, 15)) return z; |
|
1198 |
if (f) ti->tileh = _inclined_tileh[f - 15]; |
|
1199 |
} |
|
1200 |
} |
|
1201 |
||
1202 |
// default case |
|
1203 |
z = ti->z; |
|
1204 |
return GetPartialZ(ti->x&0xF, ti->y&0xF, ti->tileh) + z; |
|
1205 |
} |
|
1206 |
||
39 | 1207 |
static uint GetSlopeTileh_TunnelBridge(TileInfo *ti) { |
1208 |
// not accurate, but good enough for slope graphics drawing |
|
1209 |
return 0; |
|
1210 |
} |
|
1211 |
||
1212 |
||
473
0da86c59e3ae
(svn r724) Remove restriction that a tile can only accept 3 cargo types.
tron
parents:
337
diff
changeset
|
1213 |
static void GetAcceptedCargo_TunnelBridge(uint tile, AcceptedCargo ac) |
0 | 1214 |
{ |
1215 |
/* not used */ |
|
1216 |
} |
|
1217 |
||
1218 |
static const StringID _bridge_tile_str[(MAX_BRIDGES + 3) + (MAX_BRIDGES + 3)] = { |
|
1219 |
STR_501F_WOODEN_RAIL_BRIDGE, |
|
1220 |
STR_5020_CONCRETE_RAIL_BRIDGE, |
|
1221 |
STR_501C_STEEL_GIRDER_RAIL_BRIDGE, |
|
1222 |
STR_501E_REINFORCED_CONCRETE_SUSPENSION, |
|
1223 |
STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, |
|
1224 |
STR_501B_STEEL_SUSPENSION_RAIL_BRIDGE, |
|
1225 |
STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, |
|
1226 |
STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, |
|
1227 |
STR_501D_STEEL_CANTILEVER_RAIL_BRIDGE, |
|
1228 |
STR_501C_STEEL_GIRDER_RAIL_BRIDGE, |
|
1229 |
STR_5027_TUBULAR_RAIL_BRIDGE, |
|
1230 |
STR_5027_TUBULAR_RAIL_BRIDGE, |
|
1231 |
STR_5027_TUBULAR_RAIL_BRIDGE, |
|
1232 |
0,0,0, |
|
1233 |
||
1234 |
STR_5025_WOODEN_ROAD_BRIDGE, |
|
1235 |
STR_5026_CONCRETE_ROAD_BRIDGE, |
|
1236 |
STR_5022_STEEL_GIRDER_ROAD_BRIDGE, |
|
1237 |
STR_5024_REINFORCED_CONCRETE_SUSPENSION, |
|
1238 |
STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE, |
|
1239 |
STR_5021_STEEL_SUSPENSION_ROAD_BRIDGE, |
|
1240 |
STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE, |
|
1241 |
STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE, |
|
1242 |
STR_5023_STEEL_CANTILEVER_ROAD_BRIDGE, |
|
1243 |
STR_5022_STEEL_GIRDER_ROAD_BRIDGE, |
|
1244 |
STR_5028_TUBULAR_ROAD_BRIDGE, |
|
1245 |
STR_5028_TUBULAR_ROAD_BRIDGE, |
|
1246 |
STR_5028_TUBULAR_ROAD_BRIDGE, |
|
1247 |
0,0,0, |
|
1248 |
}; |
|
1249 |
||
1250 |
static void GetTileDesc_TunnelBridge(uint tile, TileDesc *td) |
|
1251 |
{ |
|
1252 |
int delta; |
|
1253 |
||
1254 |
if ((_map5[tile] & 0x80) == 0) { |
|
1255 |
td->str = STR_5017_RAILROAD_TUNNEL + ((_map5[tile] >> 2) & 3); |
|
1256 |
} else { |
|
1257 |
td->str = _bridge_tile_str[ (_map2[tile] >> 4) + (((_map5[tile]>>1)&3)<<4) ]; |
|
1258 |
||
1259 |
/* scan to the end of the bridge, that's where the owner is stored */ |
|
1260 |
if (_map5[tile] & 0x40) { |
|
1261 |
delta = _map5[tile] & 1 ? TILE_XY(0,-1) : TILE_XY(-1,0); |
|
1262 |
do tile += delta; while (_map5[tile] & 0x40); |
|
1263 |
} |
|
1264 |
} |
|
1265 |
td->owner = _map_owner[tile]; |
|
1266 |
} |
|
1267 |
||
1268 |
||
1269 |
static void AnimateTile_TunnelBridge(uint tile) |
|
1270 |
{ |
|
1271 |
/* not used */ |
|
1272 |
} |
|
1273 |
||
1274 |
static void TileLoop_TunnelBridge(uint tile) |
|
1275 |
{ |
|
1276 |
if (_opt.landscape == LT_HILLY) { |
|
1277 |
if ( GetTileZ(tile) > _opt.snow_line) { |
|
1278 |
if (!(_map3_hi[tile] & 0x80)) { |
|
1279 |
_map3_hi[tile] |= 0x80; |
|
1280 |
MarkTileDirtyByTile(tile); |
|
1281 |
} |
|
1282 |
} else { |
|
1283 |
if (_map3_hi[tile] & 0x80) { |
|
1284 |
_map3_hi[tile] &= ~0x80; |
|
1285 |
MarkTileDirtyByTile(tile); |
|
1286 |
} |
|
1287 |
} |
|
1288 |
} else if (_opt.landscape == LT_DESERT) { |
|
1289 |
if (GetMapExtraBits(tile) == 1 && !(_map3_hi[tile]&0x80)) { |
|
1290 |
_map3_hi[tile] |= 0x80; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1291 |
MarkTileDirtyByTile(tile); |
0 | 1292 |
} |
1293 |
} |
|
1294 |
||
1295 |
// if it's a bridge with water below, call tileloop_water on it. |
|
1296 |
if ((_map5[tile] & 0xF8) == 0xC8) TileLoop_Water(tile); |
|
1297 |
} |
|
1298 |
||
1299 |
static void ClickTile_TunnelBridge(uint tile) |
|
1300 |
{ |
|
1301 |
/* not used */ |
|
1302 |
} |
|
1303 |
||
1304 |
||
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1305 |
static uint32 GetTileTrackStatus_TunnelBridge(uint tile, TransportType mode) |
0 | 1306 |
{ |
1307 |
uint32 result; |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1308 |
byte m5 = _map5[tile]; |
0 | 1309 |
|
1310 |
if ((m5 & 0xF0) == 0) { |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1311 |
/* This is a tunnel */ |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1312 |
if (((m5 & 0xC) >> 2) == mode) { |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1313 |
/* Tranport in the tunnel is compatible */ |
0 | 1314 |
return m5&1 ? 0x202 : 0x101; |
1315 |
} |
|
1316 |
} else if (m5 & 0x80) { |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1317 |
/* This is a bridge */ |
0 | 1318 |
result = 0; |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1319 |
if (((m5 & 0x6) >> 1) == mode) { |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1320 |
/* Transport over the bridge is compatible */ |
0 | 1321 |
result = m5&1 ? 0x202 : 0x101; |
1322 |
} |
|
1323 |
if (m5 & 0x40) { |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1324 |
/* Bridge middle part */ |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1325 |
if (!(m5 & 0x20)) { |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1326 |
/* Clear ground or water underneath */ |
241
e6e62a5e7f52
(svn r242) -Fix: Pathfinding bug for road vehicles introduced in r160 fixed (blathijs)
darkvater
parents:
203
diff
changeset
|
1327 |
if ((m5 & 0x18) != 8) |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1328 |
/* Clear ground */ |
0 | 1329 |
return result; |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1330 |
else |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1331 |
if (mode != TRANSPORT_WATER) |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1332 |
return result; |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1333 |
} else { |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1334 |
/* Transport underneath */ |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1335 |
if ((m5 & 0x18) >> 3 != mode) |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1336 |
/* Incompatible transport underneath */ |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1337 |
return result; |
0 | 1338 |
} |
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1339 |
/* If we've not returned yet, there is a compatible |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1340 |
* transport or water beneath, so we can add it to |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1341 |
* result */ |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1342 |
/* Why is this xor'd ? Can't it just be or'd? */ |
0 | 1343 |
result ^= m5&1 ? 0x101 : 0x202; |
1344 |
} |
|
1345 |
return result; |
|
159
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1346 |
} else { |
139cf78bfb28
(svn r160) -Codechange: made GetTileTrackStatus more readable (blathijs)
truelight
parents:
98
diff
changeset
|
1347 |
assert(0); /* This should never occur */ |
0 | 1348 |
} |
1349 |
return 0; |
|
1350 |
} |
|
1351 |
||
1352 |
static void ChangeTileOwner_TunnelBridge(uint tile, byte old_player, byte new_player) |
|
1353 |
{ |
|
1354 |
if (_map_owner[tile] != old_player) |
|
1355 |
return; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1356 |
|
0 | 1357 |
if (new_player != 255) { |
1358 |
_map_owner[tile] = new_player; |
|
1359 |
} else { |
|
1360 |
if((_map5[tile] & 0xC0)==0xC0) { |
|
1361 |
// the stuff BELOW the middle part is owned by the deleted player. |
|
1362 |
if (!(_map5[tile] & (1 << 4 | 1 << 3))) { |
|
1363 |
// convert railway into grass. |
|
1364 |
_map5[tile] &= ~(1 << 5 | 1 << 4 | 1 << 3); // no transport route under bridge anymore.. |
|
1365 |
} else { |
|
1366 |
// for road, change the owner of the road to local authority |
|
1367 |
_map_owner[tile] = OWNER_NONE; |
|
1368 |
} |
|
1369 |
} else { |
|
1370 |
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR); |
|
1371 |
} |
|
1372 |
} |
|
1373 |
} |
|
1374 |
||
1375 |
||
1376 |
static const byte _tunnel_fractcoord_1[4] = {0x8E,0x18,0x81,0xE8}; |
|
1377 |
static const byte _tunnel_fractcoord_2[4] = {0x81,0x98,0x87,0x38}; |
|
1378 |
static const byte _tunnel_fractcoord_3[4] = {0x82,0x88,0x86,0x48}; |
|
1379 |
static const byte _exit_tunnel_track[4] = {1,2,1,2}; |
|
1380 |
||
1381 |
static const byte _road_exit_tunnel_state[4] = {8, 9, 0, 1}; |
|
1382 |
static const byte _road_exit_tunnel_frame[4] = {2, 7, 9, 4}; |
|
1383 |
||
1384 |
static const byte _tunnel_fractcoord_4[4] = {0x52, 0x85, 0x98, 0x29}; |
|
1385 |
static const byte _tunnel_fractcoord_5[4] = {0x92, 0x89, 0x58, 0x25}; |
|
1386 |
static const byte _tunnel_fractcoord_6[4] = {0x92, 0x89, 0x56, 0x45}; |
|
1387 |
static const byte _tunnel_fractcoord_7[4] = {0x52, 0x85, 0x96, 0x49}; |
|
1388 |
||
1389 |
static uint32 VehicleEnter_TunnelBridge(Vehicle *v, uint tile, int x, int y) |
|
1390 |
{ |
|
1391 |
int z; |
|
1392 |
int dir, vdir; |
|
1393 |
byte fc; |
|
1394 |
int h; |
|
1395 |
||
1396 |
if ((_map5[tile] & 0xF0) == 0) { |
|
1397 |
z = GetSlopeZ(x, y) - v->z_pos; |
|
1398 |
if (myabs(z) > 2) |
|
1399 |
return 8; |
|
1400 |
||
1401 |
if (v->type == VEH_Train) { |
|
1402 |
fc = (x&0xF)+(y<<4); |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1403 |
|
0 | 1404 |
dir = _map5[tile] & 3; |
1405 |
vdir = v->direction >> 1; |
|
1406 |
||
1407 |
if (v->u.rail.track != 0x40 && dir == vdir) { |
|
1408 |
if (v->subtype == 0 && fc == _tunnel_fractcoord_1[dir]) { |
|
1409 |
if (v->spritenum < 4) |
|
541 | 1410 |
SndPlayVehicleFx(SND_05_TRAIN_THROUGH_TUNNEL, v); |
0 | 1411 |
return 0; |
1412 |
} |
|
1413 |
if (fc == _tunnel_fractcoord_2[dir]) { |
|
1414 |
v->tile = tile; |
|
1415 |
v->u.rail.track = 0x40; |
|
1416 |
v->vehstatus |= VS_HIDDEN; |
|
1417 |
return 4; |
|
1418 |
} |
|
1419 |
} |
|
1420 |
||
1421 |
if (dir == (vdir^2) && fc == _tunnel_fractcoord_3[dir] && z == 0) { |
|
22 | 1422 |
/* We're at the tunnel exit ?? */ |
0 | 1423 |
v->tile = tile; |
1424 |
v->u.rail.track = _exit_tunnel_track[dir]; |
|
1425 |
v->vehstatus &= ~VS_HIDDEN; |
|
1426 |
return 4; |
|
1427 |
} |
|
1428 |
} else if (v->type == VEH_Road) { |
|
1429 |
fc = (x&0xF)+(y<<4); |
|
1430 |
dir = _map5[tile] & 3; |
|
1431 |
vdir = v->direction >> 1; |
|
1432 |
||
1433 |
// Enter tunnel? |
|
1434 |
if (v->u.road.state != 0xFF && dir == vdir) { |
|
1435 |
if (fc == _tunnel_fractcoord_4[dir] || |
|
1436 |
fc == _tunnel_fractcoord_5[dir]) { |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1437 |
|
0 | 1438 |
v->tile = tile; |
1439 |
v->u.road.state = 0xFF; |
|
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
159
diff
changeset
|
1440 |
v->vehstatus |= VS_HIDDEN; |
0 | 1441 |
return 4; |
1442 |
} else { |
|
1443 |
return 0; |
|
1444 |
} |
|
1445 |
} |
|
1446 |
||
1447 |
if (dir == (vdir^2) && ( |
|
22 | 1448 |
/* We're at the tunnel exit ?? */ |
0 | 1449 |
fc == _tunnel_fractcoord_6[dir] || |
1450 |
fc == _tunnel_fractcoord_7[dir]) && |
|
1451 |
z == 0) { |
|
1452 |
v->tile = tile; |
|
1453 |
v->u.road.state = _road_exit_tunnel_state[dir]; |
|
1454 |
v->u.road.frame = _road_exit_tunnel_frame[dir]; |
|
1455 |
v->vehstatus &= ~VS_HIDDEN; |
|
1456 |
return 4; |
|
1457 |
} |
|
1458 |
} |
|
1459 |
} else if (_map5[tile] & 0x80) { |
|
1460 |
if (v->type == VEH_Road || (v->type == VEH_Train && v->subtype == 0)) { |
|
334
8fb78c8c10e5
(svn r501) -Fix: Vehicles slow down under bridge if the track is on a foundation
tron
parents:
333
diff
changeset
|
1461 |
if (GetTileSlope(tile, &h) != 0) |
8fb78c8c10e5
(svn r501) -Fix: Vehicles slow down under bridge if the track is on a foundation
tron
parents:
333
diff
changeset
|
1462 |
h += 8; // Compensate for possible foundation |
8fb78c8c10e5
(svn r501) -Fix: Vehicles slow down under bridge if the track is on a foundation
tron
parents:
333
diff
changeset
|
1463 |
if (!(_map5[tile] & 0x40) || // start/end tile of bridge |
8fb78c8c10e5
(svn r501) -Fix: Vehicles slow down under bridge if the track is on a foundation
tron
parents:
333
diff
changeset
|
1464 |
myabs(h - v->z_pos) > 2) { // high above the ground -> on the bridge |
0 | 1465 |
/* modify speed of vehicle */ |
1466 |
uint16 spd = _bridge_speeds[_map2[tile] >> 4]; |
|
1467 |
if (v->type == VEH_Road) spd<<=1; |
|
1468 |
if (spd < v->cur_speed) |
|
1469 |
v->cur_speed = spd; |
|
1470 |
} |
|
1471 |
} |
|
1472 |
} |
|
1473 |
return 0; |
|
1474 |
} |
|
1475 |
||
1476 |
uint GetVehicleOutOfTunnelTile(Vehicle *v) |
|
1477 |
{ |
|
1478 |
uint tile = v->tile; |
|
1479 |
int delta_tile; |
|
1480 |
byte z; |
|
1481 |
||
1482 |
/* locate either ending of the tunnel */ |
|
1483 |
delta_tile = (v->direction&2) ? TILE_XY(0,1) : TILE_XY(1,0); |
|
1484 |
z = v->z_pos; |
|
1485 |
for(;;) { |
|
1486 |
TileInfo ti; |
|
1487 |
FindLandscapeHeightByTile(&ti, tile); |
|
1488 |
||
1489 |
if (ti.type == MP_TUNNELBRIDGE && (ti.map5 & 0xF0)==0 && (byte)ti.z == z) |
|
1490 |
break; |
|
1491 |
||
1492 |
tile += delta_tile; |
|
1493 |
} |
|
1494 |
return tile; |
|
1495 |
} |
|
1496 |
||
1497 |
const TileTypeProcs _tile_type_tunnelbridge_procs = { |
|
1498 |
DrawTile_TunnelBridge, /* draw_tile_proc */ |
|
1499 |
GetSlopeZ_TunnelBridge, /* get_slope_z_proc */ |
|
1500 |
ClearTile_TunnelBridge, /* clear_tile_proc */ |
|
1501 |
GetAcceptedCargo_TunnelBridge, /* get_accepted_cargo_proc */ |
|
1502 |
GetTileDesc_TunnelBridge, /* get_tile_desc_proc */ |
|
1503 |
GetTileTrackStatus_TunnelBridge,/* get_tile_track_status_proc */ |
|
1504 |
ClickTile_TunnelBridge, /* click_tile_proc */ |
|
1505 |
AnimateTile_TunnelBridge, /* animate_tile_proc */ |
|
1506 |
TileLoop_TunnelBridge, /* tile_loop_clear */ |
|
1507 |
ChangeTileOwner_TunnelBridge, /* change_tile_owner_clear */ |
|
1508 |
NULL, /* get_produced_cargo_proc */ |
|
1509 |
VehicleEnter_TunnelBridge, /* vehicle_enter_tile_proc */ |
|
1510 |
NULL, /* vehicle_leave_tile_proc */ |
|
39 | 1511 |
GetSlopeTileh_TunnelBridge, /* get_slope_tileh_proc */ |
0 | 1512 |
}; |