From a6c7d539832b6d3181b77ff59ad9355754f9c40c Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Sun, 8 Nov 2026 12:33:53 +0100 Subject: [PATCH] fix: SmokeDelay defaults to 0, the delay comes only from the vehicle's .fiz (eu07/maszyna#523) Without SmokeDelay in its Engine section a diesel smokes as soon as the starter turns, as before; the delay is set per locomotive in its own .fiz. The value stays a member of the vehicle's mover, read from its .fiz with an explicit default of 0. Tests: the real SM42 and ST44 with SmokeDelay=2 and 5 in the .fiz, and without it (smoke at once), next to a locomotive with a delay loaded just before, which keeps its own value. --- McZapkie/MOVER.h | 6 +++--- McZapkie/Mover.cpp | 2 +- tests/unit/test_smoke.cpp | 30 +++++++++++++++++++----------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index f39de8e26..ec8e5e9b3 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -2171,9 +2171,9 @@ class TMoverParameters bool dizel_startup{false}; // engine startup procedure request indicator bool dizel_ignition{false}; // engine ignition request indicator bool dizel_spinup{false}; // engine spin up to idle speed flag - // the starter turns the engine a while before it fires: smoke comes out only after SmokeDelay (the Engine section of the .fiz, - // seconds from the start of the spin up) has passed. 0 lets it out as soon as the starter turns, as before eu07/maszyna#523 - double dizel_SmokeDelay{2.0}; + // the starter turns the engine a while before it fires: smoke comes out only after SmokeDelay (the Engine section of the vehicle's + // .fiz, seconds from the start of the spin up) has passed. 0, the default, lets it out as soon as the starter turns, as before eu07/maszyna#523 + double dizel_SmokeDelay{0.0}; double dizel_FiringCountdown{0.0}; // seconds left until the engine being started fires, 0 once it runs on its own double dizel_engagedeltaomega = 0.0; /*roznica predkosci katowych tarcz sprzegla*/ double dizel_n_old = 0.0; /*poredkosc na potrzeby obliczen sprzegiel*/ diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 8632e404e..cb9eba023 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -11370,7 +11370,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input) extract_value(OilPump.pressure_minimum, "OilMinPressure", Input, ""); extract_value(OilPump.pressure_maximum, "OilMaxPressure", Input, ""); // the time the starter turns the engine before it fires and smokes (eu07/maszyna#523) - extract_value(dizel_SmokeDelay, "SmokeDelay", Input, ""); + extract_value(dizel_SmokeDelay, "SmokeDelay", Input, "0"); dizel_SmokeDelay = std::max(0.0, dizel_SmokeDelay); // engine cooling factore extract_value(dizel_heat.kw, "HeatKW", Input, ""); diff --git a/tests/unit/test_smoke.cpp b/tests/unit/test_smoke.cpp index a1ea788f3..281b5dbf6 100644 --- a/tests/unit/test_smoke.cpp +++ b/tests/unit/test_smoke.cpp @@ -116,8 +116,8 @@ TEST_CASE("smoke: a real diesel smokes only once its engine has fired, SmokeDela CAPTURE(path); test::track const track{}; { - // the default delay - test::vehicle locomotive{test::definition::fiz(path)}; + // SmokeDelay set in the .fiz of the locomotive + test::vehicle locomotive{test::definition{test::definition::fiz(path)}.set("Engine", "SmokeDelay", 2)}; REQUIRE(locomotive->dizel_SmokeDelay == doctest::Approx(2.0)); auto const driven{test::driving(locomotive)}; REQUIRE(start_engine(driven, track)); @@ -130,15 +130,6 @@ TEST_CASE("smoke: a real diesel smokes only once its engine has fired, SmokeDela CHECK(locomotive->dizel_FiringCountdown == 0.0); CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); } - { - // SmokeDelay=0: smoke as soon as the starter turns, as before - test::vehicle locomotive{test::definition{test::definition::fiz(path)}.set("Engine", "SmokeDelay", 0)}; - REQUIRE(locomotive->dizel_SmokeDelay == 0.0); - auto const driven{test::driving(locomotive)}; - REQUIRE(start_engine(driven, track)); - CHECK(locomotive->dizel_FiringCountdown == 0.0); - CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); - } { // a longer delay from the .fiz test::vehicle locomotive{test::definition{test::definition::fiz(path)}.set("Engine", "SmokeDelay", 5)}; @@ -151,3 +142,20 @@ TEST_CASE("smoke: a real diesel smokes only once its engine has fired, SmokeDela } } } + +TEST_CASE("smoke: without SmokeDelay in its .fiz a diesel smokes as soon as the starter turns, as before (#523)") { + for (auto const *path : {"sm42_v1/6d1", "st44_v2/m62-1151"}) { + CAPTURE(path); + test::track const track{}; + // a locomotive which has the delay, loaded first, doesn't hand it on to the next one: the value is the vehicle's own + test::vehicle delayed{test::definition{test::definition::fiz(path)}.set("Engine", "SmokeDelay", 3)}; + REQUIRE(delayed->dizel_SmokeDelay == doctest::Approx(3.0)); + test::vehicle locomotive{test::definition::fiz(path)}; + REQUIRE(locomotive->dizel_SmokeDelay == 0.0); + CHECK(delayed->dizel_SmokeDelay == doctest::Approx(3.0)); + auto const driven{test::driving(locomotive)}; + REQUIRE(start_engine(driven, track)); + CHECK(locomotive->dizel_FiringCountdown == 0.0); + CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); + } +}