TheOpenSpaceProgram / osp-magnum

A spaceship game
https://www.openspaceprogram.org/
MIT License
216 stars 32 forks source link

File access errors when OSP-Magnum not started from the build directory. #272

Open IronPepper3964 opened 6 months ago

IronPepper3964 commented 6 months ago

osp-magnum can only be started from the local build folder. If it is started from any other directory, multiple errors occur due to relative file locations changing.

Example:

When running ./osp-magnum from the Release folder created during the build, the program runs as expected - no errors

~/build-osp-magnum/Release$ ./osp-magnum

However, when running ./build-osp-magnum/Release/osp-magnum from the root folder where both the osp-magnum and build-osp-magnum folders are stored, multiple files cannot be found

~/$ ./build-osp-magnum/Release/osp-magnum

Errors:

Trade::AbstractImporter::openFile(): cannot open file OSPData/adera/spamcan.sturdy.gltf
[15:12:11.529] [testapp] [error] [load_tinygltf.cpp:342] Could not open file OSPData/adera/spamcan.sturdy.gltf
Utility::Path::read(): can't open OSPData/adera/stomper.sturdy.gltf: error 2 (No such file or directory)
Trade::AbstractImporter::openFile(): cannot open file OSPData/adera/stomper.sturdy.gltf
[15:12:11.529] [testapp] [error] [load_tinygltf.cpp:342] Could not open file OSPData/adera/stomper.sturdy.gltf
Utility::Path::read(): can't open OSPData/adera/ph_capsule.sturdy.gltf: error 2 (No such file or directory)
Trade::AbstractImporter::openFile(): cannot open file OSPData/adera/ph_capsule.sturdy.gltf
[15:12:11.529] [testapp] [error] [load_tinygltf.cpp:342] Could not open file OSPData/adera/ph_capsule.sturdy.gltf
Utility::Path::read(): can't open OSPData/adera/ph_fuselage.sturdy.gltf: error 2 (No such file or directory)
Trade::AbstractImporter::openFile(): cannot open file OSPData/adera/ph_fuselage.sturdy.gltf
[15:12:11.529] [testapp] [error] [load_tinygltf.cpp:342] Could not open file OSPData/adera/ph_fuselage.sturdy.gltf
Utility::Path::read(): can't open OSPData/adera/ph_engine.sturdy.gltf: error 2 (No such file or directory)
Trade::AbstractImporter::openFile(): cannot open file OSPData/adera/ph_engine.sturdy.gltf
[15:12:11.529] [testapp] [error] [load_tinygltf.cpp:342] Could not open file OSPData/adera/ph_engine.sturdy.gltf
Utility::Path::read(): can't open OSPData/adera/ph_rcs.sturdy.gltf: error 2 (No such file or directory)
Trade::AbstractImporter::openFile(): cannot open file OSPData/adera/ph_rcs.sturdy.gltf
[15:12:11.529] [testapp] [error] [load_tinygltf.cpp:342] Could not open file OSPData/adera/ph_rcs.sturdy.gltf
[15:12:11.529] [testapp] [info] [main.cpp:409] Resource loading complete

The OSP-Magnum Temporary Debug CLI loads, but selecting any scenario causes an error and the program closes


terminate called after throwing an instance of 'std::ios_base::failure[abi:cxx11]'
  what():  toml::parse: Error opening file "settings.toml": iostream error
Aborted (core dumped)```
Capital-Asterisk commented 6 months ago

Probably best to use the executable's file path instead of the current directory. We'd only need changes to main.cpp most likely.

ShiralynDev commented 5 months ago

This is fixed atleast in some parts in #297