Changeset - r8491:493075733a1d
[Not reviewed]
master
0 6 0
belugas - 16 years ago 2008-02-05 05:21:02
belugas@openttd.org
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
-Codechange: Remove direct access to the _bridge table in favor of the above mentioned GetBridgeSpec
-Codechange: Rationalize the use of Bridge type pointer
6 files changed with 14 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/bridge.h
Show inline comments
 
@@ -35,7 +35,7 @@ extern Bridge _bridge[MAX_BRIDGES];
 
Foundation GetBridgeFoundation(Slope tileh, Axis axis);
 
bool HasBridgeFlatRamp(Slope tileh, Axis axis);
 

	
 
static inline const Bridge *GetBridge(uint i)
 
static inline const Bridge *GetBridgeSpec(uint i)
 
{
 
	assert(i < lengthof(_bridge));
 
	return &_bridge[i];
src/bridge_gui.cpp
Show inline comments
 
@@ -79,7 +79,7 @@ static void BuildBridgeWndProc(Window *w
 

	
 
			uint y = 15;
 
			for (uint i = 0; (i < w->vscroll.cap) && ((i + w->vscroll.pos) < _bridgedata.count); i++) {
 
				const Bridge *b = &_bridge[_bridgedata.indexes[i + w->vscroll.pos]];
 
				const Bridge *b = GetBridgeSpec(_bridgedata.indexes[i + w->vscroll.pos]);
 

	
 
				SetDParam(2, _bridgedata.costs[i + w->vscroll.pos]);
 
				SetDParam(1, b->speed * 10 / 16);
 
@@ -191,7 +191,7 @@ void ShowBuildBridgeWindow(TileIndex sta
 
		for (bridge_type = 0; bridge_type != MAX_BRIDGES; bridge_type++) {
 
			if (CheckBridge_Stuff(bridge_type, bridge_len)) {
 
				/* bridge is accepted, add to list */
 
				const Bridge *b = &_bridge[bridge_type];
 
				const Bridge *b = GetBridgeSpec(bridge_type);
 
				/* Add to terraforming & bulldozing costs the cost of the
 
				 * bridge itself (not computed with DC_QUERY_COST) */
 
				_bridgedata.costs[j] = ret.GetCost() + (((int64)tot_bridgedata_len * _price.build_bridge * b->price) >> 8);
src/roadveh_cmd.cpp
Show inline comments
 
@@ -956,7 +956,7 @@ static bool RoadVehAccelerate(Vehicle *v
 
	/* Clamp */
 
	spd = min(spd, v->max_speed);
 
	if (v->u.road.state == RVSB_WORMHOLE && !(v->vehstatus & VS_HIDDEN)) {
 
		spd = min(spd, GetBridge(GetBridgeType(v->tile))->speed * 2);
 
		spd = min(spd, GetBridgeSpec(GetBridgeType(v->tile))->speed * 2);
 
	}
 

	
 
	/* updates statusbar only if speed have changed to save CPU time */
src/train_cmd.cpp
Show inline comments
 
@@ -3132,7 +3132,7 @@ static void TrainController(Vehicle *v, 
 
			 * - for bridges, only the middle part - without the bridge heads */
 
			if (!(v->vehstatus & VS_HIDDEN)) {
 
				v->cur_speed =
 
					min(v->cur_speed, GetBridge(GetBridgeType(v->tile))->speed);
 
					min(v->cur_speed, GetBridgeSpec(GetBridgeType(v->tile))->speed);
 
			}
 

	
 
			if (!IsTileType(gp.new_tile, MP_TUNNELBRIDGE) || !HasBit(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -99,7 +99,7 @@ bool HasBridgeFlatRamp(Slope tileh, Axis
 

	
 
static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table)
 
{
 
	const Bridge *bridge = &_bridge[index];
 
	const Bridge *bridge = GetBridgeSpec(index);
 
	assert(table < 7);
 
	if (bridge->sprite_table == NULL || bridge->sprite_table[table] == NULL) {
 
		return _bridge_sprite_table[index][table];
 
@@ -108,8 +108,6 @@ static inline const PalSpriteID *GetBrid
 
	}
 
}
 

	
 
static inline byte GetBridgeFlags(int index) { return _bridge[index].flags;}
 

	
 

	
 
/**
 
 * Determines the foundation for the north bridge head, and tests if the resulting slope is valid.
 
@@ -155,7 +153,7 @@ static CommandCost CheckBridgeSlopeSouth
 

	
 
bool CheckBridge_Stuff(byte bridge_type, uint bridge_len)
 
{
 
	const Bridge *b = &_bridge[bridge_type];
 
	const Bridge *b = GetBridgeSpec(bridge_type);
 
	uint max; // max possible length of a bridge (with patch 100)
 

	
 
	if (bridge_type >= MAX_BRIDGES) return false;
 
@@ -266,7 +264,7 @@ CommandCost CmdBuildBridge(TileIndex end
 

	
 
		/* Do not replace town bridges with lower speed bridges. */
 
		if (!(flags & DC_QUERY_COST) && IsTileOwner(tile_start, OWNER_TOWN) &&
 
				_bridge[bridge_type].speed < _bridge[GetBridgeType(tile_start)].speed) {
 
				GetBridgeSpec(bridge_type)->speed < GetBridgeSpec(GetBridgeType(tile_start))->speed) {
 
			Town *t = ClosestTownFromTile(tile_start, UINT_MAX);
 

	
 
			if (t == NULL) {
 
@@ -416,14 +414,12 @@ not_valid_below:;
 
	 * and cost is computed in "bridge_gui.c". For AI, Towns this has to be of course calculated
 
	 */
 
	if (!(flags & DC_QUERY_COST)) {
 
		const Bridge *b = &_bridge[bridge_type];
 

	
 
		bridge_len += 2; // begin and end tiles/ramps
 

	
 
		if (IsValidPlayer(_current_player) && !_is_old_ai_player)
 
			bridge_len = CalcBridgeLenCostFactor(bridge_len);
 

	
 
		cost.AddCost((int64)bridge_len * _price.build_bridge * b->price >> 8);
 
		cost.AddCost((int64)bridge_len * _price.build_bridge * GetBridgeSpec(bridge_type)->price >> 8);
 
	}
 

	
 
	return cost;
 
@@ -700,7 +696,7 @@ static void DrawBridgePillars(const PalS
 
{
 
	SpriteID image = psid->sprite;
 
	if (image != 0) {
 
		bool drawfarpillar = !HasBit(GetBridgeFlags(type), 0);
 
		bool drawfarpillar = !HasBit(GetBridgeSpec(type)->flags, 0);
 

	
 
		/* "side" specifies the side the pillars stand on.
 
		 * The length of the pillars is then set to the height of the bridge over the corners of this edge.
 
@@ -1130,8 +1126,8 @@ static void GetTileDesc_TunnelBridge(Til
 
		td->str = (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) ?
 
			STR_5017_RAILROAD_TUNNEL : STR_5018_ROAD_TUNNEL;
 
	} else { //so it must be a bridge
 
		int brtype = GetBridgeType(tile);
 
		td->str = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL ? _bridge[brtype].name_rail : _bridge[brtype].name_road;
 
		const Bridge *brspc = GetBridgeSpec(GetBridgeType(tile));
 
		td->str = GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL ? brspc->name_rail : brspc->name_road;
 
	}
 
	td->owner = GetTileOwner(tile);
 
}
 
@@ -1289,7 +1285,7 @@ static VehicleEnterTileStatus VehicleEnt
 

	
 
		if (v->IsPrimaryVehicle()) {
 
			/* modify speed of vehicle */
 
			uint16 spd = _bridge[GetBridgeType(tile)].speed;
 
			uint16 spd = GetBridgeSpec(GetBridgeType(tile))->speed;
 

	
 
			if (v->type == VEH_ROAD) spd *= 2;
 
			if (v->cur_speed > spd) v->cur_speed = spd;
src/yapf/follow_track.hpp
Show inline comments
 
@@ -342,7 +342,7 @@ public:
 

	
 
		// for now we handle only on-bridge speed limit
 
		if (!IsWaterTT() && IsBridgeTile(m_old_tile)) {
 
			int spd = _bridge[GetBridgeType(m_old_tile)].speed;
 
			int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed;
 
			if (IsRoadTT()) spd *= 2;
 
			if (max_speed > spd) max_speed = spd;
 
		}
0 comments (0 inline, 0 general)