From 3bdd5d8e90ee72ad675244f67379fd737ddb746c Mon Sep 17 00:00:00 2001 From: maj00r Date: Sun, 13 Sep 2026 12:44:48 +0200 Subject: [PATCH] start without scenery flag --- maj0sted/include/maj0sted/editor/join.hpp | 61 +++++++++++++++++++++++ maj0sted/src/editor/join.cpp | 51 +++++++++++++++++++ simulation/simulationstateserializer.cpp | 13 ++++- simulation/simulationstateserializer.h | 2 + 4 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 maj0sted/include/maj0sted/editor/join.hpp create mode 100644 maj0sted/src/editor/join.cpp diff --git a/maj0sted/include/maj0sted/editor/join.hpp b/maj0sted/include/maj0sted/editor/join.hpp new file mode 100644 index 00000000..72fe2500 --- /dev/null +++ b/maj0sted/include/maj0sted/editor/join.hpp @@ -0,0 +1,61 @@ +#pragma once + +// TYMCZASOWA ZASLEPKA. Modul scalania koncow (plan_join / join_ends) nie zostal nigdy +// zacommitowany: commit 4ddfeb02 dopisal `src/editor/join.cpp` do CMakeLists i `#include` w +// planpanel.cpp, ale samych plikow nie ma ani w drzewie, ani w historii, ani w stashach. Bez +// tego naglowka i join.cpp branch sie nie kompiluje wcale. Ta zaslepka odtwarza dokladnie to +// API, ktorego uzywa panel planu, i mowi "niedostepne" - zeby reszta edytora dala sie uruchomic. +// Do zastapienia prawdziwym rozwiazaniem geometrii (luk-prosta-luk) i chirurgia dokumentu. + +#include +#include + +#include "maj0sted/domain/geometry/segment_layout.hpp" // Pose +#include "maj0sted/editor/model.hpp" +#include "maj0sted/editor/solution.hpp" + +namespace maj0sted::editor { + +/// Co stanelo miedzy dwoma koncami. +enum class JoinKind { + None, + Straight, + Arc, + ArcLineArc, + ArcArc, +}; + +[[nodiscard]] const char* join_kind_name(JoinKind kind); + +/// Czym wolno gietc to, co lezy miedzy koncami. +struct JoinSettings { + double radius{300.0}; +}; + +/// Propozycja, przed tknieciem dokumentu. +struct JoinPlan { + bool ok{false}; + std::string why{}; + JoinKind kind{JoinKind::None}; + std::vector elements{}; + double tightest{0.0}; +}; + +[[nodiscard]] JoinPlan plan_join(const domain::geometry::Pose& leaving, + const domain::geometry::Pose& arriving, + const JoinSettings& settings); + +/// Co scalenie kosztowalo. +struct JoinReport { + bool ok{false}; + std::string why{}; + JoinPlan join{}; + int fused{0}; + int turnouts{0}; + bool reversed{false}; +}; + +[[nodiscard]] JoinReport join_ends(Document& document, const Solution& solution, TrackId a, + int a_end, TrackId b, int b_end, const JoinSettings& settings); + +} // namespace maj0sted::editor diff --git a/maj0sted/src/editor/join.cpp b/maj0sted/src/editor/join.cpp new file mode 100644 index 00000000..16b38855 --- /dev/null +++ b/maj0sted/src/editor/join.cpp @@ -0,0 +1,51 @@ +// TYMCZASOWA ZASLEPKA - patrz komentarz w join.hpp. + +#include "maj0sted/editor/join.hpp" + +namespace maj0sted::editor { + +namespace { +constexpr const char* kMissing = "scalanie koncow niedostepne: brak modulu join"; +} // namespace + +const char* join_kind_name(JoinKind kind) { + switch (kind) { + case JoinKind::Straight: + return "prosta"; + case JoinKind::Arc: + return "luk"; + case JoinKind::ArcLineArc: + return "luk-prosta-luk"; + case JoinKind::ArcArc: + return "luk-luk"; + case JoinKind::None: + break; + } + return "nic"; +} + +JoinPlan plan_join(const domain::geometry::Pose& leaving, const domain::geometry::Pose& arriving, + const JoinSettings& settings) { + (void)leaving; + (void)arriving; + (void)settings; + JoinPlan plan; + plan.why = kMissing; + return plan; +} + +JoinReport join_ends(Document& document, const Solution& solution, TrackId a, int a_end, TrackId b, + int b_end, const JoinSettings& settings) { + (void)document; + (void)solution; + (void)a; + (void)a_end; + (void)b; + (void)b_end; + (void)settings; + JoinReport report; + report.why = kMissing; + return report; +} + +} // namespace maj0sted::editor diff --git a/simulation/simulationstateserializer.cpp b/simulation/simulationstateserializer.cpp index e2ab7883..cc0edae8 100644 --- a/simulation/simulationstateserializer.cpp +++ b/simulation/simulationstateserializer.cpp @@ -76,8 +76,16 @@ state_serializer::deserialize_begin( std::string const &Scenariofile ) { } scene::Groups.create(); - if( false == state->input.ok() ) - throw invalid_scenery_exception(); + if( false == state->input.ok() ) { + if( false == Global.editor_startup ) { + throw invalid_scenery_exception(); + } + // the editor is allowed to work on ground that has no scenery file yet: starting with -editor, + // or beginning a new map, names a file which will only exist once it gets saved. an unreadable + // scenery means an empty world here, not a failed load + WriteLog( "Scenery \"" + Scenariofile + "\" not found, the editor starts on empty ground" ); + state->blank = true; + } // prepare deserialization function table // since all methods use the same objects, we can have simple, hard-coded binds or lambdas for the task @@ -164,6 +172,7 @@ state_serializer::deserialize_continue(std::shared_ptr state if( true == Global.file_binary_terrain && false == state->scratchpad.binary.terrain + && false == state->blank && state->scenariofile != "$.scn" ) { // if we didn't find usable binary version of the scenario files, create them now for future use // as long as the scenario file wasn't rainsted-created base file override diff --git a/simulation/simulationstateserializer.h b/simulation/simulationstateserializer.h index a5d6f2dc..ea71a3c7 100644 --- a/simulation/simulationstateserializer.h +++ b/simulation/simulationstateserializer.h @@ -16,6 +16,8 @@ namespace simulation { struct deserializer_state { std::string scenariofile; + // the named scenery has no file on disk: the world is empty, so there's nothing to compile to SBT + bool blank{ false }; cParser input; scene::scratch_data scratchpad; using deserializefunctionbind = std::function;