Changeset - r15236:52b8c9d62ef9
[Not reviewed]
master
0 4 0
rubidium - 14 years ago 2010-05-22 14:12:48
rubidium@openttd.org
(svn r19881) -Fix [FS#3827]: pay for the rail/road when constructing tunnels and bridges
4 files changed with 26 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_bridge.hpp
Show inline comments
 
@@ -83,13 +83,13 @@ public:
 
	 *       This is mph / 1.6, which is roughly km/h.
 
	 *       To get km/h multiply this number by 1.00584.
 
	 */
 
	static int32 GetMaxSpeed(BridgeID bridge_id);
 

	
 
	/**
 
	 * Get the new cost of a bridge.
 
	 * Get the new cost of a bridge, excluding the road and/or rail.
 
	 * @param bridge_id The bridge to get the new cost of.
 
	 * @param length The length of the bridge.
 
	 * @pre IsValidBridge(bridge_id).
 
	 * @return The new cost the bridge has.
 
	 */
 
	static Money GetPrice(BridgeID bridge_id, uint length);
src/ai/api/ai_changelog.hpp
Show inline comments
 
@@ -24,14 +24,15 @@
 
 * \li AIRail::GetMaxSpeed
 
 *
 
 * API removals:
 
 * \li HasNext for all lists.
 
 *
 
 * Other changes:
 
 * \li AIRoad::BuildRoadStation now allows overbuilding
 
 * \li AIRoad::BuildDriveThroughRoadStation now allows overbuilding
 
 * \li AIBridge::GetPrice now returns the price of the bridge without the cost for the rail or road.
 
 * \li AIRoad::BuildRoadStation now allows overbuilding.
 
 * \li AIRoad::BuildDriveThroughRoadStation now allows overbuilding.
 
 * \li AIEngine::GetPower can be used for road vehicles.
 
 * \li AIEngine::GetWeight can be used for road vehicles.
 
 * \li AIEngine::GetMaxTractiveEffort can be used for road vehicles.
 
 *
 
 * \b 1.0.0
 
 *
src/bridge_gui.cpp
Show inline comments
 
@@ -11,12 +11,13 @@
 

	
 
#include "stdafx.h"
 
#include "gui.h"
 
#include "command_func.h"
 
#include "economy_func.h"
 
#include "bridge.h"
 
#include "rail.h"
 
#include "strings_func.h"
 
#include "window_func.h"
 
#include "sound_func.h"
 
#include "gfx_func.h"
 
#include "tunnelbridge.h"
 
#include "sortlist_type.h"
 
@@ -391,22 +392,29 @@ void ShowBuildBridgeWindow(TileIndex sta
 
	} else {
 
		/* check which bridges can be built */
 
		const uint tot_bridgedata_len = CalcBridgeLenCostFactor(bridge_len + 2);
 

	
 
		bl = new GUIBridgeList();
 

	
 
		Money infra_cost = 0;
 
		switch (transport_type) {
 
			case TRANSPORT_ROAD: infra_cost = (bridge_len + 2) * _price[PR_BUILD_ROAD] * 2; break;
 
			case TRANSPORT_RAIL: infra_cost = (bridge_len + 2) * RailBuildCost((RailType)road_rail_type); break;
 
			default: break;
 
		}
 

	
 
		/* loop for all bridgetypes */
 
		for (BridgeType brd_type = 0; brd_type != MAX_BRIDGES; brd_type++) {
 
			if (CheckBridgeAvailability(brd_type, bridge_len).Succeeded()) {
 
				/* bridge is accepted, add to list */
 
				BuildBridgeData *item = bl->Append();
 
				item->index = brd_type;
 
				item->spec = GetBridgeSpec(brd_type);
 
				/* Add to terraforming & bulldozing costs the cost of the
 
				 * bridge itself (not computed with DC_QUERY_COST) */
 
				item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8);
 
				item->cost = ret.GetCost() + (((int64)tot_bridgedata_len * _price[PR_BUILD_BRIDGE] * item->spec->price) >> 8) + infra_cost;
 
			}
 
		}
 
	}
 

	
 
	if (bl != NULL && bl->Length() != 0) {
 
		new BuildBridgeWindow(&_build_bridge_desc, start, end, type, bl);
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -465,12 +465,18 @@ CommandCost CmdBuildBridge(TileIndex end
 
	 * and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
 
	 */
 
	Company *c = Company::GetIfValid(_current_company);
 
	if (!(flags & DC_QUERY_COST) || (c != NULL && c->is_ai)) {
 
		bridge_len += 2; // begin and end tiles/ramps
 

	
 
		switch (transport_type) {
 
			case TRANSPORT_ROAD: cost.AddCost(bridge_len * _price[PR_BUILD_ROAD] * 2); break;
 
			case TRANSPORT_RAIL: cost.AddCost(bridge_len * RailBuildCost(railtype)); break;
 
			default: break;
 
		}
 

	
 
		if (c != NULL) bridge_len = CalcBridgeLenCostFactor(bridge_len);
 

	
 
		if (transport_type != TRANSPORT_WATER) {
 
			cost.AddCost((int64)bridge_len * _price[PR_BUILD_BRIDGE] * GetBridgeSpec(bridge_type)->price >> 8);
 
		} else {
 
			/* Aqueducts use a separate base cost. */
 
@@ -593,12 +599,19 @@ CommandCost CmdBuildTunnel(TileIndex sta
 
		ret = DoCommand(end_tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
 
		if (ret.Failed()) return ret;
 
	}
 
	cost.AddCost(_price[PR_BUILD_TUNNEL]);
 
	cost.AddCost(ret);
 

	
 
	/* Pay for the rail/road in the tunnel including entrances */
 
	switch (transport_type) {
 
		case TRANSPORT_ROAD: cost.AddCost((tiles + 2) * _price[PR_BUILD_ROAD] * 2); break;
 
		case TRANSPORT_RAIL: cost.AddCost((tiles + 2) * RailBuildCost(railtype)); break;
 
		default: break;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		if (transport_type == TRANSPORT_RAIL) {
 
			MakeRailTunnel(start_tile, _current_company, direction,                 railtype);
 
			MakeRailTunnel(end_tile,   _current_company, ReverseDiagDir(direction), railtype);
 
			AddSideToSignalBuffer(start_tile, INVALID_DIAGDIR, _current_company);
 
			YapfNotifyTrackLayoutChange(start_tile, DiagDirToDiagTrack(direction));
0 comments (0 inline, 0 general)