diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index f6697d934..a09e15192 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -8161,8 +8161,13 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) if (enrot <= 0 && false == dizel_spinup) { - // a stopped engine doesn't stop those started on their own - MainSwitch(false, MainSwitchRange()); + // an engine stalling stops those started together with it, once. one already stopped, from its own switch or + // another vehicle's, or not started at all, has nothing to stop: it stays quiet, rather than stop every frame + // the engines started on their own or from the separate switches (eu07/maszyna#80) + if (true == Mains) + { + MainSwitch(false, MainSwitchRange()); + } enrot = 0; } diff --git a/tests/unit/test_engine_start.cpp b/tests/unit/test_engine_start.cpp index e763a4404..c721e5a1a 100644 --- a/tests/unit/test_engine_start.cpp +++ b/tests/unit/test_engine_start.cpp @@ -251,3 +251,48 @@ TEST_CASE("engine start: an engine stopping on its own stops the others only whe CHECK(running(second) == (false == joint)); } } + +// a stopped engine stays stopped on its own: only an engine stopping while it ran tells the others, as a joint start's +// engines stop together; one stopped from another vehicle's switch, or not started at all, doesn't stop those running, +// whatever the flags of the vehicles in a mixed train +TEST_CASE("engine start: an engine stopped from its own switch doesn't stop the others when it has spun down") { + consist train; + // the middle railcar keeps the joint start, as a .fiz without the key does. what a vehicle without the cab relays + // goes on away from the cab, so it's the third one that would stop + auto &first{train.add(sn61(false), 1).mover()}; + auto &second{train.add(sn61()).mover()}; + auto &third{train.add(sn61(false)).mover()}; + prepare(train); + engine_start::remote_switch switchb; + engine_start::remote_switch switchc; + first.MainSwitch(true, first.MainSwitchRange()); + hold(train, switchb, engine_start::engine(first, first, 2), 2.0); + hold(train, switchc, engine_start::engine(first, first, 3), 2.0); + train.run(15.0); + REQUIRE(running(first)); + REQUIRE(running(second)); + REQUIRE(running(third)); + // mainb_off + CHECK(engine_start::remote_switch::open(second)); + train.run(30.0); + CHECK_FALSE(second.Mains); + CHECK(second.enrot == 0.0); + CHECK(running(first)); + CHECK(running(third)); +} + +TEST_CASE("engine start: the stopped engine of the cab's vehicle doesn't stop the one started from its switch") { + consist train; + // the cab's railcar keeps the joint start, its engine stopped + auto &first{train.add(sn61(), 1).mover()}; + auto &second{train.add(sn61(false)).mover()}; + prepare(train); + REQUIRE_FALSE(first.Mains); + // mainb_on + engine_start::remote_switch switchb; + hold(train, switchb, engine_start::engine(first, first, 2), 2.0); + train.run(15.0); + CHECK(running(second)); + CHECK_FALSE(first.Mains); + CHECK(first.enrot == 0.0); +}