From 53060e3abf8be468387d344879d92c685e2182ae Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Thu, 2 Nov 2006 06:26:37 +0000 Subject: [PATCH] inventory overflow prompting If someone manages to get three or more items with inventory "letter" '#', compact inventory selection prompts to list "#-#" instead of showing every #. It isn't possible to selectively pick a particular one anyway, so this doesn't affect player choices. 1 #: Which item? [$#a-zA-Z] 2 #: Which item? [$##a-zA-Z] 3 #: Which item? [$#-#a-zA-Z] 4 or more #: same as 3. This doesn't address the fact that picking up enough boulders as a giant might overflow the BUFSZ buffer getobj() uses to collect inventory letters prior to calling compactify() on them. --- src/invent.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/invent.c b/src/invent.c index 02af4b4af..7385058fe 100644 --- a/src/invent.c +++ b/src/invent.c @@ -716,6 +716,15 @@ register char *buf; ilet = buf[i1]; continue; } + } else if (ilet == NOINVSYM) { + /* compact three or more consecutive '#' + characters into "#-#" */ + if (i2 >= 2 && buf[i2 - 2] == NOINVSYM && + buf[i2 - 1] == NOINVSYM) + buf[i2 - 1] = '-'; + else if (i2 >= 3 && buf[i2 - 3] == NOINVSYM && + buf[i2 - 2] == '-' && buf[i2 - 1] == NOINVSYM) + --i2; } ilet2 = ilet1; ilet1 = ilet;