changeset 16547:a11cd939c335 draft

(svn r21273) -Codechange: Return values should start at the same line.
author alberth <alberth@openttd.org>
date Sat, 20 Nov 2010 15:44:24 +0000
parents fe00a80f1232
children e2f0925a784d
files src/bridge_map.h src/command.cpp src/newgrf_object.cpp src/newgrf_station.cpp src/order_cmd.cpp src/pathfinder/npf/npf.cpp src/pathfinder/yapf/yapf_destrail.hpp src/rail_map.h src/roadveh_cmd.cpp src/station.cpp src/station_map.h src/string_func.h src/strings.cpp src/train_cmd.cpp src/tunnel_map.cpp src/viewport.cpp
diffstat 16 files changed, 55 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/src/bridge_map.h
+++ b/src/bridge_map.h
@@ -45,13 +45,8 @@
  */
 static inline bool MayHaveBridgeAbove(TileIndex t)
 {
-	return
-		IsTileType(t, MP_CLEAR) ||
-		IsTileType(t, MP_RAILWAY) ||
-		IsTileType(t, MP_ROAD) ||
-		IsTileType(t, MP_WATER) ||
-		IsTileType(t, MP_TUNNELBRIDGE) ||
-		IsTileType(t, MP_OBJECT);
+	return IsTileType(t, MP_CLEAR) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_ROAD) ||
+			IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_OBJECT);
 }
 
 /**
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -318,9 +318,7 @@
 {
 	cmd &= CMD_ID_MASK;
 
-	return
-		cmd < lengthof(_command_proc_table) &&
-		_command_proc_table[cmd].proc != NULL;
+	return cmd < lengthof(_command_proc_table) && _command_proc_table[cmd].proc != NULL;
 }
 
 /*!
--- a/src/newgrf_object.cpp
+++ b/src/newgrf_object.cpp
@@ -48,9 +48,7 @@
 
 bool ObjectSpec::IsAvailable() const
 {
-	return
-			this->enabled &&
-			_date > this->introduction_date &&
+	return this->enabled && _date > this->introduction_date &&
 			(_date < this->end_of_life_date || this->end_of_life_date < this->introduction_date + 365) &&
 			HasBit(this->climate, _settings_game.game_creation.landscape) &&
 			(flags & (_game_mode != GM_EDITOR ? OBJECT_FLAG_ONLY_IN_SCENEDIT : OBJECT_FLAG_ONLY_IN_GAME)) == 0;
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -817,10 +817,9 @@
 {
 	const StationSpec *statspec = GetStationSpec(tile);
 
-	return
-		statspec == NULL ||
-		HasBit(statspec->pylons, GetStationGfx(tile)) ||
-		!HasBit(statspec->wires, GetStationGfx(tile));
+	return statspec == NULL ||
+			HasBit(statspec->pylons, GetStationGfx(tile)) ||
+			!HasBit(statspec->wires, GetStationGfx(tile));
 }
 
 /** Helper class for animation control. */
--- a/src/order_cmd.cpp
+++ b/src/order_cmd.cpp
@@ -115,15 +115,11 @@
 	if ((this->IsType(OT_GOTO_DEPOT) && this->type == other.type) &&
 			((this->GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0 ||
 			 (other.GetDepotActionType() & ODATFB_NEAREST_DEPOT) != 0)) {
-		return
-			this->GetDepotOrderType() == other.GetDepotOrderType() &&
-			(this->GetDepotActionType() & ~ODATFB_NEAREST_DEPOT) == (other.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT);
+		return this->GetDepotOrderType() == other.GetDepotOrderType() &&
+				(this->GetDepotActionType() & ~ODATFB_NEAREST_DEPOT) == (other.GetDepotActionType() & ~ODATFB_NEAREST_DEPOT);
 	}
 
-	return
-			this->type  == other.type &&
-			this->flags == other.flags &&
-			this->dest  == other.dest;
+	return this->type == other.type && this->flags == other.flags && this->dest == other.dest;
 }
 
 uint32 Order::Pack() const
