diff --git a/polymer/eduke32/build/include/editor.h b/polymer/eduke32/build/include/editor.h index 5e1c1c7f5..e1f548941 100644 --- a/polymer/eduke32/build/include/editor.h +++ b/polymer/eduke32/build/include/editor.h @@ -13,6 +13,9 @@ #define VERSION "2.0.0devel" +#define SETUPFILENAME "mapster32.cfg" +extern char setupfilename[BMAX_PATH]; + // Build keys #define BK_MOVEFORWARD 0 #define BK_MOVEBACKWARD 1 diff --git a/polymer/eduke32/build/src/config.c b/polymer/eduke32/build/src/config.c index 421ef0444..82588e0cb 100644 --- a/polymer/eduke32/build/src/config.c +++ b/polymer/eduke32/build/src/config.c @@ -346,6 +346,44 @@ int32_t loadsetup(const char *fn) return 0; } +void writesettings(void) // save binds and aliases to _m32_settings.cfg +{ + BFILE *fp; + char *ptr = Bstrdup(setupfilename); + char tempbuf[128]; + + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + Bsprintf(tempbuf, "m32_settings.cfg"); + else Bsprintf(tempbuf, "%s_m32_settings.cfg", strtok(ptr, ".")); + + fp = Bfopen(tempbuf, "wt"); + + if (fp) + { + Bfprintf(fp,"// this file is automatically generated by Mapster32\n"); + Bfprintf(fp,"// these settings take precedence over your main cfg file\n"); + Bfprintf(fp,"// do not modify if you lack common sense\n"); + + OSD_WriteAliases(fp); + OSD_WriteCvars(fp); + + Bfclose(fp); + + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + OSD_Printf("Wrote m32_settings.cfg\n"); + else OSD_Printf("Wrote %s_m32_settings.cfg\n",ptr); + + Bfree(ptr); + return; + } + + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + OSD_Printf("Error writing m32_settings.cfg: %s\n", strerror(errno)); + else OSD_Printf("Error writing %s_m32_settings.cfg: %s\n",ptr,strerror(errno)); + + Bfree(ptr); +} + int32_t writesetup(const char *fn) { BFILE *fp; @@ -654,5 +692,7 @@ int32_t writesetup(const char *fn) Bfclose(fp); + writesettings(); + return 0; } diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index 34cd5d237..bec489f0a 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -79,7 +79,7 @@ static char g_modDir[BMAX_PATH]; static char levelname[BMAX_PATH]; // static char *startwin_labeltext = "Starting Mapster32..."; -static char setupfilename[BMAX_PATH] = "mapster32.cfg"; +char setupfilename[BMAX_PATH] = SETUPFILENAME; int32_t fixmaponsave_sprites = 1; static int32_t fixmaponsave_walls = 0; @@ -10457,7 +10457,7 @@ int32_t ExtInit(void) #ifdef USE_OPENGL glusetexcache = -1; - if (Bstrcmp(setupfilename, "mapster32.cfg")) + if (Bstrcmp(setupfilename, SETUPFILENAME)) initprintf("Using config file \"%s\".\n",setupfilename); if (loadsetup(setupfilename) < 0) @@ -10511,6 +10511,15 @@ int32_t ExtInit(void) OSD_SetParameters(0,2, 0,0, 4,0); registerosdcommands(); + { + char *ptr = Bstrdup(setupfilename), *p = strtok(ptr,"."); + if (!Bstrcmp(setupfilename, SETUPFILENAME)) + Bsprintf(tempbuf, "m32_settings.cfg"); + else Bsprintf(tempbuf,"%s_m32_settings.cfg",p); + OSD_Exec(tempbuf); + Bfree(ptr); + } + // backup pathsearchmode so that a later open // will hopefully be the same file pathsearchmode_oninit = pathsearchmode; diff --git a/polymer/eduke32/source/config.c b/polymer/eduke32/source/config.c index bc7b7f651..2f148db7d 100644 --- a/polymer/eduke32/source/config.c +++ b/polymer/eduke32/source/config.c @@ -735,7 +735,7 @@ void CONFIG_WriteBinds(void) // save binds and aliases to _settings.cfg if (fp) { - Bfprintf(fp,"// this file automatically generated by EDuke32\n"); + Bfprintf(fp,"// this file is automatically generated by EDuke32\n"); Bfprintf(fp,"// these settings take precedence over your main cfg file\n"); Bfprintf(fp,"// do not modify if you lack common sense\n");