diff --git a/src/depot.cpp b/src/depot.cpp index e73490071b..6f30839fd5 100644 --- a/src/depot.cpp +++ b/src/depot.cpp @@ -10,6 +10,7 @@ #include "core/bitmath_func.hpp" #include "tile_map.h" #include "water_map.h" +#include "vehicle_gui.h" DEFINE_OLD_POOL_GENERIC(Depot, Depot) @@ -48,6 +49,16 @@ Depot::~Depot() /* Delete the depot-window */ DeleteWindowById(WC_VEHICLE_DEPOT, this->xy); + + /* Delete the depot list */ + WindowNumber wno = (this->index << 16) | VLW_DEPOT_LIST | GetTileOwner(this->xy); + switch (GetTileType(this->xy)) { + default: break; // It can happen there is no depot here anymore (TTO/TTD savegames) + case MP_RAILWAY: DeleteWindowById(WC_TRAINS_LIST, wno | (VEH_TRAIN << 11)); break; + case MP_ROAD: DeleteWindowById(WC_ROADVEH_LIST, wno | (VEH_ROAD << 11)); break; + case MP_WATER: DeleteWindowById(WC_SHIPS_LIST, wno | (VEH_SHIP << 11)); break; + } + this->xy = INVALID_TILE; } diff --git a/src/economy.cpp b/src/economy.cpp index 199d2bbf72..c30c25d2f6 100644 --- a/src/economy.cpp +++ b/src/economy.cpp @@ -671,9 +671,18 @@ static void CompaniesPayInterest() static void HandleEconomyFluctuations() { - if (_settings_game.difficulty.economy == 0) return; + if (_settings_game.difficulty.economy != 0) { + /* When economy is Fluctuating, decrease counter */ + _economy.fluct--; + } else if (_economy.fluct <= 0) { + /* When it's Steady and we are in recession, end it now */ + _economy.fluct = -12; + } else { + /* No need to do anything else in other cases */ + return; + } - if (--_economy.fluct == 0) { + if (_economy.fluct == 0) { _economy.fluct = -(int)GB(Random(), 0, 2); AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NS_ECONOMY, 0, 0); } else if (_economy.fluct == -12) { diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index 4ada623ee1..8334c0f00c 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -1439,8 +1439,8 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags) if (v != NULL) FreeTrainTrackReservation(v); } - DoClearSquare(tile); delete GetDepotByTile(tile); + DoClearSquare(tile); AddSideToSignalBuffer(tile, dir, owner); YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir)); if (v != NULL) TryPathReserve(v, true); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index f38a789a8c..739edd320e 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -886,8 +886,8 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags) if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR; if (flags & DC_EXEC) { - DoClearSquare(tile); delete GetDepotByTile(tile); + DoClearSquare(tile); } return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot); diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp index f540a58343..b8bf4bb241 100644 --- a/src/saveload/oldloader_sl.cpp +++ b/src/saveload/oldloader_sl.cpp @@ -594,7 +594,8 @@ static bool LoadOldOrder(LoadgameState *ls, int num) { if (!LoadChunk(ls, NULL, order_chunk)) return false; - new (num) Order(UnpackOldOrder(_old_order)); + Order *o = new (num) Order(); + o->AssignOrder(UnpackOldOrder(_old_order)); /* Relink the orders to eachother (in the orders for one vehicle are behind eachother, * with an invalid order (OT_NOTHING) as indication that it is the last order */ diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index 9846d46257..3749eb8a7f 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1297,17 +1297,19 @@ static bool GrowTown(Town *t) /* No road available, try to build a random road block by * clearing some land and then building a road there. */ - tile = t->xy; - for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) { - /* Only work with plain land that not already has a house */ - if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) { - if (CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) { - DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD); - _current_company = old_company; - return true; + if (_settings_game.economy.allow_town_roads || _generating_world) { + tile = t->xy; + for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) { + /* Only work with plain land that not already has a house */ + if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) { + if (CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) { + DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD); + _current_company = old_company; + return true; + } } + tile = TILE_ADD(tile, ToTileIndexDiff(*ptr)); } - tile = TILE_ADD(tile, ToTileIndexDiff(*ptr)); } _current_company = old_company;