@@ -1752,8 +1748,8 @@
 bool Order::ShouldStopAtStation(const Vehicle *v, StationID station) const
 {
 	bool is_dest_station = this->IsType(OT_GOTO_STATION) && this->dest == station;
-	return
-			(!this->IsType(OT_GOTO_DEPOT) || (this->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0) &&
+
+	return (!this->IsType(OT_GOTO_DEPOT) || (this->GetDepotOrderType() & ODTFB_PART_OF_ORDERS) != 0) &&
 			v->last_station_visited != station && // Do stop only when we've not just been there
 			/* Finally do stop when there is no non-stop flag set for this type of station. */
 			!(this->GetNonStopType() & (is_dest_station ? ONSF_NO_STOP_AT_DESTINATION_STATION : ONSF_NO_STOP_AT_INTERMEDIATE_STATIONS));
--- a/src/pathfinder/npf/npf.cpp
+++ b/src/pathfinder/npf/npf.cpp
@@ -541,10 +541,9 @@
 {
 	const Train *v = Train::From(((NPFFindStationOrTileData *)as->user_target)->v);
 
-	return
-		IsSafeWaitingPosition(v, current->path.node.tile, current->path.node.direction, true, _settings_game.pf.forbid_90_deg) &&
-		IsWaitingPositionFree(v, current->path.node.tile, current->path.node.direction, _settings_game.pf.forbid_90_deg) ?
-			AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
+	return (IsSafeWaitingPosition(v, current->path.node.tile, current->path.node.direction, true, _settings_game.pf.forbid_90_deg) &&
+			IsWaitingPositionFree(v, current->path.node.tile, current->path.node.direction, _settings_game.pf.forbid_90_deg)) ?
+				AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
 }
 
 /* Will find a station identified using the NPFFindStationOrTileData */
--- a/src/pathfinder/yapf/yapf_destrail.hpp
+++ b/src/pathfinder/yapf/yapf_destrail.hpp
@@ -99,9 +99,8 @@
 	/** Called by YAPF to detect if node ends in the desired destination */
 	FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
 	{
-		return
-			IsSafeWaitingPosition(Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
-			IsWaitingPositionFree(Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
+		return IsSafeWaitingPosition(Yapf().GetVehicle(), tile, td, true, !TrackFollower::Allow90degTurns()) &&
+				IsWaitingPositionFree(Yapf().GetVehicle(), tile, td, !TrackFollower::Allow90degTurns());
 	}
 
 	/**
--- a/src/rail_map.h
+++ b/src/rail_map.h
@@ -424,9 +424,7 @@
 static inline bool HasSignalOnTrack(TileIndex tile, Track track)
 {
 	assert(IsValidTrack(track));
-	return
-		GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
-		(GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
+	return GetRailTileType(tile) == RAIL_TILE_SIGNALS && (GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
 }
 
 /**
@@ -439,9 +437,7 @@
 static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
 {
 	assert (IsValidTrackdir(trackdir));
-	return
-		GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
-		GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
+	return GetRailTileType(tile) == RAIL_TILE_SIGNALS && GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
 }
 
 /**
@@ -477,10 +473,8 @@
  */
 static inline bool HasPbsSignalOnTrackdir(TileIndex tile, Trackdir td)
 {
-	return
-		IsTileType(tile, MP_RAILWAY) &&
-		HasSignalOnTrackdir(tile, td) &&
-		IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td)));
+	return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, td) &&
+			IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td)));
 }
 
 /**
@@ -491,11 +485,8 @@
  */
 static inline bool HasOnewaySignalBlockingTrackdir(TileIndex tile, Trackdir td)
 {
-	return
-		IsTileType(tile, MP_RAILWAY) &&
-		HasSignalOnTrackdir(tile, ReverseTrackdir(td)) &&
-		!HasSignalOnTrackdir(tile, td) &&
-		IsOnewaySignal(tile, TrackdirToTrack(td));
+	return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, ReverseTrackdir(td)) &&
+			!HasSignalOnTrackdir(tile, td) && IsOnewaySignal(tile, TrackdirToTrack(td));
 }
 
 
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -452,12 +452,10 @@
 {
 	const Vehicle *u = (Vehicle*)data;
 
-	return
-		v->type == VEH_TRAIN &&
-		abs(v->z_pos - u->z_pos) <= 6 &&
-		abs(v->x_pos - u->x_pos) <= 4 &&
-		abs(v->y_pos - u->y_pos) <= 4 ?
-			v : NULL;
+	return (v->type == VEH_TRAIN &&
+			abs(v->z_pos - u->z_pos) <= 6 &&
+			abs(v->x_pos - u->x_pos) <= 4 &&
+			abs(v->y_pos - u->y_pos) <= 4) ? v : NULL;
 }
 
 uint RoadVehicle::Crash(bool flooded)
