diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index e001f2fedb..9eeb51011c 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -460,11 +460,9 @@ struct DepotWindow : Window { ym = (y - matrix_widget->pos_y) % this->resize.step_height; int row = this->vscroll->GetScrolledRowFromWidget(y, this, WID_D_MATRIX); - if (row == INT_MAX) return MODE_ERROR; - uint pos = (row * this->num_columns) + xt; - if (this->vehicle_list.size() + this->wagon_list.size() <= pos) { + if (row == INT_MAX || this->vehicle_list.size() + this->wagon_list.size() <= pos) { /* Clicking on 'line' / 'block' without a vehicle */ if (this->type == VEH_TRAIN) { /* End the dragging */