9front - general discussion about 9front
 help / color / mirror / Atom feed
From: qux <qu7uux@gmail.com>
To: 9front@9front.org
Subject: games/doom: fix config file never being loaded or saved
Date: Wed, 29 Jul 2015 19:11:14 +0300	[thread overview]
Message-ID: <CAAGZaiKLN1PXVWCwtHuxzt6fL8zbL9GRn5XvMgtW9K1qf7WNSA@mail.gmail.com> (raw)

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;


             reply	other threads:[~2015-07-29 16:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-29 16:11 qux [this message]
2015-07-30 18:30 ` [9front] " cinap_lenrek
2015-07-31 15:30   ` qux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAAGZaiKLN1PXVWCwtHuxzt6fL8zbL9GRn5XvMgtW9K1qf7WNSA@mail.gmail.com \
    --to=qu7uux@gmail.com \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).