Changeset - r7730:1acb6eb292e8
[Not reviewed]
master
0 7 0
maedhros - 17 years ago 2007-10-14 21:20:12
maedhros@openttd.org
(svn r11265) -Feature: Make more advanced rail types more expensive to build.
7 files changed with 45 insertions and 9 deletions:
0 comments (0 inline, 0 general)
src/newgrf.cpp
Show inline comments
 
@@ -4189,14 +4189,25 @@ static void ParamSet(byte *buf, int len)
 

	
 
	switch (target) {
 
		case 0x8E: // Y-Offset for train sprites
 
			_traininfo_vehicle_pitch = res;
 
			break;
 

	
 
		case 0x8F: // Rail track type cost factors
 
			_railtype_cost_multiplier[0] = GB(res, 0, 8);
 
			if (_patches.disable_elrails) {
 
				_railtype_cost_multiplier[1] = GB(res, 0, 8);
 
				_railtype_cost_multiplier[2] = GB(res, 8, 8);
 
			} else {
 
				_railtype_cost_multiplier[1] = GB(res, 8, 8);
 
				_railtype_cost_multiplier[2] = GB(res, 16, 8);
 
			}
 
			_railtype_cost_multiplier[3] = GB(res, 16, 8);
 
			break;
 

	
 
		/* @todo implement */
 
		case 0x8F: // Rail track type cost factors
 
		case 0x93: // Tile refresh offset to left
 
		case 0x94: // Tile refresh offset to right
 
		case 0x95: // Tile refresh offset upwards
 
		case 0x96: // Tile refresh offset downwards
 
		case 0x97: // Snow line height
 
		case 0x99: // Global ID offset
 
@@ -4693,25 +4704,25 @@ static void InitializeGRFSpecial()
 
	                   |                                        (1 << 0x16)  // eternalgame
 
	                   |                                        (1 << 0x17)  // newtrains
 
	                   |                                        (1 << 0x18)  // newrvs
 
	                   |                                        (1 << 0x19)  // newships
 
	                   |                                        (1 << 0x1A)  // newplanes
 
	                   |           ((_patches.signal_side ? 1 : 0) << 0x1B)  // signalsontrafficside
 
	                   |                                        (1 << 0x1C); // electrifiedrailway
 
	                   |       ((_patches.disable_elrails ? 0 : 1) << 0x1C); // electrifiedrailway
 

	
 
	_ttdpatch_flags[2] =                                        (1 << 0x01)  // loadallgraphics - obsolote
 
	                   |                                        (1 << 0x03)  // semaphores
 
	                   |                                        (0 << 0x0B)  // enhancedgui
 
	                   |                                        (0 << 0x0C)  // newagerating
 
	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x0D)  // buildonslopes
 
	                   |         ((_patches.full_load_any ? 1 : 0) << 0x0E)  // fullloadany
 
	                   |                                        (1 << 0x0F)  // planespeed - TODO depends on patch when implemented
 
	                   |                                        (0 << 0x10)  // moreindustriesperclimate - obsolete
 
	                   |                                        (0 << 0x11)  // moretoylandfeatures
 
	                   |                                        (1 << 0x12)  // newstations
 
	                   |                                        (0 << 0x13)  // tracktypecostdiff
 
	                   |                                        (1 << 0x13)  // tracktypecostdiff
 
	                   |                                        (1 << 0x14)  // manualconvert
 
	                   |       ((_patches.build_on_slopes ? 1 : 0) << 0x15)  // buildoncoasts
 
	                   |                                        (1 << 0x16)  // canals
 
	                   |                                        (1 << 0x17)  // newstartyear
 
	                   |    ((_patches.freight_trains > 1 ? 1 : 0) << 0x18)  // freighttrains
 
	                   |                                        (1 << 0x19)  // newhouses
 
@@ -4965,12 +4976,15 @@ static void ResetNewGRFData()
 

	
 
	/* Reset misc GRF features and train list display variables */
 
	_misc_grf_features = 0;
 
	_traininfo_vehicle_pitch = 0;
 
	_traininfo_vehicle_width = 29;
 

	
 
	/* Reset track cost multipliers. */
 
	memcpy(&_railtype_cost_multiplier, &_default_railtype_cost_multiplier, sizeof(_default_railtype_cost_multiplier));
 

	
 
	_loaded_newgrf_features.has_2CC           = false;
 
	_loaded_newgrf_features.has_newhouses     = false;
 
	_loaded_newgrf_features.has_newindustries = false;
 

	
 
	_signal_base = 0;
 
	_coast_base = 0;
src/rail.cpp
Show inline comments
 
@@ -104,12 +104,18 @@ extern const Trackdir _dir_to_diag_track
 
};
 

	
 
extern const TrackBits _corner_to_trackbits[] = {
 
	TRACK_BIT_LEFT, TRACK_BIT_LOWER, TRACK_BIT_RIGHT, TRACK_BIT_UPPER,
 
};
 

	
 
/* The default multiplier for the cost of building different types of railway
 
 * track, which will be divided by 8. Can be changed by newgrf files. */
 
const int _default_railtype_cost_multiplier[RAILTYPE_END] = {
 
	8, 12, 16, 24,
 
};
 
int _railtype_cost_multiplier[RAILTYPE_END];
 

	
 
RailType GetTileRailType(TileIndex tile)
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_RAILWAY:
 
			return GetRailType(tile);
src/rail.h
Show inline comments
 
@@ -5,12 +5,13 @@
 
#ifndef RAIL_H
 
#define RAIL_H
 

	
 
#include "gfx.h"
 
