summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-01-26 17:31:07 +0000
committerrubidium <rubidium@openttd.org>2011-01-26 17:31:07 +0000
commitb11f1bd4ed68fc0d031429df2925b87ed6baceb3 (patch)
tree5bb149c0bafdbb9a3987237fa5f1d659f92268cf /src/train_cmd.cpp
parent12b64a12b06f93d81a433cb311dfd1228d155e98 (diff)
downloadopenttd-b11f1bd4ed68fc0d031429df2925b87ed6baceb3.tar.xz
(svn r21911) -Codechange: move tcache.last_speed to gcache.last_speed and make SetLastSpeed a function of GroundVehicle
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index ccc644666..2c816c280 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1395,17 +1395,6 @@ void Train::UpdateDeltaXY(Direction direction)
this->z_extent = 6;
}
-static inline void SetLastSpeed(Train *v, int spd)
-{
- int old = v->tcache.last_speed;
- if (spd != old) {
- v->tcache.last_speed = spd;
- if (_settings_client.gui.vehicle_speed || (old == 0) != (spd == 0)) {
- SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
- }
- }
-}
-
/** Mark a train as stuck and stop it if it isn't stopped right now. */
static void MarkTrainAsStuck(Train *v)
{
@@ -1418,7 +1407,7 @@ static void MarkTrainAsStuck(Train *v)
/* Stop train */
v->cur_speed = 0;
v->subspeed = 0;
- SetLastSpeed(v, 0);
+ v->SetLastSpeed();
SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
}
@@ -1843,7 +1832,7 @@ CommandCost CmdReverseTrainDirection(TileIndex tile, DoCommandFlag flags, uint32
ToggleBit(v->flags, VRF_REVERSING);
} else {
v->cur_speed = 0;
- SetLastSpeed(v, 0);
+ v->SetLastSpeed();
HideFillingPercent(&v->fill_percent_te_id);
ReverseTrainDirection(v);
}
@@ -3659,7 +3648,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
int adv_spd = v->GetAdvanceDistance();
if (j < adv_spd) {
/* if the vehicle has speed 0, update the last_speed field. */
- if (v->cur_speed == 0) SetLastSpeed(v, v->cur_speed);
+ if (v->cur_speed == 0) v->SetLastSpeed();
} else {
TrainCheckIfLineEnds(v);
/* Loop until the train has finished moving. */
@@ -3683,7 +3672,7 @@ static bool TrainLocoHandler(Train *v, bool mode)
ProcessOrders(v);
}
}
- SetLastSpeed(v, v->cur_speed);
+ v->SetLastSpeed();
}
for (Train *u = v; u != NULL; u = u->Next()) {