summaryrefslogtreecommitdiff
path: root/src/economy.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-02-26 14:07:42 +0000
committersmatz <smatz@openttd.org>2009-02-26 14:07:42 +0000
commit3fdac6f702b0a2e8534b8f1c26faba02118ed8df (patch)
tree0664bda97b6877da1207d3896c81ef561dbf9313 /src/economy.cpp
parenta41b143e58d1290f36ab62fd402953a05e9b7e0b (diff)
downloadopenttd-3fdac6f702b0a2e8534b8f1c26faba02118ed8df.tar.xz
(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
Diffstat (limited to 'src/economy.cpp')
-rw-r--r--src/economy.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/economy.cpp b/src/economy.cpp
index eaea1dd6e..c4a6e9a84 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -398,6 +398,24 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
UpdateSignalsInBuffer();
}
+ /* convert owner of stations (including deleted ones, but excluding buoys) */
+ Station *st;
+ FOR_ALL_STATIONS(st) {
+ if (st->owner == old_owner) {
+ /* if a company goes bankrupt, set owner to OWNER_NONE so the sign doesn't disappear immediately
+ * also, drawing station window would cause reading invalid company's colour */
+ st->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
+ }
+ }
+
+ /* do the same for waypoints (we need to do this here so deleted waypoints are converted too) */
+ Waypoint *wp;
+ FOR_ALL_WAYPOINTS(wp) {
+ if (wp->owner == old_owner) {
+ wp->owner = new_owner == INVALID_OWNER ? OWNER_NONE : new_owner;
+ }
+ }
+
/* In all cases clear replace engine rules.
* Even if it was copied, it could interfere with new owner's rules */
RemoveAllEngineReplacementForCompany(GetCompany(old_owner));