This is a partial revert and fix of both rP13167 and rP13472.
These diffs intended to do two things:
- Load mods from the user "mods/" folder
- Let Atlas write maps in an appropriate location.
They succeeded in that, but unfortunately the behaviour is buggy (note that it was before, too, it just wasn't fixed).
As an example, if one starts with an empty cache, and loads a mod with the following structure: "[mod]/cache/mod", then the cached files for the mod-mod end up in the mod instead of the cache. This can also happen with screenshots, user config (see #2553), etc.
(NB: this may not actually have been buggy at the time... There's some loading-order data-race here that makes everything quite difficult to reason about)
rP13472 introduced custom mount/lookup flags to make things write to the user mod. Since that mod starts empty, we needed a way to 'force' the real directories to match. To do so, it marked directories as "replaceable", and in vfs_lookup the real directories would be overwritten. Unfortunately, vfs_lookup doesn't propragate flags, breaking everything. And, anyways, we already have a way to replace things: priorities.
Further, they introduced a duplication of mod data between the 'rdata' path and the user mod path, leading to empty folders there.
This fixes all that by:
- Adding a new lookup mode ('Real-path'), that explicitly overwrite lower-priority real subdirectories so that VFS paths match the expcted hard drive path.
- Preventing overwriting a real directory with a lower priority one in general
- Revert rP8082's GetRealPath change, re-introducing the function as GetOriginalPath.
This fixes the above bug by making sure that any path that starts with "cache" will point to the cache folder and won't be hijacked halfway through.
It also makes sure that the user mod continues working correctly, but loads it explicitly in MountMods instead of hacking it weirdly in the gameSetup.
It cleans up the duplicated mods in rdata/user path, by just loading from userdata.
TODO:
- Add warnings when doing 'illegal' stuff, such as loading a lower-priority WRITABLE directory, since for now it's silently ignored.
- warn if there are folders with name conflicts in the user path, since they won't be loaded.
This supersedes D2781, which only had the priority fix.