#include "direction.h"
 
#include "tile.h"
 
#include "variables.h"
 

	
 
/**
 
 * Enumeration for all possible railtypes.
 
 *
 
 * This enumeration defines all 4 possible railtypes.
 
 */
 
@@ -788,12 +789,27 @@ static inline bool TracksOverlap(TrackBi
 
	/* We know that there are at least two tracks present. When there are more
 
	 * than 2 tracks, they will surely overlap. When there are two, they will
 
	 * always overlap unless they are lower & upper or right & left. */
 
	return bits != TRACK_BIT_HORZ && bits != TRACK_BIT_VERT;
 
}
 

	
 

	
 
extern int _railtype_cost_multiplier[RAILTYPE_END];
 
extern const int _default_railtype_cost_multiplier[RAILTYPE_END];
 

	
 
/**
 
 * Returns the cost of building the specified railtype.
 
 * @param railtype The railtype being built.
 
 * @return The cost multiplier.
 
 */
 
static inline Money RailBuildCost(RailType railtype)
 
{
 
	assert(railtype < RAILTYPE_END);
 
	return (_price.build_rail * _railtype_cost_multiplier[railtype]) >> 3;
 
}
 

	
 
void *UpdateTrainPowerProc(Vehicle *v, void *data);
 
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
 
void DrawDefaultWaypointSprite(int x, int y, RailType railtype);
 

	
 
/**
 
 * Draws overhead wires and pylons for electric railways.
src/rail_cmd.cpp
Show inline comments
 
@@ -391,13 +391,13 @@ CommandCost CmdBuildSingleRail(TileIndex
 
	if (flags & DC_EXEC) {
 
		MarkTileDirtyByTile(tile);
 
		SetSignalsOnBothDir(tile, track);
 
		YapfNotifyTrackLayoutChange(tile, track);
 
	}
 

	
 
	return cost.AddCost(_price.build_rail);
 
	return cost.AddCost(RailBuildCost(railtype));
 
}
 

	
 
/** Remove a single piece of track
 
 * @param tile tile to remove track from
 
 * @param flags operation to perform
 
 * @param p1 unused
 
@@ -1089,13 +1089,13 @@ static CommandCost DoConvertRail(TileInd
 
		}
 

	
 
		/* update power of train engines on this tile */
 
		VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
 
	}
 

	
 
	return CommandCost(_price.build_rail / 2);
 
	return CommandCost(RailBuildCost(totype) / 2);
 
}
 

	
 
extern CommandCost DoConvertStationRail(TileIndex tile, RailType totype, bool exec);
 
extern CommandCost DoConvertStreetRail(TileIndex tile, RailType totype, bool exec);
 
extern CommandCost DoConvertTunnelBridgeRail(TileIndex tile, RailType totype, bool exec);
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -602,13 +602,13 @@ CommandCost DoConvertStreetRail(TileInde
 
		SetRailType(tile, totype);
 
		MarkTileDirtyByTile(tile);
 
		YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetCrossingRailBits(tile)));
 
		VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
 
	}
 

	
 
	return CommandCost(_price.build_rail / 2);
 
	return CommandCost(RailBuildCost(totype) / 2);
 
}
 

	
 

	
 
/** Build a long piece of road.
 
 * @param end_tile end tile of drag
 
 * @param flags operation to perform
src/station_cmd.cpp
Show inline comments
 
@@ -1242,13 +1242,13 @@ CommandCost DoConvertStationRail(TileInd
 
		SetRailType(tile, totype);
 
		MarkTileDirtyByTile(tile);
 
		YapfNotifyTrackLayoutChange(tile, GetRailStationTrack(tile));
 
		VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
 
	}
 

	
 
	return CommandCost(_price.build_rail / 2);
 
	return CommandCost(RailBuildCost(totype) / 2);
 
}
 

	
 
/**
 
 * @param truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
 
 * @param st The Station to do the whole procedure for
 
 * @return a pointer to where to link a new RoadStop*
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -770,13 +770,13 @@ CommandCost DoConvertTunnelBridgeRail(Ti
 
			YapfNotifyTrackLayoutChange(endtile, track);
 

	
 
			VehicleFromPos(tile, &tile, UpdateTrainPowerProc);
 
			VehicleFromPos(endtile, &endtile, UpdateTrainPowerProc);
 
		}
 

	
 
		return CommandCost((length + 1) * (_price.build_rail >> 1));
 
		return CommandCost((length + 1) * (RailBuildCost(totype) / 2));
 
	} else if (IsBridge(tile) && GetBridgeTransportType(tile) == TRANSPORT_RAIL) {
 
		TileIndex endtile = GetOtherBridgeEnd(tile);
 
		byte bridge_height = GetBridgeHeight(tile);
 

	
 
		if (!IsCompatibleRail(GetRailType(tile), totype) &&
 
				(FindVehicleOnTileZ(tile, bridge_height) != NULL ||
 
@@ -802,13 +802,13 @@ CommandCost DoConvertTunnelBridgeRail(Ti
 

	
 
			for (tile += delta; tile != endtile; tile += delta) {
 
				MarkTileDirtyByTile(tile); // TODO encapsulate this into a function
 
			}
 
		}
 

	
 
		return CommandCost((DistanceManhattan(tile, endtile) + 1) * (_price.build_rail >> 1));
 
		return CommandCost((DistanceManhattan(tile, endtile) + 1) * (RailBuildCost(totype) / 2));
 
	} else {
 
		return CMD_ERROR;
 
	}
 
}
 

	
 

	
0 comments (0 inline, 0 general)