1
0
Fork 0

(svn r16741) [0.7] -Backport from trunk:

- Fix: When loading a savegame Engine::grffile might be left NULL in certain cases (dynamic_engines enabled, articulated vehicle with only wagon-override action3s) (r16737)
- Fix: Show Close instead of Cancel when there is nothing to canel in the content downloading window [FS#2991] (r16732)
- Fix: [NoAI] AIDepotList contained wrong tiles for hangars when st->xy != st->airport_tile (r16731)
- Fix: The Join station window did not show all stations nearby in some cases (r16728)
- Fix: Invalidate subsidies with invalid source or destination when converting older savegames (r16710)
- Fix: The list of animated tiles could have duplicates (only for old savegames) and tiles that were not animated [FS#2994] (r16709)
release/0.7
rubidium 2009-07-04 17:20:48 +00:00
parent 660fe672e8
commit 876d064c4d
8 changed files with 92 additions and 9 deletions

View File

@ -25,7 +25,7 @@ AIDepotList::AIDepotList(AITile::TransportType transport_type)
if (st->owner == ::_current_company) { if (st->owner == ::_current_company) {
const AirportFTAClass *afc = st->Airport(); const AirportFTAClass *afc = st->Airport();
for (uint i = 0; i < afc->nof_depots; i++) { for (uint i = 0; i < afc->nof_depots; i++) {
this->AddItem(st->xy + ToTileIndexDiff(afc->airport_depots[i])); this->AddItem(st->airport_tile + ToTileIndexDiff(afc->airport_depots[i]));
} }
} }
} }

View File

@ -142,6 +142,10 @@ Industry::~Industry()
if (GetIndustryIndex(tile_cur) == this->index) { if (GetIndustryIndex(tile_cur) == this->index) {
/* MakeWaterKeepingClass() can also handle 'land' */ /* MakeWaterKeepingClass() can also handle 'land' */
MakeWaterKeepingClass(tile_cur, OWNER_NONE); MakeWaterKeepingClass(tile_cur, OWNER_NONE);
/* MakeWaterKeepingClass() doesn't remove animation if the tiles
* become watery, but be on the safe side an always remote it. */
DeleteAnimatedTile(tile_cur);
} }
} else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) { } else if (IsTileType(tile_cur, MP_STATION) && IsOilRig(tile_cur)) {
DeleteOilRig(tile_cur); DeleteOilRig(tile_cur);

View File

@ -22,6 +22,7 @@
#include "effectvehicle_func.h" #include "effectvehicle_func.h"
#include "landscape_type.h" #include "landscape_type.h"
#include "settings_type.h" #include "settings_type.h"
#include "animated_tile_func.h"
#include "table/sprites.h" #include "table/sprites.h"
@ -471,6 +472,9 @@ void DrawFoundation(TileInfo *ti, Foundation f)
void DoClearSquare(TileIndex tile) void DoClearSquare(TileIndex tile)
{ {
/* If the tile can have animation and we clear it, delete it from the animated tile list. */
if (_tile_type_procs[GetTileType(tile)]->animate_tile_proc != NULL) DeleteAnimatedTile(tile);
MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0); MakeClear(tile, CLEAR_GRASS, _generating_world ? 3 : 0);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }

View File

@ -388,6 +388,8 @@ public:
this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all); this->SetWidgetDisabledState(NCLWW_SELECT_ALL, !show_select_all);
this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade); this->SetWidgetDisabledState(NCLWW_SELECT_UPDATE, !show_select_upgrade);
this->widget[NCLWW_CANCEL].data = filesize == 0 ? STR_AI_CLOSE : STR_AI_CANCEL;
this->DrawWidgets(); this->DrawWidgets();
/* Edit box to filter for keywords */ /* Edit box to filter for keywords */

View File

@ -354,7 +354,11 @@ static Engine *GetNewEngine(const GRFFile *file, VehicleType type, uint16 intern
/* Check if the engine is registered in the override manager */ /* Check if the engine is registered in the override manager */
EngineID engine = _engine_mngr.GetID(type, internal_id, scope_grfid); EngineID engine = _engine_mngr.GetID(type, internal_id, scope_grfid);
if (engine != INVALID_ENGINE) return GetEngine(engine); if (engine != INVALID_ENGINE) {
Engine *e = GetEngine(engine);
if (e->grffile == NULL) e->grffile = file;
return e;
}
} }
/* Check if there is an unreserved slot */ /* Check if there is an unreserved slot */

View File

