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.
aThey 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 m
od instead of the cache. This can also happen with screenshots, user config (see #2553), etc.
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. However, it did so in a rather weird way, by replacing certain real directories. This worked for the user mod, but didn't fix the above bug.
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:
- Letting users mount as "WRITABLE", which is now needed for a directory to be writable.
- Making the "WRITE" lookup mode explicitly overwrite lower-priority subdirectories so that VFS paths match the hard drive.
- Preventing overwriting a real directory with a lower priority one.
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:
- Need to estimate performance impact. This might actually be faster, I'm not sure
- Need to check the cache priority thingy in test_Pathfinder, that might hide a bug
- Need to add better tests.
- Add warnings when doing 'illegal' stuff, such as loading a lower-priority WRITABLE directory, since for now it's silently ignored.
This supersedes D2781, which only had the priority fix.