Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old September 30, 2012, 07:48   #1
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
[3.4.0] Bug with parsing empty keymaps

There's a bug in the prefs parsing in 3.4.0 related to keymaps which map a key to (nothing). That is, if you do this:

Code:
1. "Create keymap"
2. Press some key (doesn't matter which, really)
3. Type "$" to terminate the keymap
4. Press "y" to save the keymap
and then append your keymaps to a file, Angband will refuse to load the keymap on next startup.

Here's a patch which fixes it, can this please be added before 3.5.x (or even 3.4.1 if that ever happens)?

Code:
diff --git a/src/prefs.c b/src/prefs.c
index 0c486df..116d7e0 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -864,13 +864,15 @@ static enum parser_error parse_prefs_b(struct parser *p)
 
 static enum parser_error parse_prefs_a(struct parser *p)
 {
-	const char *act;
+	const char *act = "";
 
 	struct prefs_data *d = parser_priv(p);
 	assert(d != NULL);
 	if (d->bypass) return PARSE_ERROR_NONE;
 
-	act = parser_getstr(p, "act");
+	if (parser_hasval(p, "act")) {
+		act = parser_getstr(p, "act");
+	}
 	keypress_from_text(d->keymap_buffer, N_ELEMENTS(d->keymap_buffer), act);
 
 	return PARSE_ERROR_NONE;
@@ -1022,7 +1024,7 @@ static struct parser *init_parse_prefs(bool user)
 		/* XXX should be split into two kinds of line */
 	parser_reg(p, "B uint idx str text", parse_prefs_b);
 		/* XXX idx should be {tval,sval} pair! */
-	parser_reg(p, "A str act", parse_prefs_a);
+	parser_reg(p, "A ?str act", parse_prefs_a);
 	parser_reg(p, "C int mode str key", parse_prefs_c);
 	parser_reg(p, "M int type sym attr", parse_prefs_m);
 	parser_reg(p, "V uint idx int k int r int g int b", parse_prefs_v);
AnonymousHero is offline   Reply With Quote
Old September 30, 2012, 15:51   #2
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Excellent spot, thanks - logged as #1683.
__________________
"3.4 is much better than 3.1, 3.2 or 3.3. It still is easier than 3.0.9, but it is more convenient to play without being ridiculously easy, so it is my new favorite of the versions." - Timo Pietila
Magnate is offline   Reply With Quote
Old September 30, 2012, 20:02   #3
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 3,002
fizzix is on a distinguished road
Thanks, we'll try to get this in for 3.4.1 We've been fixing some minor bugs behind the scenes, and we'll probably get 3.4.1 out after the competition is over.
fizzix is offline   Reply With Quote
Old October 1, 2012, 05:39   #4
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by fizzix View Post
Thanks, we'll try to get this in for 3.4.1 We've been fixing some minor bugs behind the scenes, and we'll probably get 3.4.1 out after the competition is over.
Cool, thanks.

(Btw, the reason this is quite important to me is that I use empty keymaps to rebind Return/Enter to do nothing so that I can avoid the in-game action menu when going through messages using those keys.)
AnonymousHero is offline   Reply With Quote
Old October 1, 2012, 10:23   #5
Magnate
Angband Devteam member
 
Join Date: May 2007
Location: London, UK
Posts: 5,057
Magnate is on a distinguished road
Send a message via MSN to Magnate Send a message via Yahoo to Magnate
Quote:
Originally Posted by AnonymousHero View Post
(Btw, the reason this is quite important to me is that I use empty keymaps to rebind Return/Enter to do nothing so that I can avoid the in-game action menu when going through messages using those keys.)
Given that we have an FAQ which advises precisely this ("How do I turn off that annoying Enter menu?", or something like that), it's probably a good idea that we un-break it.
__________________
"3.4 is much better than 3.1, 3.2 or 3.3. It still is easier than 3.0.9, but it is more convenient to play without being ridiculously easy, so it is my new favorite of the versions." - Timo Pietila
Magnate is offline   Reply With Quote
Old October 6, 2012, 16:13   #6
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 3,002
fizzix is on a distinguished road
I actually could not reproduce the incorrect behavior on the Windows7 build. Nevertheless, I've checked your patch and it works also. So I've sent a pull request for it. Hopefully someone can test it out and we can put it in 3.4.1.
fizzix is offline   Reply With Quote
Old October 6, 2012, 22:11   #7
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by fizzix View Post
I actually could not reproduce the incorrect behavior on the Windows7 build.
Wow. That's weird -- I wouldn't think that this has any sort of platform-dependence... but perhaps there's an extra "\r" in the .pref file (on Windows)? This would probably be enough to convince the parser that there's actual content there?
AnonymousHero is offline   Reply With Quote
Old October 6, 2012, 22:26   #8
fizzix
Prophet
 
Join Date: Aug 2009
Location: Madison, Wisconsin, US
Posts: 3,002
fizzix is on a distinguished road
Quote:
Originally Posted by AnonymousHero View Post
Wow. That's weird -- I wouldn't think that this has any sort of platform-dependence... but perhaps there's an extra "\r" in the .pref file (on Windows)? This would probably be enough to convince the parser that there's actual content there?
Not sure! Regardless, can you test out the current build on github, to make sure that it is fixed. If all is good I'll pull it into the 3.4.x release branch.

edit: The nightlies build on rephial should be updated by now as well.

Last edited by fizzix; October 6, 2012 at 22:45.
fizzix is offline   Reply With Quote
Old October 7, 2012, 09:21   #9
AnonymousHero
Veteran
 
AnonymousHero's Avatar
 
Join Date: Jun 2007
Posts: 1,367
AnonymousHero is on a distinguished road
Quote:
Originally Posted by fizzix View Post
Not sure! Regardless, can you test out the current build on github, to make sure that it is fixed. If all is good I'll pull it into the 3.4.x release branch.

edit: The nightlies build on rephial should be updated by now as well.
Well, the github patch looks exactly identical to mine and I've been running master + my patch for a few days, so it should be hunky-dory.
AnonymousHero is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Keymaps can't do what I want them to... Tobias Vanilla 1 August 1, 2011 16:41
Bug: cannot stop editing keymaps jens Development 1 June 20, 2011 16:19
Keymaps for the Macro User? Chud Vanilla 2 June 11, 2011 19:52
macros => keymaps jens Vanilla 2 May 19, 2011 02:43
Empty minded monsters are suspectible to the nether attack Ycombinator Vanilla 2 September 15, 2010 16:56


All times are GMT +1. The time now is 19:49.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.