diff src/economy.cpp @ 11234:6ebdffe6e5e6 draft

(svn r15588) -Fix: change owner of waypoints and deleted stations when merging companies or when a company benkrupts
author smatz <smatz@openttd.org>
date Thu, 26 Feb 2009 14:07:42 +0000
parents 6205ed0337b2
children 02313cc6114e
line wrap: on
line diff
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -398,6 +398,24 @@
 		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));