summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-10-06 22:08:37 +0000
committerbjarni <bjarni@openttd.org>2006-10-06 22:08:37 +0000
commitac0bada035e538fc6f329882ceb0794bbcb80d7f (patch)
tree143a8956675a8eeb64db98735ae09c94ab343847
parent13918e7cc9aae9c54349b3d3f8de29b37461cb4d (diff)
downloadopenttd-ac0bada035e538fc6f329882ceb0794bbcb80d7f.tar.xz
(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
-rw-r--r--depot_gui.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/depot_gui.c b/depot_gui.c
index 3acdd2886..0fc2c0920 100644
--- a/depot_gui.c
+++ b/depot_gui.c
@@ -393,6 +393,7 @@ static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh
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 @@ static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh
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) {