thawing ice followup

Modifying an() [actually just_an()] to treat "<thickness> ice" and
"frozen <hallucinatory liquid>" as special cases which shouldn't be
prefixed with "a" or "an" affected using something like "shaved ice"
or "frozen yogurt" as named fruit.
 |a) shaved ice
 |b) frozen yogurt (weapon in hand)
now have article "a" preceding them:
 |a) a shaved ice
 |b) a frozen yogurt (weapon in hand)
However, the existing cases
 |c) iron bars
 |d) an iron bars (weapon in hand)
still get item 'c' wrong.  'd' is slightly odd but that's because the
fruit name is ambiguous as to whether it's singular or plural.
This commit is contained in:
PatR
2023-10-26 01:28:56 -07:00
parent 04d6789c98
commit 4dc8429d9e
5 changed files with 52 additions and 18 deletions

View File

@@ -6,6 +6,13 @@
#ifndef CONFIG_H /* make sure the compiler does not see the typedefs twice */
#define CONFIG_H
#define EXTRA_SANITY_CHECKS
#define MONITOR_HEAP
#define DUMPLOG
#define SCORE_ON_BOTL
#define EDIT_GETLIN
#define LIVELOG
/*
* Section 1: Operating and window systems selection.
* Select the version of the OS you are using.
@@ -582,7 +589,7 @@ typedef unsigned char uchar;
/* An experimental minimalist inventory list capability under tty if you have
* at least 28 additional rows beneath the status window on your terminal */
/* #define TTY_PERM_INVENT */
#define TTY_PERM_INVENT /**/
/* NetHack will execute an external program whenever a new message-window
* message is shown. The program to execute is given in environment variable

View File

@@ -4359,8 +4359,26 @@ look_here(
}
}
if (dfeature && !skip_dfeature)
Sprintf(fbuf, "There is %s here.", an(dfeature));
if (dfeature && !skip_dfeature) {
const char *p;
int article = 1; /* 0 => none, 1 => a/an, 2 => the (not used here) */
/* "molten lava", "iron bars", and plain "ice" are handled as special
cases in an() but probably shouldn't be; don't rely on that */
if (!strcmp(dfeature, "molten lava")
|| !strcmp(dfeature, "iron bars")
|| !strcmp(dfeature, "ice")
|| !strncmp(dfeature, "frozen ", 7) /* ice while hallucinating */
/* thawing ice ("solid ice", "thin ice", &c) */
|| ((p = strchr(dfeature, ' ')) != 0 && !strcmpi(p, " ice")))
article = 0;
if (article == 1)
dfeature = an(dfeature);
/* hardcoded "is" worked here because "iron bars" is actually
"set of iron bars"; use vtense() instead of relying on that */
Sprintf(fbuf, "There %s %s here.", vtense(dfeature, "are"), dfeature);
}
if (!otmp || is_lava(u.ux, u.uy)
|| (is_pool(u.ux, u.uy) && !Underwater)) {

View File

@@ -1858,18 +1858,20 @@ singular(struct obj* otmp, char* (*func)(OBJ_P))
char *
just_an(char *outbuf, const char *str)
{
char c0, *p;
char c0;
*outbuf = '\0';
c0 = lowc(*str);
if (!str[1] || str[1] == ' ') {
/* single letter; might be used for named fruit or a musical note */
Strcpy(outbuf, strchr("aefhilmnosx", c0) ? "an " : "a ");
} else if (!strncmpi(str, "the ", 4) || !strcmpi(str, "molten lava")
|| !strcmpi(str, "iron bars") || !strcmpi(str, "ice")
|| !strncmpi(str, "frozen ", 7) /* ice while hallucinating */
/* thawing ice ("solid ice", "thin ice", &c) */
|| ((p = strchr(str, ' ')) != 0 && !strcmpi(p, " ice"))) {
} else if (!strncmpi(str, "the ", 4)
/* these probably shouldn't be handled here because doing so
impacts inventory when using them for named fruit */
|| !strcmpi(str, "molten lava")
|| !strcmpi(str, "iron bars")
|| !strcmpi(str, "ice")
) {
; /* no article */
} else {
/* normal case is "an <vowel>" or "a <consonant>" */
@@ -2265,7 +2267,7 @@ static const char *const special_subjs[] = {
/* return form of the verb (input plural) for present tense 3rd person subj */
char *
vtense(const char* subj, const char* verb)
vtense(const char *subj, const char *verb)
{
char *buf = nextobuf(), *bspot;
int len, ltmp;

View File

@@ -1062,7 +1062,7 @@ add_cmap_descr(
const char **firstmatch, /* output: pointer to 1st matching description */
char *out_str) /* input/output: current description gets appended */
{
char *mbuf = NULL;
char *mbuf = NULL, *p;
int absidx = abs(idx);
if (glyph == NO_GLYPH) {
@@ -1111,11 +1111,17 @@ add_cmap_descr(
Strcpy(mbuf, "lava");
x_str = mbuf;
article = !(!strncmp(x_str, "water", 5)
|| !strncmp(x_str, "ice", 3)
|| !strncmp(x_str, "lava", 4)
|| !strncmp(x_str, "swamp", 5)
|| !strncmp(x_str, "molten", 6)
|| !strncmp(x_str, "shallow", 7)
|| !strncmp(x_str, "limitless", 9));
|| !strncmp(x_str, "limitless", 9)
/* ice while hallucinating */
|| !strncmp(x_str, "frozen", 6)
/* thawing ice ("solid ice", "thin ice", &c) */
|| ((p = strchr(x_str, ' ')) != 0 && !strcmpi(p, " ice"))
);
}
if (!found) {
@@ -1124,9 +1130,9 @@ add_cmap_descr(
Sprintf(out_str, "%sa trap", prefix);
*hit_trap = TRUE;
} else {
Sprintf(out_str, "%s%s", prefix,
article == 2 ? the(x_str)
: article == 1 ? an(x_str) : x_str);
Sprintf(out_str, "%s%s", prefix, (article == 2) ? the(x_str)
: (article == 1) ? an(x_str)
: x_str);
}
*firstmatch = x_str;
found = 1;
@@ -1226,6 +1232,7 @@ do_screen_description(
if (x_str == unreconnoitered)
goto didlook;
}
check_monsters:
/* Check for monsters */
if (!iflags.terrainmode || (iflags.terrainmode & TER_MON) != 0) {
@@ -1282,8 +1289,8 @@ do_screen_description(
if (sym == DEF_INVISIBLE) {
/* for active clairvoyance, use alternate "unseen creature" */
boolean usealt = (EDetect_monsters & I_SPECIAL) != 0L;
const char *unseen_explain = usealt ? altinvisexplain
: Blind ? altinvisexplain : invisexplain;
const char *unseen_explain = (usealt || Blind) ? altinvisexplain
: invisexplain;
if (!found) {
Sprintf(out_str, "%s%s", prefix, an(unseen_explain));

View File

@@ -365,7 +365,7 @@ describe_decor(void)
} else if (dfeature) {
if (waterhere)
dfeature = strcpy(fbuf, waterbody_name(u.ux, u.uy));
if (strcmp(dfeature, "swamp"))
if (strcmp(dfeature, "swamp") && ltyp != ICE)
dfeature = an(dfeature);
if (Verbose(2, describe_decor1)) {