summaryrefslogtreecommitdiff
path: root/sys/src/games/doom/d_main.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-07-30 20:30:47 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2015-07-30 20:30:47 +0200
commitb86a12149ade500326a238753c31b6e0178d3b5b (patch)
tree95240fd5ea2f11bd33f731d90199a5cd89782a36 /sys/src/games/doom/d_main.c
parent25396d3ffdebe800b373d96515a0a109b8c47a44 (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/doom/d_main.c')
-rw-r--r--sys/src/games/doom/d_main.c16
1 files changed, 8 insertions, 8 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");
}
//