water_cmd.c
changeset 3940 8965b9bfaabc
parent 3939 75e6a7133ebb
child 3977 513433ebd092
equal deleted inserted replaced
3939:75e6a7133ebb 3940:8965b9bfaabc
   146 	    (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) {
   146 	    (MayHaveBridgeAbove(tile + delta) && IsBridgeAbove(tile + delta))) {
   147 		return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
   147 		return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
   148 	}
   148 	}
   149 
   149 
   150 	if (flags & DC_EXEC) {
   150 	if (flags & DC_EXEC) {
   151 		MakeLock(tile, dir);
   151 		MakeLock(tile, _current_player, dir);
   152 		MarkTileDirtyByTile(tile);
   152 		MarkTileDirtyByTile(tile);
   153 		MarkTileDirtyByTile(tile - delta);
   153 		MarkTileDirtyByTile(tile - delta);
   154 		MarkTileDirtyByTile(tile + delta);
   154 		MarkTileDirtyByTile(tile + delta);
   155 	}
   155 	}
   156 
   156 
   158 }
   158 }
   159 
   159 
   160 static int32 RemoveShiplift(TileIndex tile, uint32 flags)
   160 static int32 RemoveShiplift(TileIndex tile, uint32 flags)
   161 {
   161 {
   162 	TileIndexDiff delta = TileOffsByDir(GetLockDirection(tile));
   162 	TileIndexDiff delta = TileOffsByDir(GetLockDirection(tile));
       
   163 
       
   164 	if (!CheckTileOwnership(tile)) return CMD_ERROR;
   163 
   165 
   164 	// make sure no vehicle is on the tile.
   166 	// make sure no vehicle is on the tile.
   165 	if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
   167 	if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
   166 		return CMD_ERROR;
   168 		return CMD_ERROR;
   167 
   169 
   247 		ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
   249 		ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
   248 		if (CmdFailed(ret)) return ret;
   250 		if (CmdFailed(ret)) return ret;
   249 		cost += ret;
   251 		cost += ret;
   250 
   252 
   251 		if (flags & DC_EXEC) {
   253 		if (flags & DC_EXEC) {
   252 			MakeWater(tile);
   254 			if (TileHeight(tile) == 0) {
       
   255 				MakeWater(tile);
       
   256 			} else {
       
   257 				MakeCanal(tile, _current_player);
       
   258 			}
   253 			MarkTileDirtyByTile(tile);
   259 			MarkTileDirtyByTile(tile);
   254 			MarkTilesAroundDirty(tile);
   260 			MarkTilesAroundDirty(tile);
   255 		}
   261 		}
   256 
   262 
   257 		cost += _price.clear_water;
   263 		cost += _price.clear_water;
   276 			// Make sure it's not an edge tile.
   282 			// Make sure it's not an edge tile.
   277 			if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
   283 			if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
   278 					!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
   284 					!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
   279 				return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
   285 				return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
   280 			}
   286 			}
       
   287 
       
   288 			if (GetTileOwner(tile) != OWNER_WATER && !CheckTileOwnership(tile)) return CMD_ERROR;
   281 
   289 
   282 			if (flags & DC_EXEC) DoClearSquare(tile);
   290 			if (flags & DC_EXEC) DoClearSquare(tile);
   283 			return _price.clear_water;
   291 			return _price.clear_water;
   284 
   292 
   285 		case WATER_COAST: {
   293 		case WATER_COAST: {