summaryrefslogtreecommitdiff
path: root/train_gui.c
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-03-31 08:39:10 +0000
committerpeter1138 <peter1138@openttd.org>2006-03-31 08:39:10 +0000
commit9d3852bb574111508e068ea1f6a44a257ecb0529 (patch)
treeaac3e846ef9f1cf36afbeb01f4e6276812278808 /train_gui.c
parentc35546964d03dec26fbf6076fc2786a28a480a99 (diff)
downloadopenttd-9d3852bb574111508e068ea1f6a44a257ecb0529.tar.xz
(svn r4192) - Fix: In the depot, moving wagons from the end of a very long train to a short train where the short train was scrolled off the window would cause a game crash. (Thanks to SimonRC for reporting.)
Diffstat (limited to 'train_gui.c')
-rw-r--r--train_gui.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/train_gui.c b/train_gui.c
index 160e8fe7d..23ce740f9 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -515,13 +515,10 @@ found_it:
if (x < 0 && IsFrontEngine(v)) return (x >= -10) ? -2 : -1;
// skip vehicles that are scrolled off the left side
- while (skip--) v = v->next;
+ while (v != NULL && skip--) v = v->next;
/* find the vehicle in this row that was clicked */
- while ((x -= WagonLengthToPixels(v->u.rail.cached_veh_length)) >= 0) {
- v = v->next;
- if (v == NULL) break;
- }
+ while (v != NULL && (x -= WagonLengthToPixels(v->u.rail.cached_veh_length)) >= 0) v = v->next;
// if an articulated part was selected, find its parent
while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);