diff options
author | rubidium <rubidium@openttd.org> | 2007-04-29 22:33:51 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-04-29 22:33:51 +0000 |
commit | ec9ac99d01c74f1cb63e8c934c8a13d8aca2422a (patch) | |
tree | 81c46786f55f9842ddb4b237507c86df8fd72924 /src/train_cmd.cpp | |
parent | 202009522c3075e26b675ed0408075b8663b0859 (diff) | |
download | openttd-ec9ac99d01c74f1cb63e8c934c8a13d8aca2422a.tar.xz |
(svn r9755) -Codechange: refactor some more of the begin loading stuff.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r-- | src/train_cmd.cpp | 22 |
1 files changed, 7 insertions, 15 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 936d13c61..e00c0bc29 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -2522,12 +2522,17 @@ static bool ProcessTrainOrder(Vehicle *v) return !at_waypoint && CheckReverseTrain(v); } -static void MarkTrainDirty(Vehicle *v) +void Train::MarkDirty() { + Vehicle *v = this; do { v->cur_image = GetTrainImage(v, v->direction); MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1); } while ((v = v->next) != NULL); + + /* need to update acceleration and cached values since the goods on the train changed. */ + TrainCargoChanged(this); + UpdateTrainAcceleration(this); } static void HandleTrainLoading(Vehicle *v, bool mode) @@ -2551,11 +2556,7 @@ static void HandleTrainLoading(Vehicle *v, bool mode) 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); + v->MarkDirty(); } return; } @@ -2636,15 +2637,6 @@ static void TrainEnterStation(Vehicle *v, StationID station) v->BeginLoading(); v->current_order.dest = 0; - - SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC); - if (LoadUnloadVehicle(v, true) != 0) { - InvalidateWindow(WC_TRAINS_LIST, v->owner); - TrainCargoChanged(v); - UpdateTrainAcceleration(v); - } - MarkTrainDirty(v); - InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR); } static byte AfterSetTrainPos(Vehicle *v, bool new_tile) |