summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2008-04-06 14:50:37 +0000
committersmatz <smatz@openttd.org>2008-04-06 14:50:37 +0000
commitaaa1b0744a423518549a6b452c7786612659f7a5 (patch)
treee6cab465e31bab3bb792b58a20ee6ff52d90c182 /src
parentd6623cf6541af8cb27359b59b97cb9e47f61bd0e (diff)
downloadopenttd-aaa1b0744a423518549a6b452c7786612659f7a5.tar.xz
(svn r12591) -Codechange: move CommandCost accessors to header file, 8kB of binary size saved
Diffstat (limited to 'src')
-rw-r--r--src/command.cpp49
-rw-r--r--src/command_type.h48
2 files changed, 40 insertions, 57 deletions
diff --git a/src/command.cpp b/src/command.cpp
index c00a40eaa..4b6335744 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -668,52 +668,3 @@ callb_err:
ClearStorageChanges(false);
return false;
}
-
-
-CommandCost CommandCost::AddCost(CommandCost ret)
-{
- this->AddCost(ret.cost);
- if (this->success && !ret.success) {
- this->message = ret.message;
- this->success = false;
- }
- return *this;
-}
-
-CommandCost CommandCost::AddCost(Money cost)
-{
- this->cost += cost;
- return *this;
-}
-
-CommandCost CommandCost::MultiplyCost(int factor)
-{
- this->cost *= factor;
- return *this;
-}
-
-Money CommandCost::GetCost() const
-{
- return this->cost;
-}
-
-ExpensesType CommandCost::GetExpensesType() const
-{
- return this->expense_type;
-}
-
-void CommandCost::SetGlobalErrorMessage() const
-{
- extern StringID _error_message;
- if (this->message != INVALID_STRING_ID) _error_message = this->message;
-}
-
-bool CommandCost::Succeeded() const
-{
- return this->success;
-}
-
-bool CommandCost::Failed() const
-{
- return !this->success;
-}
diff --git a/src/command_type.h b/src/command_type.h
index 281933e43..2f3fe2947 100644
--- a/src/command_type.h
+++ b/src/command_type.h
@@ -49,50 +49,82 @@ public:
* @param ret the command to add the cost of.
* @return this class.
*/
- CommandCost AddCost(CommandCost ret);
+ CommandCost AddCost(CommandCost ret)
+ {
+ this->AddCost(ret.cost);
+ if (this->success && !ret.success) {
+ this->message = ret.message;
+ this->success = false;
+ }
+ return *this;
+ }
/**
* Adds the given cost to the cost of the command.
* @param cost the cost to add
* @return this class.
*/
- CommandCost AddCost(Money cost);
+ CommandCost AddCost(Money cost)
+ {
+ this->cost += cost;
+ return *this;
+ }
/**
* Multiplies the cost of the command by the given factor.
* @param cost factor to multiply the costs with
* @return this class
*/
- CommandCost MultiplyCost(int factor);
+ CommandCost MultiplyCost(int factor)
+ {
+ this->cost *= factor;
+ return *this;
+ }
/**
* The costs as made up to this moment
* @return the costs
*/
- Money GetCost() const;
+ Money GetCost() const
+ {
+ return this->cost;
+ }
/**
* The expense type of the cost
* @return the expense type
*/
- ExpensesType GetExpensesType() const;
+ ExpensesType GetExpensesType() const
+ {
+ return this->expense_type;
+ }
/**
* Sets the global error message *if* this class has one.
*/
- void SetGlobalErrorMessage() const;
+ void SetGlobalErrorMessage() const
+ {
+ extern StringID _error_message;
+ if (this->message != INVALID_STRING_ID) _error_message = this->message;
+ }
/**
* Did this command succeed?
* @return true if and only if it succeeded
*/
- bool Succeeded() const;
+ bool Succeeded() const
+ {
+ return this->success;
+ }
/**
* Did this command fail?
* @return true if and only if it failed
*/
- bool Failed() const;
+ bool Failed() const
+ {
+ return !this->success;
+ }
};
/**