[rfk-dev] [esr at thyrsus.com: More cleanup patches.]
Peter A. H. Peterson
pedro at tastytronic.net
Thu Oct 25 15:02:47 PDT 2012
Final patches.
----- Forwarded message from "Eric S. Raymond" <esr at thyrsus.com> -----
Date: Thu, 25 Oct 2012 05:23:18 -0400
From: "Eric S. Raymond" <esr at thyrsus.com>
To: rfk-dev at robotfindskitten.org, pedro at tastytronic.net
Subject: More cleanup patches.
Reply-To: esr at thyrsus.com
--
<a href="http://www.catb.org/~esr/">Eric S. Raymond</a>
>From 3cbb2e10b797eca551c33086afc9ef5c66b775e7 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 04:46:20 -0400
Subject: [PATCH 10/13] NEWS file update.
---
ChangeLog | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 5ef5c52..476845c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Oct 29 2012 Eric S. Raymond <esr at thyrsus.com>
+ * ANSI/POSIX cleanup, magic-number removal, compiler warning fixes.
+ * Added some NKIs for the new century.
+
+ [More time passes]
+
Nov 30 2007 Ryan Finnie <ryan at finnie.org>
* Fixed NKI message wrapping on small terminals (Debian bug #199680)
* Converted robotfindskitten.c from CRLF to LF. Take that, CP/M!
--
1.7.9.5
From 64d5fb1d457b936a7b55fe625cc5cd01d1ea3b7c Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 05:03:07 -0400
Subject: [PATCH 11/13] The ESC key is a lose. Stop trying to use it.
---
BUGS | 11 -----------
doc/robotfindskitten.info | 31 ++++++++++++++++---------------
doc/robotfindskitten.texi | 4 ++--
src/robotfindskitten.c | 7 +++----
4 files changed, 21 insertions(+), 32 deletions(-)
diff --git a/BUGS b/BUGS
index c70fed1..25a4c30 100644
--- a/BUGS
+++ b/BUGS
@@ -1,16 +1,5 @@
Current bugs:
-------------
-When you hit the escape key, it takes about a second to register. Why?
-
- From the getch man page (Shazdeh <zen at emgnulation.org>):
---
- Use of the escape key by a programmer for a single charac-
- ter function is discouraged, as it will cause a delay of
- up to one second while the keypad code looks for a follow-
- ing function-key sequence.
---
- Also, you can now use Q to exit the simulation.
-
ncurses doesn't cooperate with characters less than '!'. It displays
them as, eg ^A for what should by rights be a little smiley
face. draw.h uses the A_ALTCHARSET flag. It doesn't work.
diff --git a/doc/robotfindskitten.info b/doc/robotfindskitten.info
index e5db6f5..aaa7dc1 100644
--- a/doc/robotfindskitten.info
+++ b/doc/robotfindskitten.info
@@ -1,4 +1,4 @@
-This is robotfindskitten.info, produced by makeinfo version 4.8 from
+This is robotfindskitten.info, produced by makeinfo version 4.13 from
robotfindskitten.texi.
INFO-DIR-SECTION Games
@@ -118,8 +118,9 @@ File: robotfindskitten.info, Node: Controls, Next: A Word of Warning, Prev: T
Sorry if that seemed obvious, but you never know. I don't want to
be accused of writing incomplete documentation.
- 3. If you want to end the program for whatever reason, just hit
- Escape, or terminate the program by hitting control-C.
+ 3. If you want to end the program for whatever reason, just hit 'q',
+ or'Q', or 'x', or 'X', or terminate the program by hitting
+ control-C.
File: robotfindskitten.info, Node: A Word of Warning, Next: Another Word of Warning, Prev: Controls, Up: Top
@@ -329,17 +330,17 @@ Concept Index
Tag Table:
-Node: Top894
-Node: The Niceties1511
-Node: The Documentation2178
-Node: The Parts of the Simulation3082
-Node: Controls4248
-Node: A Word of Warning4965
-Node: Another Word of Warning5131
-Node: Yet Another Word of Warning5589
-Node: Technical Information for Hard-Core Geeks5922
-Node: Join the Bludgeoning robotfindskitten Community!7296
-Node: A Final Thought8319
-Node: Index10104
+Node: Top895
+Node: The Niceties1512
+Node: The Documentation2179
+Node: The Parts of the Simulation3083
+Node: Controls4249
+Node: A Word of Warning4991
+Node: Another Word of Warning5157
+Node: Yet Another Word of Warning5615
+Node: Technical Information for Hard-Core Geeks5948
+Node: Join the Bludgeoning robotfindskitten Community!7322
+Node: A Final Thought8345
+Node: Index10130
End Tag Table
diff --git a/doc/robotfindskitten.texi b/doc/robotfindskitten.texi
index c2ecc00..f2b3c1f 100644
--- a/doc/robotfindskitten.texi
+++ b/doc/robotfindskitten.texi
@@ -178,8 +178,8 @@ documentation.
@cindex ending the simulation prematurely
@item
-If you want to end the program for whatever reason, just hit Escape, or
-terminate the program by hitting control-C.
+If you want to end the program for whatever reason, just hit 'q', or'Q',
+or 'x', or 'X', or terminate the program by hitting control-C.
@end enumerate
@node A Word of Warning, Another Word of Warning, Controls, Top
diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index 8f3868b..2940bbe 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -50,8 +50,6 @@ static char* ver = VERSION;
#define ROBOT 0
#define KITTEN 1
-#define KEY_ESC 27
-
/*Nethack keycodes*/
#define NETHACK_down 'j'
#define NETHACK_DOWN 'J'
@@ -162,7 +160,7 @@ void play_game()
int input;
input = getch();
- while ((input != KEY_ESC) && (input != 'q') && (input != 'Q'))
+ while ((input != 'x')&& (input != 'X') && (input != 'q') && (input != 'Q'))
{
process_input(input);
@@ -368,7 +366,8 @@ void instructions(void)
printw("is complicated by the existence of various things which are not kitten.\n");
printw("Robot must touch items to determine if they are kitten or not. The game\n");
printw("ends when robotfindskitten. Alternatively, you may end the game by hitting\n");
- printw("the Esc key. See the documentation for more information.\n\n");
+ printw("the q key, or with a good old-fashioned Ctrl-C.\n\n");
+ printw("See the documentation for more information.\n\n");
printw("Press any key to start.\n");
refresh();
--
1.7.9.5
>From 3079c9bb7cfa7fae25eec920ae234cffc17b24cf Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 05:04:57 -0400
Subject: [PATCH 12/13] These bugs are bugs no more.
---
BUGS | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/BUGS b/BUGS
index 25a4c30..22b044d 100644
--- a/BUGS
+++ b/BUGS
@@ -1,16 +1,3 @@
-Current bugs:
--------------
-ncurses doesn't cooperate with characters less than '!'. It displays
-them as, eg ^A for what should by rights be a little smiley
-face. draw.h uses the A_ALTCHARSET flag. It doesn't work.
-
-Occasionally, there are redraw errors. Any ncurses gurus out there who can
-clear this up?
-
- There's a chance that when I fixed the problem with noecho, it
- fixed this as well, but it hasn't been tested.
- - Shazdeh <zen at emgnulation.org>
-
Possible Improvements:
----------------------
The code generally needs to be cleaned up.
--
1.7.9.5
>From e246786aa1c608dfdf816c4650e761948a3d7d31 Mon Sep 17 00:00:00 2001
From: "Eric S. Raymond" <esr at thyrsus.com>
Date: Thu, 25 Oct 2012 05:14:08 -0400
Subject: [PATCH 13/13] More magic-number elimination.
---
src/robotfindskitten.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/robotfindskitten.c b/src/robotfindskitten.c
index 2940bbe..a04014c 100644
--- a/src/robotfindskitten.c
+++ b/src/robotfindskitten.c
@@ -82,10 +82,14 @@ static char* ver = VERSION;
#define Y_MIN 3
#define Y_MAX (LINES - 1)
+/*Bounds the range of ASCII printables*/
+#define MIN_CHAR '!'
+#define MAX_CHAR '~'
+
/*Macros for generating numbers in different ranges*/
#define randx() rand() % X_MAX+1
#define randy() rand() % (Y_MAX-Y_MIN+1)+Y_MIN /*I'm feeling randy()!*/
-#define randchar() rand() % (126-'!'+1)+'!';
+#define randchar() MIN_CHAR + (rand() % (MAX_CHAR-MIN_CHAR+1))
#define randcolor() rand() % 6 + 1
#define randbold() (rand() % 2 ? true:false)
--
1.7.9.5
----- End forwarded message -----
--
Peter A. H. Peterson
Graduate Student Researcher
Laboratory for Advanced Systems Research
University of California, Los Angeles
More information about the rfk-dev
mailing list