From cd4bfe0dce4f71fd10ec6d94036f6ca12a4fabdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Mon, 23 Nov 2026 12:02:09 +0000 Subject: [PATCH 1/2] fix(map): a shared map's copies of removed nodes come back on import A map that removes a model and keeps only its copies lost the copies on import: the copy named a node the import had already removed. The copy now takes its base from the level as extracted. --- openrac/tools/shared_map.py | 5 ++++- openrac/tools/test_shared_map.py | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/openrac/tools/shared_map.py b/openrac/tools/shared_map.py index 36b6a1ae..3ae83983 100644 --- a/openrac/tools/shared_map.py +++ b/openrac/tools/shared_map.py @@ -346,6 +346,9 @@ def by_id(text: str) -> str: def find(key: str): return next((b for b in blocks if key_of(b) == key), None) + # A copy names the section it was made from as the level has it, which may be one the map + # removes (a model kept only for its copies). + pristine_by = {key_of(b): b for b in blocks if key_of(b) is not None} for key in changes.get("removed", []): gone = find(key) if gone is None: @@ -370,7 +373,7 @@ def find(key: str): continue block = carry.Block(by_id(entry["head"])) if "base" in entry: - base = find(entry["base"]) + base = find(entry["base"]) or pristine_by.get(entry["base"]) if base is None: problems.append(f"{entry['key'][5:]}: copies {entry['base'][5:]}, which this level lacks") continue diff --git a/openrac/tools/test_shared_map.py b/openrac/tools/test_shared_map.py index 23b17140..a4fd4b86 100644 --- a/openrac/tools/test_shared_map.py +++ b/openrac/tools/test_shared_map.py @@ -103,6 +103,19 @@ def test_removed_node_and_a_change_for_a_missing_node(self): self.assertEqual(len(problems), 1) + def test_a_copy_of_a_removed_node(self): + # The model is removed and only its moved copy stays: the copy still comes back. + head, rest = SCENE.split('[node name="Bolt_0011"') + text = head + '[node name="Bolt_0011_2"' + rest.replace("139, 229, 31", "160, 227, 40") + changes = shared_map.scene_changes(SCENE, text) + self.assertEqual(changes["removed"], ["node:Game/Mobys/Bolt_0011"]) + problems = [] + made = shared_map.apply_scene_changes(SCENE, changes, problems) + self.assertEqual(problems, []) + self.assertNotIn('name="Bolt_0011"', made) + self.assertIn("[9, 9, 9", made.split('name="Bolt_0011_2"')[1]) + + def project(root: Path, level: int, files: dict) -> Path: folder = root / f"level_{level:02}" for rel, data in files.items(): From 42af47536d8063ab20ee117946c03ce1044d1909 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20K=C5=82ysz?= Date: Mon, 23 Nov 2026 13:56:40 +0000 Subject: [PATCH 2/2] fix(map): a shared map's planet shows its author and description in Mods The planet made from a shared map had no description, so the launcher's Mods list showed only its kind. Its pack now carries the map's author and its line about the map. --- openrac/tools/map_mod.py | 8 +++++++- openrac/tools/planet.py | 20 +++++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/openrac/tools/map_mod.py b/openrac/tools/map_mod.py index dc2351bd..31919613 100644 --- a/openrac/tools/map_mod.py +++ b/openrac/tools/map_mod.py @@ -20,7 +20,8 @@ def export_map(packed: Path, project: Path, out: Path, name: str, level: int, spawn: list[float] | None = None, heading: float | None = None, skip_movies: bool = True, - skip_cutscenes: bool = True, destination: bool = False, map_id: str | None = None) -> dict: + skip_cutscenes: bool = True, destination: bool = False, map_id: str | None = None, + author: str = "", description: str = "") -> dict: """Only copies inputs; never changes the editor project, packed files or an existing export.""" packed, project, out = Path(packed), Path(project), Path(out) if out.exists(): @@ -32,6 +33,11 @@ def export_map(packed: Path, project: Path, out: Path, name: str, level: int, "game": "rac1", "version": note["version"], "name": name, "map": {"level": level, "spawn": spawn, "heading": heading, "skip_movies": skip_movies, "skip_cutscenes": skip_cutscenes}} + # What the launcher's Mods list shows under the name. + if author.strip(): + manifest["author"] = author.strip()[:80] + if description.strip(): + manifest["description"] = description.strip()[:300] prefix = f"level_{level:02}" # The level's project, the folder of every level's project (--split), or the level folder itself. level_dir = next((p for p in (project / "levels" / prefix, project / prefix / "levels" / prefix, diff --git a/openrac/tools/planet.py b/openrac/tools/planet.py index 962c51f6..8b554a0c 100644 --- a/openrac/tools/planet.py +++ b/openrac/tools/planet.py @@ -13,6 +13,7 @@ from __future__ import annotations import openrac_root # noqa: F401,I001 (OpenRAC's extractor on the import path) +import json import re import secrets import tempfile @@ -165,6 +166,21 @@ def level_of(project: Path) -> int: return found[0] +def map_note(project: Path) -> tuple[str, str]: + """The author and the line about the map a shared map's import keeps (.openrac/map.json), + else the author the project's settings name.""" + note = {} + try: + note = json.loads((project / ".openrac" / "map.json").read_text(encoding="utf-8")) + except (OSError, ValueError): + pass + if not isinstance(note, dict): + note = {} + author = note.get("author") if isinstance(note.get("author"), str) else "" + about = note.get("about") if isinstance(note.get("about"), str) else "" + return author or settings(project).get("map/author", "").strip(), about + + def add_planet(disc, survey: dict, project: Path, into: Path) -> dict: """Packs PROJECT's level, exports it as a new planet and installs it in the launcher's packs folder INTO: what was done, for the report.""" @@ -184,7 +200,9 @@ def add_planet(disc, survey: dict, project: Path, into: Path) -> dict: if refused: raise PlanetError("Some edits could not be packed:\n" + "\n".join(f" {line}" for line in refused), INCOMPLETE) out = Path(temp) / "planet" - manifest = export_map(packed, project, out, name, level, destination=True, map_id=ident) + author, about = map_note(project) + manifest = export_map(packed, project, out, name, level, destination=True, map_id=ident, + author=author, description=about) installed, _, _ = overrides.add(out, into) return {"name": name, "id": ident, "installed": installed, "level": level, "report": report, "spawn": manifest["map"]["spawn"]}