summaryrefslogtreecommitdiff
path: root/src/depot_gui.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-09-26 19:26:08 +0000
committeralberth <alberth@openttd.org>2009-09-26 19:26:08 +0000
commitdd108f2399a7beb197e3c1cc950d6728cd98c96b (patch)
treea807232860c166d238306635755ea1d32ac20678 /src/depot_gui.cpp
parentf7120de1f79e35856036e3fae3901f5c23e44305 (diff)
downloadopenttd-dd108f2399a7beb197e3c1cc950d6728cd98c96b.tar.xz
(svn r17650) -Codechange: Checking a condition once is enough.
Diffstat (limited to 'src/depot_gui.cpp')
-rw-r--r--src/depot_gui.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 92d173488..afb0b912c 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -870,31 +870,28 @@ struct DepotWindow : Window {
}
} break;
- case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN:
- if (!this->IsWidgetDisabled(DEPOT_WIDGET_SELL) &&
- this->sel != INVALID_VEHICLE) {
+ case DEPOT_WIDGET_SELL: case DEPOT_WIDGET_SELL_CHAIN: {
+ if (this->IsWidgetDisabled(widget)) return;
+ if (this->sel == INVALID_VEHICLE) return;
- if (this->IsWidgetDisabled(widget)) return;
- if (this->sel == INVALID_VEHICLE) return;
+ this->HandleButtonClick(widget);
- this->HandleButtonClick(widget);
+ const Vehicle *v = Vehicle::Get(this->sel);
+ this->sel = INVALID_VEHICLE;
+ this->SetDirty();
- const Vehicle *v = Vehicle::Get(this->sel);
- this->sel = INVALID_VEHICLE;
- this->SetDirty();
+ int sell_cmd = (v->type == VEH_TRAIN && (widget == DEPOT_WIDGET_SELL_CHAIN || _ctrl_pressed)) ? 1 : 0;
- 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;
+ BackupVehicleOrders(v);
+ }
- if (is_engine) {
- _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:
this->sel = INVALID_VEHICLE;
this->SetDirty();