Fix tutorials double Scenarios in path#3659
Conversation
|
Oddly enough, it seems to be working fine for me as-is. What platform are you testing with? |
|
I am using Gentoo Linux x86_64. I used the GOG version of the game (installed with Wine but that makes no difference here, as I did not use Wine to run OpenLoco) I compiled OpenLoco using cmake -B build
cd build
ninjaSo nothing fancy here. I default to GCC which is up to date on version 15.2.1_p20260214. I did not copy OpenLoco into my installation folder but rather ran the executable from said folder. Since you said you do not experience this I wrote this short test program: #include <filesystem>
#include <iostream>
#include <ostream>
int main(int argc, char **argv)
{
std::cout << "Current Folder: " << std::filesystem::current_path() << std::endl;
std::cout << "Current Root Path: " << std::filesystem::current_path().root_path() << std::endl;
std::cout << "Has Current Root Path: " << std::filesystem::current_path().has_root_path() << std::endl;
std::cout << "Scenario File String: " << fs::path("Scenarios/Boulder Breakers.SC5") << std::endl;
std::cout << "Scenario Root Path: " << std::filesystem::path("Scenarios/Boulder Breakers.SC5").root_path() << std::endl;
std::cout << "Has Scenario Root Path: " << std::filesystem::path("Scenarios/Boulder Breakers.SC5").has_root_path() << std::endl;
return 0;
}Which using g++ or clang++ gives me the output: and MSVC running in wine (tbf this is a bit running on fumes but it is the real MSVC from Microsoft just not running on Windows; A test on Windows runtime might still yield different results tbf): Which again would cause the if clause to trigger and add // 0x00442837
bool load(const fs::path& path)
{
WindowManager::closeConstructionWindows();
WindowManager::closeAllFloatingWindows();
// Resolve filenames to base game scenario directory
fs::path fullPath = path;
if (!fullPath.has_root_path())
{
auto scenarioPath = Environment::getPath(Environment::PathId::scenarios);
fullPath = scenarioPath / path;
}
Audio::pauseSound();
auto result = S5::importSaveToGameState(fullPath, S5::LoadFlags::scenario);
Audio::unpauseSound();
return result;
}As stated above: I am aware that this seems like a too obvious bug so I am absolutely open to this being on me. If so I would like to know what I am doing wrong/what is different about my system. |
|
Appreciate the testing. I'm generally on macOS myself, so this could just be a platform issue, hence the question. I'll do some digging on my Linux setup when I'm home. |
|
Tutorials are working on master (67a1ff0) on Arch Linux for me, similar to macOS. Very odd that this change does make it work for you on Gentoo Linux. Not sure what's going wrong there, or indeed what to suggest. |
|
I am very sorry for taking your time. I have added a simple line that will now convert relative inputs to absolute inputs. Now I understand this was rather silly on my part but I didn't really want to input the long path. Now in my slight defense since I always launched through Lutris or the terminal I always had the working directory set to the installation directory so I didn't notice that inputing a dot was a bad idea. |
|
Right, that'll do it 😄 Thanks for the deep dive and writing up your findings. It'll make for a nice story in the dev log in the next release. Ultimately, we should make the Linux/POSIX version of the game a little user friendlier than it is currently, what with it just prompting for a path using Anyway, let me just add a changelog entry and merge this. |
|
Did some more testing and discovered that while Switching to |
Clicking on any tutorial mission from the main menu crashes the game with:
This is because in
src/OpenLoco/src/Scenario/Scenario.cppinScenarios::loadit puzzles the path together like this:scenarioPath is "Scenarios" and path is the given path which is set to
Environment::PathId::boulderBreakersinsrc/OpenLoco/src/Tutorial.cppwhich is "Scenarios/Boulder Breakers.SC5"