water_cmd.c
changeset 1981 3c9c682f1212
parent 1980 6c5917cfcb78
child 2049 538e73c53f54
equal deleted inserted replaced
1980:6c5917cfcb78 1981:3c9c682f1212
    39 	if (p1 > 3) return CMD_ERROR;
    39 	if (p1 > 3) return CMD_ERROR;
    40 
    40 
    41 	tile = TileVirtXY(x, y);
    41 	tile = TileVirtXY(x, y);
    42 	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
    42 	if (!EnsureNoVehicle(tile)) return CMD_ERROR;
    43 
    43 
    44 	tile2 = tile + (p1 ? TILE_XY(0,1) : TILE_XY(1,0));
    44 	tile2 = tile + (p1 ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
    45 	if (!EnsureNoVehicle(tile2)) return CMD_ERROR;
    45 	if (!EnsureNoVehicle(tile2)) return CMD_ERROR;
    46 
    46 
    47 	if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2))
    47 	if (!IsClearWaterTile(tile) || !IsClearWaterTile(tile2))
    48 		return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER);
    48 		return_cmd_error(STR_3801_MUST_BE_BUILT_ON_WATER);
    49 
    49 
    85 		return CMD_ERROR;
    85 		return CMD_ERROR;
    86 
    86 
    87 	if (!EnsureNoVehicle(tile))
    87 	if (!EnsureNoVehicle(tile))
    88 		return CMD_ERROR;
    88 		return CMD_ERROR;
    89 
    89 
    90 	tile2 = tile + ((_map5[tile] & 2) ? TILE_XY(0,1) : TILE_XY(1,0));
    90 	tile2 = tile + ((_map5[tile] & 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
    91 
    91 
    92 	if (!EnsureNoVehicle(tile2))
    92 	if (!EnsureNoVehicle(tile2))
    93 		return CMD_ERROR;
    93 		return CMD_ERROR;
    94 
    94 
    95 	if (flags & DC_EXEC) {
    95 	if (flags & DC_EXEC) {
   208 
   208 
   209 	/* Outside the editor you can only drag canals, and not areas */
   209 	/* Outside the editor you can only drag canals, and not areas */
   210 	if (_game_mode != GM_EDITOR && (sx != x && sy != y)) return CMD_ERROR;
   210 	if (_game_mode != GM_EDITOR && (sx != x && sy != y)) return CMD_ERROR;
   211 
   211 
   212 	cost = 0;
   212 	cost = 0;
   213 	BEGIN_TILE_LOOP(tile, size_x, size_y, TILE_XY(sx, sy)) {
   213 	BEGIN_TILE_LOOP(tile, size_x, size_y, TileXY(sx, sy)) {
   214 		ret = 0;
   214 		ret = 0;
   215 		if (GetTileSlope(tile, NULL) != 0) return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   215 		if (GetTileSlope(tile, NULL) != 0) return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   216 
   216 
   217 			// can't make water of water!
   217 			// can't make water of water!
   218 			if (IsTileType(tile, MP_WATER)) {
   218 			if (IsTileType(tile, MP_WATER)) {
   304 		// ship depot
   304 		// ship depot
   305 		if (flags & DC_AUTO)
   305 		if (flags & DC_AUTO)
   306 			return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
   306 			return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
   307 
   307 
   308 		if (m5 == 0x80 || m5 == 0x82) {}
   308 		if (m5 == 0x80 || m5 == 0x82) {}
   309 		else if (m5 == 0x81) { tile -= TILE_XY(1,0); }
   309 		else if (m5 == 0x81) { tile -= TileDiffXY(1, 0); }
   310 		else if (m5 == 0x83) { tile -= TILE_XY(0,1); }
   310 		else if (m5 == 0x83) { tile -= TileDiffXY(0, 1); }
   311 		else
   311 		else
   312 			return CMD_ERROR;
   312 			return CMD_ERROR;
   313 
   313 
   314 		return RemoveShipDepot(tile,flags);
   314 		return RemoveShipDepot(tile,flags);
   315 	}
   315 	}
   678 {
   678 {
   679 	byte m5 = _map5[tile] - 0x80;
   679 	byte m5 = _map5[tile] - 0x80;
   680 
   680 
   681 	if (IS_BYTE_INSIDE(m5, 0, 3+1)) {
   681 	if (IS_BYTE_INSIDE(m5, 0, 3+1)) {
   682 		if (m5 & 1)
   682 		if (m5 & 1)
   683 			tile += (m5==1) ? TILE_XY(-1,0) : TILE_XY(0,-1);
   683 			tile += (m5 == 1) ? TileDiffXY(-1, 0) : TileDiffXY(0, -1);
   684 		ShowShipDepotWindow(tile);
   684 		ShowShipDepotWindow(tile);
   685 	}
   685 	}
   686 }
   686 }
   687 
   687 
   688 static void ChangeTileOwner_Water(TileIndex tile, byte old_player, byte new_player)
   688 static void ChangeTileOwner_Water(TileIndex tile, byte old_player, byte new_player)