307 } |
307 } |
308 } |
308 } |
309 |
309 |
310 static void DrawCatenaryOnBridge(const TileInfo *ti) |
310 static void DrawCatenaryOnBridge(const TileInfo *ti) |
311 { |
311 { |
312 TileIndex start = GetOtherBridgeEnd(GetSouthernBridgeEnd(ti->tile)); |
312 TileIndex end = GetSouthernBridgeEnd(ti->tile); |
313 uint length = GetBridgeLength(GetSouthernBridgeEnd(ti->tile), GetOtherBridgeEnd(GetSouthernBridgeEnd(ti->tile))); |
313 TileIndex start = GetOtherBridgeEnd(end); |
|
314 |
|
315 uint length = GetBridgeLength(start, end); |
314 uint num = DistanceMax(ti->tile, start); |
316 uint num = DistanceMax(ti->tile, start); |
|
317 |
315 const SortableSpriteStruct *sss; |
318 const SortableSpriteStruct *sss; |
316 Axis axis = GetBridgeAxis(ti->tile); |
319 Axis axis = GetBridgeAxis(ti->tile); |
317 TLG tlg = GetTLG(ti->tile); |
320 TLG tlg = GetTLG(ti->tile); |
318 |
321 |
319 CatenarySprite offset = axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH; |
322 CatenarySprite offset = axis == AXIS_X ? 0 : WIRE_Y_FLAT_BOTH - WIRE_X_FLAT_BOTH; |
320 |
323 |
321 if ((length % 2) && num == length) { |
324 if ((length % 2) && num == length) { |
|
325 /* Draw the "short" wire on the southern end of the bridge |
|
326 * only needed if the length of the bridge is odd */ |
322 sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset]; |
327 sss = &CatenarySpriteData[WIRE_X_FLAT_BOTH + offset]; |
323 } else { |
328 } else { |
|
329 /* Draw "long" wires on all other tiles of the bridge (one pylon every two tiles) */ |
324 sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset]; |
330 sss = &CatenarySpriteData[WIRE_X_FLAT_SW + (num % 2) + offset]; |
325 } |
331 } |
326 |
332 |
|
333 AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
|
334 sss->x_size, sss->y_size, sss->z_size, GetBridgeHeight(ti->tile) + sss->z_offset + 8); |
|
335 |
|
336 /* Finished with wires, draw pylons */ |
|
337 /* every other tile needs a pylon on the northern end */ |
327 if (num % 2) { |
338 if (num % 2) { |
328 if (axis == AXIS_X) { |
339 if (axis == AXIS_X) { |
329 AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
340 AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
330 } else { |
341 } else { |
331 AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
342 AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y, 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
332 } |
343 } |
333 } |
344 } |
334 |
345 |
335 if (DistanceMax(ti->tile, start) == length) { /* need a pylon here (the southern end) */ |
346 /* need a pylon on the southern end of the bridge */ |
|
347 if (DistanceMax(ti->tile, start) == length) { |
336 if (axis == AXIS_X) { |
348 if (axis == AXIS_X) { |
337 AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
349 AddSortableSpriteToDraw( pylons_bridge[0 + HASBIT(tlg, 0)], ti->x + 16, ti->y + 4 + 8 * HASBIT(tlg, 0), 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
338 } else { |
350 } else { |
339 AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
351 AddSortableSpriteToDraw( pylons_bridge[2 + HASBIT(tlg, 1)], ti->x + 4 + 8 * HASBIT(tlg, 1), ti->y + 16, 1, 1, 10, GetBridgeHeight(ti->tile) + 8); |
340 } |
352 } |
341 } |
353 } |
342 |
|
343 AddSortableSpriteToDraw( sss->image, ti->x + sss->x_offset, ti->y + sss->y_offset, |
|
344 sss->x_size, sss->y_size, sss->z_size, GetBridgeHeight(ti->tile) + sss->z_offset + 8); |
|
345 } |
354 } |
346 |
355 |
347 void DrawCatenary(const TileInfo *ti) |
356 void DrawCatenary(const TileInfo *ti) |
348 { |
357 { |
349 switch (GetTileType(ti->tile)) { |
358 switch (GetTileType(ti->tile)) { |