diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-30 20:30:47 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-30 20:30:47 +0200 |
commit | b86a12149ade500326a238753c31b6e0178d3b5b (patch) | |
tree | 95240fd5ea2f11bd33f731d90199a5cd89782a36 /sys/src/games | |
parent | 25396d3ffdebe800b373d96515a0a109b8c47a44 (diff) |
games/doom: fix config file never being loaded or saved (thanks qu7uux)
basedefault[], the default path to the config file, is never set and remains
blank, unless -config %s is used (cd d_main.c). when games/doom attempts to
open the file, it silently fails and no config file is ever read or written.
this patch sets basedefault to a file in whatever directory a valid wad is
found in I_IdentifyWAD().
Diffstat (limited to 'sys/src/games')
-rw-r--r-- | sys/src/games/doom/d_main.c | 16 | ||||
-rw-r--r-- | sys/src/games/doom/m_misc.c | 6 |
2 files changed, 10 insertions, 12 deletions
diff --git a/sys/src/games/doom/d_main.c b/sys/src/games/doom/d_main.c index 369d67650..f42b34e40 100644 --- a/sys/src/games/doom/d_main.c +++ b/sys/src/games/doom/d_main.c @@ -563,7 +563,7 @@ void D_AddFile (char *file) // void IdentifyVersion (void) { - char *wadfile; + char *wadfile, *slash; if (M_CheckParm ("-shdev")) { @@ -615,35 +615,35 @@ void IdentifyVersion (void) language = french; printf("French version\n"); D_AddFile (wadfile); - return; } else if ( (wadfile = I_IdentifyWAD("doom2.wad")) ) { gamemode = commercial; D_AddFile (wadfile); - return; } else if ( (wadfile = I_IdentifyWAD("plutonia.wad")) ) { gamemode = commercial; D_AddFile (wadfile); - return; } else if ( (wadfile = I_IdentifyWAD("tnt.wad")) ) { gamemode = commercial; D_AddFile (wadfile); - return; } else if ( (wadfile = I_IdentifyWAD("doomu.wad")) ) { gamemode = retail; D_AddFile (wadfile); - return; } else if ( (wadfile = I_IdentifyWAD("doom.wad")) ) { gamemode = registered; D_AddFile (wadfile); - return; } else if ( (wadfile = I_IdentifyWAD("doom1.wad")) ) { gamemode = shareware; D_AddFile (wadfile); - return; } else { printf("Game mode indeterminate.\n"); gamemode = indetermined; + return; } + strncpy(basedefault, wadfile, sizeof(basedefault)-5); + basedefault[sizeof(basedefault)-5] = '\0'; + slash = strrchr(basedefault, '/'); + if (slash++ == 0) + slash = basedefault; + strcpy(slash, "cfg"); } // diff --git a/sys/src/games/doom/m_misc.c b/sys/src/games/doom/m_misc.c index ca3d5ccec..3d9988d46 100644 --- a/sys/src/games/doom/m_misc.c +++ b/sys/src/games/doom/m_misc.c @@ -300,13 +300,11 @@ void M_LoadDefaults (void) // check for a custom default file i = M_CheckParm ("-config"); if (i && i<myargc-1) - { defaultfile = myargv[i+1]; - printf (" default file: %s\n",defaultfile); - } else defaultfile = basedefault; - + printf (" default file: %s\n",defaultfile); + // read the file in, overriding any set defaults f = fopen (defaultfile, "r"); if (f) |