mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r21123) -Codechange: Remove max_speed from the Vehicle class.
This commit is contained in:
parent
e1ff8aeb09
commit
6a38925ca3
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 ),
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue