summaryrefslogtreecommitdiff
path: root/train_gui.c
diff options
context:
space:
mode:
authordarkvater <darkvater@openttd.org>2004-09-07 19:01:06 +0000
committerdarkvater <darkvater@openttd.org>2004-09-07 19:01:06 +0000
commitbf9c8068be695e95662a541eb76465d60af6c976 (patch)
tree29dca88c305d0bd459c03c65b6c285d4eb8eef5a /train_gui.c
parent51d928a478f5cc83285d4f87453fa5c2ce69f77b (diff)
downloadopenttd-bf9c8068be695e95662a541eb76465d60af6c976.tar.xz
(svn r175) -Fix: [1023771] inconsistent/missing stations in station list. Forgot to change owner-sort after changing function.
-Codechange: some more asserts to vehicle-sorts to quickly find any possible problems.
Diffstat (limited to 'train_gui.c')
-rw-r--r--train_gui.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/train_gui.c b/train_gui.c
index 9e09d0a00..a08aec3c1 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -1164,7 +1164,6 @@ static void MakeSortedTrainList(byte owner)
// Player0: 25; Player1: (41-25) 16; Player2: (43-41) 2
for (i = &_num_train_sort[1]; i != endof(_num_train_sort); i++) {*i += *(i-1);}
-
// sort by owner, then only subsort the requested owner-vehicles
qsort(_train_sort, n, sizeof(_train_sort[0]), GeneralOwnerSorter);
@@ -1236,6 +1235,8 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
StringID str;
v = DEREF_VEHICLE(_train_sort[i].index);
+ assert(v->type == VEH_Train && v->subtype == 0 && v->owner == window_number);
+
DrawTrainImage(v, x + 21, y + 6, 10, 0, INVALID_VEHICLE);
DrawVehicleProfitButton(v, x, y+13);
@@ -1274,22 +1275,22 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
ShowDropDownMenu(w, _vehicle_sort_listing, _train_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4
return;
case 6: { /* Matrix to show vehicles */
- int id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
+ uint32 id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
- if ((uint)id_v >= w->vscroll.cap) { return;} // click out of bounds
+ if (id_v >= w->vscroll.cap) { return;} // click out of bounds
id_v += w->vscroll.pos;
{
- byte owner = (byte)w->window_number;
- uint16 adder = (owner == 0) ? 0 : _num_train_sort[owner - 1]; // first element in list
+ const byte owner = (byte)w->window_number;
Vehicle *v;
+ id_v += (owner == 0) ? 0 : _num_train_sort[owner - 1]; // first element in list
- if (id_v + adder >= _num_train_sort[owner]) { return;} // click out of vehicle bound
+ if (id_v >= _num_train_sort[owner]) { return;} // click out of vehicle bound
- v = DEREF_VEHICLE(_train_sort[adder+id_v].index); // add the offset id_x to that
+ v = DEREF_VEHICLE(_train_sort[id_v].index); // add the offset id_x to that
- assert(v->type == VEH_Train && v->subtype == 0 && v->owner == owner && v->owner == _train_sort[adder+id_v].owner);
+ assert(v->type == VEH_Train && v->subtype == 0 && v->owner == owner);
ShowTrainViewWindow(v);
}