File diff r8043:83739684a751 → r8044:fb0f34142941
src/water_cmd.cpp
Show inline comments
 
@@ -580,24 +580,34 @@ static void GetTileDesc_Water(TileIndex 
 
		default: assert(0); break;
 
	}
 

	
 
	td->owner = GetTileOwner(tile);
 
}
 

	
 
static void AnimateTile_Water(TileIndex tile)
 
{
 
	/* not used */
 
}
 

	
 
/**
 
 * Marks tile dirty if it is a canal tile.
 
 * Called to avoid glitches when flooding tiles next to canal tile.
 
 *
 
 * @param tile tile to check
 
 */
 
static inline void MarkTileDirtyIfCanal(TileIndex tile) {
 
	if (IsTileType(tile, MP_WATER) && IsCanal(tile)) MarkTileDirtyByTile(tile);
 
}
 

	
 
/**
 
 * Floods neighboured floodable tiles
 
 *
 
 * @param tile The water source tile that causes the flooding.
 
 * @param offs[0] Destination tile to flood.
 
 * @param offs[1] First corner of edge between source and dest tile.
 
 * @param offs[2] Second corder of edge between source and dest tile.
 
 * @param offs[3] Third corner of dest tile.
 
 * @param offs[4] Fourth corner of dest tile.
 
 */
 
static void TileLoopWaterHelper(TileIndex tile, const TileIndexDiffC *offs)
 
{
 
	TileIndex target = TILE_ADD(tile, ToTileIndexDiff(offs[0]));
 
@@ -641,24 +651,29 @@ static void TileLoopWaterHelper(TileInde
 
		}
 
	} else {
 
		/* Flood vehicles */
 
		_current_player = OWNER_WATER;
 

	
 
		Vehicle *v = FindFloodableVehicleOnTile(target);
 
		if (v != NULL) FloodVehicle(v);
 

	
 
		/* flood flat tile */
 
		if (CmdSucceeded(DoCommand(target, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
 
			MakeWater(target);
 
			MarkTileDirtyByTile(target);
 
			/* Mark surrounding canal tiles dirty too to avoid glitches */
 
			MarkTileDirtyIfCanal(target + TileDiffXY(0, 1));
 
			MarkTileDirtyIfCanal(target + TileDiffXY(1, 0));
 
			MarkTileDirtyIfCanal(target + TileDiffXY(0, -1));
 
			MarkTileDirtyIfCanal(target + TileDiffXY(-1, 0));
 
		}
 
	}
 
}
 

	
 
/**
 
 * Finds a vehicle to flood.
 
 * It does not find vehicles that are already crashed on bridges, i.e. flooded.
 
 * @param tile the tile where to find a vehicle to flood
 
 * @return a vehicle too flood or NULL when there is no vehicle too flood.
 
 */
 
static Vehicle *FindFloodableVehicleOnTile(TileIndex tile)
 
{