903 |
903 |
904 // fast routine for getting the height of a middle bridge tile. 'tile' MUST be a middle bridge tile. |
904 // fast routine for getting the height of a middle bridge tile. 'tile' MUST be a middle bridge tile. |
905 static uint GetBridgeHeight(const TileInfo *ti) |
905 static uint GetBridgeHeight(const TileInfo *ti) |
906 { |
906 { |
907 uint delta; |
907 uint delta; |
908 TileInfo ti_end; |
908 TileIndex tile = ti->tile; |
909 uint tile = ti->tile; |
|
910 uint z_correction = 0; |
|
911 |
909 |
912 // find the end tile of the bridge. |
910 // find the end tile of the bridge. |
913 delta = (_map5[tile] & 1) ? TILE_XY(0,1) : TILE_XY(1,0); |
911 delta = (_map5[tile] & 1) ? TILE_XY(0,1) : TILE_XY(1,0); |
914 do { |
912 do { |
915 assert((_map5[tile] & 0xC0) == 0xC0); // bridge and middle part |
913 assert((_map5[tile] & 0xC0) == 0xC0); // bridge and middle part |
916 tile += delta; |
914 tile += delta; |
917 } while (_map5[tile] & 0x40); // while bridge middle parts |
915 } while (_map5[tile] & 0x40); // while bridge middle parts |
918 |
916 |
919 // if the end of the bridge is on a tileh 7, the z coordinate is 1 tile too low |
917 /* Return the height there (the height of the NORTH CORNER) |
920 // correct it. |
918 * If the end of the bridge is on a tileh 7 (all raised, except north corner), |
921 FindLandscapeHeightByTile(&ti_end, tile); |
919 * the z coordinate is 1 height level too low. Compensate for that */ |
922 if (HASBIT(1 << 7, ti_end.tileh)) |
920 return TilePixelHeight(tile) + (GetTileSlope(tile, NULL) == 7 ? 8 : 0); |
923 z_correction += 8; |
|
924 |
|
925 // return the height there (the height of the NORTH CORNER) |
|
926 return TilePixelHeight(tile) + z_correction; |
|
927 } |
921 } |
928 |
922 |
929 static const byte _bridge_foundations[2][16] = { |
923 static const byte _bridge_foundations[2][16] = { |
930 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
924 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
931 {1,16,18,3,20,5,0,7,22,0,10,11,12,13,14}, |
925 {1,16,18,3,20,5,0,7,22,0,10,11,12,13,14}, |