thewierdnut / endless-mobile

Space exploration, trading, and combat game.
https://endless-sky.github.io/
GNU General Public License v3.0
116 stars 8 forks source link

Current implementation of Files::Init() is not setting the correct path. #96

Closed thewierdnut closed 1 year ago

thewierdnut commented 1 year ago

Is there an existing issue for this?

Describe the bug

Files::Init() is doing something stupid. It is calling SDL_GetPrefPath("endless-sky", "saves") to get a writable directory for game saves, then is using the parent directory for all of its configuration. This happens to work for desktop configurations, but on android, the org and app arguments are known by the system in advance, so those arguments are not used by SDL, and we end up writing files directly into the app's data directory (which is meant to be used by the android system).

This also has the side effect that all save files are in a "files" directory, not a "saves" directory.

Steps to Reproduce

You can see the botched file structure in android

$ adb shell
ocean:/ $ run-as com.github.thewierdnut.endless_mobile
ocean:/data/data/com.github.thewierdnut.endless_mobile $ find
.
./cache
./code_cache
./shared_prefs
./files
./files/a jerk.txt
./files/a jerk~~previous-1.txt
./files/a jerk~~previous-2.txt
./files/a jerk~~previous-3.txt
./crash_state.txt
./keys.txt
./preferences.txt
./recent.txt
./global conditions.txt
./errors.txt
./plugins
./plugins.txt

Expected Behavior

The file structure should look more like this

./cache
./code_cache
./shared_prefs
./files
./files/saves
./files/saves/a jerk.txt
./files/saves/a jerk~~previous-1.txt
./files/saves/a jerk~~previous-2.txt
./files/saves/a jerk~~previous-3.txt
./files/crash_state.txt
./files/keys.txt
./files/preferences.txt
./files/recent.txt
./files/global conditions.txt
./files/errors.txt
./files/plugins
./files/plugins.txt

Screenshots

No response

Link to save file

No response

Device type

asdf

Game Version

build 37

Additional Information

Any fix for this will need to move the existing save files.

  1. Move all text files in ./files/ to ./files/saves/
  2. Move ./plugins to ./files/plugins/
  3. Move all text files in ./ to ./files
thewierdnut commented 1 year ago

This has been fixed upstream. Naively rebasing on upstream will break saves though, without some sort of backwards compatibility code.