18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 12:57:06 +01:00
Files
maszyna/editor/project/projectMigration.hpp
T
maj00r b15f7dcdec fix(editor): file names outside the code page don't crash the project, includes are found in any case, a project file cut short isn't put in place
- The scenario index made a string of the name of every file in the folder, which throws on Windows for a name the ANSI code
  page can't hold (the class of GE#560). It looks at the extension first and leaves out a .scn the game couldn't open by its
  name either; the messages of the project file show paths as UTF-8.
- The includes are read with the FileCased() fallback of the game (scenery_text::file_text), so on Linux an include written in
  another case no longer drops the scenario from the index, skips the migration of its file or marks its tracks as changed by
  hand.
- save() closes the file before looking at it: a failed last flush no longer renames a truncated .new over the project.
- "next node 0" is refused instead of wrapping to 0xffffffff.
- open_project() writes no .eu07proj when there were no //$ lines to migrate, and asks exists() without throwing.
2026-11-24 18:54:33 +01:00

72 lines
3.7 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
#pragma once
#include "editor/project/projectFile.hpp"
#include "scene/scenelayers.h"
#include <filesystem>
#include <map>
#include <string>
#include <string_view>
#include <vector>
// The //$ lines of an old scenery taken into the project file when its map is first opened (editor-tracks-domain.md §9, §10): what the
// domain has a place for becomes its lines and nodes, the rest is kept as it was written; the lines stay in the scenery files, untouched.
//
// //$h an alignment designed: a line between two nodes, its vertices with their radii, transitions and cants, the shape of its
// transitions, its chainage at the start (the origin) and its speed as the class of the line. Not one the domain lays otherwise:
// a compound curve, two transitions with no arc between them, cant ramps of its own, a curve turning the longer way, a design kept
// for a part of its line, one the domain lays to another length. The ends of two lines at one place join at a node. The record is
// kept as it was, with the line it became: the points clicked, the old norms, the pieces, the fit have no place in the domain.
// //$p a grade line designed along such a line: its breaks with their vertical curves as the breaks of the line, the heights of its
// ends as those of the nodes. Not one with a break with no vertical curve, or along no line of an alignment. Kept as it was too.
// //$r switches (E5), //$k the kilometrage of the railway lines, //$t the tracks fitted, //$w the tracks sharing a grade line, //$b
// the objects bound to the tracks (E6), //$s the stations (E7): no place in the domain yet, kept as they were.
// //$c, //$o, //$z the camera, the orthophoto and the area of the downloads: what the editor keeps of itself in the scenery, not the
// track geometry; not taken.
namespace project
{
// the //$ lines of a scenery file by the letter of their mark, the mark taken off as the editor takes it (scene::node_layers::scan()):
// the lines other tools put after the same marks left out, those of the old letters of the marks under the new ones
std::map<char, std::vector<std::string>> marked_lines(std::string_view const Text);
struct marked_file
{
std::string file; // relative to the scenery folder
scene::layer_context context; // the placement in effect where the lines are, their coordinates are those of the file
std::map<char, std::vector<std::string>> lines;
};
struct migration
{
document project;
std::vector<std::string> notes; // what was kept as it was and why, the ends joined at the nodes
};
// the project of the //$ lines of the files, in the order of the files; the norms by place as given
migration migrate(std::vector<marked_file> const &Files, norms::area_map const &Areas = {});
// the files of the map (Map relative to the scenery folder, its includes followed) with their //$ lines and the placement in effect at
// their includes
std::vector<marked_file> marked_files(std::filesystem::path const &Folder, std::string const &Map);
struct opened
{
read_result project;
bool migrated{false}; // there was no project file: it was made of the //$ lines and written; with none of them, nothing is written
std::vector<std::string> notes;
};
// the project of the map: its file read, or made of the //$ lines of the files of the map where there's none yet and written next to it;
// the scenery files aren't written
opened open_project(std::filesystem::path const &Folder, std::string const &Map, norms::area_map const &Areas = {});
} // namespace project