Merge branch 'improved_breakdowns-sx' into jgrpp
# Conflicts: # src/saveload/extended_ver_sl.cpp # src/settings.cpp
This commit is contained in:
@@ -309,7 +309,7 @@ CommandCost CmdBuildAircraft(TileIndex tile, DoCommandFlag flags, const Engine *
|
|||||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||||
/* higher speed means higher breakdown chance */
|
/* higher speed means higher breakdown chance */
|
||||||
/* to somewhat compensate for the fact that fast aircraft spend less time in the air */
|
/* to somewhat compensate for the fact that fast aircraft spend less time in the air */
|
||||||
v->breakdown_chance = Clamp(64 + (AircraftVehInfo(v->engine_type)->max_speed >> 3), 0, 255);
|
v->breakdown_chance_factor = Clamp(64 + (AircraftVehInfo(v->engine_type)->max_speed >> 3), 0, 255);
|
||||||
v->max_age = e->GetLifeLengthInDays();
|
v->max_age = e->GetLifeLengthInDays();
|
||||||
|
|
||||||
_new_vehicle_id = v->index;
|
_new_vehicle_id = v->index;
|
||||||
@@ -1336,18 +1336,18 @@ static void MaybeCrashAirplane(Aircraft *v)
|
|||||||
Station *st = Station::Get(v->targetairport);
|
Station *st = Station::Get(v->targetairport);
|
||||||
|
|
||||||
/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
|
/* FIXME -- MaybeCrashAirplane -> increase crashing chances of very modern airplanes on smaller than AT_METROPOLITAN airports */
|
||||||
uint32 prob = (_settings_game.vehicle.improved_breakdowns && _settings_game.difficulty.vehicle_breakdowns) ?
|
uint32 prob = (0x4000 << _settings_game.vehicle.plane_crashes);
|
||||||
0x10000 / 10000 : 0x4000 << _settings_game.vehicle.plane_crashes;
|
|
||||||
|
|
||||||
if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
|
if ((st->airport.GetFTA()->flags & AirportFTAClass::SHORT_STRIP) &&
|
||||||
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
|
(AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) &&
|
||||||
!_cheats.no_jetcrash.value) {
|
!_cheats.no_jetcrash.value) {
|
||||||
prob /= 20;
|
prob /= 20;
|
||||||
} else if (!_settings_game.vehicle.improved_breakdowns) {
|
} else {
|
||||||
prob /= 1500;
|
prob /= 1500;
|
||||||
} else if (v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_AIRCRAFT_EM_LANDING) {
|
}
|
||||||
/* Airplanes that are attempting an emergency landing have a 2% chance to crash */
|
if (_settings_game.vehicle.improved_breakdowns && v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_AIRCRAFT_EM_LANDING) {
|
||||||
prob = 0x10000 / 50;
|
/* Airplanes that are attempting an emergency landing have a 2% chance to crash */
|
||||||
|
prob = max<uint32>(prob, 0x10000 / 50);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GB(Random(), 0, 22) > prob) return;
|
if (GB(Random(), 0, 22) > prob) return;
|
||||||
|
@@ -78,14 +78,15 @@ void GroundVehicle<T, Type>::CalculatePower(uint32& total_power, uint32& max_te,
|
|||||||
|
|
||||||
for (const T *u = v; u != NULL; u = u->Next()) {
|
for (const T *u = v; u != NULL; u = u->Next()) {
|
||||||
uint32 current_power = u->GetPower() + u->GetPoweredPartPower(u);
|
uint32 current_power = u->GetPower() + u->GetPoweredPartPower(u);
|
||||||
|
|
||||||
|
if (breakdowns && u->breakdown_ctr == 1 && u->breakdown_type == BREAKDOWN_LOW_POWER) {
|
||||||
|
current_power = current_power * u->breakdown_severity / 256;
|
||||||
|
}
|
||||||
|
|
||||||
total_power += current_power;
|
total_power += current_power;
|
||||||
|
|
||||||
/* Only powered parts add tractive effort. */
|
/* Only powered parts add tractive effort. */
|
||||||
if (current_power > 0) max_te += u->GetWeight() * u->GetTractiveEffort();
|
if (current_power > 0) max_te += u->GetWeight() * u->GetTractiveEffort();
|
||||||
|
|
||||||
if (breakdowns && u->breakdown_ctr == 1 && u->breakdown_type == BREAKDOWN_LOW_POWER) {
|
|
||||||
total_power = total_power * u->breakdown_severity / 256;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
max_te *= 10000; // Tractive effort in (tonnes * 1000 * 10 =) N.
|
max_te *= 10000; // Tractive effort in (tonnes * 1000 * 10 =) N.
|
||||||
@@ -138,7 +139,6 @@ int GroundVehicle<T, Type>::GetAcceleration()
|
|||||||
* and km/h to m/s conversion below result in a maxium of
|
* and km/h to m/s conversion below result in a maxium of
|
||||||
* about 1.1E11, way more than 4.3E9 of int32. */
|
* about 1.1E11, way more than 4.3E9 of int32. */
|
||||||
int64 power = this->gcache.cached_power * 746ll;
|
int64 power = this->gcache.cached_power * 746ll;
|
||||||
uint32 max_te = this->gcache.cached_max_te; // [N]
|
|
||||||
|
|
||||||
/* This is constructed from:
|
/* This is constructed from:
|
||||||
* - axle resistance: U16 power * 10 for 128 vehicles.
|
* - axle resistance: U16 power * 10 for 128 vehicles.
|
||||||
@@ -171,8 +171,8 @@ int GroundVehicle<T, Type>::GetAcceleration()
|
|||||||
AccelStatus mode = v->GetAccelerationStatus();
|
AccelStatus mode = v->GetAccelerationStatus();
|
||||||
|
|
||||||
/* handle breakdown power reduction */
|
/* handle breakdown power reduction */
|
||||||
//TODO
|
uint32 max_te = this->gcache.cached_max_te; // [N]
|
||||||
if( Type == VEH_TRAIN && mode == AS_ACCEL && HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER)) {
|
if (Type == VEH_TRAIN && mode == AS_ACCEL && HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER)) {
|
||||||
/* We'd like to cache this, but changing cached_power has too many unwanted side-effects */
|
/* We'd like to cache this, but changing cached_power has too many unwanted side-effects */
|
||||||
uint32 power_temp;
|
uint32 power_temp;
|
||||||
this->CalculatePower(power_temp, max_te, true);
|
this->CalculatePower(power_temp, max_te, true);
|
||||||
@@ -198,7 +198,7 @@ int GroundVehicle<T, Type>::GetAcceleration()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If power is 0 because of a breakdown, we make the force 0 if accelerating */
|
/* If power is 0 because of a breakdown, we make the force 0 if accelerating */
|
||||||
if ( Type == VEH_TRAIN && mode == AS_ACCEL && HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER) && power == 0) {
|
if (Type == VEH_TRAIN && mode == AS_ACCEL && HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER) && power == 0) {
|
||||||
force = 0;
|
force = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,15 +214,13 @@ int GroundVehicle<T, Type>::GetAcceleration()
|
|||||||
uint64 breakdown_factor = (uint64)abs(resistance) * (uint64)(this->cur_speed << 16);
|
uint64 breakdown_factor = (uint64)abs(resistance) * (uint64)(this->cur_speed << 16);
|
||||||
breakdown_factor /= (max(force, (int64)100) * this->gcache.cached_max_track_speed);
|
breakdown_factor /= (max(force, (int64)100) * this->gcache.cached_max_track_speed);
|
||||||
breakdown_factor = min((64 << 16) + (breakdown_factor * 128), 255 << 16);
|
breakdown_factor = min((64 << 16) + (breakdown_factor * 128), 255 << 16);
|
||||||
if ( Type == VEH_TRAIN && Train::From(this)->tcache.cached_num_engines > 1) {
|
if (Type == VEH_TRAIN && Train::From(this)->tcache.cached_num_engines > 1) {
|
||||||
/* For multiengine trains, breakdown chance is multiplied by 3 / (num_engines + 2) */
|
/* For multiengine trains, breakdown chance is multiplied by 3 / (num_engines + 2) */
|
||||||
breakdown_factor *= 3;
|
breakdown_factor *= 3;
|
||||||
breakdown_factor /= (Train::From(this)->tcache.cached_num_engines + 2);
|
breakdown_factor /= (Train::From(this)->tcache.cached_num_engines + 2);
|
||||||
}
|
}
|
||||||
/* breakdown_chance is at least 5 (5 / 128 = ~4% of the normal chance) */
|
/* breakdown_chance is at least 5 (5 / 128 = ~4% of the normal chance) */
|
||||||
this->breakdown_chance = max(breakdown_factor >> 16, (uint64)5);
|
this->breakdown_chance_factor = max(breakdown_factor >> 16, (uint64)5);
|
||||||
} else {
|
|
||||||
this->breakdown_chance = 128;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mode == AS_ACCEL) {
|
if (mode == AS_ACCEL) {
|
||||||
@@ -236,9 +234,9 @@ int GroundVehicle<T, Type>::GetAcceleration()
|
|||||||
* same (maximum) speed. */
|
* same (maximum) speed. */
|
||||||
int accel = ClampToI32((force - resistance) / (mass * 4));
|
int accel = ClampToI32((force - resistance) / (mass * 4));
|
||||||
accel = force < resistance ? min(-1, accel) : max(1, accel);
|
accel = force < resistance ? min(-1, accel) : max(1, accel);
|
||||||
if (this->type == VEH_TRAIN ) {
|
if (this->type == VEH_TRAIN) {
|
||||||
if(_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL &&
|
if(_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL &&
|
||||||
HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER)) {
|
HasBit(Train::From(this)->flags, VRF_BREAKDOWN_POWER)) {
|
||||||
/* We need to apply the power reducation for non-realistic acceleration here */
|
/* We need to apply the power reducation for non-realistic acceleration here */
|
||||||
uint32 power;
|
uint32 power;
|
||||||
CalculatePower(power, max_te, true);
|
CalculatePower(power, max_te, true);
|
||||||
@@ -246,11 +244,10 @@ int GroundVehicle<T, Type>::GetAcceleration()
|
|||||||
accel -= this->acceleration >> 1;
|
accel -= this->acceleration >> 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->IsFrontEngine() && !(this->current_order_time & 0x1FF) &&
|
||||||
if ( this->IsFrontEngine() && !(this->current_order_time & 0x1FF) &&
|
!(this->current_order.IsType(OT_LOADING)) &&
|
||||||
!(this->current_order.IsType(OT_LOADING)) &&
|
!(Train::From(this)->flags & (VRF_IS_BROKEN | (1 << VRF_TRAIN_STUCK))) &&
|
||||||
!(Train::From(this)->flags & (VRF_IS_BROKEN | (1 << VRF_TRAIN_STUCK))) &&
|
this->cur_speed < 3 && accel < 5) {
|
||||||
this->cur_speed < 3 && accel < 5) {
|
|
||||||
SetBit(Train::From(this)->flags, VRF_TOO_HEAVY);
|
SetBit(Train::From(this)->flags, VRF_TOO_HEAVY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -370,22 +370,24 @@ protected:
|
|||||||
uint spd = this->subspeed + accel;
|
uint spd = this->subspeed + accel;
|
||||||
this->subspeed = (byte)spd;
|
this->subspeed = (byte)spd;
|
||||||
|
|
||||||
|
int tempmax = max_speed;
|
||||||
|
|
||||||
/* When we are going faster than the maximum speed, reduce the speed
|
/* When we are going faster than the maximum speed, reduce the speed
|
||||||
* somewhat gradually. But never lower than the maximum speed. */
|
* somewhat gradually. But never lower than the maximum speed. */
|
||||||
int tempmax = ((this->breakdown_ctr == 1) ? this->cur_speed : max_speed);
|
|
||||||
|
|
||||||
if (this->breakdown_ctr == 1) {
|
if (this->breakdown_ctr == 1) {
|
||||||
if (this->breakdown_type == BREAKDOWN_LOW_POWER) {
|
if (this->breakdown_type == BREAKDOWN_LOW_POWER) {
|
||||||
if((this->tick_counter & 0x7) == 0) {
|
if ((this->tick_counter & 0x7) == 0 && _settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) {
|
||||||
if(this->cur_speed > (this->breakdown_severity * max_speed) >> 8) {
|
if (this->cur_speed > (this->breakdown_severity * max_speed) >> 8) {
|
||||||
tempmax = this->cur_speed - (this->cur_speed / 10) - 1;
|
tempmax = this->cur_speed - (this->cur_speed / 10) - 1;
|
||||||
} else {
|
} else {
|
||||||
tempmax = (this->breakdown_severity * max_speed) >> 8;
|
tempmax = (this->breakdown_severity * max_speed) >> 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (this->breakdown_type == BREAKDOWN_LOW_SPEED) {
|
||||||
if(this->breakdown_type == BREAKDOWN_LOW_SPEED)
|
|
||||||
tempmax = min(max_speed, this->breakdown_severity);
|
tempmax = min(max_speed, this->breakdown_severity);
|
||||||
|
} else {
|
||||||
|
tempmax = this->cur_speed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this->cur_speed > max_speed) {
|
if (this->cur_speed > max_speed) {
|
||||||
|
@@ -4089,7 +4089,8 @@ STR_VEHICLE_STATUS_LEAVING :{LTBLUE}Leaving
|
|||||||
STR_VEHICLE_STATUS_CRASHED :{RED}Crashed!
|
STR_VEHICLE_STATUS_CRASHED :{RED}Crashed!
|
||||||
STR_VEHICLE_STATUS_BROKEN_DOWN :{RED}Broken down
|
STR_VEHICLE_STATUS_BROKEN_DOWN :{RED}Broken down
|
||||||
STR_VEHICLE_STATUS_STOPPED :{RED}Stopped
|
STR_VEHICLE_STATUS_STOPPED :{RED}Stopped
|
||||||
STR_VEHICLE_STATUS_BROKEN_DOWN_VEL :{RED}Broken down - {STRING1}, {LTBLUE} {VELOCITY}
|
STR_VEHICLE_STATUS_BROKEN_DOWN_VEL :{RED}Broken down - {STRING2}, {LTBLUE} {VELOCITY}
|
||||||
|
STR_VEHICLE_STATUS_BROKEN_DOWN_VEL_SHORT :{RED}Broken down - {STRING2}
|
||||||
STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL :{RED}Stopping, {VELOCITY}
|
STR_VEHICLE_STATUS_TRAIN_STOPPING_VEL :{RED}Stopping, {VELOCITY}
|
||||||
STR_VEHICLE_STATUS_TRAIN_NO_POWER :{RED}No power
|
STR_VEHICLE_STATUS_TRAIN_NO_POWER :{RED}No power
|
||||||
STR_VEHICLE_STATUS_TRAIN_STUCK :{ORANGE}Waiting for free path
|
STR_VEHICLE_STATUS_TRAIN_STUCK :{ORANGE}Waiting for free path
|
||||||
@@ -4128,7 +4129,7 @@ STR_VEHICLE_INFO_AGE_RUNNING_COST_YR :{BLACK}Age: {LT
|
|||||||
|
|
||||||
STR_RUNNING :{LTBLUE}Running
|
STR_RUNNING :{LTBLUE}Running
|
||||||
STR_NEED_REPAIR :{ORANGE}Train needs repair - max speed reduced to {VELOCITY}
|
STR_NEED_REPAIR :{ORANGE}Train needs repair - max speed reduced to {VELOCITY}
|
||||||
STR_CURRENT_STATUS :{BLACK}Current status: {STRING2}
|
STR_CURRENT_STATUS :{BLACK}Current status: {STRING3}
|
||||||
|
|
||||||
# The next two need to stay in this order
|
# The next two need to stay in this order
|
||||||
STR_VEHICLE_INFO_AGE :{COMMA} year{P "" s} ({COMMA})
|
STR_VEHICLE_INFO_AGE :{COMMA} year{P "" s} ({COMMA})
|
||||||
|
@@ -299,7 +299,7 @@ CommandCost CmdBuildRoadVehicle(TileIndex tile, DoCommandFlag flags, const Engin
|
|||||||
|
|
||||||
v->reliability = e->reliability;
|
v->reliability = e->reliability;
|
||||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||||
v->breakdown_chance = 128;
|
v->breakdown_chance_factor = 128;
|
||||||
v->max_age = e->GetLifeLengthInDays();
|
v->max_age = e->GetLifeLengthInDays();
|
||||||
_new_vehicle_id = v->index;
|
_new_vehicle_id = v->index;
|
||||||
|
|
||||||
|
@@ -2898,31 +2898,34 @@ bool AfterLoadGame()
|
|||||||
|
|
||||||
/* Set some breakdown-related variables to the correct values. */
|
/* Set some breakdown-related variables to the correct values. */
|
||||||
if (SlXvIsFeatureMissing(XSLFI_IMPROVED_BREAKDOWNS)) {
|
if (SlXvIsFeatureMissing(XSLFI_IMPROVED_BREAKDOWNS)) {
|
||||||
|
Train *v;
|
||||||
|
FOR_ALL_TRAINS(v) {
|
||||||
|
if (v->IsFrontEngine()) {
|
||||||
|
if (v->breakdown_ctr == 1) SetBit(v->flags, VRF_BREAKDOWN_STOPPED);
|
||||||
|
} else if (v->IsEngine() || v->IsMultiheaded()) {
|
||||||
|
/** Non-front engines could have a reliability of 0.
|
||||||
|
* Set it to the reliability of the front engine or the maximum, whichever is lower. */
|
||||||
|
const Engine *e = Engine::Get(v->engine_type);
|
||||||
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||||
|
v->reliability = min(v->First()->reliability, e->reliability);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!SlXvIsFeaturePresent(XSLFI_IMPROVED_BREAKDOWNS, 3)) {
|
||||||
Vehicle *v;
|
Vehicle *v;
|
||||||
FOR_ALL_VEHICLES(v) {
|
FOR_ALL_VEHICLES(v) {
|
||||||
switch(v->type) {
|
switch(v->type) {
|
||||||
case VEH_TRAIN: {
|
case VEH_TRAIN:
|
||||||
if (Train::From(v)->IsFrontEngine()) {
|
|
||||||
if (v->breakdown_ctr == 1) SetBit(Train::From(v)->flags, VRF_BREAKDOWN_STOPPED);
|
|
||||||
} else if (Train::From(v)->IsEngine() || Train::From(v)->IsMultiheaded()) {
|
|
||||||
/** Non-front engines could have a reliability of 0.
|
|
||||||
* Set it to the reliability of the front engine or the maximum, whichever is lower. */
|
|
||||||
const Engine *e = Engine::Get(v->engine_type);
|
|
||||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
|
||||||
v->reliability = min(v->First()->reliability, e->reliability);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* FALL THROUGH */
|
|
||||||
case VEH_ROAD:
|
case VEH_ROAD:
|
||||||
v->breakdown_chance = 128;
|
v->breakdown_chance_factor = 128;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_SHIP:
|
case VEH_SHIP:
|
||||||
v->breakdown_chance = 64;
|
v->breakdown_chance_factor = 64;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case VEH_AIRCRAFT:
|
case VEH_AIRCRAFT:
|
||||||
v->breakdown_chance = Clamp(64 + (AircraftVehInfo(v->engine_type)->max_speed >> 3), 0, 255);
|
v->breakdown_chance_factor = Clamp(64 + (AircraftVehInfo(v->engine_type)->max_speed >> 3), 0, 255);
|
||||||
v->breakdown_severity = 40;
|
v->breakdown_severity = 40;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -55,7 +55,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = {
|
|||||||
{ XSLFI_TIMETABLES_START_TICKS, XSCF_NULL, 1, 1, "timetable_start_ticks", NULL, NULL, NULL },
|
{ XSLFI_TIMETABLES_START_TICKS, XSCF_NULL, 1, 1, "timetable_start_ticks", NULL, NULL, NULL },
|
||||||
{ XSLFI_TOWN_CARGO_ADJ, XSCF_IGNORABLE_UNKNOWN, 1, 1, "town_cargo_adj", NULL, NULL, NULL },
|
{ XSLFI_TOWN_CARGO_ADJ, XSCF_IGNORABLE_UNKNOWN, 1, 1, "town_cargo_adj", NULL, NULL, NULL },
|
||||||
{ XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 1, 1, "signal_tunnel_bridge", NULL, NULL, NULL },
|
{ XSLFI_SIG_TUNNEL_BRIDGE, XSCF_NULL, 1, 1, "signal_tunnel_bridge", NULL, NULL, NULL },
|
||||||
{ XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 2, 2, "improved_breakdowns", NULL, NULL, NULL },
|
{ XSLFI_IMPROVED_BREAKDOWNS, XSCF_NULL, 3, 3, "improved_breakdowns", NULL, NULL, NULL },
|
||||||
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL },
|
{ XSLFI_TT_WAIT_IN_DEPOT, XSCF_NULL, 1, 1, "tt_wait_in_depot", NULL, NULL, NULL },
|
||||||
{ XSLFI_AUTO_TIMETABLE, XSCF_NULL, 3, 3, "auto_timetables", NULL, NULL, NULL },
|
{ XSLFI_AUTO_TIMETABLE, XSCF_NULL, 3, 3, "auto_timetables", NULL, NULL, NULL },
|
||||||
{ XSLFI_VEHICLE_REPAIR_COST, XSCF_NULL, 1, 1, "vehicle_repair_cost", NULL, NULL, NULL },
|
{ XSLFI_VEHICLE_REPAIR_COST, XSCF_NULL, 1, 1, "vehicle_repair_cost", NULL, NULL, NULL },
|
||||||
|
@@ -692,6 +692,7 @@ const SaveLoad *GetVehicleDescription(VehicleType vt)
|
|||||||
SLE_VAR(Vehicle, breakdown_delay, SLE_UINT8),
|
SLE_VAR(Vehicle, breakdown_delay, SLE_UINT8),
|
||||||
SLE_VAR(Vehicle, breakdowns_since_last_service, SLE_UINT8),
|
SLE_VAR(Vehicle, breakdowns_since_last_service, SLE_UINT8),
|
||||||
SLE_VAR(Vehicle, breakdown_chance, SLE_UINT8),
|
SLE_VAR(Vehicle, breakdown_chance, SLE_UINT8),
|
||||||
|
SLE_CONDVAR_X(Vehicle, breakdown_chance_factor, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_IMPROVED_BREAKDOWNS, 3)),
|
||||||
SLE_CONDVAR_X(Vehicle, breakdown_type, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_IMPROVED_BREAKDOWNS)),
|
SLE_CONDVAR_X(Vehicle, breakdown_type, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_IMPROVED_BREAKDOWNS)),
|
||||||
SLE_CONDVAR_X(Vehicle, breakdown_severity, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_IMPROVED_BREAKDOWNS)),
|
SLE_CONDVAR_X(Vehicle, breakdown_severity, SLE_UINT8, 0, SL_MAX_VERSION, SlXvFeatureTest(XSLFTO_AND, XSLFI_IMPROVED_BREAKDOWNS)),
|
||||||
SLE_CONDVAR(Vehicle, build_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
|
SLE_CONDVAR(Vehicle, build_year, SLE_FILE_U8 | SLE_VAR_I32, 0, 30),
|
||||||
|
@@ -1026,7 +1026,7 @@ static bool RoadVehAccelerationModelChanged(int32 p1)
|
|||||||
RoadVehicle *rv;
|
RoadVehicle *rv;
|
||||||
FOR_ALL_ROADVEHICLES(rv) {
|
FOR_ALL_ROADVEHICLES(rv) {
|
||||||
if (rv->IsFrontEngine()) {
|
if (rv->IsFrontEngine()) {
|
||||||
rv->breakdown_chance = 128;
|
rv->breakdown_chance_factor = 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1349,6 +1349,33 @@ static bool MaxVehiclesChanged(int32 p1)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool ImprovedBreakdownsSettingChanged(int32 p1)
|
||||||
|
{
|
||||||
|
if (!_settings_game.vehicle.improved_breakdowns) return true;
|
||||||
|
|
||||||
|
Vehicle *v;
|
||||||
|
FOR_ALL_VEHICLES(v) {
|
||||||
|
switch(v->type) {
|
||||||
|
case VEH_TRAIN:
|
||||||
|
if (v->IsFrontEngine()) {
|
||||||
|
v->breakdown_chance_factor = 128;
|
||||||
|
Train::From(v)->UpdateAcceleration();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case VEH_ROAD:
|
||||||
|
if (v->IsFrontEngine()) {
|
||||||
|
v->breakdown_chance_factor = 128;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
|
|
||||||
static bool UpdateClientName(int32 p1)
|
static bool UpdateClientName(int32 p1)
|
||||||
|
@@ -390,15 +390,15 @@ static bool ShipAccelerate(Vehicle *v)
|
|||||||
spd = min(v->cur_speed + 1, v->vcache.cached_max_speed);
|
spd = min(v->cur_speed + 1, v->vcache.cached_max_speed);
|
||||||
spd = min(spd, v->current_order.GetMaxSpeed() * 2);
|
spd = min(spd, v->current_order.GetMaxSpeed() * 2);
|
||||||
|
|
||||||
if(v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_LOW_POWER && v->cur_speed > (v->breakdown_severity * ShipVehInfo(v->engine_type)->max_speed) >> 8) {
|
if (v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_LOW_POWER && v->cur_speed > (v->breakdown_severity * ShipVehInfo(v->engine_type)->max_speed) >> 8) {
|
||||||
if((v->tick_counter & 0x7) == 0 && v->cur_speed > 0) {
|
if ((v->tick_counter & 0x7) == 0 && v->cur_speed > 0) {
|
||||||
spd = v->cur_speed - 1;
|
spd = v->cur_speed - 1;
|
||||||
} else {
|
} else {
|
||||||
spd = v->cur_speed;
|
spd = v->cur_speed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_LOW_SPEED) {
|
if (v->breakdown_ctr == 1 && v->breakdown_type == BREAKDOWN_LOW_SPEED) {
|
||||||
spd = min(spd, v->breakdown_severity);
|
spd = min(spd, v->breakdown_severity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -759,7 +759,7 @@ CommandCost CmdBuildShip(TileIndex tile, DoCommandFlag flags, const Engine *e, u
|
|||||||
|
|
||||||
v->reliability = e->reliability;
|
v->reliability = e->reliability;
|
||||||
v->reliability_spd_dec = e->reliability_spd_dec;
|
v->reliability_spd_dec = e->reliability_spd_dec;
|
||||||
v->breakdown_chance = 64; // ships have a 50% lower breakdown chance than normal
|
v->breakdown_chance_factor = 64; // ships have a 50% lower breakdown chance than normal
|
||||||
v->max_age = e->GetLifeLengthInDays();
|
v->max_age = e->GetLifeLengthInDays();
|
||||||
_new_vehicle_id = v->index;
|
_new_vehicle_id = v->index;
|
||||||
|
|
||||||
|
@@ -42,6 +42,7 @@ static bool InvalidateCompanyInfrastructureWindow(int32 p1);
|
|||||||
static bool InvalidateCompanyWindow(int32 p1);
|
static bool InvalidateCompanyWindow(int32 p1);
|
||||||
static bool ZoomMinMaxChanged(int32 p1);
|
static bool ZoomMinMaxChanged(int32 p1);
|
||||||
static bool MaxVehiclesChanged(int32 p1);
|
static bool MaxVehiclesChanged(int32 p1);
|
||||||
|
static bool ImprovedBreakdownsSettingChanged(int32 p1);
|
||||||
|
|
||||||
#ifdef ENABLE_NETWORK
|
#ifdef ENABLE_NETWORK
|
||||||
static bool UpdateClientName(int32 p1);
|
static bool UpdateClientName(int32 p1);
|
||||||
@@ -1276,6 +1277,7 @@ var = vehicle.improved_breakdowns
|
|||||||
guiflags = SGF_NO_NETWORK
|
guiflags = SGF_NO_NETWORK
|
||||||
def = false
|
def = false
|
||||||
str = STR_CONFIG_SETTING_IMPROVED_BREAKDOWNS
|
str = STR_CONFIG_SETTING_IMPROVED_BREAKDOWNS
|
||||||
|
proc = ImprovedBreakdownsSettingChanged
|
||||||
patxname = ""improved_breakdowns.vehicle.improved_breakdowns""
|
patxname = ""improved_breakdowns.vehicle.improved_breakdowns""
|
||||||
|
|
||||||
[SDT_BOOL]
|
[SDT_BOOL]
|
||||||
|
@@ -296,7 +296,7 @@ protected: // These functions should not be called outside acceleration code.
|
|||||||
*/
|
*/
|
||||||
inline AccelStatus GetAccelerationStatus() const
|
inline AccelStatus GetAccelerationStatus() const
|
||||||
{
|
{
|
||||||
return (this->vehstatus & VS_STOPPED) || HasBit(this->flags, VRF_REVERSING) || HasBit(this->flags, VRF_TRAIN_STUCK ) || HasBit(this->flags, VRF_BREAKDOWN_BRAKING) ? AS_BRAKE : AS_ACCEL;
|
return ((this->vehstatus & VS_STOPPED) || HasBit(this->flags, VRF_REVERSING) || HasBit(this->flags, VRF_TRAIN_STUCK) || HasBit(this->flags, VRF_BREAKDOWN_BRAKING)) ? AS_BRAKE : AS_ACCEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -132,7 +132,7 @@ void CheckTrainsLengths()
|
|||||||
void CheckBreakdownFlags(Train *v)
|
void CheckBreakdownFlags(Train *v)
|
||||||
{
|
{
|
||||||
assert(v->IsFrontEngine());
|
assert(v->IsFrontEngine());
|
||||||
/* clear the flags we're gonna check first, we'll set them again later (if applicable ) */
|
/* clear the flags we're gonna check first, we'll set them again later (if applicable) */
|
||||||
CLRBITS(v->flags, (1 << VRF_BREAKDOWN_BRAKING) | VRF_IS_BROKEN);
|
CLRBITS(v->flags, (1 << VRF_BREAKDOWN_BRAKING) | VRF_IS_BROKEN);
|
||||||
|
|
||||||
for (const Train *w = v; w != NULL; w = w->Next()) {
|
for (const Train *w = v; w != NULL; w = w->Next()) {
|
||||||
@@ -151,6 +151,17 @@ void CheckBreakdownFlags(Train *v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16 GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, const Train *front)
|
||||||
|
{
|
||||||
|
uint16 speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed);
|
||||||
|
if (HasBit(u->flags, VRF_NEED_REPAIR) && front->IsFrontEngine()) {
|
||||||
|
for (uint i = 0; i < u->critical_breakdown_count; i++) {
|
||||||
|
speed = min(speed - (speed / (front->tcache.cached_num_engines + 2)) + 1, speed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return speed;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recalculates the cached stuff of a train. Should be called each time a vehicle is added
|
* Recalculates the cached stuff of a train. Should be called each time a vehicle is added
|
||||||
* to/removed from the chain, and when the game is loaded.
|
* to/removed from the chain, and when the game is loaded.
|
||||||
@@ -241,12 +252,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
|
|||||||
|
|
||||||
/* 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 */
|
||||||
if ((rvi_u->railveh_type != RAILVEH_WAGON || _settings_game.vehicle.wagon_speed_limits) && !UsesWagonOverride(u)) {
|
if ((rvi_u->railveh_type != RAILVEH_WAGON || _settings_game.vehicle.wagon_speed_limits) && !UsesWagonOverride(u)) {
|
||||||
uint16 speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed);
|
uint16 speed = GetTrainVehicleMaxSpeed(u, rvi_u, this);
|
||||||
if (HasBit(u->flags, VRF_NEED_REPAIR) && this->IsFrontEngine()) {
|
|
||||||
for (uint i = 0; i < u->critical_breakdown_count; i++) {
|
|
||||||
speed = min(speed - (speed / (this->tcache.cached_num_engines + 2)) + 1, speed);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (speed != 0) max_speed = min(speed, max_speed);
|
if (speed != 0) max_speed = min(speed, max_speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -495,10 +501,8 @@ void Train::UpdateAcceleration()
|
|||||||
|
|
||||||
if (_settings_game.vehicle.improved_breakdowns) {
|
if (_settings_game.vehicle.improved_breakdowns) {
|
||||||
if (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) {
|
if (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) {
|
||||||
this->breakdown_chance = max(128 * 3 / (this->tcache.cached_num_engines + 2), 5);
|
this->breakdown_chance_factor = max(128 * 3 / (this->tcache.cached_num_engines + 2), 5);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
this->breakdown_chance = 128;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4440,7 +4444,6 @@ void Train::OnNewDay()
|
|||||||
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
||||||
|
|
||||||
if (this->IsFrontEngine()) {
|
if (this->IsFrontEngine()) {
|
||||||
|
|
||||||
CheckIfTrainNeedsService(this);
|
CheckIfTrainNeedsService(this);
|
||||||
|
|
||||||
CheckOrders(this);
|
CheckOrders(this);
|
||||||
@@ -4467,7 +4470,7 @@ void Train::OnNewDay()
|
|||||||
SetWindowClassesDirty(WC_TRAINS_LIST);
|
SetWindowClassesDirty(WC_TRAINS_LIST);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(IsEngine() || IsMultiheaded()) {
|
if (IsEngine() || IsMultiheaded()) {
|
||||||
CheckVehicleBreakdown(this);
|
CheckVehicleBreakdown(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -21,6 +21,8 @@
|
|||||||
|
|
||||||
#include "safeguards.h"
|
#include "safeguards.h"
|
||||||
|
|
||||||
|
uint16 GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, const Train *front);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback for building wagons.
|
* Callback for building wagons.
|
||||||
* @param result The result of the command.
|
* @param result The result of the command.
|
||||||
@@ -254,20 +256,20 @@ static void TrainDetailsInfoTab(const Train *v, int left, int right, int y, byte
|
|||||||
case 2:
|
case 2:
|
||||||
if (v->breakdown_ctr == 1) {
|
if (v->breakdown_ctr == 1) {
|
||||||
if (_settings_game.vehicle.improved_breakdowns) {
|
if (_settings_game.vehicle.improved_breakdowns) {
|
||||||
SetDParam(0, STR_VEHICLE_STATUS_BROKEN_DOWN_VEL);
|
SetDParam(0, STR_VEHICLE_STATUS_BROKEN_DOWN_VEL_SHORT);
|
||||||
SetDParam(1, STR_BREAKDOWN_TYPE_CRITICAL + v->breakdown_type);
|
SetDParam(1, STR_BREAKDOWN_TYPE_CRITICAL + v->breakdown_type);
|
||||||
if (v->breakdown_type == BREAKDOWN_LOW_SPEED) {
|
if (v->breakdown_type == BREAKDOWN_LOW_SPEED) {
|
||||||
SetDParam(2, min( v->First()->GetCurrentMaxSpeed(), v->breakdown_severity));
|
SetDParam(2, min(v->First()->GetCurrentMaxSpeed(), v->breakdown_severity));
|
||||||
} else if (v->breakdown_type == BREAKDOWN_LOW_POWER) {
|
} else if (v->breakdown_type == BREAKDOWN_LOW_POWER) {
|
||||||
SetDParam(2, v->breakdown_severity * 100 / 256 );
|
SetDParam(2, v->breakdown_severity * 100 / 256);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SetDParam( 0, STR_VEHICLE_STATUS_BROKEN_DOWN );
|
SetDParam(0, STR_VEHICLE_STATUS_BROKEN_DOWN);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (HasBit(v->flags, VRF_NEED_REPAIR)) {
|
if (HasBit(v->flags, VRF_NEED_REPAIR)) {
|
||||||
SetDParam(0, STR_NEED_REPAIR);
|
SetDParam(0, STR_NEED_REPAIR);
|
||||||
SetDParam(1, v->vcache.cached_max_speed);
|
SetDParam(1, GetTrainVehicleMaxSpeed(v, &(v->GetEngine()->u.rail), v->First()));
|
||||||
} else {
|
} else {
|
||||||
SetDParam(0, STR_RUNNING);
|
SetDParam(0, STR_RUNNING);
|
||||||
}
|
}
|
||||||
|
@@ -160,6 +160,8 @@ void VehicleServiceInDepot(Vehicle *v)
|
|||||||
|
|
||||||
v->breakdowns_since_last_service = 0;
|
v->breakdowns_since_last_service = 0;
|
||||||
v->reliability = v->GetEngine()->reliability;
|
v->reliability = v->GetEngine()->reliability;
|
||||||
|
/* Prevent vehicles from breaking down directly after exiting the depot. */
|
||||||
|
v->breakdown_chance = 0;
|
||||||
v = v->Next();
|
v = v->Next();
|
||||||
} while (v != NULL && v->HasEngineType());
|
} while (v != NULL && v->HasEngineType());
|
||||||
}
|
}
|
||||||
@@ -181,7 +183,7 @@ bool Vehicle::NeedsServicing() const
|
|||||||
if ((this->ServiceIntervalIsPercent() ?
|
if ((this->ServiceIntervalIsPercent() ?
|
||||||
(this->reliability >= this->GetEngine()->reliability * (100 - this->service_interval) / 100) :
|
(this->reliability >= this->GetEngine()->reliability * (100 - this->service_interval) / 100) :
|
||||||
(this->date_of_last_service + this->service_interval >= _date))
|
(this->date_of_last_service + this->service_interval >= _date))
|
||||||
&& !(this->type == VEH_TRAIN && HasBit(Train::From(this)->flags ,VRF_NEED_REPAIR))) {
|
&& !(this->type == VEH_TRAIN && HasBit(Train::From(this)->flags, VRF_NEED_REPAIR))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1394,15 +1396,21 @@ void CheckVehicleBreakdown(Vehicle *v)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 r1 = Random();
|
uint32 r = Random();
|
||||||
uint32 r2 = Random();
|
|
||||||
|
/* increase chance of failure */
|
||||||
|
int chance = v->breakdown_chance + 1;
|
||||||
|
if (Chance16I(1, 25, r)) chance += 25;
|
||||||
|
chance = min(255, chance);
|
||||||
|
v->breakdown_chance = chance;
|
||||||
|
|
||||||
byte chance = 128;
|
|
||||||
if (_settings_game.vehicle.improved_breakdowns) {
|
if (_settings_game.vehicle.improved_breakdowns) {
|
||||||
/* Dual engines have their breakdown chances reduced to 70% of the normal value */
|
if (v->type == VEH_TRAIN && Train::From(v)->IsMultiheaded()) {
|
||||||
chance = (v->type == VEH_TRAIN && Train::From(v)->IsMultiheaded()) ? v->First()->breakdown_chance * 7 / 10 : v->First()->breakdown_chance;
|
/* Dual engines have their breakdown chances reduced to 70% of the normal value */
|
||||||
} else if(v->type == VEH_SHIP) {
|
chance = chance * 7 / 10;
|
||||||
chance = 64;
|
}
|
||||||
|
chance *= v->First()->breakdown_chance_factor;
|
||||||
|
chance >>= 7;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Chance is (1 - reliability) * breakdown_setting * breakdown_chance / 10.
|
* Chance is (1 - reliability) * breakdown_setting * breakdown_chance / 10.
|
||||||
@@ -1412,9 +1420,12 @@ void CheckVehicleBreakdown(Vehicle *v)
|
|||||||
* However, because breakdowns are no longer by definition a complete stop,
|
* However, because breakdowns are no longer by definition a complete stop,
|
||||||
* their impact will be significantly less.
|
* their impact will be significantly less.
|
||||||
*/
|
*/
|
||||||
|
uint32 r1 = Random();
|
||||||
if ((uint32) (0xffff - v->reliability) * _settings_game.difficulty.vehicle_breakdowns * chance > GB(r1, 0, 24) * 10) {
|
if ((uint32) (0xffff - v->reliability) * _settings_game.difficulty.vehicle_breakdowns * chance > GB(r1, 0, 24) * 10) {
|
||||||
|
uint32 r2 = Random();
|
||||||
v->breakdown_ctr = GB(r1, 24, 6) + 0xF;
|
v->breakdown_ctr = GB(r1, 24, 6) + 0xF;
|
||||||
v->breakdown_delay = GB(r2, 0, 7) + 0x80;
|
v->breakdown_delay = GB(r2, 0, 7) + 0x80;
|
||||||
|
v->breakdown_chance = 0;
|
||||||
DetermineBreakdownType(v, r2);
|
DetermineBreakdownType(v, r2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1547,7 +1558,7 @@ bool Vehicle::HandleBreakdown()
|
|||||||
if ((this->tick_counter & (this->type == VEH_TRAIN ? 3 : 1)) == 0) {
|
if ((this->tick_counter & (this->type == VEH_TRAIN ? 3 : 1)) == 0) {
|
||||||
if (--this->breakdown_delay == 0) {
|
if (--this->breakdown_delay == 0) {
|
||||||
this->breakdown_ctr = 0;
|
this->breakdown_ctr = 0;
|
||||||
if(this->type == VEH_TRAIN) {
|
if (this->type == VEH_TRAIN) {
|
||||||
CheckBreakdownFlags(Train::From(this->First()));
|
CheckBreakdownFlags(Train::From(this->First()));
|
||||||
this->First()->MarkDirty();
|
this->First()->MarkDirty();
|
||||||
SetWindowDirty(WC_VEHICLE_VIEW, this->First()->index);
|
SetWindowDirty(WC_VEHICLE_VIEW, this->First()->index);
|
||||||
|
@@ -210,6 +210,7 @@ public:
|
|||||||
|
|
||||||
byte breakdown_severity; ///< severity of the breakdown. Note that lower means more severe
|
byte breakdown_severity; ///< severity of the breakdown. Note that lower means more severe
|
||||||
byte breakdown_type; ///< Type of breakdown
|
byte breakdown_type; ///< Type of breakdown
|
||||||
|
byte breakdown_chance_factor; ///< Improved breakdowns: current multiplier for breakdown_chance * 128, used for head vehicle only
|
||||||
SpriteID colourmap; ///< NOSAVE: cached colour mapping
|
SpriteID colourmap; ///< NOSAVE: cached colour mapping
|
||||||
|
|
||||||
/* Related to age and service time */
|
/* Related to age and service time */
|
||||||
|
@@ -2840,7 +2840,7 @@ public:
|
|||||||
} else if (v->breakdown_ctr == 1 || (v->type == VEH_TRAIN && Train::From(v)->flags & VRF_IS_BROKEN)) {
|
} else if (v->breakdown_ctr == 1 || (v->type == VEH_TRAIN && Train::From(v)->flags & VRF_IS_BROKEN)) {
|
||||||
if (_settings_game.vehicle.improved_breakdowns) {
|
if (_settings_game.vehicle.improved_breakdowns) {
|
||||||
str = STR_VEHICLE_STATUS_BROKEN_DOWN_VEL;
|
str = STR_VEHICLE_STATUS_BROKEN_DOWN_VEL;
|
||||||
SetDParam(2, v->GetDisplaySpeed());
|
SetDParam(3, v->GetDisplaySpeed());
|
||||||
} else {
|
} else {
|
||||||
str = STR_VEHICLE_STATUS_BROKEN_DOWN;
|
str = STR_VEHICLE_STATUS_BROKEN_DOWN;
|
||||||
}
|
}
|
||||||
@@ -2857,9 +2857,17 @@ public:
|
|||||||
SetDParam(0, STR_BREAKDOWN_TYPE_CRITICAL + w->breakdown_type);
|
SetDParam(0, STR_BREAKDOWN_TYPE_CRITICAL + w->breakdown_type);
|
||||||
|
|
||||||
if (w->breakdown_type == BREAKDOWN_LOW_SPEED) {
|
if (w->breakdown_type == BREAKDOWN_LOW_SPEED) {
|
||||||
SetDParam(1, min( w->First()->GetDisplayMaxSpeed(), w->breakdown_severity >> ((v->type == VEH_TRAIN) ? 0 : 1)));
|
SetDParam(1, min(w->First()->GetDisplayMaxSpeed(), w->breakdown_severity >> ((v->type == VEH_TRAIN) ? 0 : 1)));
|
||||||
} else if (w->breakdown_type == BREAKDOWN_LOW_POWER) {
|
} else if (w->breakdown_type == BREAKDOWN_LOW_POWER) {
|
||||||
SetDParam(1, w->breakdown_severity * 100 / 256);
|
int percent;
|
||||||
|
if (v->type == VEH_TRAIN) {
|
||||||
|
uint32 power, te;
|
||||||
|
Train::From(v)->CalculatePower(power, te, true);
|
||||||
|
percent = (100 * power) / Train::From(v)->gcache.cached_power;
|
||||||
|
} else {
|
||||||
|
percent = w->breakdown_severity * 100 / 256;
|
||||||
|
}
|
||||||
|
SetDParam(1, percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (v->vehstatus & VS_STOPPED) {
|
} else if (v->vehstatus & VS_STOPPED) {
|
||||||
|
Reference in New Issue
Block a user