mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r20003) -Feature [FS#3886]: [NewGRF] var 43 depot build date for railtypes
This commit is contained in:
parent
f2d6bf6b58
commit
9cfb61adf5
|
@ -24,6 +24,7 @@ struct Depot : DepotPool::PoolItem<&_depot_pool> {
|
||||||
|
|
||||||
TileIndex xy;
|
TileIndex xy;
|
||||||
uint16 town_cn; ///< The Nth depot for this town (consecutive number)
|
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(TileIndex xy = INVALID_TILE) : xy(xy) {}
|
||||||
~Depot();
|
~Depot();
|
||||||
|
|
|
@ -15,6 +15,9 @@
|
||||||
#include "newgrf_railtype.h"
|
#include "newgrf_railtype.h"
|
||||||
#include "newgrf_spritegroup.h"
|
#include "newgrf_spritegroup.h"
|
||||||
#include "core/bitmath_func.hpp"
|
#include "core/bitmath_func.hpp"
|
||||||
|
#include "date_func.h"
|
||||||
|
#include "depot_base.h"
|
||||||
|
#include "rail_map.h"
|
||||||
|
|
||||||
static uint32 RailTypeGetRandomBits(const ResolverObject *object)
|
static uint32 RailTypeGetRandomBits(const ResolverObject *object)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +44,7 @@ static uint32 RailTypeGetVariable(const ResolverObject *object, byte variable, b
|
||||||
case 0x40: return 0;
|
case 0x40: return 0;
|
||||||
case 0x41: return 0;
|
case 0x41: return 0;
|
||||||
case 0x42: return 0;
|
case 0x42: return 0;
|
||||||
|
case 0x43: return _date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +52,9 @@ static uint32 RailTypeGetVariable(const ResolverObject *object, byte variable, b
|
||||||
case 0x40: return GetTerrainType(tile);
|
case 0x40: return GetTerrainType(tile);
|
||||||
case 0x41: return 0;
|
case 0x41: return 0;
|
||||||
case 0x42: return IsLevelCrossingTile(tile) && IsCrossingBarred(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);
|
DEBUG(grf, 1, "Unhandled rail type tile property 0x%X", variable);
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
#include "pbs.h"
|
#include "pbs.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
|
#include "date_func.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
|
@ -869,6 +870,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Depot *d = new Depot(tile);
|
Depot *d = new Depot(tile);
|
||||||
|
d->build_date = _date;
|
||||||
|
|
||||||
MakeRailDepot(tile, _current_company, d->index, dir, railtype);
|
MakeRailDepot(tile, _current_company, d->index, dir, railtype);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
|
@ -2644,6 +2646,7 @@ static void GetTileDesc_Track(TileIndex tile, TileDesc *td)
|
||||||
td->rail_speed = 61;
|
td->rail_speed = 61;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
td->build_date = Depot::GetByTile(tile)->build_date;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "newgrf_railtype.h"
|
#include "newgrf_railtype.h"
|
||||||
|
#include "date_func.h"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
|
@ -909,6 +910,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Depot *dep = new Depot(tile);
|
Depot *dep = new Depot(tile);
|
||||||
|
dep->build_date = _date;
|
||||||
|
|
||||||
MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
|
MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
|
||||||
MarkTileDirtyByTile(tile);
|
MarkTileDirtyByTile(tile);
|
||||||
|
@ -1534,6 +1536,7 @@ static void GetTileDesc_Road(TileIndex tile, TileDesc *td)
|
||||||
case ROAD_TILE_DEPOT:
|
case ROAD_TILE_DEPOT:
|
||||||
td->str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
|
td->str = STR_LAI_ROAD_DESCRIPTION_ROAD_VEHICLE_DEPOT;
|
||||||
road_owner = GetTileOwner(tile); // Tile has only one owner, roadtype does not matter
|
road_owner = GetTileOwner(tile); // Tile has only one owner, roadtype does not matter
|
||||||
|
td->build_date = Depot::GetByTile(tile)->build_date;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
|
@ -2126,6 +2126,11 @@ bool AfterLoadGame()
|
||||||
FOR_ALL_DEPOTS(d) MakeDefaultName(d);
|
FOR_ALL_DEPOTS(d) MakeDefaultName(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (CheckSavegameVersion(142)) {
|
||||||
|
Depot *d;
|
||||||
|
FOR_ALL_DEPOTS(d) d->build_date = _date;
|
||||||
|
}
|
||||||
|
|
||||||
/* Road stops is 'only' updating some caches */
|
/* Road stops is 'only' updating some caches */
|
||||||
AfterLoadRoadStops();
|
AfterLoadRoadStops();
|
||||||
AfterLoadLabelMaps();
|
AfterLoadLabelMaps();
|
||||||
|
|
|
@ -24,6 +24,7 @@ static const SaveLoad _depot_desc[] = {
|
||||||
SLE_CONDREF(Depot, town, REF_TOWN, 141, SL_MAX_VERSION),
|
SLE_CONDREF(Depot, town, REF_TOWN, 141, SL_MAX_VERSION),
|
||||||
SLE_CONDVAR(Depot, town_cn, SLE_UINT16, 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_CONDSTR(Depot, name, SLE_STR, 0, 141, SL_MAX_VERSION),
|
||||||
|
SLE_CONDVAR(Depot, build_date, SLE_INT32, 142, SL_MAX_VERSION),
|
||||||
SLE_END()
|
SLE_END()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
#include "saveload_internal.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
|
SavegameType _savegame_type; ///< type of savegame we are loading
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "ai/ai.hpp"
|
#include "ai/ai.hpp"
|
||||||
#include "core/random_func.hpp"
|
#include "core/random_func.hpp"
|
||||||
#include "core/backup_type.hpp"
|
#include "core/backup_type.hpp"
|
||||||
|
#include "date_func.h"
|
||||||
|
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
@ -131,6 +132,7 @@ CommandCost CmdBuildShipDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
|
||||||
|
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
Depot *depot = new Depot(tile);
|
Depot *depot = new Depot(tile);
|
||||||
|
depot->build_date = _date;
|
||||||
|
|
||||||
MakeShipDepot(tile, _current_company, depot->index, DEPOT_NORTH, axis, wc1);
|
MakeShipDepot(tile, _current_company, depot->index, DEPOT_NORTH, axis, wc1);
|
||||||
MakeShipDepot(tile2, _current_company, depot->index, DEPOT_SOUTH, axis, wc2);
|
MakeShipDepot(tile2, _current_company, depot->index, DEPOT_SOUTH, axis, wc2);
|
||||||
|
@ -729,7 +731,10 @@ static void GetTileDesc_Water(TileIndex tile, TileDesc *td)
|
||||||
break;
|
break;
|
||||||
case WATER_TILE_COAST: td->str = STR_LAI_WATER_DESCRIPTION_COAST_OR_RIVERBANK; 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_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->build_date = Depot::GetByTile(tile)->build_date;
|
||||||
|
break;
|
||||||
default: NOT_REACHED(); break;
|
default: NOT_REACHED(); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue