mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-08 21:00:03 +01:00
fix(app): a scenery file named in another case than given is found, a scenario that can't be opened goes back to the launcher
The command line gives the name of the scenery lowercased, and the sceneries made on Windows name their files and includes in any case: on a case-sensitive filesystem they weren't found. FileCased() finds the file whose name differs only in case; the parser and the scenario loader use it. A scenario that can't be opened logs the reason and goes back to the launcher instead of ending with an exception.
This commit is contained in:
@@ -41,11 +41,25 @@ bool scenarioloader_mode::update() {
|
||||
WriteLog("using simulation seed: " + std::to_string(Global.random_seed), logtype::generic);
|
||||
WriteLog("using simulation starting timestamp: " + std::to_string(Global.starting_timestamp), logtype::generic);
|
||||
|
||||
// the command line gives the name lowercased, the file may be named in another case, as a scenery made on Windows;
|
||||
// the scenery is saved back to its own file then
|
||||
if (auto const cased{FileCased(Global.asCurrentSceneryPath + Global.SceneryFile)}; cased.size() > Global.asCurrentSceneryPath.size())
|
||||
Global.SceneryFile = cased.substr(Global.asCurrentSceneryPath.size());
|
||||
Application.set_title( Global.AppName + " (" + Global.SceneryFile + ")" );
|
||||
WriteLog( "\nLoading scenario \"" + Global.SceneryFile + "\"..." );
|
||||
|
||||
timestart = std::chrono::system_clock::now();
|
||||
state = simulation::State.deserialize_begin(Global.SceneryFile);
|
||||
try {
|
||||
state = simulation::State.deserialize_begin(Global.SceneryFile);
|
||||
}
|
||||
catch (std::exception const &e) {
|
||||
ErrorLog("Bad init: scenario \"" + Global.SceneryFile + "\" couldn't be opened (" + e.what() + ")");
|
||||
state.reset();
|
||||
Global.SceneryFile.clear();
|
||||
Application.pop_mode();
|
||||
Application.push_mode(eu07_application::mode::launcher);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user