mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-17 03:59:19 +02:00
feat(tracks): switches keep their neighbours joined on replacing, flipping and moving; events copied on splitting; circuits, overhead line, sleepers and events of the paths; curve design through the switches of a line; changes in files included more than once or with parameters reported instead of written; split of a straight at the point found, not a share of its length
This commit is contained in:
@@ -792,6 +792,8 @@ save_result node_layers::save(std::vector<std::string> const &Rootstatements)
|
||||
edit.node = Node;
|
||||
state.patches[Layer].edits.emplace_back(std::move(edit));
|
||||
};
|
||||
// changes which can't be written, as their definition stands for more than one node
|
||||
std::vector<std::string> unwritten;
|
||||
// traction and event launchers are rewritten when the editor moved them along with the track they belong to
|
||||
std::vector<basic_node *> patchednodes;
|
||||
auto const patch_node = [&](basic_node *Node, auto const &Patch) {
|
||||
@@ -801,10 +803,15 @@ save_result node_layers::save(std::vector<std::string> const &Rootstatements)
|
||||
return true;
|
||||
}
|
||||
auto const &source{lookup->second};
|
||||
if (false == is_output(resolve(source.layer)) || false == writable(source.layer))
|
||||
if (false == is_output(resolve(source.layer)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (false == writable(source.layer))
|
||||
{
|
||||
unwritten.push_back(Node->name());
|
||||
return true;
|
||||
}
|
||||
if (false == load(source.layer))
|
||||
{
|
||||
return false;
|
||||
@@ -876,15 +883,22 @@ save_result node_layers::save(std::vector<std::string> const &Rootstatements)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
created[nodelayer].emplace_back(path, path_text(*path, layer(nodelayer).context_insert().offset));
|
||||
// a file included more than once would get a copy of the new path at every inclusion
|
||||
auto const target{writable(nodelayer) ? nodelayer : root};
|
||||
created[target].emplace_back(path, path_text(*path, layer(target).context_insert().offset));
|
||||
savedpaths.push_back(path);
|
||||
continue;
|
||||
}
|
||||
auto const &source{lookup->second};
|
||||
if ((false == path->m_editorremoved && false == path->dirty()) || false == writable(source.layer))
|
||||
if (false == path->m_editorremoved && false == path->dirty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (false == writable(source.layer))
|
||||
{
|
||||
unwritten.push_back(path->name().empty() ? std::string{"(noname)"} : path->name());
|
||||
continue;
|
||||
}
|
||||
if (false == load(source.layer))
|
||||
{
|
||||
return fail(state.error);
|
||||
@@ -1636,6 +1650,21 @@ save_result node_layers::save(std::vector<std::string> const &Rootstatements)
|
||||
result.message += file + (&file != &result.files.back() ? ", " : "");
|
||||
}
|
||||
}
|
||||
if (false == unwritten.empty())
|
||||
{
|
||||
std::string names;
|
||||
for (std::size_t i = 0; i < std::min<std::size_t>(unwritten.size(), 5); ++i)
|
||||
{
|
||||
names += (i > 0 ? ", " : "") + unwritten[i];
|
||||
}
|
||||
if (unwritten.size() > 5)
|
||||
{
|
||||
names += ", ...";
|
||||
}
|
||||
auto const warning{std::to_string(unwritten.size()) + " changed nodes not saved, their files are included with parameters or more than once: " + names};
|
||||
WriteLog("Scenery save: " + warning, logtype::generic);
|
||||
result.message = result.files.empty() ? warning : result.message + ". " + warning;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user