From 0315cd876a6d6c56e4b55f72f48a6023f75c8385 Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Sun, 8 May 2022 22:50:01 +0900 Subject: [PATCH 1/3] split fixing curse trouble into separate function --- src/pray.c | 67 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/src/pray.c b/src/pray.c index d8a3cc97c..dea8abe27 100644 --- a/src/pray.c +++ b/src/pray.c @@ -7,6 +7,7 @@ static int prayer_done(void); static struct obj *worst_cursed_item(void); static int in_trouble(void); +static void fix_curse_trouble(struct obj *, const char *); static void fix_worst_trouble(int); static void angrygods(aligntyp); static void at_your_feet(const char *); @@ -328,6 +329,30 @@ worst_cursed_item(void) return otmp; } +static void +fix_curse_trouble(struct obj *otmp, const char *what) +{ + if (!otmp) { + impossible("fix_worst_trouble: nothing to uncurse."); + return; + } + if (otmp == uarmg && Glib) { + make_glib(0); + Your("%s are no longer slippery.", gloves_simple_name(uarmg)); + if (!otmp->cursed) + return; + } + if (!Blind || (otmp == ublindf && Blindfolded_only)) { + pline("%s %s.", + what ? what : (const char *) Yobjnam2(otmp, "softly glow"), + hcolor(NH_AMBER)); + iflags.last_msg = PLNMSG_OBJ_GLOWS; + otmp->bknown = !Hallucination; /* ok to skip set_bknown() */ + } + uncurse(otmp); + update_inventory(); +} + static void fix_worst_trouble(int trouble) { @@ -409,8 +434,10 @@ fix_worst_trouble(int trouble) if (otmp == uright) what = rightglow; } - if (otmp) - goto decurse; + if (otmp) { + fix_curse_trouble(otmp, what); + break; + } } break; case TROUBLE_STUCK_IN_WALL: @@ -441,11 +468,13 @@ fix_worst_trouble(int trouble) if (otmp == uright) what = rightglow; } - goto decurse; + fix_curse_trouble(otmp, what); + break; case TROUBLE_UNUSEABLE_HANDS: if (welded(uwep)) { otmp = uwep; - goto decurse; + fix_curse_trouble(otmp, what); + break; } if (Upolyd && nohands(g.youmonst.data)) { if (!Unchanging) { @@ -453,7 +482,8 @@ fix_worst_trouble(int trouble) rehumanize(); /* "You return to {normal} form." */ } else if ((otmp = unchanger()) != 0 && otmp->cursed) { /* otmp is an amulet of unchanging */ - goto decurse; + fix_curse_trouble(otmp, what); + break; } } if (nohands(g.youmonst.data) || !freehand()) @@ -461,7 +491,8 @@ fix_worst_trouble(int trouble) break; case TROUBLE_CURSED_BLINDFOLD: otmp = ublindf; - goto decurse; + fix_curse_trouble(otmp, what); + break; case TROUBLE_LYCANTHROPE: you_unwere(TRUE); break; @@ -479,8 +510,7 @@ fix_worst_trouble(int trouble) otmp = uarmg; else if (Cursed_obj(uarmf, FUMBLE_BOOTS)) otmp = uarmf; - goto decurse; - /*NOTREACHED*/ + fix_curse_trouble(otmp, what); break; case TROUBLE_CURSED_ITEMS: otmp = worst_cursed_item(); @@ -488,26 +518,7 @@ fix_worst_trouble(int trouble) what = rightglow; else if (otmp == uleft) what = leftglow; - decurse: - if (!otmp) { - impossible("fix_worst_trouble: nothing to uncurse."); - return; - } - if (otmp == uarmg && Glib) { - make_glib(0); - Your("%s are no longer slippery.", gloves_simple_name(uarmg)); - if (!otmp->cursed) - break; - } - if (!Blind || (otmp == ublindf && Blindfolded_only)) { - pline("%s %s.", - what ? what : (const char *) Yobjnam2(otmp, "softly glow"), - hcolor(NH_AMBER)); - iflags.last_msg = PLNMSG_OBJ_GLOWS; - otmp->bknown = !Hallucination; /* ok to skip set_bknown() */ - } - uncurse(otmp); - update_inventory(); + fix_curse_trouble(otmp, what); break; case TROUBLE_POISONED: /* override Fixed_abil; ignore items which confer that */ From 3baa00bb1ea5034798448e8d0499a5fc70c3e6c3 Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Sat, 21 May 2022 00:33:53 +0900 Subject: [PATCH 2/3] adjust the function name in impossible() --- src/pray.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pray.c b/src/pray.c index dea8abe27..a6335ec30 100644 --- a/src/pray.c +++ b/src/pray.c @@ -333,7 +333,7 @@ static void fix_curse_trouble(struct obj *otmp, const char *what) { if (!otmp) { - impossible("fix_worst_trouble: nothing to uncurse."); + impossible("fix_curse_trouble: nothing to uncurse."); return; } if (otmp == uarmg && Glib) { From 0c0262eab0c71cce2c39824de7210cd90a6d7781 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 20 May 2022 16:40:57 -0400 Subject: [PATCH 3/3] Handle -eaux plurals in makeplural/makesingular I noticed a comment about -eau pluralizing as -eaux, e.g. "gateau" -> "gateaux", was not consistent with the actual output of makeplural. Same thing with "VAX" -> "VAXen" in the line below it; they're very old comments, so maybe they were originally meant to point out some plurals makeplural got wrong? Since they predate the addition of "oxen" and "geese" to one_off[] (and the array itself), it seems like the other special cases mentioned in the comments would also have been wrong at the time they were written. Address this horrifying pastry-related oversight by adding handling for '-eaux' plurals to makeplural, with an exception for 'bureau' (plural 'bureaus'; according to the dictionary, 'bureaux' is an acceptable variant but 'bureaus' is more common, at least in American English). There's also an exception for 'Bordeaux' (as in a bottle of the wine), since the singular and plural are the same. A bit surprised this wasn't already in there, since 'gateau' is a real food item and seems like a much more likely fruit name than some of the inedible items makeplural has special rules for. Also add " au " to compounds[] in singplur_compound, so that 'gateau au chocolat' will pluralize correctly to 'gateaux au chocolat'. Without that change, the result is 'gateau au chocolats'. --- src/objnam.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/objnam.c b/src/objnam.c index 5d28e29d1..b72c00702 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -2359,7 +2359,8 @@ static const char *const as_is[] = { "tuna", "yaki", "-hai", "krill", "manes", "moose", "ninja", "sheep", "ronin", "roshi", "shito", "tengu", "ki-rin", "Nazgul", "gunyoki", - "piranha", "samurai", "shuriken", "haggis", 0, + "piranha", "samurai", "shuriken", "haggis", "Bordeaux", + 0, /* Note: "fish" and "piranha" are collective plurals, suitable for "wiped out all ". For "3 ", they should be "fishes" and "piranhas" instead. We settle for collective @@ -2453,7 +2454,8 @@ singplur_compound(char *str) " versus ", " from ", " in ", " on ", " a la ", " with", /* " with "? */ " de ", " d'", " du ", - "-in-", "-at-", 0 + "-in-", "-at-", " au ", + 0 }, /* list of first characters for all compounds[] entries */ compound_start[] = " -"; @@ -2566,6 +2568,7 @@ makeplural(const char* oldstr) { static const char *const already_plural[] = { "ae", /* algae, larvae, &c */ + "eaux", /* chateaux, gateaux */ "matzot", 0, }; @@ -2624,6 +2627,13 @@ makeplural(const char* oldstr) Strcasecpy(spot - 1, "es"); goto bottom; } + /* -eau/-eaux (gateau, chapeau...) */ + if (len >= 3 && !strcmpi(spot - 2, "eau") + /* 'bureaus' is the more common plural of 'bureau' */ + && strncmpi(str, "bureau", 6)) { + Strcasecpy(spot + 1, "x"); + goto bottom; + } /* matzoh/matzot, possible food name */ if (len >= 6 && (!strcmpi(spot - 5, "matzoh") || !strcmpi(spot - 5, "matzah"))) { @@ -2636,7 +2646,6 @@ makeplural(const char* oldstr) goto bottom; } - /* note: -eau/-eaux (gateau, bordeau...) */ /* note: ox/oxen, VAX/VAXen, goose/geese */ lo_c = lowc(*spot); @@ -2795,8 +2804,9 @@ makesingular(const char* oldstr) goto bottom; } /* matzot -> matzo, algae -> alga */ - if (!BSTRCMPI(bp, p - 6, "matzot") || !BSTRCMPI(bp, p - 2, "ae")) { - *(p - 1) = '\0'; /* drop t/e */ + if (!BSTRCMPI(bp, p - 6, "matzot") || !BSTRCMPI(bp, p - 2, "ae") + || !BSTRCMPI(bp, p - 4, "eaux")) { + *(p - 1) = '\0'; /* drop t/e/x */ goto bottom; } /* balactheria -> balactherium */