summaryrefslogtreecommitdiff
path: root/src/command.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/command.cpp')
-rw-r--r--src/command.cpp16
1 files changed, 2 insertions, 14 deletions
diff --git a/src/command.cpp b/src/command.cpp
index 4370f9b19..e2133fe4f 100644
--- a/src/command.cpp
+++ b/src/command.cpp
@@ -677,25 +677,13 @@ CommandCost CommandCost::AddCost(CommandCost ret)
CommandCost CommandCost::AddCost(Money cost)
{
- /* Overflow protection */
- if (cost < 0 && (this->cost + cost) > this->cost) {
- this->cost = INT64_MIN;
- } else if (cost > 0 && (this->cost + cost) < this->cost) {
- this->cost = INT64_MAX;
- } else {
- this->cost += cost;
- }
+ this->cost += cost;
return *this;
}
CommandCost CommandCost::MultiplyCost(int factor)
{
- /* Overflow protection */
- if (factor != 0 && (INT64_MAX / myabs(factor)) < myabs(this->cost)) {
- this->cost = (this->cost < 0 == factor < 0) ? INT64_MAX : INT64_MIN;
- } else {
- this->cost *= factor;
- }
+ this->cost *= factor;
return *this;
}