Changeset - r4087:fcaef5928f56
[Not reviewed]
master
0 5 0
peter1138 - 18 years ago 2006-06-28 17:33:04
peter1138@openttd.org
(svn r5403) - Feature: Allow building canals at sea-level, using ctrl to toggle canal or plain water tile. This allows building of non-raisable sea-level water ways (useful in multiplayer) and dikes for low-level areas.
5 files changed with 32 insertions and 14 deletions:
0 comments (0 inline, 0 general)
dock_gui.c
Show inline comments
 
@@ -148,13 +148,13 @@ static void BuildDocksToolbWndProc(Windo
 

	
 
	case WE_PLACE_MOUSEUP:
 
		if (e->click.pt.x != -1) {
 
			if ((e->place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
 
				GUIPlaceProcDragXY(e);
 
			} else if (e->place.userdata == VPM_X_OR_Y) {
 
				DoCommandP(e->place.tile, e->place.starttile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
 
				DoCommandP(e->place.tile, e->place.starttile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
 
			}
 
		}
 
		break;
 

	
 
	case WE_ABORT_PLACE_OBJ:
 
		UnclickWindowButtons(w);
lang/english.txt
Show inline comments
 
@@ -1156,13 +1156,13 @@ STR_LEVEL_LAND_TOOLTIP                  
 

	
 

	
 
STR_TREES_RANDOM_TYPE                                           :{BLACK}Trees of random type
 
STR_TREES_RANDOM_TYPE_TIP                                       :{BLACK}Place trees of random type
 

	
 
STR_CANT_BUILD_CANALS                                           :{WHITE}Can't build canals here...
 
STR_BUILD_CANALS_TIP                                            :{BLACK}Build canals
 
STR_BUILD_CANALS_TIP                                            :{BLACK}Build canals. Press CTRL to place sea tiles (at sea-level only.)
 
STR_LANDINFO_CANAL                                              :Canal
 

	
 
STR_CANT_BUILD_LOCKS                                            :{WHITE}Can't build locks here...
 
STR_BUILD_LOCKS_TIP                                             :{BLACK}Build locks
 
STR_LANDINFO_LOCK                                               :Lock
 

	
terraform_gui.c
Show inline comments
 
@@ -107,13 +107,13 @@ bool GUIPlaceProcDragXY(const WindowEven
 
		GenerateRockyArea(end_tile, start_tile);
 
		break;
 
	case GUI_PlaceProc_DesertArea >> 4:
 
		GenerateDesertArea(end_tile, start_tile);
 
		break;
 
	case GUI_PlaceProc_WaterArea >> 4:
 
		DoCommandP(end_tile, start_tile, 0, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
 
		DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
 
		break;
 
	default: return false;
 
	}
 

	
 
	return true;
 
}
tunnelbridge_cmd.c
Show inline comments
 
@@ -634,13 +634,13 @@ static int32 DoClearBridge(TileIndex til
 

	
 
			if (flags & DC_EXEC) {
 
				SetClearUnderBridge(tile);
 
				MarkTileDirtyByTile(tile);
 
			}
 
			return cost;
 
		} else if (IsWaterUnderBridge(tile) && TilePixelHeight(tile) != 0) {
 
		} else if (IsWaterUnderBridge(tile) && !IsTileOwner(tile, OWNER_WATER)) {
 
			/* delete canal under bridge */
 

	
 
			// check for vehicles under bridge
 
			if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
 

	
 
			if (flags & DC_EXEC) {
 
@@ -707,13 +707,17 @@ static int32 DoClearBridge(TileIndex til
 
				MarkTileDirtyByTile(c);
 
			} else {
 
				if (IsClearUnderBridge(c)) {
 
					DoClearSquare(c);
 
				} else {
 
					if (GetTileSlope(c, NULL) == SLOPE_FLAT) {
 
						MakeWater(c);
 
						if (IsTileOwner(c, OWNER_WATER)) {
 
							MakeWater(c);
 
						} else {
 
							MakeCanal(c, GetTileOwner(c));
 
						}
 
					} else {
 
						MakeShore(c);
 
					}
 
					MarkTileDirtyByTile(c);
 
				}
 
			}
 
@@ -1027,13 +1031,13 @@ static void DrawTile_TunnelBridge(TileIn
 
				if (IsClearUnderBridge(ti->tile)) {
 
					image = (ice ? SPR_FLAT_SNOWY_TILE : SPR_FLAT_GRASS_TILE);
 
					DrawGroundSprite(image + _tileh_to_sprite[ti->tileh]);
 
				} else {
 
					if (ti->tileh == SLOPE_FLAT) {
 
						DrawGroundSprite(SPR_FLAT_WATER_TILE);
 
						if (ti->z != 0) DrawCanalWater(ti->tile);
 
						if (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER)) DrawCanalWater(ti->tile);
 
					} else {
 
						DrawGroundSprite(_water_shore_sprites[ti->tileh]);
 
					}
 
				}
 
			}
 

	
water_cmd.c
Show inline comments
 
@@ -197,13 +197,13 @@ int32 CmdBuildLock(TileIndex tile, uint3
 
	return DoBuildShiplift(tile, dir, flags);
 
}
 

	
 
/** Build a piece of canal.
 
 * @param tile end tile of stretch-dragging
 
 * @param p1 start tile of stretch-dragging
 
 * @param p2 unused
 
 * @param p2 ctrl pressed - toggles ocean / canals at sealevel
 
 */
 
int32 CmdBuildCanal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	int32 cost;
 
	int size_x, size_y;
 
	int x;
 
@@ -231,24 +231,24 @@ int32 CmdBuildCanal(TileIndex tile, uint
 
	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
 
		if (GetTileSlope(tile, NULL) != SLOPE_FLAT) {
 
			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
 
		}
 

	
 
		// can't make water of water!
 
		if (IsTileType(tile, MP_WATER)) continue;
 
		if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || HASBIT(p2, 0))) continue;
 

	
 
		/* is middle piece of a bridge? */
 
		if (IsBridgeTile(tile) && IsBridgeMiddle(tile)) {
 
			if (IsTransportUnderBridge(tile)) {
 
				return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
 
			}
 

	
 
			if (IsWaterUnderBridge(tile)) return_cmd_error(STR_1007_ALREADY_BUILT);
 
			if (IsWaterUnderBridge(tile) && (!IsTileOwner(tile, OWNER_WATER) || HASBIT(p2, 0))) return_cmd_error(STR_1007_ALREADY_BUILT);
 

	
 
			if (flags & DC_EXEC) {
 
				if (TileHeight(tile) == 0) {
 
				if (TileHeight(tile) == 0 && HASBIT(p2, 0)) {
 
					SetWaterUnderBridge(tile);
 
				} else {
 
					SetCanalUnderBridge(tile, _current_player);
 
				}
 
			}
 
		} else {
 
@@ -256,13 +256,13 @@ int32 CmdBuildCanal(TileIndex tile, uint
 
			int32 ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 

	
 
			if (CmdFailed(ret)) return ret;
 
			cost += ret;
 

	
 
			if (flags & DC_EXEC) {
 
				if (TileHeight(tile) == 0) {
 
				if (TileHeight(tile) == 0 && HASBIT(p2, 0)) {
 
					MakeWater(tile);
 
				} else {
 
					MakeCanal(tile, _current_player);
 
				}
 
			}
 
		}
 
@@ -349,13 +349,24 @@ static int32 ClearTile_Water(TileIndex t
 

	
 
// return true if a tile is a water tile.
 
static bool IsWateredTile(TileIndex tile)
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_WATER:
 
			return !IsCoast(tile);
 
			if (!IsCoast(tile)) return true;
 

	
 
			switch (GetTileSlope(tile, NULL)) {
 
				case SLOPE_W:
 
				case SLOPE_S:
 
				case SLOPE_E:
 
				case SLOPE_N:
 
					return true;
 

	
 
				default:
 
					return false;
 
			}
 

	
 
		case MP_STATION:
 
			return IsOilRig(tile) || IsDock(tile) || IsBuoy_(tile);
 

	
 
		case MP_TUNNELBRIDGE:
 
			return IsBridge(tile) && IsBridgeMiddle(tile) && IsWaterUnderBridge(tile);
 
@@ -433,13 +444,13 @@ static void DrawWaterStuff(const TileInf
 

	
 
static void DrawTile_Water(TileInfo *ti)
 
{
 
	switch (GetWaterTileType(ti->tile)) {
 
		case WATER_CLEAR:
 
			DrawGroundSprite(SPR_FLAT_WATER_TILE);
 
			if (ti->z != 0) DrawCanalWater(ti->tile);
 
			if (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER)) DrawCanalWater(ti->tile);
 
			break;
 

	
 
		case WATER_COAST:
 
			assert(!IsSteepSlope(ti->tileh));
 
			DrawGroundSprite(_water_shore_sprites[ti->tileh]);
 
			break;
 
@@ -484,13 +495,13 @@ static void GetAcceptedCargo_Water(TileI
 
}
 

	
 
static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
 
{
 
	switch (GetWaterTileType(tile)) {
 
		case WATER_CLEAR:
 
			if (TilePixelHeight(tile) == 0) {
 
			if (TilePixelHeight(tile) == 0 || IsTileOwner(tile, OWNER_WATER)) {
 
				td->str = STR_3804_WATER;
 
			} else {
 
				td->str = STR_LANDINFO_CANAL;
 
			}
 
			break;
 
		case WATER_COAST: td->str = STR_3805_COAST_OR_RIVERBANK; break;
 
@@ -639,12 +650,15 @@ void TileLoop_Water(TileIndex tile)
 
		{{-1,  0}, {0, 0}, {0, 1}, {-1,  0}, {-1,  1}},
 
		{{ 0,  1}, {0, 1}, {1, 1}, { 0,  2}, { 1,  2}},
 
		{{ 1,  0}, {1, 0}, {1, 1}, { 2,  0}, { 2,  1}},
 
		{{ 0, -1}, {0, 0}, {1, 0}, { 0, -1}, { 1, -1}}
 
	};
 

	
 
	/* Ensure sea-level canals do not flood */
 
	if (!IsTileOwner(tile, OWNER_WATER)) return;
 

	
 
	if (IS_INT_INSIDE(TileX(tile), 1, MapSizeX() - 3 + 1) &&
 
			IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) {
 
		uint i;
 

	
 
		for (i = 0; i != lengthof(_tile_loop_offs_array); i++) {
 
			TileLoopWaterHelper(tile, _tile_loop_offs_array[i]);
0 comments (0 inline, 0 general)