diff --git a/application/editormodesrk.cpp b/application/editormodesrk.cpp index d447dafc..45385c72 100644 --- a/application/editormodesrk.cpp +++ b/application/editormodesrk.cpp @@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "application/editormodeshared.h" #include "application/editorprojection.h" #include "application/editoruilayer.h" +#include "editor/editorAlignmentStore.hpp" #include "editor/editorFormat.hpp" #include "editor/editorGeometry.hpp" #include "editor/editorIncludeInfo.hpp" @@ -360,11 +361,7 @@ srk_tool::record &srk_tool::record_of_open() auto *first{m_layout->switches.front()}; entry.anchor = first->name(); entry.track = first; - entry.layer = scene::Layers.resolve(first->layer()); - if (false == scene::Layers.valid(entry.layer) || false == scene::Layers.accepts(entry.layer)) - entry.layer = scene::Layers.active(); - if (false == scene::Layers.valid(entry.layer)) - entry.layer = 1; + entry.layer = alignment_store::layer_of(*first); m_records.push_back(std::move(entry)); m_record = static_cast(m_records.size()) - 1; m_anchor = first; diff --git a/editor/editorAlignmentStore.cpp b/editor/editorAlignmentStore.cpp index e57258d2..37b70795 100644 --- a/editor/editorAlignmentStore.cpp +++ b/editor/editorAlignmentStore.cpp @@ -863,7 +863,12 @@ void restore(std::vector Records) scene::layer_handle layer_of(TTrack const &Track) { - auto const usable = [](scene::layer_handle const Layer) { return scene::Layers.valid(Layer) && scene::Layers.accepts(Layer) && false == scene::Layers.layer(Layer).name.ends_with(".txtf"); }; + auto const usable = [](scene::layer_handle const Layer) { + if (false == scene::Layers.valid(Layer) || false == scene::Layers.accepts(Layer)) + return false; + auto const &name{scene::Layers.layer(Layer).name}; + return false == name.ends_with(".txtf") && false == name.ends_with("_ter.scm"); + }; auto layer{scene::Layers.resolve(Track.layer())}; if (false == usable(layer)) layer = scene::Layers.active(); diff --git a/editor/editorAlignmentStore.hpp b/editor/editorAlignmentStore.hpp index 61dff97d..aea28a14 100644 --- a/editor/editorAlignmentStore.hpp +++ b/editor/editorAlignmentStore.hpp @@ -104,8 +104,8 @@ std::optional> take_changes(); void settle(); // puts the records back as they were, for undo and redo void restore(std::vector Records); -// layer the editor keeps the records of the track in: its own, unless it's a terrain file (.txtf), whose binary version -// (.btf) the editor doesn't read the records from +// layer the editor keeps the records of the track in: its own, unless it's a terrain file: a .txtf, whose binary version (.btf) +// the editor doesn't read the records from, or a _ter.scm, which isn't written back while the scenery has its .sbt scene::layer_handle layer_of(TTrack const &Track); } // namespace alignment_store