@ -28,6 +28,7 @@
#include "../company_func.h" #include "../company_func.h"
#include "../road_cmd.h" #include "../road_cmd.h"
#include "../ai/ai.hpp" #include "../ai/ai.hpp"
#include "../animated_tile_func.h"
#include "table/strings.h" #include "table/strings.h"
@ -1845,6 +1846,60 @@ bool AfterLoadGame()
} }
} }
if (CheckSavegameVersion(122)) {
/* Animated tiles would sometimes not be actually animated or
* in case of old savegames duplicate. */
extern TileIndex *_animated_tile_list;
extern uint _animated_tile_count;
for (uint i = 0; i < _animated_tile_count; /* Nothing */) {
/* Remove if tile is not animated */
bool remove = _tile_type_procs[GetTileType(_animated_tile_list[i])]->animate_tile_proc == NULL;
/* and remove if duplicate */
for (uint j = 0; !remove && j < i; j++) {
remove = _animated_tile_list[i] == _animated_tile_list[j];
}
if (remove) {
DeleteAnimatedTile(_animated_tile_list[i]);
} else {
i++;
}
}
/* Delete invalid subsidies possibly present in old versions (but converted to new savegame) */
for (Subsidy *s = _subsidies; s < endof(_subsidies); s++) {
if (s->cargo_type == CT_INVALID) continue;
if (s->age >= 12) {
/* Station -> Station */
const Station *from = IsValidStationID(s->from) ? GetStation(s->from) : NULL;
const Station *to = IsValidStationID(s->to) ? GetStation(s->to) : NULL;
if (from != NULL && to != NULL && from->owner == to->owner && IsValidCompanyID(from->owner)) continue;
} else {
const CargoSpec *cs = GetCargo(s->cargo_type);
switch (cs->town_effect) {
case TE_PASSENGERS:
case TE_MAIL:
/* Town -> Town */
if (IsValidTownID(s->from) && IsValidTownID(s->to)) continue;
break;
case TE_GOODS:
case TE_FOOD:
/* Industry -> Town */
if (IsValidIndustryID(s->from) && IsValidTownID(s->to)) continue;
break;
default:
/* Industry -> Industry */
if (IsValidIndustryID(s->from) && IsValidIndustryID(s->to)) continue;
break;
}
}
s->cargo_type = CT_INVALID;
}
}
GamelogPrintDebug(1); GamelogPrintDebug(1);
bool ret = InitializeWindowsAndCaches(); bool ret = InitializeWindowsAndCaches();

View File

@ -1038,6 +1038,8 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uin
} }
} }
/* Remove animation if overbuilding */
DeleteAnimatedTile(tile);
byte old_specindex = IsTileType(tile, MP_STATION) ? GetCustomStationSpecIndex(tile) : 0; byte old_specindex = IsTileType(tile, MP_STATION) ? GetCustomStationSpecIndex(tile) : 0;
MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p1, 0, 4)); MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p1, 0, 4));
/* Free the spec if we overbuild something */ /* Free the spec if we overbuild something */
@ -3048,6 +3050,7 @@ void BuildOilRig(TileIndex tile)
st->string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG); st->string_id = GenerateStationName(st, tile, STATIONNAMING_OILRIG);
assert(IsTileType(tile, MP_INDUSTRY)); assert(IsTileType(tile, MP_INDUSTRY));
DeleteAnimatedTile(tile);
MakeOilrig(tile, st->index, GetWaterClass(tile)); MakeOilrig(tile, st->index, GetWaterClass(tile));
st->owner = OWNER_NONE; st->owner = OWNER_NONE;

View File

@ -1000,8 +1000,14 @@ void ShowStationViewWindow(StationID station)
AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station); AllocateWindowDescFront<StationViewWindow>(&_station_view_desc, station);
} }
/** Struct containing TileIndex and StationID */
struct TileAndStation {
TileIndex tile; ///< TileIndex
StationID station; ///< StationID
};
static SmallVector<TileAndStation, 8> _deleted_stations_nearby;
static SmallVector<StationID, 8> _stations_nearby_list; static SmallVector<StationID, 8> _stations_nearby_list;
static SmallMap<TileIndex, StationID, 8> _deleted_stations_nearby;
/** Context for FindStationsNearby */ /** Context for FindStationsNearby */
struct FindNearbyStationContext { struct FindNearbyStationContext {
@ -1020,11 +1026,14 @@ static bool AddNearbyStation(TileIndex tile, void *user_data)
{ {
FindNearbyStationContext *ctx = (FindNearbyStationContext *)user_data; FindNearbyStationContext *ctx = (FindNearbyStationContext *)user_data;
/* First check if there was a deleted station here */ /* First check if there were deleted stations here */
SmallPair<TileIndex, StationID> *dst = _deleted_stations_nearby.Find(tile); for (uint i = 0; i < _deleted_stations_nearby.Length(); i++) {
if (dst != _deleted_stations_nearby.End()) { TileAndStation *ts = _deleted_stations_nearby.Get(i);
_stations_nearby_list.Include(dst->second); if (ts->tile == tile) {
return false; *_stations_nearby_list.Append() = _deleted_stations_nearby[i].station;
_deleted_stations_nearby.Erase(ts);
i--;
}
} }
/* Check if own station and if we stay within station spread */ /* Check if own station and if we stay within station spread */
@ -1072,7 +1081,9 @@ static const Station *FindStationsNearby(TileIndex tile, int w, int h, bool dist
if (st->facilities == 0 && st->owner == _local_company) { if (st->facilities == 0 && st->owner == _local_company) {
/* Include only within station spread (yes, it is strictly less than) */ /* Include only within station spread (yes, it is strictly less than) */
if (max(DistanceMax(tile, st->xy), DistanceMax(TILE_ADDXY(tile, w - 1, h - 1), st->xy)) < _settings_game.station.station_spread) { if (max(DistanceMax(tile, st->xy), DistanceMax(TILE_ADDXY(tile, w - 1, h - 1), st->xy)) < _settings_game.station.station_spread) {
_deleted_stations_nearby.Insert(st->xy, st->index); TileAndStation *ts = _deleted_stations_nearby.Append();
ts->tile = st->xy;
ts->station = st->index;
/* Add the station when it's within where we're going to build */ /* Add the station when it's within where we're going to build */
if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) && if (IsInsideBS(TileX(st->xy), TileX(ctx.tile), ctx.w) &&