9front - general discussion about 9front
 help / color / mirror / Atom feed
* 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

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).