mirror of https://github.com/OpenTTD/OpenTTD
(svn r17650) -Codechange: Checking a condition once is enough.
parent
f7120de1f7
commit
dd108f2399
|
@ -870,31 +870,28 @@ struct DepotWindow : Window {
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
|
case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN: {
|
||||||
if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
|
if (this->IsWidgetDisabled(widget)) return;
|
||||||
this->sel != INVALID_VEHICLE) {
|
if (this->sel == INVALID_VEHICLE) return;
|
||||||
|
|
||||||
if (this->IsWidgetDisabled(widget)) return;
|
this->HandleButtonClick(widget);
|
||||||
if (this->sel == INVALID_VEHICLE) return;
|
|
||||||
|
|
||||||
this->HandleButtonClick(widget);
|
const Vehicle *v = Vehicle::Get(this->sel);
|
||||||
|
this->sel = INVALID_VEHICLE;
|
||||||
|
this->SetDirty();
|
||||||
|
|
||||||
const Vehicle *v = Vehicle::Get(this->sel);
|
int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
|
||||||
this->sel = INVALID_VEHICLE;
|
|
||||||
this->SetDirty();
|
|
||||||
|
|
||||||
int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
|
bool is_engine = (v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine());
|
||||||
|
|
||||||
bool is_engine = (v->type != VEH_TRAIN || Train::From(v)->IsFrontEngine());
|
if (is_engine) {
|
||||||
|
_backup_orders_tile = v->tile;
|
||||||
if (is_engine) {
|
BackupVehicleOrders(v);
|
||||||
_backup_orders_tile = v->tile;
|
|
||||||
BackupVehicleOrders(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!DoCommandP(v->tile, v->index, sell_cmd, GetCmdSellVeh(v->type)) && is_engine) _backup_orders_tile = 0;
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
if (!DoCommandP(v->tile, v->index, sell_cmd, GetCmdSellVeh(v->type)) && is_engine) _backup_orders_tile = 0;
|
||||||
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
this->sel = INVALID_VEHICLE;
|
this->sel = INVALID_VEHICLE;
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
Loading…
Reference in New Issue