summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authoryexo <yexo@openttd.org>2009-09-14 22:09:50 +0000
committeryexo <yexo@openttd.org>2009-09-14 22:09:50 +0000
commit5ef54ed4f9a57c9808a3ab96aafbb4f8186ceb49 (patch)
treebcdca406a024f714482ef10eb7c5b62f4f8cf42a /src/economy.cpp
parent2d9c54c9a81f5cd6f14585f9b398eef071db1c9e (diff)
downloadopenttd-5ef54ed4f9a57c9808a3ab96aafbb4f8186ceb49.tar.xz
(svn r17542) -Fix: don't access variables in the company struct after it has been deleted
-Cleanup: remove some never-used code
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index cca81413a..340b6fdb7 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -1553,8 +1553,11 @@ CommandCost CmdBuyCompany(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/* Do not allow companies to take over themselves */
if ((CompanyID)p1 == _current_company) return CMD_ERROR;
+ /* Get the cost here as the company is deleted in DoAcquireCompany. */
+ CommandCost cost(EXPENSES_OTHER, c->bankrupt_value);
+
if (flags & DC_EXEC) {
DoAcquireCompany(c);
}
- return CommandCost(EXPENSES_OTHER, c->bankrupt_value);
+ return cost;
}