Changeset - r15350:38997da618b5
[Not reviewed]
master
0 8 0
yexo - 14 years ago 2010-06-20 19:13:02
yexo@openttd.org
(svn r20003) -Feature [FS#3886]: [NewGRF] var 43 depot build date for railtypes
8 files changed with 27 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/depot_base.h
Show inline comments
 
@@ -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)
 
	{
src/newgrf_railtype.cpp
Show inline comments
 
@@ -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;
 
		}
 
	}
 

	
 
	switch (variable) {
 
		case 0x40: return GetTerrainType(tile);
 
		case 0x41: return 0;
 
		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;
src/rail_cmd.cpp
Show inline comments
 
@@ -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 "date_func.h"
 

	
 
#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();
 
	}
 
}
src/road_cmd.cpp
Show inline comments
 
@@ -33,12 +33,13 @@
 
#include "elrail_func.h"
 
#include "roadveh.h"
 
#include "town.h"
 
#include "company_base.h"
 
#include "core/random_func.hpp"
 
#include "newgrf_railtype.h"
 
#include "date_func.h"
 

	
 
#include "table/strings.h"
 

	
 
/**
 
 * 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 
 
	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 *dep = new Depot(tile);
 
		dep->build_date = _date;
 

	
 
		MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
 
		MarkTileDirtyByTile(tile);
 
		MakeDefaultName(dep);
 
	}
 
	cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
 
@@ -1531,12 +1533,13 @@ static void GetTileDesc_Road(TileIndex t
 
			break;
 
		}
 

	
 
		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
 
			td->build_date = Depot::GetByTile(tile)->build_date;
 
			break;
 

	
 
		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);
src/saveload/afterload.cpp
Show inline comments
 
@@ -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)) {
 
		Depot *d;
 
		FOR_ALL_DEPOTS(d) d->build_date = _date;
 
	}
 

	
 
	/* Road stops is 'only' updating some caches */
 
	AfterLoadRoadStops();
 
	AfterLoadLabelMaps();
 

	
 
	GamelogPrintDebug(1);
 

	
src/saveload/depot_sl.cpp
Show inline comments
 
@@ -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;
src/saveload/saveload.cpp
Show inline comments
 
@@ -44,13 +44,13 @@
 
#include "../fios.h"
 

	
 
#include "table/strings.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!
src/water_cmd.cpp
Show inline comments
 
@@ -32,12 +32,13 @@
 
#include "effectvehicle_func.h"
 
#include "tunnelbridge_map.h"
 
#include "station_base.h"
 
#include "ai/ai.hpp"
 
#include "core/random_func.hpp"
 
#include "core/backup_type.hpp"
 
#include "date_func.h"
 

	
 
#include "table/sprites.h"
 
#include "table/strings.h"
 

	
 
/**
 
 * Describes the behaviour of a tile during flooding.
 
@@ -128,12 +129,13 @@ CommandCost CmdBuildShipDepot(TileIndex 
 
	if (ret.Failed()) return ret;
 

	
 
	if (!Depot::CanAllocateItem()) return CMD_ERROR;
 

	
 
	if (flags & DC_EXEC) {
 
		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(tile);
 
		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;
 
			}
 
			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->build_date = Depot::GetByTile(tile)->build_date;
 
			break;
 
		default: NOT_REACHED(); break;
 
	}
 

	
 
	td->owner[0] = GetTileOwner(tile);
 
}
 

	
0 comments (0 inline, 0 general)