roadveh_gui.c
changeset 969 8c4bede35fcc
parent 968 9c47631d62dc
child 971 1b6f956d8ac5
--- a/roadveh_gui.c	Mon Jan 10 14:24:40 2005 +0000
+++ b/roadveh_gui.c	Mon Jan 10 14:36:08 2005 +0000
@@ -544,7 +544,7 @@
 
 static int GetVehicleFromRoadDepotWndPt(Window *w, int x, int y, Vehicle **veh)
 {
-	uint xt,yt,xm;
+	uint xt,row,xm;
 	TileIndex tile;
 	Vehicle *v;
 	int pos;
@@ -554,11 +554,11 @@
 	if (xt >= 5)
 		return 1;
 
-	yt = (y - 14) / 14;
-	if (yt >= 3)
+	row = (y - 14) / 14;
+	if (row >= w->vscroll.cap)
 		return 1;
 
-	pos = (yt + w->vscroll.pos) * 5 + xt;
+	pos = (row + w->vscroll.pos) * 5 + xt;
 
 	tile = w->window_number;
 	FOR_ALL_VEHICLES(v) {