tribute passage limit

Death Quotes have reached the current limit of 30 passages per 'book'.
Instead of increasing that, change the selection code to be able to
operate on a subset (dropped from 30 down to 20) at a time while
keeping the excess available for later selection.

Chatting with Death (more than 20 times since he also delivers non-
tribute messages) should cycle through 20 of his 30 passages without
repeating.  After that, another subset of 20 out of the 30 will be
chosen, independent of the first set so might contain all, some, or
none of the 10 that left out before.
This commit is contained in:
PatR
2016-02-18 14:46:25 -08:00
parent 63ef462185
commit ba5449e17e
2 changed files with 30 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 context.h $NHDT-Date: 1447653421 2015/11/16 05:57:01 $ $NHDT-Branch: master $:$NHDT-Revision: 1.28 $ */
/* NetHack 3.6 context.h $NHDT-Date: 1455835579 2016/02/18 22:46:19 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.29 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -93,7 +93,15 @@ struct tribute_info {
struct novel_tracking { /* for choosing random passage when reading novel */
unsigned id; /* novel oid from previous passage selection */
int count; /* number of passage indices available in pasg[] */
xchar pasg[30]; /* pasg[0..count] are passage indices */
xchar pasg[20]; /* pasg[0..count-1] are passage indices */
/* tribute file is allowed to have more than 20 passages for a novel;
if it does, reading will first choose a random subset of 20 of them;
reading all 20 or switching to a different novel and then back again
will pick a new subset, independent of previous ones so might not
contain all--or even any--of the ones left out of the prior subset;
chatting with Death works the same as reading a novel except that
sometimes he delivers one of a few hardcoded messages rather than a
passage from the Death Quotes section of dat/tribute */
};
struct context_info {

View File

@@ -1,4 +1,4 @@
/* NetHack 3.6 files.c $NHDT-Date: 1454035130 2016/01/29 02:38:50 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.202 $ */
/* NetHack 3.6 files.c $NHDT-Date: 1455835581 2016/02/18 22:46:21 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.204 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
@@ -3468,7 +3468,7 @@ boolean wildcards;
#define TITLESCOPE 2
#define PASSAGESCOPE 3
#define MAXPASSAGES SIZE(context.novel.pasg) /* 30 */
#define MAXPASSAGES SIZE(context.novel.pasg) /* 20 */
static int FDECL(choose_passage, (int, unsigned));
@@ -3476,24 +3476,35 @@ static int FDECL(choose_passage, (int, unsigned));
been chosen, reset the tracking to make all passages available again */
static int
choose_passage(passagecnt, oid)
int passagecnt; /* total of available passages, 1..MAXPASSAGES */
int passagecnt; /* total of available passages */
unsigned oid; /* book.o_id, used to determine whether re-reading same book */
{
int idx, res;
if (passagecnt < 1)
return 0;
if (passagecnt > MAXPASSAGES)
passagecnt = MAXPASSAGES;
/* if a different book or we've used up all the passages already,
reset in order to have all 'passagecnt' passages available */
if (oid != context.novel.id || context.novel.count == 0) {
int i, range = passagecnt, limit = MAXPASSAGES;
context.novel.id = oid;
context.novel.count = passagecnt;
for (idx = 0; idx < MAXPASSAGES; idx++)
context.novel.pasg[idx] = (xchar) ((idx < passagecnt) ? idx + 1
: 0);
if (range <= limit) {
/* collect all of the N indices */
context.novel.count = passagecnt;
for (idx = 0; idx < MAXPASSAGES; idx++)
context.novel.pasg[idx] = (xchar) ((idx < passagecnt)
? idx + 1 : 0);
} else {
/* collect MAXPASSAGES of the N indices */
context.novel.count = MAXPASSAGES;
for (idx = i = 0; i < passagecnt; ++i, --range)
if (range > 0 && rn2(range) < limit) {
context.novel.pasg[idx++] = (xchar) (i + 1);
--limit;
}
}
}
idx = rn2(context.novel.count);
@@ -3584,8 +3595,6 @@ unsigned oid; /* book identifier */
if ((p2 = index(p1, ')')) != 0) {
*p2 = '\0';
passagecnt = atoi(p1);
if (passagecnt > MAXPASSAGES)
passagecnt = MAXPASSAGES;
scope = TITLESCOPE;
if (matchedsection && !strcmpi(st, tribtitle)) {
matchedtitle = TRUE;