From 94eef3c3db8b818fc83e297312ec8d9ff86b4c8c Mon Sep 17 00:00:00 2001 From: SHIRAKATA Kentaro Date: Sun, 14 Jul 2024 23:34:50 +0900 Subject: [PATCH] split "poof" in potion_dip() into a separate function --- src/potion.c | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/src/potion.c b/src/potion.c index a51be8127..25e5e4f0c 100644 --- a/src/potion.c +++ b/src/potion.c @@ -41,6 +41,7 @@ staticfn int dip_ok(struct obj *); staticfn int dip_hands_ok(struct obj *); staticfn void hold_potion(struct obj *, const char *, const char *, const char *); +staticfn void poof(struct obj *); staticfn int potion_dip(struct obj *obj, struct obj *potion); /* used to indicate whether quaff or dip has skipped an opportunity to @@ -2379,6 +2380,14 @@ dip_into(void) return potion_dip(obj, potion); } +staticfn void +poof(struct obj *potion) +{ + if (potion->dknown) + trycall(potion); + useup(potion); +} + /* called by dodip() or dip_into() after obj and potion have been chosen */ staticfn int potion_dip(struct obj *obj, struct obj *potion) @@ -2403,8 +2412,10 @@ potion_dip(struct obj *obj, struct obj *potion) boolean useeit = !Blind || (obj == ublindf && Blindfolded_only); const char *obj_glows = Yobjnam2(obj, "glow"); - if (H2Opotion_dip(potion, obj, useeit, obj_glows)) - goto poof; + if (H2Opotion_dip(potion, obj, useeit, obj_glows)) { + poof(potion); + return ECMD_TIME; + } } else if (obj->otyp == POT_POLYMORPH || potion->otyp == POT_POLYMORPH) { /* some objects can't be polymorphed */ if (obj_unpolyable(obj->otyp == POT_POLYMORPH ? potion : obj)) { @@ -2434,7 +2445,8 @@ potion_dip(struct obj *obj, struct obj *potion) return ECMD_TIME; } else { pline1(nothing_seems_to_happen); - goto poof; + poof(potion); + return ECMD_TIME; } } potion->in_use = FALSE; /* didn't go poof */ @@ -2561,7 +2573,8 @@ potion_dip(struct obj *obj, struct obj *potion) if (potion->otyp == POT_WATER && obj->otyp == TOWEL) { pline_The("towel soaks it up!"); /* wetting towel already done via water_damage() in H2Opotion_dip */ - goto poof; + poof(potion); + return ECMD_TIME; } if (is_poisonable(obj)) { @@ -2574,19 +2587,23 @@ potion_dip(struct obj *obj, struct obj *potion) Strcpy(buf, The(xname(potion))); pline("%s forms a coating on %s.", buf, the(xname(obj))); obj->opoisoned = TRUE; - goto poof; + poof(potion); + return ECMD_TIME; } else if (obj->opoisoned && (potion->otyp == POT_HEALING || potion->otyp == POT_EXTRA_HEALING || potion->otyp == POT_FULL_HEALING)) { pline("A coating wears off %s.", the(xname(obj))); obj->opoisoned = 0; - goto poof; + poof(potion); + return ECMD_TIME; } } if (potion->otyp == POT_ACID) { - if (erode_obj(obj, 0, ERODE_CORRODE, EF_GREASE) != ER_NOTHING) - goto poof; + if (erode_obj(obj, 0, ERODE_CORRODE, EF_GREASE) != ER_NOTHING) { + poof(potion); + return ECMD_TIME; + } } if (potion->otyp == POT_OIL) { @@ -2736,12 +2753,6 @@ potion_dip(struct obj *obj, struct obj *potion) pline("Interesting..."); return ECMD_TIME; - - poof: - if (potion->dknown) - trycall(potion); - useup(potion); - return ECMD_TIME; } /* *monp grants a wish and then leaves the game */