Index: docs/landscape.html =================================================================== --- docs/landscape.html (revision 27200) +++ docs/landscape.html (working copy) @@ -975,7 +975,7 @@
  • m6 bits 5..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy, waypoint)
  • m6 bit 2: pbs reservation state for railway stations/waypoints
  • - +
  • m6 bit 0: river restoration flag for whenever a canal is removed
  • m7 bits 4..0: owner of road (road stops)
  • m7 bits 7..6: present road types (road stops)
  • m7: animation frame (railway stations/waypoints, airports)
  • @@ -1088,6 +1088,7 @@ +
  • m6 bit 0: river restoration flag for whenever a canal is removed
  • @@ -1429,6 +1430,7 @@
  • m6 bits 5..3: random triggers (NewGRF)
  • m6 bit 2: bit 8 of type (see m5)
  • +
  • m6 bit 0: river restoration flag for whenever a canal is removed
  • m7: animation frame
  • @@ -1599,6 +1601,7 @@
  • m2: index into the array of objects, bits 0 to 15 (upper bits in m5)
  • m3: random bits
  • m5: index into the array of objects, bits 16 to 23 (lower bits in m2)
  • +
  • m6 bit 0: river restoration flag for whenever a canal is removed
  • m7: animation counter
  • Index: docs/landscape_grid.html =================================================================== --- docs/landscape_grid.html (revision 27200) +++ docs/landscape_grid.html (working copy) @@ -236,7 +236,7 @@ OOOO OOOO OOOO OOOO ~~~~ ~XXX - OOXX XOOO + OOXX XOOX OOOO OOOO @@ -260,7 +260,7 @@ OOOO OOOO OOOO OOOO ~~~~ ~~~~ - OOXX XOOO + OOXX XOOX OOOO OOOO @@ -272,7 +272,7 @@ OOOO OOOO OOOO OOOO ~~~~ ~~~~ - OOXX XOOO + OOXX XOOX OOOO OOOO @@ -297,8 +297,8 @@ OOOO OOOO XXXX XXXX -inherit- + OOOO OOOX OOOO OOOO - OOOO OOOO shipdepot @@ -309,8 +309,8 @@ OOOO OOOO OOOO OOOO -inherit- + OOOO OOOX OOOO OOOO - OOOO OOOO 8 @@ -322,7 +322,7 @@ XXXX XXXX XXXX XXXX XXXX XXXX - OOXX XXOO + OOXX XXOX XXXX XXXX @@ -360,7 +360,7 @@ XXXX XXXX OOOO OOOO XXXX XXXX - OOOO OOOO + OOOO OOOX XXXX XXXX Index: src/industry_cmd.cpp =================================================================== --- src/industry_cmd.cpp (revision 27200) +++ src/industry_cmd.cpp (working copy) @@ -1755,9 +1755,9 @@ i->location.Add(cur_tile); WaterClass wc = (IsWaterTile(cur_tile) ? GetWaterClass(cur_tile) : WATER_CLASS_INVALID); - + bool river = HasBit(_me[cur_tile].m6, 0); DoCommand(cur_tile, 0, 0, DC_EXEC | DC_NO_TEST_TOWN_RATING | DC_NO_MODIFY_TOWN_RATING, CMD_LANDSCAPE_CLEAR); - + if (river) SB(_me[cur_tile].m6, 0, 1, 1); MakeIndustry(cur_tile, i->index, it->gfx, Random(), wc); if (_generating_world) { Index: src/saveload/company_sl.cpp =================================================================== --- src/saveload/company_sl.cpp (revision 27200) +++ src/saveload/company_sl.cpp (working copy) @@ -179,8 +179,11 @@ if (IsShipDepot(tile)) c->infrastructure.water += LOCK_DEPOT_TILE_FACTOR; if (IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE) { /* The middle tile specifies the owner of the lock. */ - c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // the middle tile specifies the owner of the - break; // do not count the middle tile as canal + c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; + + /* Only count the middle tile as canal if the tile is not river. */ + if (GetWaterClass(tile) != WATER_CLASS_RIVER) c->infrastructure.water++; + break; } } } Index: src/station_cmd.cpp =================================================================== --- src/station_cmd.cpp (revision 27200) +++ src/station_cmd.cpp (working copy) @@ -2511,7 +2511,7 @@ /* Get the water class of the water tile before it is cleared.*/ WaterClass wc = GetWaterClass(tile_cur); - + bool river = HasBit(_me[tile_cur].m6, 0); ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; @@ -2551,7 +2551,7 @@ DirtyCompanyInfrastructureWindows(st->owner); MakeDock(tile, st->owner, st->index, direction, wc); - + if (river) SB(_me[tile + TileOffsByDiagDir(direction)].m6, 0, 1, 1); st->UpdateVirtCoord(); UpdateStationAcceptance(st, false); st->RecomputeIndustriesNear(); Index: src/table/build_industry.h =================================================================== --- src/table/build_industry.h (revision 27200) +++ src/table/build_industry.h (working copy) @@ -293,6 +293,19 @@ MK(-2, -4, 255), MK(-3, -4, 255), MK(2, 0, 255), + MK(2, -1, 255), + MK(1, -1, 255), + MK(0, -1, 255), + MK(-1, -1, 255), + MK(-1, 0, 255), + MK(-1, 1, 255), + MK(-1, 2, 255), + MK(-1, 3, 255), + MK(0, 3, 255), + MK(1, 3, 255), + MK(2, 3, 255), + MK(2, 2, 255), + MK(2, 1, 255), MKEND }; Index: src/water_cmd.cpp =================================================================== --- src/water_cmd.cpp (revision 27200) +++ src/water_cmd.cpp (working copy) @@ -39,7 +39,7 @@ #include "company_base.h" #include "company_gui.h" #include "newgrf_generic.h" - +#include "cheat_type.h" #include "table/strings.h" #include "safeguards.h" @@ -123,6 +123,8 @@ CommandCost cost = CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_DEPOT_SHIP]); bool add_cost = !IsWaterTile(tile); + bool river1 = HasBit(_me[tile].m6, 0); + bool river2 = HasBit(_me[tile2].m6, 0); CommandCost ret = DoCommand(tile, 0, 0, flags | DC_AUTO, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; if (add_cost) { @@ -145,7 +147,8 @@ } Company::Get(_current_company)->infrastructure.water += 2 * LOCK_DEPOT_TILE_FACTOR; DirtyCompanyInfrastructureWindows(_current_company); - + if (river1) SB(_me[tile].m6, 0, 1, 1); + if (river2) SB(_me[tile2].m6, 0, 1, 1); MakeShipDepot(tile, _current_company, depot->index, DEPOT_PART_NORTH, axis, wc1); MakeShipDepot(tile2, _current_company, depot->index, DEPOT_PART_SOUTH, axis, wc2); MarkTileDirtyByTile(tile); @@ -192,7 +195,7 @@ wc = WATER_CLASS_CANAL; } - + bool river = HasBit(_me[tile].m6, 0); /* Zero map array and terminate animation */ DoClearSquare(tile); @@ -199,7 +202,9 @@ /* Maybe change to water */ switch (wc) { case WATER_CLASS_SEA: MakeSea(tile); break; - case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); break; + case WATER_CLASS_CANAL: MakeCanal(tile, o, Random()); + if (river) SB(_me[tile].m6, 0, 1, 1); + break; case WATER_CLASS_RIVER: MakeRiver(tile, Random()); break; default: break; } @@ -258,9 +263,14 @@ /* middle tile */ WaterClass wc_middle = IsWaterTile(tile) ? GetWaterClass(tile) : WATER_CLASS_CANAL; - ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); - if (ret.Failed()) return ret; - cost.AddCost(ret); + + if (!IsWaterTile(tile)) { + ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); + if (ret.Failed()) return ret; + cost.AddCost(ret); + /* Add an extra cost only if not building on a river. */ + cost.AddCost(_price[PR_BUILD_CANAL]); + } /* lower tile */ WaterClass wc_lower = IsWaterTile(tile - delta) ? GetWaterClass(tile - delta) : WATER_CLASS_CANAL; @@ -291,7 +301,8 @@ if (IsBridgeAbove(tile) || IsBridgeAbove(tile - delta) || IsBridgeAbove(tile + delta)) { return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST); } - + bool river_lower = HasBit(_me[tile - delta].m6, 0); + bool river_upper = HasBit(_me[tile + delta].m6, 0); if (flags & DC_EXEC) { /* Update company infrastructure counts. */ Company *c = Company::GetIfValid(_current_company); @@ -298,12 +309,14 @@ if (c != NULL) { /* Counts for the water. */ if (!IsWaterTile(tile - delta)) c->infrastructure.water++; + if (!IsWaterTile(tile)) c->infrastructure.water++; if (!IsWaterTile(tile + delta)) c->infrastructure.water++; /* Count for the lock itself. */ c->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock is three tiles. DirtyCompanyInfrastructureWindows(_current_company); } - + if (river_lower) SB(_me[tile - delta].m6, 0, 1, 1); + if (river_upper) SB(_me[tile + delta].m6, 0, 1, 1); MakeLock(tile, _current_company, dir, wc_lower, wc_upper, wc_middle); MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile - delta); @@ -324,6 +337,8 @@ */ static CommandCost RemoveLock(TileIndex tile, DoCommandFlag flags) { + CommandCost cost(EXPENSES_CONSTRUCTION); + if (GetTileOwner(tile) != OWNER_NONE) { CommandCost ret = CheckTileOwnership(tile); if (ret.Failed()) return ret; @@ -337,6 +352,9 @@ if (ret.Succeeded()) ret = EnsureNoVehicleOnGround(tile - delta); if (ret.Failed()) return ret; + /* Add an extra cost only if it was not built on a river. */ + if (GetWaterClass(tile) != WATER_CLASS_RIVER) cost.AddCost(_price[PR_CLEAR_CANAL]); + if (flags & DC_EXEC) { /* Remove middle part from company infrastructure count. */ Company *c = Company::GetIfValid(GetTileOwner(tile)); @@ -348,6 +366,7 @@ if (GetWaterClass(tile) == WATER_CLASS_RIVER) { MakeRiver(tile, Random()); } else { + if (c != NULL) c->infrastructure.water--; // Make sure it's not a leftover or neutral lock. DoClearSquare(tile); } MakeWaterKeepingClass(tile + delta, GetTileOwner(tile + delta)); @@ -357,7 +376,9 @@ MarkCanalsAndRiversAroundDirty(tile + delta); } - return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_LOCK]); + cost.AddCost(_price[PR_CLEAR_LOCK]); + return cost; + } /** @@ -419,6 +440,7 @@ if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || wc == WATER_CLASS_SEA)) continue; bool water = IsWaterTile(tile); + bool river = HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_RIVER; ret = DoCommand(tile, 0, 0, flags | DC_FORCE_CLEAR_TILE, CMD_LANDSCAPE_CLEAR); if (ret.Failed()) return ret; @@ -442,6 +464,7 @@ /* FALL THROUGH */ default: + if (river) SB(_me[tile].m6, 0, 1, 1); MakeCanal(tile, _current_company, Random()); if (Company::IsValidID(_current_company)) { Company::Get(_current_company)->infrastructure.water++; @@ -465,6 +488,7 @@ static CommandCost ClearTile_Water(TileIndex tile, DoCommandFlag flags) { + bool canal_on_river = HasBit(_me[tile].m6, 0); switch (GetWaterTileType(tile)) { case WATER_TILE_CLEAR: { if (flags & DC_NO_WATER) return_cmd_error(STR_ERROR_CAN_T_BUILD_ON_WATER); @@ -486,12 +510,16 @@ if (ret.Failed()) return ret; } + if (IsRiver(tile) && _game_mode == GM_NORMAL && !_cheats.magic_bulldozer.value) base_cost = 0; + if (flags & DC_EXEC) { if (IsCanal(tile) && Company::IsValidID(owner)) { Company::Get(owner)->infrastructure.water--; DirtyCompanyInfrastructureWindows(owner); } + bool river = HasTileWaterClass(tile) && GetWaterClass(tile) == WATER_CLASS_RIVER; DoClearSquare(tile); + if ((canal_on_river || river) && _game_mode == GM_NORMAL && !_cheats.magic_bulldozer.value) MakeRiver(tile, Random()); MarkCanalsAndRiversAroundDirty(tile); } @@ -1275,9 +1303,15 @@ bool is_lock_middle = IsLock(tile) && GetLockPart(tile) == LOCK_PART_MIDDLE; /* No need to dirty company windows here, we'll redraw the whole screen anyway. */ - if (is_lock_middle) Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts. + if (is_lock_middle) { + Company::Get(old_owner)->infrastructure.water -= 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts. + if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(old_owner)->infrastructure.water--; + } if (new_owner != INVALID_OWNER) { - if (is_lock_middle) Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts. + if (is_lock_middle) { + Company::Get(new_owner)->infrastructure.water += 3 * LOCK_DEPOT_TILE_FACTOR; // Lock has three parts. + if (GetWaterClass(tile) == WATER_CLASS_CANAL) Company::Get(new_owner)->infrastructure.water++; + } /* Only subtract from the old owner here if the new owner is valid, * otherwise we clear ship depots and canal water below. */ if (GetWaterClass(tile) == WATER_CLASS_CANAL && !is_lock_middle) { @@ -1313,6 +1347,7 @@ { /* Canals can't be terraformed */ if (IsWaterTile(tile) && IsCanal(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_CANAL_FIRST); + if (IsWaterTile(tile) && IsRiver(tile)) return_cmd_error(STR_ERROR_SITE_UNSUITABLE); return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); }