mirror of https://github.com/OpenTTD/OpenTTD
Merge 25c7e5de10
into 0b102db421
commit
0cc65320fe
|
@ -56,12 +56,14 @@ void GroundVehicle<T, Type>::PowerChanged()
|
||||||
|
|
||||||
this->gcache.cached_air_drag = air_drag + 3 * air_drag * number_of_parts / 20;
|
this->gcache.cached_air_drag = air_drag + 3 * air_drag * number_of_parts / 20;
|
||||||
|
|
||||||
|
if (total_power == 0) {
|
||||||
|
/* Ensure that vehicles are never completely stuck */
|
||||||
|
total_power = 1;
|
||||||
|
}
|
||||||
|
|
||||||
max_te *= GROUND_ACCELERATION; // Tractive effort in (tonnes * 1000 * 9.8 =) N.
|
max_te *= GROUND_ACCELERATION; // Tractive effort in (tonnes * 1000 * 9.8 =) N.
|
||||||
max_te /= 256; // Tractive effort is a [0-255] coefficient.
|
max_te /= 256; // Tractive effort is a [0-255] coefficient.
|
||||||
if (this->gcache.cached_power != total_power || this->gcache.cached_max_te != max_te) {
|
if (this->gcache.cached_power != total_power || this->gcache.cached_max_te != max_te) {
|
||||||
/* Stop the vehicle if it has no power. */
|
|
||||||
if (total_power == 0) this->vehstatus |= VS_STOPPED;
|
|
||||||
|
|
||||||
this->gcache.cached_power = total_power;
|
this->gcache.cached_power = total_power;
|
||||||
this->gcache.cached_max_te = max_te;
|
this->gcache.cached_max_te = max_te;
|
||||||
SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
|
SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
|
||||||
|
|
|
@ -47,6 +47,7 @@ enum RailTypes : uint64_t {
|
||||||
RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC, ///< Electrified rails
|
RAILTYPES_ELECTRIC = 1 << RAILTYPE_ELECTRIC, ///< Electrified rails
|
||||||
RAILTYPES_MONO = 1 << RAILTYPE_MONO, ///< Monorail!
|
RAILTYPES_MONO = 1 << RAILTYPE_MONO, ///< Monorail!
|
||||||
RAILTYPES_MAGLEV = 1 << RAILTYPE_MAGLEV, ///< Ever fast maglev
|
RAILTYPES_MAGLEV = 1 << RAILTYPE_MAGLEV, ///< Ever fast maglev
|
||||||
|
RAILTYPES_ALL = UINT64_MAX, ///< All railtypes
|
||||||
INVALID_RAILTYPES = UINT64_MAX, ///< Invalid railtypes
|
INVALID_RAILTYPES = UINT64_MAX, ///< Invalid railtypes
|
||||||
};
|
};
|
||||||
DECLARE_ENUM_AS_BIT_SET(RailTypes)
|
DECLARE_ENUM_AS_BIT_SET(RailTypes)
|
||||||
|
|
|
@ -114,7 +114,8 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
|
||||||
const RailVehicleInfo *rvi_v = RailVehInfo(this->engine_type);
|
const RailVehicleInfo *rvi_v = RailVehInfo(this->engine_type);
|
||||||
EngineID first_engine = this->IsFrontEngine() ? this->engine_type : EngineID::Invalid();
|
EngineID first_engine = this->IsFrontEngine() ? this->engine_type : EngineID::Invalid();
|
||||||
this->gcache.cached_total_length = 0;
|
this->gcache.cached_total_length = 0;
|
||||||
this->compatible_railtypes = RAILTYPES_NONE;
|
RailTypes all_compatible = RAILTYPES_ALL;
|
||||||
|
RailTypes any_powered = RAILTYPES_NONE;
|
||||||
|
|
||||||
bool train_can_tilt = true;
|
bool train_can_tilt = true;
|
||||||
int16_t min_curve_speed_mod = INT16_MAX;
|
int16_t min_curve_speed_mod = INT16_MAX;
|
||||||
|
@ -169,17 +170,20 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!u->IsArticulatedPart()) {
|
if (!u->IsArticulatedPart()) {
|
||||||
/* Do not count powered wagons for the compatible railtypes, as wagons always
|
|
||||||
have railtype normal */
|
|
||||||
if (rvi_u->power > 0) {
|
|
||||||
this->compatible_railtypes |= GetRailTypeInfo(u->railtype)->powered_railtypes;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Some electric engines can be allowed to run on normal rail. It happens to all
|
/* Some electric engines can be allowed to run on normal rail. It happens to all
|
||||||
* existing electric engines when elrails are disabled and then re-enabled */
|
* existing electric engines when elrails are disabled and then re-enabled */
|
||||||
if (HasBit(u->flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL)) {
|
if (HasBit(u->flags, VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL)) {
|
||||||
u->railtype = RAILTYPE_RAIL;
|
u->railtype = RAILTYPE_RAIL;
|
||||||
u->compatible_railtypes |= RAILTYPES_RAIL;
|
}
|
||||||
|
|
||||||
|
/* collect railtypes compatible with every vehicle */
|
||||||
|
all_compatible &= GetRailTypeInfo(u->railtype)->compatible_railtypes;
|
||||||
|
|
||||||
|
/* Do not count powered wagons for the compatible railtypes, as wagons always
|
||||||
|
have railtype normal */
|
||||||
|
if (rvi_u->power > 0) {
|
||||||
|
/* collect railtypes powering any engine */
|
||||||
|
any_powered |= GetRailTypeInfo(u->railtype)->powered_railtypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* max speed is the minimum of the speed limits of all vehicles in the consist */
|
/* max speed is the minimum of the speed limits of all vehicles in the consist */
|
||||||
|
@ -230,6 +234,8 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
|
||||||
u->InvalidateNewGRFCache();
|
u->InvalidateNewGRFCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->compatible_railtypes = all_compatible & any_powered;
|
||||||
|
|
||||||
/* store consist weight/max speed in cache */
|
/* store consist weight/max speed in cache */
|
||||||
this->vcache.cached_max_speed = max_speed;
|
this->vcache.cached_max_speed = max_speed;
|
||||||
this->tcache.cached_tilt = train_can_tilt;
|
this->tcache.cached_tilt = train_can_tilt;
|
||||||
|
|
Loading…
Reference in New Issue