mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 05:09:19 +02:00
train acceleration logic tweak, train protection system magnet activation tweak
This commit is contained in:
18
Driver.cpp
18
Driver.cpp
@@ -1418,7 +1418,14 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
|
|||||||
// NOTE: magnet induction calculation presumes the driver is located in the front vehicle
|
// NOTE: magnet induction calculation presumes the driver is located in the front vehicle
|
||||||
// TBD, TODO: take into account actual position of controlled/occupied vehicle in the consist, whichever comes first
|
// TBD, TODO: take into account actual position of controlled/occupied vehicle in the consist, whichever comes first
|
||||||
auto const magnetlocation { pVehicles[ end::front ]->MoverParameters->SecuritySystem.MagnetLocation };
|
auto const magnetlocation { pVehicles[ end::front ]->MoverParameters->SecuritySystem.MagnetLocation };
|
||||||
|
auto const magnetrange { 1.0 };
|
||||||
|
auto const ismagnetpassed { Point.fDist < -( magnetlocation + magnetrange ) };
|
||||||
if( Point.fDist < -( magnetlocation ) ) {
|
if( Point.fDist < -( magnetlocation ) ) {
|
||||||
|
// NOTE: normally we'd activate the magnet once the leading vehicle passes it
|
||||||
|
// but on a fresh scan after direction change it would be detected as long as it's under consist, and meet the (simple) activation condition
|
||||||
|
// thus we're doing a more precise check in such situation (we presume direction change takes place only if the vehicle is standing still)
|
||||||
|
if( ( mvOccupied->Vel > EU07_AI_NOMOVEMENT )
|
||||||
|
|| ( false == ismagnetpassed ) ) {
|
||||||
mvOccupied->SecuritySystem.SHPLock |= ( !AIControllFlag ); // don't make life difficult for the ai, but a human driver is a fair game
|
mvOccupied->SecuritySystem.SHPLock |= ( !AIControllFlag ); // don't make life difficult for the ai, but a human driver is a fair game
|
||||||
PutCommand(
|
PutCommand(
|
||||||
Point.evEvent->input_text(),
|
Point.evEvent->input_text(),
|
||||||
@@ -1426,8 +1433,9 @@ TController::TableUpdateEvent( double &Velocity, TCommandType &Command, TSpeedPo
|
|||||||
Point.evEvent->input_value( 2 ),
|
Point.evEvent->input_value( 2 ),
|
||||||
nullptr );
|
nullptr );
|
||||||
}
|
}
|
||||||
if( Point.fDist < -( magnetlocation + 0.5 ) ) {
|
}
|
||||||
Point.Clear(); // magnet passed, deactivate
|
if( ismagnetpassed ) {
|
||||||
|
Point.Clear();
|
||||||
mvOccupied->SecuritySystem.SHPLock = false;
|
mvOccupied->SecuritySystem.SHPLock = false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -7549,8 +7557,10 @@ TController::adjust_desired_speed_for_current_speed() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// HACK: limit acceleration for cargo trains, to reduce probability of breaking couplers on sudden jolts
|
// HACK: limit acceleration for cargo trains, to reduce probability of breaking couplers on sudden jolts
|
||||||
auto MaxAcc{ 0.5 * (mvOccupied->Couplers[mvOccupied->DirAbsolute >= 0 ? 1 : 0].FmaxC) / fMass };
|
auto MaxAcc{ 0.5 * mvOccupied->Couplers[(mvOccupied->DirAbsolute >= 0 ? end::rear : end::front)].FmaxC / fMass };
|
||||||
MaxAcc *= clamp(vel * 0.2, 0.2, 1.0);
|
if( iVehicles - ControlledEnginesCount > 0 ) {
|
||||||
|
MaxAcc *= clamp( vel * 0.025, 0.2, 1.0 );
|
||||||
|
}
|
||||||
AccDesired = std::min(AccDesired, clamp(MaxAcc, HeavyCargoTrainAcceleration, AccPreferred));
|
AccDesired = std::min(AccDesired, clamp(MaxAcc, HeavyCargoTrainAcceleration, AccPreferred));
|
||||||
// TBD: expand this behaviour to all trains with car(s) exceeding certain weight?
|
// TBD: expand this behaviour to all trains with car(s) exceeding certain weight?
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -11507,7 +11507,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
|
|||||||
// security system
|
// security system
|
||||||
// by default place the magnet in the vehicle centre
|
// by default place the magnet in the vehicle centre
|
||||||
if( SecuritySystem.MagnetLocation == 0 ) {
|
if( SecuritySystem.MagnetLocation == 0 ) {
|
||||||
SecuritySystem.MagnetLocation = Dim.L / 2 - 0.25;
|
SecuritySystem.MagnetLocation = Dim.L / 2 - 0.5;
|
||||||
}
|
}
|
||||||
SecuritySystem.MagnetLocation = clamp( SecuritySystem.MagnetLocation, 0.0, Dim.L );
|
SecuritySystem.MagnetLocation = clamp( SecuritySystem.MagnetLocation, 0.0, Dim.L );
|
||||||
|
|
||||||
@@ -12042,7 +12042,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
|||||||
{
|
{
|
||||||
SecuritySystem.VelocityAllowed = static_cast<int>(floor(CValue1));
|
SecuritySystem.VelocityAllowed = static_cast<int>(floor(CValue1));
|
||||||
SecuritySystem.NextVelocityAllowed = static_cast<int>(floor(CValue2));
|
SecuritySystem.NextVelocityAllowed = static_cast<int>(floor(CValue2));
|
||||||
SecuritySystem.SystemSoundSHPTimer = 0; // hunter-091012
|
// SecuritySystem.SystemSoundSHPTimer = 0; // hunter-091012
|
||||||
SetFlag(SecuritySystem.Status, s_active);
|
SetFlag(SecuritySystem.Status, s_active);
|
||||||
}
|
}
|
||||||
// else OK:=false;
|
// else OK:=false;
|
||||||
|
|||||||
Reference in New Issue
Block a user