Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#1940 closed defect (fixed)

[PATCH] Fix VFS to write mod data correctly

Reported by: historic_bruno Owned by: leper
Priority: Must Have Milestone: Alpha 14
Component: Core engine Keywords: patch
Cc: leper Patch:

Description

The VFS can associate many real paths with a single virtual path, which is how e.g. mods work. This is correct for reading, it makes sense that the VFS can read files from one of the several real paths in some defined order. However, for writing files, this is incorrect behavior, there should be a single well-defined real path for writing a file to a given virtual path.

This results in problems like #895, where the mod data may be in a read-only directory or in an archive, the write fails and causes the game to crash.

The desired behavior is as follows:

  • For SVN/Git users, mod data is saved directly within the game's data directory (e.g. binaries/data/mods/public) - always a writable location. This is a convenience for devs, so they can modify the game's data and commit back to the repo.
  • For everyone else, mod data is saved in the user mod directory (see GameDataPaths) - also a guaranteed writable location.

Attachments (1)

vfs-mod-write.patch (8.0 KB ) - added by leper 11 years ago.
Dev implies -noUserMod. Exclude dev.cfg from release packaging. Updated to work properly with mods present in both mod folders

Download all attachments as: .zip

Change History (6)

comment:1 by leper, 11 years ago

Keywords: patch review added
Milestone: BacklogAlpha 14
Summary: Fix VFS to write mod data correctly[PATCH] Fix VFS to write mod data correctly

The attached patch writes to the user mod directory if a config/dev.cfg file is not present. Otherwise it writes to the game data directory of the last mod that has a directory in there. This is not really optimal if a dev wants to keep one of his mods in the user mod directory.

Something missing from the patch is the exclusion of the dev.cfg file from the archive builder for releases.

(testing this should be done with -noUserMod) (maybe that should be implied by the presence of the dev.cfg file)

Any input on how to handle the dev case would be appreciated.

comment:2 by leper, 11 years ago

Thinking about mods present in both directories (user mod and binaries/) it'd be better to mount them with different priorities to make this more explicit, instead of relying on the date of the file or the file loader precedence. I'll attach a new patch.

by leper, 11 years ago

Attachment: vfs-mod-write.patch added

Dev implies -noUserMod. Exclude dev.cfg from release packaging. Updated to work properly with mods present in both mod folders

comment:3 by historic_bruno, 11 years ago

Looks good, here's a few comments:

  • We can add a comment to dev.cfg explaining its purpose
  • dev.cfg should be excluded from the OS X bundle in build-osx-bundle.sh
  • The mods variable on line 465 of GameSetup.cpp could be a const?

I don't really like the inconsistency in the dev and non-dev cases, in terms of mounting the read-only and user-writable mods, but I can't think of a better way of doing it yet. It's already a big improvement over what we have, so I say commit it :)

comment:4 by leper, 11 years ago

Owner: set to leper
Resolution: fixed
Status: newclosed

In 13472:

Write mod data correctly. Fixes #1940.

comment:5 by leper, 11 years ago

Keywords: review removed
Note: See TracTickets for help on using tickets.