Skip to content

Commit b504341

Browse files
override default path creation when path must be from root
The default file path is always the primary mod user directory, however some files are only ever created and read from the root user directory. This allows for an override in such cases so that the location_flags variable will match the intended root path. Fixes #4384
1 parent 83c4858 commit b504341

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

code/cfile/cfilesystem.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1981,15 +1981,27 @@ int cf_get_file_list_preallocated(int max, char arr[][MAX_FILENAME_LEN], char**
19811981
// Output: path - Fully qualified pathname.
19821982
//Returns 0 if the result would be too long (invalid result)
19831983
int cf_create_default_path_string(char* path, uint path_max, int pathtype, const char* filename, bool localize,
1984-
uint32_t location_flags)
1984+
uint32_t _location_flags)
19851985
{
1986+
uint32_t location_flags = _location_flags;
1987+
19861988
if ( filename && strchr(filename, DIR_SEPARATOR_CHAR) ) {
19871989
// Already has full path
19881990
strncpy( path, filename, path_max );
19891991

19901992
} else {
19911993
cf_root* root = nullptr;
19921994

1995+
// override location flags for path types which should always come from the root (NOT mod directories)
1996+
// NOTE: cache directories should NOT be added here to avoid possible mod breakage
1997+
switch(pathtype) {
1998+
case CF_TYPE_PLAYERS:
1999+
case CF_TYPE_MULTI_PLAYERS:
2000+
case CF_TYPE_SINGLE_PLAYERS:
2001+
location_flags = CF_LOCATION_ROOT_USER | CF_LOCATION_ROOT_GAME | CF_LOCATION_TYPE_ROOT;
2002+
break;
2003+
}
2004+
19932005
for (auto i = 0; i < Num_roots; ++i) {
19942006
auto current_root = cf_get_root(i);
19952007

0 commit comments

Comments
 (0)