From 5a6d3a601db0c5cb95293227046dc365178bdd82 Mon Sep 17 00:00:00 2001 From: rubidium Date: Wed, 31 Dec 2008 17:52:42 +0000 Subject: (svn r14779) -Fix (r14747) [FS#2485]: selling an articulated vehicle removed only the first part and not the rest. --- src/train_cmd.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index d1fa79a97..e98461410 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -938,7 +938,11 @@ static Vehicle *UnlinkWagon(Vehicle *v, Vehicle *first) if (v == NULL) return NULL; if (IsTrainWagon(v)) SetFreeWagon(v); - first->SetNext(NULL); + + /* First can be an articulated engine, meaning GetNextVehicle() isn't + * v->Next(). Thus set the next vehicle of the last articulated part + * and the last articulated part is just before the next vehicle (v). */ + v->Previous()->SetNext(NULL); return v; } -- cgit v1.2.3-54-g00ecf