(svn r6673) -Codechange: [depot window] replaced a piece of code to calculate max number of vehicles in a row with a simple read of the matrix grid
authorbjarni
Fri, 06 Oct 2006 22:08:37 +0000
changeset 4759 4cc941b61b07
parent 4758 c955385b5432
child 4760 eec35189bfeb
(svn r6673) -Codechange: [depot window] replaced a piece of code to calculate max number of vehicles in a row with a simple read of the matrix grid
depot_gui.c
--- a/depot_gui.c	Fri Oct 06 21:44:18 2006 +0000
+++ b/depot_gui.c	Fri Oct 06 22:08:37 2006 +0000
@@ -393,6 +393,7 @@
 	Vehicle **vl = WP(w, depot_d).vehicle_list;
 	uint xt, row, xm = 0, ym = 0;
 	int pos, skip = 0;
+	uint16 boxes_in_each_row = w->widget[DEPOT_WIDGET_MATRIX].data & 0xFF;
 
 	if (WP(w, depot_d).type == VEH_Train) {
 		xt = 0;
@@ -408,7 +409,7 @@
 	row = (y - 14) / w->resize.step_height;
 	if (row >= w->vscroll.cap) return MODE_ERROR;
 
-	pos = (row + w->vscroll.pos) * (WP(w, depot_d).type == VEH_Train ? 1 : w->hscroll.cap) + xt;
+	pos = ((row + w->vscroll.pos) * boxes_in_each_row) + xt;
 
 	if (WP(w, depot_d).engine_count + WP(w, depot_d).wagon_count <= pos) {
 		if (WP(w, depot_d).type == VEH_Train) {