Changeset - r14880:4a8d29bc60a7
[Not reviewed]
master
0 2 0
alberth - 15 years ago 2010-03-20 16:47:07
alberth@openttd.org
(svn r19486) -Codechange: Code style, move var declarations closer to their first use.
2 files changed with 11 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/autoreplace.cpp
Show inline comments
 
@@ -54,16 +54,14 @@ EngineID EngineReplacement(EngineRenewLi
 
	}
 
	return er == NULL ? INVALID_ENGINE : er->to;
 
}
 

	
 
CommandCost AddEngineReplacement(EngineRenewList *erl, EngineID old_engine, EngineID new_engine, GroupID group, DoCommandFlag flags)
 
{
 
	EngineRenew *er;
 

	
 
	/* Check if the old vehicle is already in the list */
 
	er = GetEngineReplacement(*erl, old_engine, group);
 
	EngineRenew *er = GetEngineReplacement(*erl, old_engine, group);
 
	if (er != NULL) {
 
		if (flags & DC_EXEC) er->to = new_engine;
 
		return CommandCost();
 
	}
 

	
 
	if (!EngineRenew::CanAllocateItem()) return CMD_ERROR;
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -192,14 +192,12 @@ bool CheckBridge_Stuff(BridgeType bridge
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	RailType railtype = INVALID_RAILTYPE;
 
	RoadTypes roadtypes = ROADTYPES_NONE;
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	Owner owner;
 

	
 
	/* unpack parameters */
 
	BridgeType bridge_type = GB(p2, 0, 8);
 

	
 
	if (p1 >= MapSize()) return CMD_ERROR;
 

	
 
@@ -263,12 +261,14 @@ CommandCost CmdBuildBridge(TileIndex end
 

	
 
	CommandCost terraform_cost_north = CheckBridgeSlopeNorth(direction, &tileh_start, &z_start);
 
	CommandCost terraform_cost_south = CheckBridgeSlopeSouth(direction, &tileh_end,   &z_end);
 

	
 
	if (z_start != z_end) return_cmd_error(STR_ERROR_BRIDGEHEADS_NOT_SAME_HEIGHT);
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	Owner owner;
 
	if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) &&
 
			GetOtherBridgeEnd(tile_start) == tile_end &&
 
			GetTunnelBridgeTransportType(tile_start) == transport_type) {
 
		/* Replace a current bridge. */
 

	
 
		/* If this is a railway bridge, make sure the railtypes match. */
 
@@ -478,13 +478,12 @@ CommandCost CmdBuildBridge(TileIndex end
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	TransportType transport_type = (TransportType)GB(p1, 9, 1);
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 

	
 
	_build_tunnel_endtile = 0;
 
	if (transport_type == TRANSPORT_RAIL) {
 
		if (!ValParamRailtype((RailType)p1)) return CMD_ERROR;
 
	} else {
 
		const RoadTypes rts = (RoadTypes)GB(p1, 0, 2);
 
@@ -521,12 +520,13 @@ CommandCost CmdBuildTunnel(TileIndex sta
 
	int tiles_coef = 3;
 
	/* Number of tiles from start of tunnel */
 
	int tiles = 0;
 
	/* Number of tiles at which the cost increase coefficient per tile is halved */
 
	int tiles_bump = 25;
 

	
 
	CommandCost cost(EXPENSES_CONSTRUCTION);
 
	Slope end_tileh;
 
	for (;;) {
 
		end_tile += delta;
 
		if (!IsValidTile(end_tile)) return_cmd_error(STR_ERROR_TUNNEL_THROUGH_MAP_BORDER);
 
		end_tileh = GetTileSlope(end_tile, &end_z);
 

	
 
@@ -637,27 +637,25 @@ static inline CommandCost CheckAllowRemo
 
 * @param tile Tile containing one of the endpoints of the tunnel.
 
 * @param flags Command flags.
 
 * @return Succeeded or failed command.
 
 */
 
static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
 
{
 
	Town *t = NULL;
 
	TileIndex endtile;
 

	
 
	CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	endtile = GetOtherTunnelEnd(tile);
 
	TileIndex endtile = GetOtherTunnelEnd(tile);
 

	
 
	ret = TunnelBridgeIsFree(tile, endtile);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	_build_tunnel_endtile = endtile;
 

	
 
	Town *t = NULL;
 
	if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
 
		t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating
 

	
 
		/* Check if you are allowed to remove the tunnel owned by a town
 
		 * Removal depends on difficulty settings */
 
		CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
 
@@ -708,30 +706,26 @@ static CommandCost DoClearTunnel(TileInd
 
 * @param tile Tile containing one of the endpoints of the bridge.
 
 * @param flags Command flags.
 
 * @return Succeeded or failed command.
 
 */
 
static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
 
{
 
	DiagDirection direction;
 
	TileIndexDiff delta;
 
	TileIndex endtile;
 
	Town *t = NULL;
 

	
 
	CommandCost ret = CheckAllowRemoveTunnelBridge(tile);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	endtile = GetOtherBridgeEnd(tile);
 
	TileIndex endtile = GetOtherBridgeEnd(tile);
 

	
 
	ret = TunnelBridgeIsFree(tile, endtile);
 
	ret.SetGlobalErrorMessage();
 
	if (ret.Failed()) return ret;
 

	
 
	direction = GetTunnelBridgeDirection(tile);
 
	delta = TileOffsByDiagDir(direction);
 
	DiagDirection direction = GetTunnelBridgeDirection(tile);
 
	TileIndexDiff delta = TileOffsByDiagDir(direction);
 

	
 
	Town *t = NULL;
 
	if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR) {
 
		t = ClosestTownFromTile(tile, UINT_MAX); // town penalty rating
 

	
 
		/* Check if you are allowed to remove the bridge owned by a town
 
		 * Removal depends on difficulty settings */
 
		CommandCost ret = CheckforTownRating(flags, t, TUNNELBRIDGE_REMOVE);
 
@@ -922,13 +916,12 @@ static void DrawBridgeTramBits(int x, in
 
 * <li>Bit 3 and more: Railtype Specific subset</li>
 
 * </ul>
 
 * Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3
 
 */
 
static void DrawTile_TunnelBridge(TileInfo *ti)
 
{
 
	SpriteID image;
 
	TransportType transport_type = GetTunnelBridgeTransportType(ti->tile);
 
	DiagDirection tunnelbridge_direction = GetTunnelBridgeDirection(ti->tile);
 

	
 
	if (IsTunnel(ti->tile)) {
 
		/* Front view of tunnel bounding boxes:
 
		 *
 
@@ -948,12 +941,13 @@ static void DrawTile_TunnelBridge(TileIn
 
			{  0,  1, -14, -15, 15,  0,  1, 16, 1, 0, 15, 16 }, // NW
 
		};
 
		const int *BB_data = _tunnel_BB[tunnelbridge_direction];
 

	
 
		bool catenary = false;
 

	
 
		SpriteID image;
 
		if (transport_type == TRANSPORT_RAIL) {
 
			image = GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.tunnel;
 
		} else {
 
			image = SPR_TUNNEL_ENTRY_REAR_ROAD;
 
		}
 

	
0 comments (0 inline, 0 general)