summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/roadveh.h2
-rw-r--r--src/roadveh_cmd.cpp10
-rw-r--r--src/saveload/vehicle_sl.cpp1
3 files changed, 4 insertions, 9 deletions
diff --git a/src/roadveh.h b/src/roadveh.h
index adec81bba..3cfecd609 100644
--- a/src/roadveh.h
+++ b/src/roadveh.h
@@ -104,7 +104,7 @@ struct RoadVehicle : public GroundVehicle<RoadVehicle, VEH_ROAD> {
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
bool IsPrimaryVehicle() const { return this->IsFrontEngine(); }
SpriteID GetImage(Direction direction) const;
- int GetDisplaySpeed() const { return this->cur_speed / 2; }
+ int GetDisplaySpeed() const { return this->gcache.last_speed / 2; }
int GetDisplayMaxSpeed() const { return this->vcache.cached_max_speed / 2; }
Money GetRunningCost() const;
int GetDisplayImageWidth(Point *offset = NULL) const;
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 036b7c200..c955fe87e 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -651,7 +651,6 @@ static void RoadVehArrivesAt(const RoadVehicle *v, Station *st)
*/
static int RoadVehAccelerate(RoadVehicle *v)
{
- uint oldspeed = v->cur_speed;
uint accel = v->overtaking != 0 ? 256 : 0;
accel += (_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL) ? 256 : v->GetAcceleration();
uint spd = v->subspeed + accel;
@@ -673,13 +672,6 @@ static int RoadVehAccelerate(RoadVehicle *v)
first->cur_speed = min(first->cur_speed, GetBridgeSpec(GetBridgeType(v->tile))->speed * 2);
}
- /* Update statusbar only if speed has changed to save CPU time */
- if (oldspeed != v->cur_speed) {
- if (_settings_client.gui.vehicle_speed) {
- SetWindowWidgetDirty(WC_VEHICLE_VIEW, v->index, VVW_WIDGET_START_STOP_VEH);
- }
- }
-
int scaled_spd = v->GetAdvanceSpeed(spd);
scaled_spd += v->progress;
@@ -1497,6 +1489,8 @@ static bool RoadVehController(RoadVehicle *v)
if (j >= adv_spd && RoadVehCheckTrainCrash(v)) break;
}
+ v->SetLastSpeed();
+
for (RoadVehicle *u = v; u != NULL; u = u->Next()) {
if ((u->vehstatus & VS_HIDDEN) != 0) continue;
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 32b692f1d..61dece380 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -345,6 +345,7 @@ void AfterLoadVehicles(bool part_of_load)
case VEH_ROAD: {
RoadVehicle *rv = RoadVehicle::From(v);
if (rv->IsFrontEngine()) {
+ rv->gcache.last_speed = rv->cur_speed; // update displayed road vehicle speed
RoadVehUpdateCache(rv);
if (_settings_game.vehicle.roadveh_acceleration_model != AM_ORIGINAL) {
rv->CargoChanged();