summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorzuu <zuu@openttd.org>2013-02-10 19:49:04 +0000
committerzuu <zuu@openttd.org>2013-02-10 19:49:04 +0000
commitb1016f66ba199966d7f1487a51113329b0ca786d (patch)
tree107b2d05cb04ef41ba55f2fecf9daac0ce5ac205 /src/economy.cpp
parente27582d104c7bbcf987c5320edce94d84b6e59f7 (diff)
downloadopenttd-b1016f66ba199966d7f1487a51113329b0ca786d.tar.xz
(svn r24986) -Change: Cleanup goals and cargo monitors of companies when they go bankrupt or are taken over.
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index f1b5c9666..39cb8ddaa 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -45,6 +45,7 @@
#include "water.h"
#include "game/game.hpp"
#include "cargomonitor.h"
+#include "goal_base.h"
#include "table/strings.h"
#include "table/pricebase.h"
@@ -508,6 +509,15 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
if (si->owner == old_owner) si->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
}
+ /* Remove Game Script created Goals and CargoMonitors. */
+ Goal *g;
+ FOR_ALL_GOALS(g) {
+ if (g->company == old_owner) delete g;
+ }
+
+ ClearCargoPickupMonitoring(old_owner);
+ ClearCargoDeliveryMonitoring(old_owner);
+
/* Change colour of existing windows */
if (new_owner != INVALID_OWNER) ChangeWindowOwner(old_owner, new_owner);