mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 11:47:06 +01:00
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.
This commit is contained in:
@@ -166,6 +166,16 @@ TEST_CASE("project migration: the golden //$ lines of data/records made into a p
|
||||
CHECK(station->name == editor_records::read_station(files[7].lines.at('s')[1])->name);
|
||||
}
|
||||
|
||||
TEST_CASE("project migration: a map with no //$ lines gets an empty project and no file next to it") {
|
||||
test::scratch_folder folder{"project_migration_none"};
|
||||
std::ofstream{folder.root() / "pusta.scm", std::ios::binary} << "node -1 0 t1 track normal 100 1.435 0.2 25 20 0 flat vis 0 0 0 0 0 0 0 0 0 0 100 0 endtrack\n";
|
||||
auto const opened{project::open_project(folder.root(), "pusta.scm")};
|
||||
REQUIRE_MESSAGE(opened.project.project.has_value(), opened.project.error);
|
||||
CHECK(opened.project.project->network.lines().empty());
|
||||
CHECK_FALSE(opened.migrated);
|
||||
CHECK_FALSE(std::filesystem::exists(folder.root() / "pusta.eu07proj"));
|
||||
}
|
||||
|
||||
TEST_CASE("project migration: a map opened for the first time gets its project of the //$ lines of its files; the files stay as they were") {
|
||||
test::scratch_folder folder{"project_migration"};
|
||||
auto const source{std::filesystem::path{EU07_UNIT_TESTS_DATA} / "project" / "migration"};
|
||||
|
||||
Reference in New Issue
Block a user