diff options
author | tron <tron@openttd.org> | 2007-01-27 16:45:16 +0000 |
---|---|---|
committer | tron <tron@openttd.org> | 2007-01-27 16:45:16 +0000 |
commit | 430e64c8483cfedc9042fcb1b0b28a098fa57333 (patch) | |
tree | b5470e475855d90fb8a567db1465f3b37fded17a /src/train_cmd.cpp | |
parent | 08c21c0c61be2e6e19517559288f3f40b77c0f0f (diff) | |
download | openttd-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/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 56 |
1 files changed, 30 insertions, 26 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index e4f67cb4f..4378a3d75 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2605,42 +2605,46 @@ static void MarkTrainDirty(Vehicle *v) static void HandleTrainLoading(Vehicle *v, bool mode) { - if (v->current_order.type == OT_NOTHING) return; - - if (v->current_order.type != OT_DUMMY) { - if (v->current_order.type != OT_LOADING) return; - if (mode) return; - - // don't mark the train as lost if we're loading on the final station. - if (v->current_order.flags & OF_NON_STOP) - v->u.rail.days_since_order_progr = 0; - - if (--v->load_unload_time_rem) return; + switch (v->current_order.type) { + case OT_LOADING: + if (mode) return; - if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD || - (_patches.gradual_loading && !HASBIT(v->load_status, LS_LOADING_FINISHED)))) { - v->u.rail.days_since_order_progr = 0; /* Prevent a train lost message for full loading trains */ - SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); - if (LoadUnloadVehicle(v, false)) { - InvalidateWindow(WC_TRAINS_LIST, v->owner); - MarkTrainDirty(v); + // don't mark the train as lost if we're loading on the final station. + if (v->current_order.flags & OF_NON_STOP) { + v->u.rail.days_since_order_progr = 0; + } - // need to update acceleration and cached values since the goods on the train changed. - TrainCargoChanged(v); - UpdateTrainAcceleration(v); + 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)) + )) { + v->u.rail.days_since_order_progr = 0; /* Prevent a train lost message for full loading trains */ + SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); + if (LoadUnloadVehicle(v, false)) { + InvalidateWindow(WC_TRAINS_LIST, v->owner); + MarkTrainDirty(v); + + // need to update acceleration and cached values since the goods on the train changed. + TrainCargoChanged(v); + UpdateTrainAcceleration(v); + } + return; } - return; - } - TrainPlayLeaveStationSound(v); + TrainPlayLeaveStationSound(v); - { Order b = v->current_order; v->LeaveStation(); // If this was not the final order, don't remove it from the list. if (!(b.flags & OF_NON_STOP)) return; - } + break; + + case OT_DUMMY: break; + + default: return; } v->u.rail.days_since_order_progr = 0; |