(svn r7167) -Fix: [FS#367] Crash: engine.h:194: RailVehInfo: Assertion (reported by skidd13)
authorKUDr
Thu, 16 Nov 2006 13:59:26 +0000
changeset 5097 c9ebf6608b16
parent 5096 739033ce923c
child 5098 7de23befaee4
(svn r7167) -Fix: [FS#367] Crash: engine.h:194: RailVehInfo: Assertion (reported by skidd13)
train_gui.c
--- a/train_gui.c	Thu Nov 16 12:31:38 2006 +0000
+++ b/train_gui.c	Thu Nov 16 13:59:26 2006 +0000
@@ -578,7 +578,9 @@
 
 				case BUILD_TRAIN_WIDGET_LIST: {
 					uint i = ((e->we.click.pt.y - 26) / 14) + w->vscroll.pos;
-					if (i < (uint)(WP(w, buildvehicle_d).list_a_length + WP(w, buildvehicle_d).list_b_length)) {
+					uint num_items = (HASBIT(WP(w,buildvehicle_d).show_engine_button, 0) ? WP(w, buildvehicle_d).list_a_length : 0)
+					               + (HASBIT(WP(w,buildvehicle_d).show_engine_button, 1) ? WP(w, buildvehicle_d).list_b_length : 0);
+					if (i < num_items) {
 						if (i < WP(w, buildvehicle_d).list_a_length && HASBIT(WP(w,buildvehicle_d).show_engine_button, 0)) {
 							WP(w,buildvehicle_d).sel_engine = WP(w, buildvehicle_d).list_a[i];
 						} else {