summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/aircraft_cmd.cpp1
-rw-r--r--src/articulated_vehicles.cpp1
-rw-r--r--src/roadveh_cmd.cpp1
-rw-r--r--src/saveload/afterload.cpp1
-rw-r--r--src/saveload/oldloader_sl.cpp4
-rw-r--r--src/saveload/vehicle_sl.cpp5
-rw-r--r--src/ship_cmd.cpp3
-rw-r--r--src/train_cmd.cpp13
-rw-r--r--src/vehicle_base.h1
9 files changed, 12 insertions, 18 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp
index c66d47881..1c3a29549 100644
--- a/src/aircraft_cmd.cpp
+++ b/src/aircraft_cmd.cpp
@@ -269,7 +269,6 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
v->name = NULL;
v->last_station_visited = INVALID_STATION;
- v->max_speed = avi->max_speed;
v->acceleration = avi->acceleration;
v->engine_type = e->index;
u->engine_type = e->index;
diff --git a/src/articulated_vehicles.cpp b/src/articulated_vehicles.cpp
index a8c9b9f3a..c1bb1f838 100644
--- a/src/articulated_vehicles.cpp
+++ b/src/articulated_vehicles.cpp
@@ -380,7 +380,6 @@ void AddArticulatedParts(Vehicle *first)
v->vehstatus = first->vehstatus & ~VS_STOPPED;
v->cargo_subtype = 0;
- v->max_speed = 0;
v->max_age = 0;
v->engine_type = engine_type;
v->value = 0;
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 3eb66acd5..188deb876 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -232,7 +232,6 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
v->cargo_cap = rvi->capacity;
v->last_station_visited = INVALID_STATION;
- v->max_speed = rvi->max_speed;
v->engine_type = e->index;
v->rcache.first_engine = INVALID_ENGINE; // needs to be set before first callback
diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp
index b12b4c469..b7908525f 100644
--- a/src/saveload/afterload.cpp
+++ b/src/saveload/afterload.cpp
@@ -1340,7 +1340,6 @@ bool AfterLoadGame()
const AircraftVehicleInfo *avi = AircraftVehInfo(v->engine_type);
v->cur_speed *= 128;
v->cur_speed /= 10;
- v->max_speed = avi->max_speed;
v->acceleration = avi->acceleration;
}
}
diff --git a/src/saveload/oldloader_sl.cpp b/src/saveload/oldloader_sl.cpp
index 59e18bf6f..b360a2da6 100644
--- a/src/saveload/oldloader_sl.cpp
+++ b/src/saveload/oldloader_sl.cpp
@@ -1133,8 +1133,8 @@ static const OldChunks vehicle_chunk[] = {
OCL_SVAR( OC_UINT16, Vehicle, service_interval ),
OCL_SVAR( OC_FILE_U8 | OC_VAR_U16, Vehicle, last_station_visited ),
OCL_SVAR( OC_TTD | OC_UINT8, Vehicle, tick_counter ),
- OCL_SVAR( OC_TTD | OC_UINT16, Vehicle, max_speed ),
- OCL_SVAR( OC_TTO | OC_FILE_U8 | OC_VAR_U16, Vehicle, max_speed ),
+ OCL_CNULL( OC_TTD, 2 ), ///< max_speed, now it is calculated.
+ OCL_CNULL( OC_TTO, 1 ), ///< max_speed, now it is calculated.
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, x_pos ),
OCL_SVAR( OC_FILE_U16 | OC_VAR_I32, Vehicle, y_pos ),
diff --git a/src/saveload/vehicle_sl.cpp b/src/saveload/vehicle_sl.cpp
index 7817e81ba..5aea72a9f 100644
--- a/src/saveload/vehicle_sl.cpp
+++ b/src/saveload/vehicle_sl.cpp
@@ -180,7 +180,8 @@ void UpdateOldAircraft()
AircraftLeaveHangar(a); // make airplane visible if it was in a depot for example
a->vehstatus &= ~VS_STOPPED; // make airplane moving
- a->cur_speed = a->max_speed; // so aircraft don't have zero speed while in air
+ UpdateAircraftCache(a);
+ a->cur_speed = a->vcache.cached_max_speed; // so aircraft don't have zero speed while in air
if (!a->current_order.IsType(OT_GOTO_STATION) && !a->current_order.IsType(OT_GOTO_DEPOT)) {
/* reset current order so aircraft doesn't have invalid "station-only" order */
a->current_order.MakeDummy();
@@ -443,7 +444,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
SLE_CONDNULL(5, 0, 57),
SLE_VAR(Vehicle, engine_type, SLE_UINT16),
- SLE_VAR(Vehicle, max_speed, SLE_UINT16),
+ SLE_CONDNULL(2, 0, 151),
SLE_VAR(Vehicle, cur_speed, SLE_UINT16),
SLE_VAR(Vehicle, subspeed, SLE_UINT8),
SLE_VAR(Vehicle, acceleration, SLE_UINT8),
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index f220e13a0..3882dc8e3 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -155,7 +155,7 @@ static void CheckIfShipNeedsService(Vehicle *v)
void Ship::UpdateCache()
{
- this->vcache.cached_max_speed = GetVehicleProperty(this, PROP_SHIP_SPEED, this->max_speed);
+ this->vcache.cached_max_speed = GetVehicleProperty(this, PROP_SHIP_SPEED, ShipVehInfo(this->engine_type)->max_speed);
}
Money Ship::GetRunningCost() const
@@ -604,7 +604,6 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, u
v->cargo_cap = svi->capacity;
v->last_station_visited = INVALID_STATION;
- v->max_speed = svi->max_speed;
v->engine_type = e->index;
v->reliability = e->reliability;
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 574972694..399fd8253 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -466,8 +466,6 @@ void Train::UpdateAcceleration()
{
assert(this->IsFrontEngine());
- this->max_speed = this->acc_cache.cached_max_track_speed;
-
uint power = this->acc_cache.cached_power;
uint weight = this->acc_cache.cached_weight;
assert(weight != 0);
@@ -733,7 +731,6 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, const Engin
v->spritenum = rvi->image_index;
v->cargo_type = e->GetDefaultCargoType();
v->cargo_cap = rvi->capacity;
- v->max_speed = rvi->max_speed;
v->last_station_visited = INVALID_STATION;
v->engine_type = e->index;
@@ -2781,14 +2778,16 @@ void Train::MarkDirty()
int Train::UpdateSpeed()
{
uint accel;
+ uint16 max_speed;
switch (_settings_game.vehicle.train_acceleration_model) {
default: NOT_REACHED();
case AM_ORIGINAL:
+ max_speed = this->acc_cache.cached_max_track_speed;
accel = this->acceleration * (this->GetAccelerationStatus() == AS_BRAKE ? -4 : 2);
break;
case AM_REALISTIC:
- this->max_speed = this->GetCurrentMaxSpeed();
+ max_speed = this->GetCurrentMaxSpeed();
accel = this->GetAcceleration();
break;
}
@@ -2796,8 +2795,8 @@ int Train::UpdateSpeed()
uint spd = this->subspeed + accel;
this->subspeed = (byte)spd;
{
- int tempmax = this->max_speed;
- if (this->cur_speed > this->max_speed) {
+ int tempmax = max_speed;
+ if (this->cur_speed > max_speed) {
tempmax = this->cur_speed - (this->cur_speed / 10) - 1;
}
this->cur_speed = spd = Clamp(this->cur_speed + ((int)spd >> 8), 0, tempmax);
@@ -2876,7 +2875,7 @@ static inline void AffectSpeedByZChange(Train *v, byte old_z)
v->cur_speed -= (v->cur_speed * rsp->z_up >> 8);
} else {
uint16 spd = v->cur_speed + rsp->z_down;
- if (spd <= v->max_speed) v->cur_speed = spd;
+ if (spd <= v->acc_cache.cached_max_track_speed) v->cur_speed = spd;
}
}
diff --git a/src/vehicle_base.h b/src/vehicle_base.h
index e757ef581..65d3020b5 100644
--- a/src/vehicle_base.h
+++ b/src/vehicle_base.h
@@ -161,7 +161,6 @@ public:
TextEffectID fill_percent_te_id; ///< a text-effect id to a loading indicator object
UnitID unitnumber; ///< unit number, for display purposes only
- uint16 max_speed; ///< maximum speed
uint16 cur_speed; ///< current speed
byte subspeed; ///< fractional speed
byte acceleration; ///< used by train & aircraft