(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:
rubidium 2009-09-07 14:09:45 +00:00
parent a442343076
commit 58ebb4c65c
6 changed files with 37 additions and 14 deletions

View File

@ -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;
}

View File

@ -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) {

View File

@ -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);

View File

@ -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);

View File

@ -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 */

View File

@ -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;