From 7368c740a646c958797b5dff90d6c5b51236e2a4 Mon Sep 17 00:00:00 2001 From: smatz Date: Sun, 4 Jan 2009 15:32:25 +0000 Subject: (svn r14828) -Codechange: move most of save/load-specific code to separate files --- src/water_cmd.cpp | 82 ------------------------------------------------------- 1 file changed, 82 deletions(-) (limited to 'src/water_cmd.cpp') diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp index 0c7907f20..6735d2231 100644 --- a/src/water_cmd.cpp +++ b/src/water_cmd.cpp @@ -101,88 +101,6 @@ static void MarkCanalsAndRiversAroundDirty(TileIndex tile) } } -/** - * Makes a tile canal or water depending on the surroundings. - * - * Must only be used for converting old savegames. Use WaterClass now. - * - * This as for example docks and shipdepots do not store - * whether the tile used to be canal or 'normal' water. - * @param t the tile to change. - * @param o the owner of the new tile. - * @param include_invalid_water_class Also consider WATER_CLASS_INVALID, i.e. industry tiles on land - */ -void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class) -{ - /* If the slope is not flat, we always assume 'land' (if allowed). Also for one-corner-raised-shores. - * Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */ - if (GetTileSlope(t, NULL) != SLOPE_FLAT) { - if (include_invalid_water_class) { - SetWaterClass(t, WATER_CLASS_INVALID); - return; - } else { - NOT_REACHED(); - } - } - - /* Mark tile dirty in all cases */ - MarkTileDirtyByTile(t); - - if (TileX(t) == 0 || TileY(t) == 0 || TileX(t) == MapMaxX() - 1 || TileY(t) == MapMaxY() - 1) { - /* tiles at map borders are always WATER_CLASS_SEA */ - SetWaterClass(t, WATER_CLASS_SEA); - return; - } - - bool has_water = false; - bool has_canal = false; - bool has_river = false; - - for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) { - TileIndex neighbour = TileAddByDiagDir(t, dir); - switch (GetTileType(neighbour)) { - case MP_WATER: - /* clear water and shipdepots have already a WaterClass associated */ - if (IsCoast(neighbour)) { - has_water = true; - } else if (!IsLock(neighbour)) { - switch (GetWaterClass(neighbour)) { - case WATER_CLASS_SEA: has_water = true; break; - case WATER_CLASS_CANAL: has_canal = true; break; - case WATER_CLASS_RIVER: has_river = true; break; - default: NOT_REACHED(); - } - } - break; - - case MP_RAILWAY: - /* Shore or flooded halftile */ - has_water |= (GetRailGroundType(neighbour) == RAIL_GROUND_WATER); - break; - - case MP_TREES: - /* trees on shore */ - has_water |= (GetTreeGround(neighbour) == TREE_GROUND_SHORE); - break; - - default: break; - } - } - - if (!has_water && !has_canal && !has_river && include_invalid_water_class) { - SetWaterClass(t, WATER_CLASS_INVALID); - return; - } - - if (has_river && !has_canal) { - SetWaterClass(t, WATER_CLASS_RIVER); - } else if (has_canal || !has_water) { - SetWaterClass(t, WATER_CLASS_CANAL); - } else { - SetWaterClass(t, WATER_CLASS_SEA); - } -} - /** Build a ship depot. * @param tile tile where ship depot is built -- cgit v1.2.3-54-g00ecf