@@ -727,9 +725,7 @@
 {
 	const OvertakeData *od = (OvertakeData*)data;
 
-	return
-		v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v ?
-			v : NULL;
+	return (v->type == VEH_ROAD && v->First() == v && v != od->u && v != od->v) ? v : NULL;
 }
 
 /**
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -363,11 +363,8 @@
  */
 bool StationRect::PtInExtendedRect(int x, int y, int distance) const
 {
-	return
-			this->left - distance <= x &&
-			x <= this->right + distance &&
-			this->top - distance <= y &&
-			y <= this->bottom + distance;
+	return this->left - distance <= x && x <= this->right + distance &&
+			this->top - distance <= y && y <= this->bottom + distance;
 }
 
 bool StationRect::IsEmpty() const
--- a/src/station_map.h
+++ b/src/station_map.h
@@ -379,12 +379,10 @@
 static inline bool IsCompatibleTrainStationTile(TileIndex t1, TileIndex t2)
 {
 	assert(IsRailStationTile(t2));
-	return
-		IsRailStationTile(t1) &&
-		IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
-		GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
-		GetStationIndex(t1) == GetStationIndex(t2) &&
-		!IsStationTileBlocked(t1);
+	return IsRailStationTile(t1) && IsCompatibleRail(GetRailType(t1), GetRailType(t2)) &&
+			GetRailStationAxis(t1) == GetRailStationAxis(t2) &&
+			GetStationIndex(t1) == GetStationIndex(t2) &&
+			!IsStationTileBlocked(t1);
 }
 
 /**
--- a/src/string_func.h
+++ b/src/string_func.h
@@ -273,10 +273,7 @@
  */
 static inline bool IsWhitespace(WChar c)
 {
-	return
-	  c == 0x0020 /* SPACE */ ||
-	  c == 0x3000 /* IDEOGRAPHIC SPACE */
-	;
+	return c == 0x0020 /* SPACE */ || c == 0x3000; /* IDEOGRAPHIC SPACE */
 }
 
 /* Needed for NetBSD version (so feature) testing */
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -1308,20 +1308,19 @@
 
 bool LanguagePackHeader::IsValid() const
 {
-	return
-			this->ident        == TO_LE32(LanguagePackHeader::IDENT) &&
-			this->version      == TO_LE32(LANGUAGE_PACK_VERSION) &&
-			this->plural_form  <  LANGUAGE_MAX_PLURAL &&
-			this->text_dir     <= 1 &&
-			this->newgrflangid < MAX_LANG &&
-			this->num_genders  < MAX_NUM_GENDERS &&
-			this->num_cases    < MAX_NUM_CASES &&
-			StrValid(this->name,                           lastof(this->name)) &&
-			StrValid(this->own_name,                       lastof(this->own_name)) &&
-			StrValid(this->isocode,                        lastof(this->isocode)) &&
-			StrValid(this->digit_group_separator,          lastof(this->digit_group_separator)) &&
-			StrValid(this->digit_group_separator_currency, lastof(this->digit_group_separator_currency)) &&
-			StrValid(this->digit_decimal_separator,        lastof(this->digit_decimal_separator));
+	return this->ident        == TO_LE32(LanguagePackHeader::IDENT) &&
+	       this->version      == TO_LE32(LANGUAGE_PACK_VERSION) &&
+	       this->plural_form  <  LANGUAGE_MAX_PLURAL &&
+	       this->text_dir     <= 1 &&
+	       this->newgrflangid < MAX_LANG &&
+	       this->num_genders  < MAX_NUM_GENDERS &&
+	       this->num_cases    < MAX_NUM_CASES &&
+	       StrValid(this->name,                           lastof(this->name)) &&
+	       StrValid(this->own_name,                       lastof(this->own_name)) &&
+	       StrValid(this->isocode,                        lastof(this->isocode)) &&
+	       StrValid(this->digit_group_separator,          lastof(this->digit_group_separator)) &&
+	       StrValid(this->digit_group_separator_currency, lastof(this->digit_group_separator_currency)) &&
+	       StrValid(this->digit_decimal_separator,        lastof(this->digit_decimal_separator));
 }
 
 bool ReadLanguagePack(const LanguageMetadata *lang)
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2703,11 +2703,8 @@
 /* Check if the vehicle is compatible with the specified tile */
 static inline bool CheckCompatibleRail(const Train *v, TileIndex tile)
 {
-	return
-		IsTileOwner(tile, v->owner) && (
-			!v->IsFrontEngine() ||
-			HasBit(v->compatible_railtypes, GetRailType(tile))
-		);
+	return IsTileOwner(tile, v->owner) &&
+			(!v->IsFrontEngine() || HasBit(v->compatible_railtypes, GetRailType(tile)));
 }
 
 struct RailtypeSlowdownParams {
--- a/src/tunnel_map.cpp
+++ b/src/tunnel_map.cpp
@@ -56,10 +56,7 @@
 		height = GetTileZ(tile);
 	} while (z < height);
 
