summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2010-02-14 15:30:08 +0000
committeralberth <alberth@openttd.org>2010-02-14 15:30:08 +0000
commite8d40d6a1987220137e386b1f505947de8d8b514 (patch)
tree34a4e0fcda875f6d15626f8a53de434d90278c56 /src
parent151babee57709529e8db2a3871abc4bf66feb1ec (diff)
downloadopenttd-e8d40d6a1987220137e386b1f505947de8d8b514.tar.xz
(svn r19128) -Codechange: CommandCost cost methods return void instead of a copy of *this.
Diffstat (limited to 'src')
-rw-r--r--src/command.cpp8
-rw-r--r--src/command_type.h17
-rw-r--r--src/rail_cmd.cpp6
-rw-r--r--src/road_cmd.cpp3
-rw-r--r--src/unmovable_cmd.cpp3
5 files changed, 18 insertions, 19 deletions
diff --git a/src/command.cpp b/src/command.cpp
index 3a20b7e82..1e422a777 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -682,12 +682,16 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
#undef return_dcpi
-CommandCost CommandCost::AddCost(CommandCost ret)
+/**
+ * Adds the cost of the given command return value to this cost.
+ * Also takes a possible error message when it is set.
+ * @param ret The command to add the cost of.
+ */
+void CommandCost::AddCost(CommandCost ret)
{
this->AddCost(ret.cost);
if (this->success && !ret.success) {
this->message = ret.message;
this->success = false;
}
- return *this;
}
diff --git a/src/command_type.h b/src/command_type.h
index a02ac750f..100a96bc9 100644
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -50,34 +50,25 @@ public:
*/
CommandCost(ExpensesType ex_t, Money cst) : expense_type(ex_t), cost(cst), message(INVALID_STRING_ID), success(true) {}
- /**
- * Adds the cost of the given command return value to this cost.
- * Also takes a possible error message when it is set.
- * @param ret the command to add the cost of.
- * @return this class.
- */
- CommandCost AddCost(CommandCost ret);
/**
* Adds the given cost to the cost of the command.
* @param cost the cost to add
- * @return this class.
*/
- CommandCost AddCost(Money cost)
+ void AddCost(Money cost)
{
this->cost += cost;
- return *this;
}
+ void AddCost(CommandCost ret);
+
/**
* Multiplies the cost of the command by the given factor.
* @param factor factor to multiply the costs with
- * @return this class
*/
- CommandCost MultiplyCost(int factor)
+ void MultiplyCost(int factor)
{
this->cost *= factor;
- return *this;
}
/**
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 199adc666..56827b8ef 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -493,7 +493,8 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
YapfNotifyTrackLayoutChange(tile, track);
}
- return cost.AddCost(RailBuildCost(railtype));
+ cost.AddCost(RailBuildCost(railtype));
+ return cost;
}
/** Remove a single piece of track
@@ -866,7 +867,8 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
}
- return cost.AddCost(_price[PR_BUILD_DEPOT_TRAIN]);
+ cost.AddCost(_price[PR_BUILD_DEPOT_TRAIN]);
+ return cost;
}
/** Build signals, alternate between double/single, signal/semaphore,
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index c877bf0ef..8ee878745 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -888,7 +888,8 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
MarkTileDirtyByTile(tile);
}
- return cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
+ cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
+ return cost;
}
static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index c48263abd..6f2359d28 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -159,7 +159,8 @@ CommandCost CmdPurchaseLandArea(TileIndex tile, DoCommandFlag flags, uint32 p1,
MarkTileDirtyByTile(tile);
}
- return cost.AddCost(GetUnmovableSpec(UNMOVABLE_OWNED_LAND)->GetBuildingCost());
+ cost.AddCost(GetUnmovableSpec(UNMOVABLE_OWNED_LAND)->GetBuildingCost());
+ return cost;
}
/** Sell a land area. Actually you only sell one tile, so