* games/doom: fix config file never being loaded or saved
@ 2015-07-29 16:11 qux
2015-07-30 18:30 ` [9front] " cinap_lenrek
0 siblings, 1 reply; 3+ messages in thread
From: qux @ 2015-07-29 16:11 UTC (permalink / raw)
To: 9front
games/doom: fix config file never being loaded or saved
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().
if the config file is correctly saved/loaded, volume levels, screen size, key
bindings, etc. are restored when games/doom is started again.
this is cumbersome, because there there are four places where doom data files
can be stored, rather than one.
diff -r aa2b4dca05f1 sys/src/games/doom/i_system.c
--- a/sys/src/games/doom/i_system.c Wed Jul 29 14:51:00 2015 +0200
+++ b/sys/src/games/doom/i_system.c Wed Jul 29 18:58:03 2015 +0300
@@ -121,11 +121,13 @@
char *home;
snprint(path, sizeof path, wadname);
+ snprintf(basedefault, sizeof basedefault, "cfg");
if (I_FileExists (path))
return path;
if(home = getenv("home")){
snprintf(path, sizeof path, "%s/lib/doom/%s", home, wadname);
+ snprintf(basedefault, sizeof basedefault, "%s/lib/doom/cfg", home);
free(home);
if (I_FileExists (path))
@@ -133,10 +135,12 @@
}
snprintf(path, sizeof path, "/sys/lib/doom/%s", wadname);
+ snprintf(basedefault, sizeof basedefault, "/sys/lib/doom/cfg", home);
if (I_FileExists (path))
return path;
snprintf(path, sizeof path, "/sys/games/lib/doom/%s", wadname);
+ snprintf(basedefault, sizeof basedefault, "/sys/games/lib/doom/cfg", home);
if (I_FileExists (path))
return path;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] games/doom: fix config file never being loaded or saved
2015-07-29 16:11 games/doom: fix config file never being loaded or saved qux
@ 2015-07-30 18:30 ` cinap_lenrek
2015-07-31 15:30 ` qux
0 siblings, 1 reply; 3+ messages in thread
From: cinap_lenrek @ 2015-07-30 18:30 UTC (permalink / raw)
To: 9front
this can be done better in IdentifyVersion(), where it even used to set
basedefault[].
diff -r b357d5b16135 sys/src/games/doom/d_main.c
--- a/sys/src/games/doom/d_main.c Thu Jul 30 20:02:23 2015 +0200
+++ b/sys/src/games/doom/d_main.c Thu Jul 30 20:28:13 2015 +0200
@@ -563,7 +563,7 @@
//
void IdentifyVersion (void)
{
- char *wadfile;
+ char *wadfile, *slash;
if (M_CheckParm ("-shdev"))
{
@@ -615,35 +615,35 @@
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");
}
//
--
cinap
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9front] games/doom: fix config file never being loaded or saved
2015-07-30 18:30 ` [9front] " cinap_lenrek
@ 2015-07-31 15:30 ` qux
0 siblings, 0 replies; 3+ messages in thread
From: qux @ 2015-07-31 15:30 UTC (permalink / raw)
To: 9front
On 7/30/15, cinap_lenrek@felloff.net <cinap_lenrek@felloff.net> wrote:
> this can be done better in IdentifyVersion(), where it even used to set
> basedefault[].
>
> diff -r b357d5b16135 sys/src/games/doom/d_main.c
> --- a/sys/src/games/doom/d_main.c Thu Jul 30 20:02:23 2015 +0200
> +++ b/sys/src/games/doom/d_main.c Thu Jul 30 20:28:13 2015 +0200
> @@ -563,7 +563,7 @@
> //
> void IdentifyVersion (void)
> {
> - char *wadfile;
> + char *wadfile, *slash;
>
> if (M_CheckParm ("-shdev"))
> {
> @@ -615,35 +615,35 @@
> 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");
> }
>
> //
>
> --
> cinap
>
Yeah, it's much better that way.
Thank you for your work!
qwx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-31 15:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-29 16:11 games/doom: fix config file never being loaded or saved qux
2015-07-30 18:30 ` [9front] " cinap_lenrek
2015-07-31 15:30 ` qux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).