-	return
-		z == height &&
-		IsTunnelTile(tile) &&
-		GetTunnelBridgeDirection(tile) == dir;
+	return z == height && IsTunnelTile(tile) && GetTunnelBridgeDirection(tile) == dir;
 }
 
 /**
@@ -70,7 +67,6 @@
  */
 bool IsTunnelInWay(TileIndex tile, uint z)
 {
-	return
-		IsTunnelInWayDir(tile, z, (TileX(tile) > (MapMaxX() / 2)) ? DIAGDIR_NE : DIAGDIR_SW) ||
-		IsTunnelInWayDir(tile, z, (TileY(tile) > (MapMaxY() / 2)) ? DIAGDIR_NW : DIAGDIR_SE);
+	return IsTunnelInWayDir(tile, z, (TileX(tile) > (MapMaxX() / 2)) ? DIAGDIR_NE : DIAGDIR_SW) ||
+			IsTunnelInWayDir(tile, z, (TileY(tile) > (MapMaxY() / 2)) ? DIAGDIR_NW : DIAGDIR_SE);
 }
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1729,11 +1729,8 @@
 	x = ScaleByZoom(x - vp->left, vp->zoom) + vp->virtual_left;
 	y = ScaleByZoom(y - vp->top, vp->zoom) + vp->virtual_top;
 
-	return
-			y >= sign->top &&
-			y <  sign->top + sign_height &&
-			x >= sign->center - sign_half_width &&
-			x <  sign->center + sign_half_width;
+	return y >= sign->top && y < sign->top + sign_height &&
+			x >= sign->center - sign_half_width && x < sign->center + sign_half_width;
 }
 
 static bool CheckClickOnTown(const ViewPort *vp, int x, int y)