mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r17456) [0.7] -Backport from trunk:
- Fix: When building roads is not allowed for town, then do not build the initial piece either [FS#3173] (r17444) - Fix: Destruction of depots did not remove any vehicle lists related to the depot, causing windows pointing to deleted depots and (thus) crashes [FS#3180] (r17442) - Fix: Economy recession would never end when economy is set to Steady while in recession (r17426) - Fix: The index of orders loaded from old savegames was owerwritten with an unitialized value (r17419)
This commit is contained in:
parent
a442343076
commit
58ebb4c65c
|
@ -10,6 +10,7 @@
|
||||||
#include "core/bitmath_func.hpp"
|
#include "core/bitmath_func.hpp"
|
||||||
#include "tile_map.h"
|
#include "tile_map.h"
|
||||||
#include "water_map.h"
|
#include "water_map.h"
|
||||||
|
#include "vehicle_gui.h"
|
||||||
|
|
||||||
DEFINE_OLD_POOL_GENERIC(Depot, Depot)
|
DEFINE_OLD_POOL_GENERIC(Depot, Depot)
|
||||||
|
|
||||||
|
@ -48,6 +49,16 @@ Depot::~Depot()
|
||||||
|
|
||||||
/* Delete the depot-window */
|
/* Delete the depot-window */
|
||||||
DeleteWindowById(WC_VEHICLE_DEPOT, this->xy);
|
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;
|
this->xy = INVALID_TILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -671,9 +671,18 @@ static void CompaniesPayInterest()
|
||||||
|
|
||||||
static void HandleEconomyFluctuations()
|
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);
|
_economy.fluct = -(int)GB(Random(), 0, 2);
|
||||||
AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NS_ECONOMY, 0, 0);
|
AddNewsItem(STR_7073_WORLD_RECESSION_FINANCIAL, NS_ECONOMY, 0, 0);
|
||||||
} else if (_economy.fluct == -12) {
|
} else if (_economy.fluct == -12) {
|
||||||
|
|
|
@ -1439,8 +1439,8 @@ static CommandCost RemoveTrainDepot(TileIndex tile, DoCommandFlag flags)
|
||||||
if (v != NULL) FreeTrainTrackReservation(v);
|
if (v != NULL) FreeTrainTrackReservation(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
DoClearSquare(tile);
|
|
||||||
delete GetDepotByTile(tile);
|
delete GetDepotByTile(tile);
|
||||||
|
DoClearSquare(tile);
|
||||||
AddSideToSignalBuffer(tile, dir, owner);
|
AddSideToSignalBuffer(tile, dir, owner);
|
||||||
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
|
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
|
||||||
if (v != NULL) TryPathReserve(v, true);
|
if (v != NULL) TryPathReserve(v, true);
|
||||||
|
|
|
@ -886,8 +886,8 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
|
||||||
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
DoClearSquare(tile);
|
|
||||||
delete GetDepotByTile(tile);
|
delete GetDepotByTile(tile);
|
||||||
|
DoClearSquare(tile);
|
||||||
}
|
}
|
||||||
|
|
||||||
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot);
|
return CommandCost(EXPENSES_CONSTRUCTION, _price.remove_road_depot);
|
||||||
|
|
|
@ -594,7 +594,8 @@ static bool LoadOldOrder(LoadgameState *ls, int num)
|
||||||
{
|
{
|
||||||
if (!LoadChunk(ls, NULL, order_chunk)) return false;
|
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,
|
/* 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 */
|
* with an invalid order (OT_NOTHING) as indication that it is the last order */
|
||||||
|
|
|
@ -1297,17 +1297,19 @@ static bool GrowTown(Town *t)
|
||||||
|
|
||||||
/* No road available, try to build a random road block by
|
/* No road available, try to build a random road block by
|
||||||
* clearing some land and then building a road there. */
|
* clearing some land and then building a road there. */
|
||||||
tile = t->xy;
|
if (_settings_game.economy.allow_town_roads || _generating_world) {
|
||||||
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
|
tile = t->xy;
|
||||||
/* Only work with plain land that not already has a house */
|
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
|
||||||
if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) {
|
/* Only work with plain land that not already has a house */
|
||||||
if (CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
|
if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) {
|
||||||
DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
|
if (CmdSucceeded(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
|
||||||
_current_company = old_company;
|
DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
|
||||||
return true;
|
_current_company = old_company;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
|
||||||
}
|
}
|
||||||
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_current_company = old_company;
|
_current_company = old_company;
|
||||||
|
|
Loading…
Reference in New Issue