From b1016f66ba199966d7f1487a51113329b0ca786d Mon Sep 17 00:00:00 2001 From: zuu Date: Sun, 10 Feb 2013 19:49:04 +0000 Subject: (svn r24986) -Change: Cleanup goals and cargo monitors of companies when they go bankrupt or are taken over. --- src/economy.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/economy.cpp') 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); -- cgit v1.2.3-54-g00ecf