Fix some more whitespace/formatting issues.

pull/6/merge
Jonathan G Rennison 8 years ago
parent 5e924262f4
commit 9742300a1e

@ -171,8 +171,7 @@ int GroundVehicle<T, Type>::GetAcceleration()
AccelStatus mode = v->GetAccelerationStatus();
/* handle breakdown power reduction */
//TODO
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 */
uint32 power_temp;
this->CalculatePower(power_temp, max_te, true);
@ -198,7 +197,7 @@ int GroundVehicle<T, Type>::GetAcceleration()
}
/* 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;
}
@ -214,7 +213,7 @@ int GroundVehicle<T, Type>::GetAcceleration()
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 = 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) */
breakdown_factor *= 3;
breakdown_factor /= (Train::From(this)->tcache.cached_num_engines + 2);
@ -238,7 +237,7 @@ int GroundVehicle<T, Type>::GetAcceleration()
accel = force < resistance ? min(-1, accel) : max(1, accel);
if (this->type == VEH_TRAIN ) {
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 */
uint32 power;
CalculatePower(power, max_te, true);
@ -246,11 +245,10 @@ int GroundVehicle<T, Type>::GetAcceleration()
accel -= this->acceleration >> 1;
}
if ( this->IsFrontEngine() && !(this->current_order_time & 0x1FF) &&
!(this->current_order.IsType(OT_LOADING)) &&
!(Train::From(this)->flags & (VRF_IS_BROKEN | (1 << VRF_TRAIN_STUCK))) &&
this->cur_speed < 3 && accel < 5) {
if (this->IsFrontEngine() && !(this->current_order_time & 0x1FF) &&
!(this->current_order.IsType(OT_LOADING)) &&
!(Train::From(this)->flags & (VRF_IS_BROKEN | (1 << VRF_TRAIN_STUCK))) &&
this->cur_speed < 3 && accel < 5) {
SetBit(Train::From(this)->flags, VRF_TOO_HEAVY);
}
}

@ -376,16 +376,17 @@ protected:
if (this->breakdown_ctr == 1) {
if (this->breakdown_type == BREAKDOWN_LOW_POWER) {
if((this->tick_counter & 0x7) == 0) {
if(this->cur_speed > (this->breakdown_severity * max_speed) >> 8) {
if ((this->tick_counter & 0x7) == 0) {
if (this->cur_speed > (this->breakdown_severity * max_speed) >> 8) {
tempmax = this->cur_speed - (this->cur_speed / 10) - 1;
} else {
tempmax = (this->breakdown_severity * max_speed) >> 8;
}
}
}
if(this->breakdown_type == BREAKDOWN_LOW_SPEED)
if (this->breakdown_type == BREAKDOWN_LOW_SPEED) {
tempmax = min(max_speed, this->breakdown_severity);
}
}
if (this->cur_speed > max_speed) {

@ -382,15 +382,15 @@ static bool ShipAccelerate(Vehicle *v)
spd = min(v->cur_speed + 1, v->vcache.cached_max_speed);
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->tick_counter & 0x7) == 0 && v->cur_speed > 0) {
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) {
spd = v->cur_speed - 1;
} else {
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);
}

@ -4079,7 +4079,7 @@ void Train::OnNewDay()
SetWindowClassesDirty(WC_TRAINS_LIST);
}
}
if(IsEngine() || IsMultiheaded()) {
if (IsEngine() || IsMultiheaded()) {
CheckVehicleBreakdown(this);
}
}

@ -1430,7 +1430,7 @@ bool Vehicle::HandleBreakdown()
if ((this->tick_counter & (this->type == VEH_TRAIN ? 3 : 1)) == 0) {
if (--this->breakdown_delay == 0) {
this->breakdown_ctr = 0;
if(this->type == VEH_TRAIN) {
if (this->type == VEH_TRAIN) {
CheckBreakdownFlags(Train::From(this->First()));
this->First()->MarkDirty();
SetWindowDirty(WC_VEHICLE_VIEW, this->First()->index);

Loading…
Cancel
Save