summaryrefslogtreecommitdiff
path: root/src/ship_cmd.cpp
diff options
context:
space:
mode:
authortron <tron@openttd.org>2007-01-27 16:45:16 +0000
committertron <tron@openttd.org>2007-01-27 16:45:16 +0000
commit430e64c8483cfedc9042fcb1b0b28a098fa57333 (patch)
treeb5470e475855d90fb8a567db1465f3b37fded17a /src/ship_cmd.cpp
parent08c21c0c61be2e6e19517559288f3f40b77c0f0f (diff)
downloadopenttd-430e64c8483cfedc9042fcb1b0b28a098fa57333.tar.xz
(svn r8430) -Fix
Replace the rather obscure control flow for handling aircraft/ship/train orders by something remotly comprehensible (see r3584)
Diffstat (limited to 'src/ship_cmd.cpp')
-rw-r--r--src/ship_cmd.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index aa4d77656..50f92f600 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -273,28 +273,31 @@ static void ProcessShipOrder(Vehicle *v)
static void HandleShipLoading(Vehicle *v)
{
- if (v->current_order.type == OT_NOTHING) return;
-
- if (v->current_order.type != OT_DUMMY) {
- if (v->current_order.type != OT_LOADING) return;
- if (--v->load_unload_time_rem) return;
-
- if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD ||
- (_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED)))) {
- SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
- if (LoadUnloadVehicle(v, false)) {
- InvalidateWindow(WC_SHIPS_LIST, v->owner);
- MarkShipDirty(v);
+ switch (v->current_order.type) {
+ case OT_LOADING:
+ if (--v->load_unload_time_rem) return;
+
+ if (CanFillVehicle(v) && (
+ v->current_order.flags & OF_FULL_LOAD ||
+ (_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED))
+ )) {
+ SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
+ if (LoadUnloadVehicle(v, false)) {
+ InvalidateWindow(WC_SHIPS_LIST, v->owner);
+ MarkShipDirty(v);
+ }
+ return;
}
- return;
- }
- PlayShipSound(v);
+ PlayShipSound(v);
- {
Order b = v->current_order;
v->LeaveStation();
if (!(b.flags & OF_NON_STOP)) return;
- }
+ break;
+
+ case OT_DUMMY: break;
+
+ default: return;
}
v->cur_order_index++;