From 219836b4648020de36f1ccf7dc7d7edc71b8e2a6 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Wed, 14 Oct 2026 13:55:06 +0200 Subject: [PATCH] test: track_friction case key for slippery rail scenarios --- tests/scenarios/README.md | 1 + tests/scenarios/run.py | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/tests/scenarios/README.md b/tests/scenarios/README.md index 23f793018..463086cc5 100644 --- a/tests/scenarios/README.md +++ b/tests/scenarios/README.md @@ -59,6 +59,7 @@ scenery is newer. | `base_scenery` | scenery file in the game's `scenery/` dir | | `strip_trainsets` | drop the base scenery's trainsets (default `true`) | | `time` | replace the scenery start time, `HH:MM` | +| `track_friction` | set the friction of every track of the base scenery (default in the sceneries is 0.15), e.g. for slippery rail | | `fragment` | `.scn` file in `cases/` added to the scenery: trainsets after `FirstInit` (before it they derail on unlinked track), the rest before it (launchers read after it never fire) | | `vars` | values for `{{name}}` in the fragment; a list becomes one line per item | | `duration` | seconds of simulation to record | diff --git a/tests/scenarios/run.py b/tests/scenarios/run.py index 419906700..32be5dfc0 100644 --- a/tests/scenarios/run.py +++ b/tests/scenarios/run.py @@ -86,6 +86,12 @@ def set_start_time(text: str, hhmm: str) -> str: return re.sub(r"(?im)^(\s*time\s+)\d{1,2}:\d{2}", lambda m: m.group(1) + hhmm, text, count=1) +def set_track_friction(text: str, friction: float) -> str: + """Sets the friction of every track: node track ...""" + return re.sub(r"(?im)^(\s*node\s+\S+\s+\S+\s+\S+\s+track\s+\S+\s+\S+\s+\S+\s+)[-\d.]+", + lambda m: m.group(1) + f"{friction}", text) + + def fill_vars(fragment: str, values: dict, keep=frozenset()) -> str: """Replaces {{name}} with the case's value; a list value becomes one line per item.""" def value(m): @@ -107,6 +113,8 @@ def build_scenery(case: dict, game_dir: Path, case_name: str, vehicle: str) -> s text, _ = split_trainsets(text) if "time" in case: text = set_start_time(text, case["time"]) + if "track_friction" in case: + text = set_track_friction(text, case["track_friction"]) fragment = (CASES_DIR / case["fragment"]).read_bytes().decode("latin-1") # vars first: {{vehicle}} inside a var's value gets filled in the second pass fragment = fill_vars(fragment, case.get("vars", {}), keep={"vehicle"})