Make "cookie-only" rumors explicit in rumors file

The prior behavior was an ugly kludge that treated rumors as
only-eligible-to-appear-from-fortune-cookies if they contained the
string "fortune" or "pity". This commit gets rid of that system and
introduces a system where each rumor can be specified as such by
prefixing it with "[cookie]".

In order to avoid changing existing behavior, I have applied the
[cookie] prefix to all the rumors which were affected under the old
rules. However, several rumors seem like they were misclassified under
the old rules, and I am in favor of changing them as follows:

Should be made cookie-only (they only really make sense in context of
eating a fortune cookie):
- "Ouch. I hate when that happens."
- "PLEASE ignore previous rumor."
- "Suddenly, the dungeon will collapse..."
- "Unfortunately, this message was left intentionally blank."

Should be made non-cookie-only (they make sense if they appear as
engravings, Oracle messages, or artifact whispers):
- "They say that a gypsy could tell your fortune for a price."
- "They say that fortune cookies are food for thought."
This commit is contained in:
copperwater
2023-03-18 17:05:13 -04:00
committed by Pasi Kallinen
parent 4126eb3cbe
commit 4542d14d23
2 changed files with 31 additions and 20 deletions

View File

@@ -121,6 +121,8 @@ getrumor(
dlb *rumors;
long beginning, ending;
char line[BUFSZ];
static const char *cookie_marker = "[cookie] ";
const int marklen = strlen(cookie_marker);
rumor_buf[0] = '\0';
if (gt.true_rumor_size < 0L) /* a previous try failed to open RUMORFILE */
@@ -163,9 +165,8 @@ getrumor(
Strcpy(rumor_buf,
get_rnd_line(rumors, line, (unsigned) sizeof line, rn2,
beginning, ending, MD_PAD_RUMORS));
} while (count++ < 50 && (exclude_cookie
&& (strstri(rumor_buf, "fortune")
|| strstri(rumor_buf, "pity"))));
} while (count++ < 50 && exclude_cookie
&& !strncmp(rumor_buf, cookie_marker, marklen));
(void) dlb_fclose(rumors);
if (count >= 50)
impossible("Can't find non-cookie rumor?");
@@ -175,6 +176,16 @@ getrumor(
couldnt_open_file(RUMORFILE);
gt.true_rumor_size = -1; /* don't try to open it again */
}
if (!exclude_cookie
&& !strncmp(rumor_buf, cookie_marker, marklen)) {
/* remove cookie_marker from the string */
char *src = rumor_buf + marklen;
char *dst = rumor_buf;
for (; *src != '\0'; ++src, ++dst) {
*dst = *src;
}
*dst = '\0'; /* terminator wasn't copied */
}
return rumor_buf;
}