changeset 16871:39e28608198f draft

(svn r21605) -Fix [FS#4324]: crash due to cargo payments belonging to an non-existing company
author rubidium <rubidium@openttd.org>
date Thu, 23 Dec 2010 07:17:00 +0000
parents 35ca0d633732
children 3db61837d3c0
files src/economy.cpp
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -382,6 +382,9 @@
 					v->colourmap = PAL_NONE;
 					if (v->IsEngineCountable()) Company::Get(new_owner)->num_engines[v->engine_type]++;
 					if (v->IsPrimaryVehicle()) v->unitnumber = unitidgen[v->type].NextID();
+
+					/* Invalidate the vehicle's cargo payment "owner cache". */
+					if (v->cargo_payment != NULL) v->cargo_payment->owner = NULL;
 				}
 			}
 		}