From 6151bab0d1d5902e6d4bebf3b2b1c915cad36dd8 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 31 Jan 2024 00:15:12 +0900 Subject: [PATCH] [quakefs] Support loading dirconf directly With this, it is a little easier to make qwaq independent of quake. The default dirconf is still meant for quake, and fs_dirconf can still be used to override the configuration. --- include/QF/quakefs.h | 12 ++++++++++++ libs/util/quakefs.c | 12 +++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/QF/quakefs.h b/include/QF/quakefs.h index 17b4f4a53..0eeb42a7f 100644 --- a/include/QF/quakefs.h +++ b/include/QF/quakefs.h @@ -109,6 +109,7 @@ extern int qfs_filesize; struct cache_user_s; struct dstring_s; struct memhunk_s; +struct plitem_s; /** Initialize the Quake Filesystem. @@ -125,6 +126,17 @@ struct memhunk_s; */ void QFS_Init (struct memhunk_s *hunk, const char *game); +/** Set the directory configuration prior to initialization + + This allows the default configuration to be overriden at build time. Must + be called before QFS_Init is called. fs_dirconf will still allow the + configuration to be overridden. + + \param config Property list specifity the directory layout used by the + engine. The list will be 'retained'. +*/ +void QFS_SetConfig (struct plitem_s *config); + /** Change the current game directory. The configuration for the game directory is taken from \ref dirconf. diff --git a/libs/util/quakefs.c b/libs/util/quakefs.c index ae736d433..6dea5ce08 100644 --- a/libs/util/quakefs.c +++ b/libs/util/quakefs.c @@ -718,6 +718,14 @@ no_config: qfs_gd_plist = PL_GetPropertyList (qfs_default_dirconf, 0); } +void +QFS_SetConfig (plitem_t *config) +{ + PL_Retain (config); + PL_Release (qfs_gd_plist); + qfs_gd_plist = config; +} + /* qfs_contains_updir @@ -1492,7 +1500,9 @@ QFS_Init (memhunk_t *hunk, const char *game) qfs_userpath = Sys_ExpandSquiggle (fs_userpath); - qfs_load_config (); + if (!qfs_gd_plist || *fs_dirconf) { + qfs_load_config (); + } qfs_game = game;