@@ -21,12 +21,13 @@ extern DepotPool _depot_pool;
struct Depot : DepotPool::PoolItem<&_depot_pool> {
Town *town;
char *name;
TileIndex xy;
uint16 town_cn; ///< The Nth depot for this town (consecutive number)
Date build_date; ///< Date of construction
Depot(TileIndex xy = INVALID_TILE) : xy(xy) {}
~Depot();
static FORCEINLINE Depot *GetByTile(TileIndex tile)
{
@@ -12,12 +12,15 @@
#include "newgrf.h"
#include "newgrf_callbacks.h"
#include "newgrf_commons.h"
#include "newgrf_railtype.h"
#include "newgrf_spritegroup.h"
#include "core/bitmath_func.hpp"
#include "date_func.h"
#include "depot_base.h"
#include "rail_map.h"
static uint32 RailTypeGetRandomBits(const ResolverObject *object)
TileIndex tile = object->u.routes.tile;
uint tmp = CountBits(tile + (TileX(tile) + TileY(tile)) * TILE_SIZE);
return GB(tmp, 0, 2);
@@ -38,19 +41,23 @@ static uint32 RailTypeGetVariable(const
if (tile == INVALID_TILE) {
switch (variable) {
case 0x40: return 0;
case 0x41: return 0;
case 0x42: return 0;
case 0x43: return _date;
}
case 0x40: return GetTerrainType(tile);
case 0x42: return IsLevelCrossingTile(tile) && IsCrossingBarred(tile);
case 0x43:
if (IsRailDepotTile(tile)) return Depot::GetByTile(tile)->build_date;
return _date;
DEBUG(grf, 1, "Unhandled rail type tile property 0x%X", variable);
*available = false;
return UINT_MAX;
@@ -34,12 +34,13 @@
#include "functions.h"
#include "elrail_func.h"
#include "town.h"
#include "pbs.h"
#include "company_base.h"
#include "core/backup_type.hpp"
#include "table/strings.h"
#include "table/sprites.h"
#include "table/railtypes.h"
#include "table/track_land.h"
@@ -866,12 +867,13 @@ CommandCost CmdBuildTrainDepot(TileIndex
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_ERROR_MUST_DEMOLISH_BRIDGE_FIRST);
if (!Depot::CanAllocateItem()) return CMD_ERROR;
if (flags & DC_EXEC) {
Depot *d = new Depot(tile);
d->build_date = _date;
MakeRailDepot(tile, _current_company, d->index, dir, railtype);
MarkTileDirtyByTile(tile);
MakeDefaultName(d);
AddSideToSignalBuffer(tile, INVALID_DIAGDIR, _current_company);
@@ -2641,12 +2643,13 @@ static void GetTileDesc_Track(TileIndex
if (td->rail_speed > 0) {
td->rail_speed = min(td->rail_speed, 61);
} else {
td->rail_speed = 61;
td->build_date = Depot::GetByTile(tile)->build_date;
break;
default:
NOT_REACHED();
@@ -33,12 +33,13 @@
#include "roadveh.h"
#include "core/random_func.hpp"
/**
* Verify whether a road vehicle is available.
* @return \c true if at least one road vehicle is available, \c false if not
@@ -906,12 +907,13 @@ CommandCost CmdBuildRoadDepot(TileIndex
Depot *dep = new Depot(tile);
dep->build_date = _date;
MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
MakeDefaultName(dep);
cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
@@ -1531,12 +1533,13 @@ static void GetTileDesc_Road(TileIndex t
case ROAD_TILE_DEPOT:
td->str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
road_owner = GetTileOwner(tile); // Tile has only one owner, roadtype does not matter
default: {
RoadTypes rts = GetRoadTypes(tile);
td->str = (HasBit(rts, ROADTYPE_ROAD) ? _road_tile_strings[GetRoadside(tile)] : STR_LAI_ROAD_DESCRIPTION_TRAMWAY);
if (HasBit(rts, ROADTYPE_ROAD)) road_owner = GetRoadOwner(tile, ROADTYPE_ROAD);
@@ -2123,12 +2123,17 @@ bool AfterLoadGame()
Depot *d;
FOR_ALL_DEPOTS(d) d->town_cn = UINT16_MAX;
FOR_ALL_DEPOTS(d) MakeDefaultName(d);
if (CheckSavegameVersion(142)) {
FOR_ALL_DEPOTS(d) d->build_date = _date;
/* Road stops is 'only' updating some caches */
AfterLoadRoadStops();
AfterLoadLabelMaps();
GamelogPrintDebug(1);
@@ -21,12 +21,13 @@ static const SaveLoad _depot_desc[] = {
SLE_CONDVAR(Depot, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Depot, xy, SLE_UINT32, 6, SL_MAX_VERSION),
SLEG_CONDVAR(_town_index, SLE_UINT16, 0, 140),
SLE_CONDREF(Depot, town, REF_TOWN, 141, SL_MAX_VERSION),
SLE_CONDVAR(Depot, town_cn, SLE_UINT16, 141, SL_MAX_VERSION),
SLE_CONDSTR(Depot, name, SLE_STR, 0, 141, SL_MAX_VERSION),
SLE_CONDVAR(Depot, build_date, SLE_INT32, 142, SL_MAX_VERSION),
SLE_END()
};
static void Save_DEPT()
Depot *depot;
@@ -44,13 +44,13 @@
#include "../fios.h"
#include "saveload_internal.h"
extern const uint16 SAVEGAME_VERSION = 141;
extern const uint16 SAVEGAME_VERSION = 142;
SavegameType _savegame_type; ///< type of savegame we are loading
uint32 _ttdp_version; ///< version of TTDP savegame (if applicable)
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
@@ -32,12 +32,13 @@
#include "effectvehicle_func.h"
#include "tunnelbridge_map.h"
#include "station_base.h"
#include "ai/ai.hpp"
* Describes the behaviour of a tile during flooding.
@@ -128,12 +129,13 @@ CommandCost CmdBuildShipDepot(TileIndex
if (ret.Failed()) return ret;
Depot *depot = new Depot(tile);
depot->build_date = _date;
MakeShipDepot(tile, _current_company, depot->index, DEPOT_NORTH, axis, wc1);
MakeShipDepot(tile2, _current_company, depot->index, DEPOT_SOUTH, axis, wc2);
MarkTileDirtyByTile(tile2);
MakeDefaultName(depot);
@@ -726,13 +728,16 @@ static void GetTileDesc_Water(TileIndex
case WATER_CLASS_RIVER: td->str = STR_LAI_WATER_DESCRIPTION_RIVER; break;
default: NOT_REACHED(); break;
case WATER_TILE_COAST: td->str = STR_LAI_WATER_DESCRIPTION_COAST_OR_RIVERBANK; break;
case WATER_TILE_LOCK : td->str = STR_LAI_WATER_DESCRIPTION_LOCK; break;
case WATER_TILE_DEPOT: td->str = STR_LAI_WATER_DESCRIPTION_SHIP_DEPOT; break;
case WATER_TILE_DEPOT:
td->str = STR_LAI_WATER_DESCRIPTION_SHIP_DEPOT;
td->owner[0] = GetTileOwner(tile);
Status change: