src/tunnelbridge_cmd.cpp
branchnoai
changeset 9694 e72987579514
parent 9686 d3c195c226f9
child 9701 d1ac22c62f64
equal deleted inserted replaced
9693:31fcaa5375a1 9694:e72987579514
   386 
   386 
   387 			case MP_RAILWAY:
   387 			case MP_RAILWAY:
   388 				if (!IsPlainRailTile(tile)) goto not_valid_below;
   388 				if (!IsPlainRailTile(tile)) goto not_valid_below;
   389 				break;
   389 				break;
   390 
   390 
   391 			case MP_STREET:
   391 			case MP_ROAD:
   392 				if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) goto not_valid_below;
   392 				if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) goto not_valid_below;
   393 				break;
   393 				break;
   394 
   394 
   395 			case MP_TUNNELBRIDGE:
   395 			case MP_TUNNELBRIDGE:
   396 				if (IsTunnel(tile)) break;
   396 				if (IsTunnel(tile)) break;
   502 
   502 
   503 	/** Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price*/
   503 	/** Tile shift coeficient. Will decrease for very long tunnels to avoid exponential growth of price*/
   504 	int tiles_coef = 3;
   504 	int tiles_coef = 3;
   505 	/** Number of tiles from start of tunnel */
   505 	/** Number of tiles from start of tunnel */
   506 	int tiles = 0;
   506 	int tiles = 0;
       
   507 	/** Number of tiles at which the cost increase coefficient per tile is halved */
       
   508 	int tiles_bump = 25;
   507 
   509 
   508 	for (;;) {
   510 	for (;;) {
   509 		end_tile += delta;
   511 		end_tile += delta;
   510 		end_tileh = GetTileSlope(end_tile, &end_z);
   512 		end_tileh = GetTileSlope(end_tile, &end_z);
   511 
   513 
   514 		if (!_cheats.crossing_tunnels.value && IsTunnelInWayDir(end_tile, start_z, tunnel_in_way_dir)) {
   516 		if (!_cheats.crossing_tunnels.value && IsTunnelInWayDir(end_tile, start_z, tunnel_in_way_dir)) {
   515 			return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY);
   517 			return_cmd_error(STR_5003_ANOTHER_TUNNEL_IN_THE_WAY);
   516 		}
   518 		}
   517 
   519 
   518 		tiles++;
   520 		tiles++;
   519 		if (tiles == 25 || tiles == 50 || tiles == 100 || tiles == 200 || tiles == 400 || tiles == 800) tiles_coef++;
   521 		if (tiles == tiles_bump) {
       
   522 			tiles_coef++;
       
   523 			tiles_bump *= 2;
       
   524 		}
   520 
   525 
   521 		cost.AddCost(_price.build_tunnel);
   526 		cost.AddCost(_price.build_tunnel);
   522 		cost.AddCost(cost.GetCost() >> tiles_coef); // add a multiplier for longer tunnels
   527 		cost.AddCost(cost.GetCost() >> tiles_coef); // add a multiplier for longer tunnels
   523 	}
   528 	}
   524 
   529 
   823 	if (image != 0) {
   828 	if (image != 0) {
   824 		bool drawfarpillar = !HASBIT(GetBridgeFlags(type), 0);
   829 		bool drawfarpillar = !HASBIT(GetBridgeFlags(type), 0);
   825 		int back_height, front_height;
   830 		int back_height, front_height;
   826 		int i = z;
   831 		int i = z;
   827 		const byte *p;
   832 		const byte *p;
   828 		SpriteID pal;
       
   829 
   833 
   830 		static const byte _tileh_bits[4][8] = {
   834 		static const byte _tileh_bits[4][8] = {
   831 			{ 2, 1, 8, 4,  16,  2, 0, 9 },
   835 			{ 2, 1, 8, 4,  16,  2, 0, 9 },
   832 			{ 1, 8, 4, 2,   2, 16, 9, 0 },
   836 			{ 1, 8, 4, 2,   2, 16, 9, 0 },
   833 			{ 4, 8, 1, 2,  16,  2, 0, 9 },
   837 			{ 4, 8, 1, 2,  16,  2, 0, 9 },
   834 			{ 2, 4, 8, 1,   2, 16, 9, 0 }
   838 			{ 2, 4, 8, 1,   2, 16, 9, 0 }
   835 		};
   839 		};
   836 
   840 
   837 		if (HASBIT(_transparent_opt, TO_BRIDGES)) {
       
   838 			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
       
   839 			pal = PALETTE_TO_TRANSPARENT;
       
   840 		} else {
       
   841 			pal = psid->pal;
       
   842 		}
       
   843 
       
   844 		p = _tileh_bits[(image & 1) * 2 + (axis == AXIS_X ? 0 : 1)];
   841 		p = _tileh_bits[(image & 1) * 2 + (axis == AXIS_X ? 0 : 1)];
   845 		front_height = ti->z + (ti->tileh & p[0] ? TILE_HEIGHT : 0);
   842 		front_height = ti->z + (ti->tileh & p[0] ? TILE_HEIGHT : 0);
   846 		back_height  = ti->z + (ti->tileh & p[1] ? TILE_HEIGHT : 0);
   843 		back_height  = ti->z + (ti->tileh & p[1] ? TILE_HEIGHT : 0);
   847 
   844 
   848 		if (IsSteepSlope(ti->tileh)) {
   845 		if (IsSteepSlope(ti->tileh)) {
   853 		for (; z >= front_height || z >= back_height; z -= TILE_HEIGHT) {
   850 		for (; z >= front_height || z >= back_height; z -= TILE_HEIGHT) {
   854 			/* HACK set height of the BB of pillars to 1, because the origin of the
   851 			/* HACK set height of the BB of pillars to 1, because the origin of the
   855 			 * sprites is at the top
   852 			 * sprites is at the top
   856 			 */
   853 			 */
   857 			if (z >= front_height) { // front facing pillar
   854 			if (z >= front_height) { // front facing pillar
   858 				AddSortableSpriteToDraw(image, pal, x, y, p[4], p[5], 1, z);
   855 				AddSortableSpriteToDraw(image, psid->pal, x, y, p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
   859 			}
   856 			}
   860 
   857 
   861 			if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar
   858 			if (drawfarpillar && z >= back_height && z < i - TILE_HEIGHT) { // back facing pillar
   862 				AddSortableSpriteToDraw(image, pal, x - p[6], y - p[7], p[4], p[5], 1, z);
   859 				AddSortableSpriteToDraw(image, psid->pal, x - p[6], y - p[7], p[4], p[5], 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
   863 			}
   860 			}
   864 		}
   861 		}
   865 	}
   862 	}
   866 }
   863 }
   867 
   864 
   868 uint GetBridgeFoundation(Slope tileh, Axis axis)
   865 Foundation GetBridgeFoundation(Slope tileh, Axis axis)
   869 {
   866 {
   870 	uint i;
   867 	if (HASBIT(BRIDGE_NO_FOUNDATION, tileh)) return FOUNDATION_NONE;
   871 
   868 	if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return FlatteningFoundation(tileh);
   872 	if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return tileh;
   869 	return InclinedFoundation(axis);
   873 
       
   874 	/* inclined sloped building */
       
   875 	switch (tileh) {
       
   876 		case SLOPE_W:
       
   877 		case SLOPE_STEEP_W: i = 0; break;
       
   878 		case SLOPE_S:
       
   879 		case SLOPE_STEEP_S: i = 2; break;
       
   880 		case SLOPE_E:
       
   881 		case SLOPE_STEEP_E: i = 4; break;
       
   882 		case SLOPE_N:
       
   883 		case SLOPE_STEEP_N: i = 6; break;
       
   884 		default: return 0;
       
   885 	}
       
   886 	if (axis != AXIS_X) ++i;
       
   887 	return i + 15;
       
   888 }
   870 }
   889 
   871 
   890 /**
   872 /**
   891  * Draws the trambits over an already drawn (lower end) of a bridge.
   873  * Draws the trambits over an already drawn (lower end) of a bridge.
   892  * @param x       the x of the bridge
   874  * @param x       the x of the bridge
   902 	static const SpriteID front_offsets[6]   =   {  97,  98, 103, 106, 104, 105 };
   884 	static const SpriteID front_offsets[6]   =   {  97,  98, 103, 106, 104, 105 };
   903 
   885 
   904 	static const uint size_x[6] = { 11, 16, 16, 16, 16, 16 };
   886 	static const uint size_x[6] = { 11, 16, 16, 16, 16, 16 };
   905 	static const uint size_y[6] = { 16, 11, 16, 16, 16, 16 };
   887 	static const uint size_y[6] = { 16, 11, 16, 16, 16, 16 };
   906 
   888 
   907 	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z);
   889 	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z, HASBIT(_transparent_opt, TO_BRIDGES));
   908 
   890 
   909 	SpriteID front = SPR_TRAMWAY_BASE + front_offsets[offset];
   891 	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + back_offsets[offset],  PAL_NONE, x, y, size_x[offset], size_y[offset], 0, z, HASBIT(_transparent_opt, TO_BUILDINGS));
   910 	SpriteID back  = SPR_TRAMWAY_BASE + back_offsets[offset];
       
   911 	SpriteID pal   = PAL_NONE;
       
   912 	if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
       
   913 		SETBIT(front, PALETTE_MODIFIER_TRANSPARENT);
       
   914 		SETBIT(back,  PALETTE_MODIFIER_TRANSPARENT);
       
   915 		pal = PALETTE_TO_TRANSPARENT;
       
   916 	}
       
   917 
       
   918 	AddSortableSpriteToDraw(back,  pal, x, y, size_x[offset], size_y[offset], 0, z);
       
   919 	/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
   892 	/* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
   920 	AddSortableSpriteToDraw(front, pal, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z);
   893 	AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + front_offsets[offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z, HASBIT(_transparent_opt, TO_BUILDINGS));
   921 }
   894 }
   922 
   895 
   923 /**
   896 /**
   924  * Draws a tunnel of bridge tile.
   897  * Draws a tunnel of bridge tile.
   925  * For tunnels, this is rather simple, as you only needa draw the entrance.
   898  * For tunnels, this is rather simple, as you only needa draw the entrance.
   934  * Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3
   907  * Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3
   935  */
   908  */
   936 static void DrawTile_TunnelBridge(TileInfo *ti)
   909 static void DrawTile_TunnelBridge(TileInfo *ti)
   937 {
   910 {
   938 	SpriteID image;
   911 	SpriteID image;
   939 	SpriteID pal;
       
   940 
   912 
   941 	if (IsTunnel(ti->tile)) {
   913 	if (IsTunnel(ti->tile)) {
   942 		if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
   914 		if (GetTunnelTransportType(ti->tile) == TRANSPORT_RAIL) {
   943 			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
   915 			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
   944 		} else {
   916 		} else {
   978 		}
   950 		}
   979 
   951 
   980 		/* as the lower 3 bits are used for other stuff, make sure they are clear */
   952 		/* as the lower 3 bits are used for other stuff, make sure they are clear */
   981 		assert( (base_offset & 0x07) == 0x00);
   953 		assert( (base_offset & 0x07) == 0x00);
   982 
   954 
   983 		if (!HASBIT(BRIDGE_NO_FOUNDATION, ti->tileh)) {
   955 		DrawFoundation(ti, GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetBridgeRampDirection(ti->tile))));
   984 			int f = GetBridgeFoundation(ti->tileh, DiagDirToAxis(GetBridgeRampDirection(ti->tile)));
       
   985 			if (f != 0) DrawFoundation(ti, f);
       
   986 		}
       
   987 
   956 
   988 		/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
   957 		/* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
   989 		base_offset += (6 - GetBridgeRampDirection(ti->tile)) % 4;
   958 		base_offset += (6 - GetBridgeRampDirection(ti->tile)) % 4;
   990 
   959 
   991 		if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
   960 		if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
   997 			DrawClearLandTile(ti, 3);
   966 			DrawClearLandTile(ti, 3);
   998 		} else {
   967 		} else {
   999 			DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE);
   968 			DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE);
  1000 		}
   969 		}
  1001 
   970 
  1002 		image = psid->sprite;
       
  1003 
       
  1004 		/* draw ramp */
   971 		/* draw ramp */
  1005 		if (HASBIT(_transparent_opt, TO_BRIDGES)) {
       
  1006 			SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
       
  1007 			pal = PALETTE_TO_TRANSPARENT;
       
  1008 		} else {
       
  1009 			pal = psid->pal;
       
  1010 		}
       
  1011 
   972 
  1012 		/* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on
   973 		/* HACK set the height of the BB of a sloped ramp to 1 so a vehicle on
  1013 		 * it doesn't disappear behind it
   974 		 * it doesn't disappear behind it
  1014 		 */
   975 		 */
  1015 		AddSortableSpriteToDraw(
   976 		AddSortableSpriteToDraw(
  1016 			image, pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z
   977 			psid->sprite, psid->pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z, HASBIT(_transparent_opt, TO_BRIDGES)
  1017 		);
   978 		);
  1018 
   979 
  1019 		if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
   980 		if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
  1020 			RoadTypes rts = GetRoadTypes(ti->tile);
   981 			RoadTypes rts = GetRoadTypes(ti->tile);
  1021 
   982 
  1074 
  1035 
  1075 
  1036 
  1076 void DrawBridgeMiddle(const TileInfo* ti)
  1037 void DrawBridgeMiddle(const TileInfo* ti)
  1077 {
  1038 {
  1078 	const PalSpriteID* psid;
  1039 	const PalSpriteID* psid;
  1079 	SpriteID image;
       
  1080 	SpriteID pal;
       
  1081 	uint base_offset;
  1040 	uint base_offset;
  1082 	TileIndex rampnorth;
  1041 	TileIndex rampnorth;
  1083 	TileIndex rampsouth;
  1042 	TileIndex rampsouth;
  1084 	Axis axis;
  1043 	Axis axis;
  1085 	uint piece;
  1044 	uint piece;
  1112 	x = ti->x;
  1071 	x = ti->x;
  1113 	y = ti->y;
  1072 	y = ti->y;
  1114 	uint bridge_z = GetBridgeHeight(rampsouth);
  1073 	uint bridge_z = GetBridgeHeight(rampsouth);
  1115 	z = bridge_z - 3;
  1074 	z = bridge_z - 3;
  1116 
  1075 
  1117 	image = psid->sprite;
       
  1118 	if (HASBIT(_transparent_opt, TO_BRIDGES)) {
       
  1119 		SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
       
  1120 		pal = PALETTE_TO_TRANSPARENT;
       
  1121 	} else {
       
  1122 		pal = psid->pal;
       
  1123 	}
       
  1124 
       
  1125 	if (axis == AXIS_X) {
  1076 	if (axis == AXIS_X) {
  1126 		AddSortableSpriteToDraw(image, pal, x, y, 16, 11, 1, z);
  1077 		AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 11, 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
  1127 	} else {
  1078 	} else {
  1128 		AddSortableSpriteToDraw(image, pal, x, y, 11, 16, 1, z);
  1079 		AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 11, 16, 1, z, HASBIT(_transparent_opt, TO_BRIDGES));
  1129 	}
  1080 	}
  1130 
  1081 
  1131 	psid++;
  1082 	psid++;
  1132 	image = psid->sprite;
       
  1133 	if (HASBIT(_transparent_opt, TO_BRIDGES)) {
       
  1134 		SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
       
  1135 		pal = PALETTE_TO_TRANSPARENT;
       
  1136 	} else {
       
  1137 		pal = psid->pal;
       
  1138 	}
       
  1139 
  1083 
  1140 	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
  1084 	if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
  1141 		RoadTypes rts = GetRoadTypes(rampsouth);
  1085 		RoadTypes rts = GetRoadTypes(rampsouth);
  1142 
  1086 
  1143 		if (HASBIT(rts, ROADTYPE_TRAM)) {
  1087 		if (HASBIT(rts, ROADTYPE_TRAM)) {
  1148 	}
  1092 	}
  1149 
  1093 
  1150 	/* draw roof, the component of the bridge which is logically between the vehicle and the camera */
  1094 	/* draw roof, the component of the bridge which is logically between the vehicle and the camera */
  1151 	if (axis == AXIS_X) {
  1095 	if (axis == AXIS_X) {
  1152 		y += 12;
  1096 		y += 12;
  1153 		if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 16, 1, 0x28, z);
  1097 		if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 16, 1, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES));
  1154 	} else {
  1098 	} else {
  1155 		x += 12;
  1099 		x += 12;
  1156 		if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 1, 16, 0x28, z);
  1100 		if (psid->sprite & SPRITE_MASK) AddSortableSpriteToDraw(psid->sprite, psid->pal, x, y, 1, 16, 0x28, z, HASBIT(_transparent_opt, TO_BRIDGES));
  1157 	}
  1101 	}
  1158 
  1102 
  1159 	psid++;
  1103 	psid++;
  1160 	if (ti->z + 5 == z) {
  1104 	if (ti->z + 5 == z) {
  1161 		/* draw poles below for small bridges */
  1105 		/* draw poles below for small bridges */
  1162 		if (psid->sprite != 0) {
  1106 		if (psid->sprite != 0) {
  1163 			image = psid->sprite;
  1107 			SpriteID image = psid->sprite;
       
  1108 			SpriteID pal   = psid->pal;
  1164 			if (HASBIT(_transparent_opt, TO_BRIDGES)) {
  1109 			if (HASBIT(_transparent_opt, TO_BRIDGES)) {
  1165 				SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
  1110 				SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
  1166 				pal = PALETTE_TO_TRANSPARENT;
  1111 				pal = PALETTE_TO_TRANSPARENT;
  1167 			} else {
       
  1168 				pal = psid->pal;
       
  1169 			}
  1112 			}
  1170 
  1113 
  1171 			DrawGroundSpriteAt(image, pal, x, y, z);
  1114 			DrawGroundSpriteAt(image, pal, x, y, z);
  1172 		}
  1115 		}
  1173 	} else if (_patches.bridge_pillars) {
  1116 	} else if (_patches.bridge_pillars) {
  1192 		if (5 <= pos && pos <= 10) return z;
  1135 		if (5 <= pos && pos <= 10) return z;
  1193 	} else {
  1136 	} else {
  1194 		DiagDirection dir = GetBridgeRampDirection(tile);
  1137 		DiagDirection dir = GetBridgeRampDirection(tile);
  1195 		uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
  1138 		uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
  1196 
  1139 
       
  1140 		z += ApplyFoundationToSlope(GetBridgeFoundation(tileh, DiagDirToAxis(dir)), &tileh);
       
  1141 
  1197 		/* On the bridge ramp? */
  1142 		/* On the bridge ramp? */
  1198 		if (5 <= pos && pos <= 10) {
  1143 		if (5 <= pos && pos <= 10) {
  1199 			uint delta;
  1144 			uint delta;
  1200 
  1145 
  1201 			if (IsSteepSlope(tileh)) return z + TILE_HEIGHT * 2;
       
  1202 			if (HASBIT(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT;
  1146 			if (HASBIT(BRIDGE_HORZ_RAMP, tileh)) return z + TILE_HEIGHT;
  1203 
  1147 
  1204 			if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) z += TILE_HEIGHT;
       
  1205 			switch (dir) {
  1148 			switch (dir) {
  1206 				default: NOT_REACHED();
  1149 				default: NOT_REACHED();
  1207 				case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break;
  1150 				case DIAGDIR_NE: delta = (TILE_SIZE - 1 - x) / 2; break;
  1208 				case DIAGDIR_SE: delta = y / 2; break;
  1151 				case DIAGDIR_SE: delta = y / 2; break;
  1209 				case DIAGDIR_SW: delta = x / 2; break;
  1152 				case DIAGDIR_SW: delta = x / 2; break;
  1210 				case DIAGDIR_NW: delta = (TILE_SIZE - 1 - y) / 2; break;
  1153 				case DIAGDIR_NW: delta = (TILE_SIZE - 1 - y) / 2; break;
  1211 			}
  1154 			}
  1212 			return z + 1 + delta;
  1155 			return z + 1 + delta;
  1213 		} else {
       
  1214 			uint f = GetBridgeFoundation(tileh, DiagDirToAxis(dir));
       
  1215 
       
  1216 			if (f != 0) {
       
  1217 				if (IsSteepSlope(tileh)) {
       
  1218 					z += TILE_HEIGHT;
       
  1219 				} else if (f < 15) {
       
  1220 					return z + TILE_HEIGHT;
       
  1221 				}
       
  1222 				tileh = (Slope)_inclined_tileh[f - 15];
       
  1223 			}
       
  1224 		}
  1156 		}
  1225 	}
  1157 	}
  1226 
  1158 
  1227 	return z + GetPartialZ(x, y, tileh);
  1159 	return z + GetPartialZ(x, y, tileh);
  1228 }
  1160 }
  1229 
  1161 
  1230 static Slope GetSlopeTileh_TunnelBridge(TileIndex tile, Slope tileh)
  1162 static Foundation GetFoundation_TunnelBridge(TileIndex tile, Slope tileh)
  1231 {
  1163 {
  1232 	if (IsTunnel(tile)) {
  1164 	return IsTunnel(tile) ? FOUNDATION_NONE : GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
  1233 		return tileh;
       
  1234 	} else {
       
  1235 		if (HASBIT(BRIDGE_NO_FOUNDATION, tileh)) {
       
  1236 			return tileh;
       
  1237 		} else {
       
  1238 			uint f = GetBridgeFoundation(tileh, DiagDirToAxis(GetBridgeRampDirection(tile)));
       
  1239 
       
  1240 			if (f == 0) return tileh;
       
  1241 			if (f < 15) return SLOPE_FLAT;
       
  1242 			return (Slope)_inclined_tileh[f - 15];
       
  1243 		}
       
  1244 	}
       
  1245 }
  1165 }
  1246 
  1166 
  1247 
  1167 
  1248 static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac)
  1168 static void GetAcceptedCargo_TunnelBridge(TileIndex tile, AcceptedCargo ac)
  1249 {
  1169 {
  1511 	AnimateTile_TunnelBridge,        /* animate_tile_proc */
  1431 	AnimateTile_TunnelBridge,        /* animate_tile_proc */
  1512 	TileLoop_TunnelBridge,           /* tile_loop_clear */
  1432 	TileLoop_TunnelBridge,           /* tile_loop_clear */
  1513 	ChangeTileOwner_TunnelBridge,    /* change_tile_owner_clear */
  1433 	ChangeTileOwner_TunnelBridge,    /* change_tile_owner_clear */
  1514 	NULL,                            /* get_produced_cargo_proc */
  1434 	NULL,                            /* get_produced_cargo_proc */
  1515 	VehicleEnter_TunnelBridge,       /* vehicle_enter_tile_proc */
  1435 	VehicleEnter_TunnelBridge,       /* vehicle_enter_tile_proc */
  1516 	GetSlopeTileh_TunnelBridge,      /* get_slope_tileh_proc */
  1436 	GetFoundation_TunnelBridge,      /* get_foundation_proc */
  1517 };
  1437 };