Skip to content

Commit e885425

Browse files
Merge pull request #4410 from notimaginative/fix_hud_config_presets
Fix issues with loading of hud config presets
2 parents 049fa72 + b504341 commit e885425

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

code/cfile/cfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ cf_pathtype Pathtypes[CF_MAX_PATH_TYPES] = {
7474
{ CF_TYPE_FONT, "data" DIR_SEPARATOR_STR "fonts", ".vf .ttf .otf", CF_TYPE_DATA },
7575
{ CF_TYPE_EFFECTS, "data" DIR_SEPARATOR_STR "effects", ".ani .eff .pcx .neb .tga .jpg .png .dds .sdr", CF_TYPE_DATA },
7676
{ CF_TYPE_HUD, "data" DIR_SEPARATOR_STR "hud", ".pcx .ani .eff .tga .jpg .png .dds", CF_TYPE_DATA },
77-
{ CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", CF_TYPE_DATA },
77+
{ CF_TYPE_PLAYERS, "data" DIR_SEPARATOR_STR "players", ".hcf", /* DON'T add pilot files here!! */ CF_TYPE_DATA },
7878
{ CF_TYPE_PLAYER_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "images", ".pcx .png .dds", CF_TYPE_PLAYERS },
7979
{ CF_TYPE_SQUAD_IMAGES, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "squads", ".pcx .png .dds", CF_TYPE_PLAYERS },
8080
{ CF_TYPE_SINGLE_PLAYERS, "data" DIR_SEPARATOR_STR "players" DIR_SEPARATOR_STR "single", ".pl2 .cs2 .plr .csg .css .json", CF_TYPE_PLAYERS },

code/cfile/cfilesystem.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,7 @@ int cf_get_file_list(SCP_vector<SCP_string>& list, int pathtype, const char* fil
15511551
}
15521552

15531553
bool skip_packfiles = false;
1554-
if ( (pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
1554+
if ( (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS) ) {
15551555
skip_packfiles = true;
15561556
} else if (Get_file_list_child != NULL) {
15571557
skip_packfiles = true;
@@ -1708,7 +1708,7 @@ int cf_get_file_list(int max, char** list, int pathtype, const char* filter, int
17081708
}
17091709

17101710
bool skip_packfiles = false;
1711-
if ((pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS)) {
1711+
if ((pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS)) {
17121712
skip_packfiles = true;
17131713
}
17141714
else if (Get_file_list_child != NULL) {
@@ -1887,7 +1887,7 @@ int cf_get_file_list_preallocated(int max, char arr[][MAX_FILENAME_LEN], char**
18871887
}
18881888

18891889
bool skip_packfiles = false;
1890-
if ((pathtype == CF_TYPE_PLAYERS) || (pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS)) {
1890+
if ((pathtype == CF_TYPE_SINGLE_PLAYERS) || (pathtype == CF_TYPE_MULTI_PLAYERS)) {
18911891
skip_packfiles = true;
18921892
}
18931893
else if (Get_file_list_child != NULL) {
@@ -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)