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