tunnelbridge_cmd.c
changeset 1041 94db182c3614
parent 1035 812f837ee03f
child 1059 fe97d81a1b4f
equal deleted inserted replaced
1040:ac75cbea819a 1041:94db182c3614
   696 	/* delete stuff under the middle part if there's a transport route there..? */
   696 	/* delete stuff under the middle part if there's a transport route there..? */
   697 	if ((_map5[tile] & 0xE0) == 0xE0) {
   697 	if ((_map5[tile] & 0xE0) == 0xE0) {
   698 		int32 cost;
   698 		int32 cost;
   699 
   699 
   700 		// check if we own the tile below the bridge..
   700 		// check if we own the tile below the bridge..
   701 		if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TileHeight(tile))))
   701 		if (_current_player != OWNER_WATER && (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile))))
   702 			return CMD_ERROR;
   702 			return CMD_ERROR;
   703 
   703 
   704 		cost = (_map5[tile] & 8) ? _price.remove_road * 2 : _price.remove_rail;
   704 		cost = (_map5[tile] & 8) ? _price.remove_road * 2 : _price.remove_rail;
   705 
   705 
   706 		if (flags & DC_EXEC) {
   706 		if (flags & DC_EXEC) {
   709 			MarkTileDirtyByTile(tile);
   709 			MarkTileDirtyByTile(tile);
   710 		}
   710 		}
   711 		return cost;
   711 		return cost;
   712 
   712 
   713 	/* delete canal under bridge */
   713 	/* delete canal under bridge */
   714 	} else if(_map5[tile] == 0xC8 && TileHeight(tile) != 0) {
   714 	} else if(_map5[tile] == 0xC8 && TilePixelHeight(tile) != 0) {
   715 		int32 cost;
   715 		int32 cost;
   716 
   716 
   717 		// check for vehicles under bridge
   717 		// check for vehicles under bridge
   718 		if (!EnsureNoVehicleZ(tile, TileHeight(tile)))
   718 		if (!EnsureNoVehicleZ(tile, TilePixelHeight(tile)))
   719 			return CMD_ERROR;
   719 			return CMD_ERROR;
   720 		cost = _price.clear_water;
   720 		cost = _price.clear_water;
   721 		if (flags & DC_EXEC) {
   721 		if (flags & DC_EXEC) {
   722 			_map5[tile] = _map5[tile] & ~0x38;
   722 			_map5[tile] = _map5[tile] & ~0x38;
   723 			_map_owner[tile] = OWNER_NONE;
   723 			_map_owner[tile] = OWNER_NONE;
   741 			Omit tile and endtile, since these are already checked, thus solving the problem
   741 			Omit tile and endtile, since these are already checked, thus solving the problem
   742 			of bridges over water, or higher bridges, where z is not increased, eg level bridge
   742 			of bridges over water, or higher bridges, where z is not increased, eg level bridge
   743 	*/
   743 	*/
   744 	tile		+= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
   744 	tile		+= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
   745 	endtile	-= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
   745 	endtile	-= direction ? TILE_XY(0, 1) : TILE_XY( 1,0);
   746 	if ((v = FindVehicleBetween(tile, endtile, TileHeight(tile) + 8)) != NULL) {
   746 	if ((v = FindVehicleBetween(tile, endtile, TilePixelHeight(tile) + 8)) != NULL) {
   747 		VehicleInTheWayErrMsg(v);
   747 		VehicleInTheWayErrMsg(v);
   748 		return CMD_ERROR;
   748 		return CMD_ERROR;
   749 	}
   749 	}
   750 
   750 
   751 	/* Put the tiles back to start/end position */
   751 	/* Put the tiles back to start/end position */
   850 		}
   850 		}
   851 		return (length + 1) * (_price.build_rail >> 1);
   851 		return (length + 1) * (_price.build_rail >> 1);
   852 	} else if ((_map5[tile] & 0xF8) == 0xE0) {
   852 	} else if ((_map5[tile] & 0xF8) == 0xE0) {
   853 		// bridge middle part with rail below
   853 		// bridge middle part with rail below
   854 		// only check for train under bridge
   854 		// only check for train under bridge
   855 		if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TileHeight(tile)))
   855 		if (!CheckTileOwnership(tile) || !EnsureNoVehicleZ(tile, TilePixelHeight(tile)))
   856 			return CMD_ERROR;
   856 			return CMD_ERROR;
   857 
   857 
   858 		// tile is already of requested type?
   858 		// tile is already of requested type?
   859 		if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR;
   859 		if ( (uint)(_map3_lo[tile] & 0xF) == totype) return CMD_ERROR;
   860 		// change type.
   860 		// change type.
   918 	FindLandscapeHeightByTile(&ti_end, tile);
   918 	FindLandscapeHeightByTile(&ti_end, tile);
   919 	if (HASBIT(1 << 7, ti_end.tileh))
   919 	if (HASBIT(1 << 7, ti_end.tileh))
   920 		z_correction += 8;
   920 		z_correction += 8;
   921 
   921 
   922 	// return the height there (the height of the NORTH CORNER)
   922 	// return the height there (the height of the NORTH CORNER)
   923 	return TileHeight(tile) + z_correction;
   923 	return TilePixelHeight(tile) + z_correction;
   924 }
   924 }
   925 
   925 
   926 static const byte _bridge_foundations[2][16] = {
   926 static const byte _bridge_foundations[2][16] = {
   927 // 0 1  2  3  4 5 6 7  8 9 10 11 12 13 14 15
   927 // 0 1  2  3  4 5 6 7  8 9 10 11 12 13 14 15
   928 	{1,16,18,3,20,5,0,7,22,0,10,11,12,13,14},
   928 	{1,16,18,3,20,5,0,7,22,0,10,11,12,13,14},