Merge branch 'improved_breakdowns' into jgrpp
This commit is contained in:
@@ -1306,8 +1306,7 @@ static const byte _breakdown_chances[4][4] = {
|
||||
* @param v the vehicle in question.
|
||||
* @param r the random number to use. (Note that bits 0..6 are already used)
|
||||
*/
|
||||
void
|
||||
DetermineBreakdownType( Vehicle *v, uint32 r ) {
|
||||
void DetermineBreakdownType(Vehicle *v, uint32 r) {
|
||||
/* if 'improved breakdowns' is off, just do the classic breakdown */
|
||||
if (!_settings_game.vehicle.improved_breakdowns) {
|
||||
v->breakdown_type = BREAKDOWN_CRITICAL;
|
||||
@@ -1454,7 +1453,6 @@ bool Vehicle::HandleBreakdown()
|
||||
(this->current_order.GetDepotOrderType() & ODTFB_BREAKDOWN) &&
|
||||
GetTargetAirportIfValid(Aircraft::From(this)) != NULL)) return false;
|
||||
FindBreakdownDestination(Aircraft::From(this));
|
||||
|
||||
} else if (this->type == VEH_TRAIN) {
|
||||
if (this->breakdown_type == BREAKDOWN_LOW_POWER ||
|
||||
this->First()->cur_speed <= ((this->breakdown_type == BREAKDOWN_LOW_SPEED) ? this->breakdown_severity : 0)) {
|
||||
@@ -1466,7 +1464,7 @@ bool Vehicle::HandleBreakdown()
|
||||
(train_or_ship ? SND_10_TRAIN_BREAKDOWN : SND_0F_VEHICLE_BREAKDOWN) :
|
||||
(train_or_ship ? SND_3A_COMEDY_BREAKDOWN_2 : SND_35_COMEDY_BREAKDOWN), this);
|
||||
}
|
||||
if (!(this->vehstatus & VS_HIDDEN)) {
|
||||
if (!(this->vehstatus & VS_HIDDEN) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_NO_BREAKDOWN_SMOKE) && this->breakdown_delay > 0) {
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 4, 4, 5, EV_BREAKDOWN_SMOKE);
|
||||
if (u != NULL) u->animation_state = this->breakdown_delay * 2;
|
||||
}
|
||||
@@ -1478,10 +1476,8 @@ bool Vehicle::HandleBreakdown()
|
||||
if (rvi->max_speed > this->vcache.cached_max_speed)
|
||||
this->vcache.cached_max_speed = rvi->max_speed;
|
||||
}
|
||||
this->vcache.cached_max_speed =
|
||||
min(
|
||||
this->vcache.cached_max_speed - (this->vcache.cached_max_speed >> 1) / Train::From(this->First())->tcache.cached_num_engines + 1,
|
||||
this->vcache.cached_max_speed);
|
||||
this->vcache.cached_max_speed = min(this->vcache.cached_max_speed -
|
||||
(this->vcache.cached_max_speed >> 1) / Train::From(this->First())->tcache.cached_num_engines + 1, this->vcache.cached_max_speed);
|
||||
SetBit(Train::From(this)->flags, VRF_NEED_REPAIR);
|
||||
Train::From(this->First())->ConsistChanged(CCF_TRACK);
|
||||
}
|
||||
@@ -1499,7 +1495,6 @@ bool Vehicle::HandleBreakdown()
|
||||
break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
|
||||
this->First()->MarkDirty();
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, this->index);
|
||||
SetWindowDirty(WC_VEHICLE_DETAILS, this->index);
|
||||
@@ -1509,8 +1504,10 @@ bool Vehicle::HandleBreakdown()
|
||||
SetBit(Train::From(this)->flags, VRF_BREAKDOWN_BRAKING);
|
||||
return false;
|
||||
}
|
||||
if ( ( !( this->vehstatus & VS_HIDDEN ) ) && ( ( this->breakdown_type == BREAKDOWN_LOW_SPEED || this->breakdown_type == BREAKDOWN_LOW_POWER ) && ( this->tick_counter & 0x1F ) == 0 ) ) {
|
||||
CreateEffectVehicleRel( this, 0, 0, 2, EV_BREAKDOWN_SMOKE ); //some grey clouds to indicate a broken engine
|
||||
if ((!(this->vehstatus & VS_HIDDEN)) && (this->breakdown_type == BREAKDOWN_LOW_SPEED || this->breakdown_type == BREAKDOWN_LOW_POWER)
|
||||
&& !HasBit(EngInfo(this->engine_type)->misc_flags, EF_NO_BREAKDOWN_SMOKE)) {
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 0, 0, 2, EV_BREAKDOWN_SMOKE); //some grey clouds to indicate a broken engine
|
||||
if (u != NULL) u->animation_state = 25;
|
||||
}
|
||||
} else {
|
||||
switch (this->breakdown_type) {
|
||||
@@ -1518,7 +1515,7 @@ bool Vehicle::HandleBreakdown()
|
||||
if (!PlayVehicleSound(this, VSE_BREAKDOWN)) {
|
||||
SndPlayVehicleFx((_settings_game.game_creation.landscape != LT_TOYLAND) ? SND_0F_VEHICLE_BREAKDOWN : SND_35_COMEDY_BREAKDOWN, this);
|
||||
}
|
||||
if (!(this->vehstatus & VS_HIDDEN)) {
|
||||
if (!(this->vehstatus & VS_HIDDEN) && !HasBit(EngInfo(this->engine_type)->misc_flags, EF_NO_BREAKDOWN_SMOKE) && this->breakdown_delay > 0) {
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 4, 4, 5, EV_BREAKDOWN_SMOKE);
|
||||
if (u != NULL) u->animation_state = this->breakdown_delay * 2;
|
||||
}
|
||||
@@ -1532,11 +1529,11 @@ bool Vehicle::HandleBreakdown()
|
||||
break;
|
||||
default: NOT_REACHED();
|
||||
}
|
||||
if ( ( !( this->vehstatus & VS_HIDDEN ) ) && (
|
||||
( this->breakdown_type == BREAKDOWN_LOW_SPEED || this->breakdown_type == BREAKDOWN_LOW_POWER ) &&
|
||||
( this->tick_counter & 0x1F ) == 0 ) ) {
|
||||
if ((!(this->vehstatus & VS_HIDDEN)) &&
|
||||
(this->breakdown_type == BREAKDOWN_LOW_SPEED || this->breakdown_type == BREAKDOWN_LOW_POWER)) {
|
||||
/* Some gray clouds to indicate a broken RV */
|
||||
CreateEffectVehicleRel( this, 0, 0, 2, EV_BREAKDOWN_SMOKE );
|
||||
EffectVehicle *u = CreateEffectVehicleRel(this, 0, 0, 2, EV_BREAKDOWN_SMOKE);
|
||||
if (u != NULL) u->animation_state = 25;
|
||||
}
|
||||
this->First()->MarkDirty();
|
||||
SetWindowDirty(WC_VEHICLE_VIEW, this->index);
|
||||
|
Reference in New Issue
Block a user