From 9fa4c57bfbd866b63448136554db389f13a09144 Mon Sep 17 00:00:00 2001 From: Paul Broadhead Date: Sun, 20 Oct 2024 14:00:50 +0100 Subject: [PATCH] Option to use a per-server-ID updates directory. Change from fully specified path to one based on the ID from servers.lst. The option now just enables/disables the new path. For example: an ID of pk uses /updates/pk/. --- elconfig.c | 2 +- init.c | 2 +- init.h | 2 +- io/elpathwrapper.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/elconfig.c b/elconfig.c index 50c43a789..300229b58 100755 --- a/elconfig.c +++ b/elconfig.c @@ -3157,7 +3157,7 @@ static void init_ELC_vars(void) SERVER); add_var(OPT_BOOL,"write_ini_on_exit", "wini", &write_ini_on_exit, change_var, 1,"Save INI","Save options when you quit",SERVER); add_var(OPT_STRING,"data_dir","dir",datadir,change_dir_name,90,"Data Directory","Place were we keep our data. Can only be changed with a Client restart.",SERVER); - add_var(OPT_STRING,"alt_updates_dir","aupdir",alt_updates_dir,change_dir_name,90,"Alt Updates Directory","Full path to an alternative updates directory for data files. Normally blank.",SERVER); + add_var(OPT_BOOL,"use_perserver_updates_dir", "uaupdir", &use_perserver_updates_dir, change_var, 0,"Use Per-Server Updates Directory","If enabled a per-server-ID updates directory is used rather than the default that uses the client version. A change only takes effect after a client restart.",SERVER); #endif // ANDROID add_var(OPT_BOOL,"serverpopup","spu",&use_server_pop_win,change_var,1,"Use Special Text Window","Toggles whether server messages from channel 255 are displayed in a pop up window.",SERVER); /* Note: We don't take any action on the already-running thread, as that wouldn't necessarily be good. */ diff --git a/init.c b/init.c index 6cf2b4f29..de9cc68f2 100644 --- a/init.c +++ b/init.c @@ -113,7 +113,7 @@ char datadir[256]=DATA_DIR; char datadir[256]="./"; #endif //DATA_DIR -char alt_updates_dir[256]=""; +int use_perserver_updates_dir = 0; static const char *cfg_filename = "el.cfg"; #ifdef JSON_FILES diff --git a/init.h b/init.h index 46cc766b3..66c1014cb 100644 --- a/init.h +++ b/init.h @@ -251,7 +251,7 @@ typedef struct extern char configdir[256]; /*!< the default directory where we look for configuration files */ extern char datadir[256]; /*!< the default directory where we look for data files (aka installation dir) */ -extern char alt_updates_dir[256]; /*!< an alternative updates directory for data files, if blank, default is /updates/ */ +extern int use_perserver_updates_dir; /*!< by default /updates/ is used for updates, if true /updates/server_ID will be used */ /*! * \ingroup loadsave diff --git a/io/elpathwrapper.c b/io/elpathwrapper.c index dec22e297..b35c1dd63 100644 --- a/io/elpathwrapper.c +++ b/io/elpathwrapper.c @@ -193,8 +193,8 @@ const char * get_path_updates(void) } #ifndef MAP_EDITOR - if (alt_updates_dir[0] != '\0') - safe_snprintf(locbuffer, sizeof(locbuffer), "%s", alt_updates_dir); + if (use_perserver_updates_dir) + safe_snprintf(locbuffer, sizeof(locbuffer), "%supdates/%s/", get_path_config_base(), get_server_name()); else #endif safe_snprintf(locbuffer, sizeof(locbuffer), "%supdates/%d_%d_%d/", get_path_config_base(), VER_MAJOR, VER_MINOR, VER_RELEASE);