split 'nothing_special' of arti_invoke() into separate function

This commit is contained in:
SHIRAKATA Kentaro
2023-11-16 18:10:17 +09:00
committed by PatR
parent 34d6c3cf7c
commit c68f870819

View File

@@ -22,9 +22,11 @@ staticfn struct artifact *get_artifact(struct obj *) NONNULL; /* never returns n
: &artilist[ART_NONARTIFACT]) */ : &artilist[ART_NONARTIFACT]) */
staticfn boolean bane_applies(const struct artifact *, struct monst *) staticfn boolean bane_applies(const struct artifact *, struct monst *)
NONNULLARG12; NONNULLARG12;
staticfn int spec_applies(const struct artifact *, struct monst *) NONNULLARG12; staticfn int spec_applies(const struct artifact *, struct monst *)
NONNULLARG12;
staticfn int invoke_ok(struct obj *); staticfn int invoke_ok(struct obj *);
staticfn void nothing_special(struct obj *) NONNULLARG1;
staticfn int arti_invoke(struct obj *); staticfn int arti_invoke(struct obj *);
staticfn boolean Mb_hit(struct monst * magr, struct monst *mdef, staticfn boolean Mb_hit(struct monst * magr, struct monst *mdef,
struct obj *, int *, int, boolean, char *); struct obj *, int *, int, boolean, char *);
@@ -1666,6 +1668,13 @@ doinvoke(void)
return arti_invoke(obj); return arti_invoke(obj);
} }
staticfn void
nothing_special(struct obj *obj)
{
if (carried(obj))
You_feel("a surge of power, but nothing seems to happen.");
}
staticfn int staticfn int
arti_invoke(struct obj *obj) arti_invoke(struct obj *obj)
{ {
@@ -1722,8 +1731,10 @@ arti_invoke(struct obj *obj)
due to PermaBlind or eyeless polymorph; due to PermaBlind or eyeless polymorph;
vary the message in that situation */ vary the message in that situation */
&& (HBlinded & ~TIMEOUT) != 0L) ? "slightly " : ""); && (HBlinded & ~TIMEOUT) != 0L) ? "slightly " : "");
else else {
goto nothing_special; nothing_special(obj);
return ECMD_TIME;
}
if (healamt > 0) { if (healamt > 0) {
if (Upolyd) if (Upolyd)
u.mh += healamt; u.mh += healamt;
@@ -1750,8 +1761,10 @@ arti_invoke(struct obj *obj)
u.uen += epboost; u.uen += epboost;
disp.botl = TRUE; disp.botl = TRUE;
You_feel("re-energized."); You_feel("re-energized.");
} else } else {
goto nothing_special; nothing_special(obj);
return ECMD_TIME;
}
break; break;
} }
case UNTRAP: { case UNTRAP: {
@@ -1810,7 +1823,8 @@ arti_invoke(struct obj *obj)
n = select_menu(tmpwin, PICK_ONE, &selected); n = select_menu(tmpwin, PICK_ONE, &selected);
if (n <= 0) { if (n <= 0) {
destroy_nhwindow(tmpwin); destroy_nhwindow(tmpwin);
goto nothing_special; nothing_special(obj);
return ECMD_TIME;
} }
i = selected[0].item.a_int - 1; i = selected[0].item.a_int - 1;
free((genericptr_t) selected); free((genericptr_t) selected);
@@ -1848,8 +1862,10 @@ arti_invoke(struct obj *obj)
case CREATE_AMMO: { case CREATE_AMMO: {
struct obj *otmp = mksobj(ARROW, TRUE, FALSE); struct obj *otmp = mksobj(ARROW, TRUE, FALSE);
if (!otmp) if (!otmp) {
goto nothing_special; nothing_special(obj);
return ECMD_TIME;
}
otmp->blessed = obj->blessed; otmp->blessed = obj->blessed;
otmp->cursed = obj->cursed; otmp->cursed = obj->cursed;
otmp->bknown = obj->bknown; otmp->bknown = obj->bknown;
@@ -1979,10 +1995,8 @@ arti_invoke(struct obj *obj)
} }
if ((eprop & ~W_ARTI) || iprop) { if ((eprop & ~W_ARTI) || iprop) {
nothing_special:
/* you had the property from some other source too */ /* you had the property from some other source too */
if (carried(obj)) nothing_special(obj);
You_feel("a surge of power, but nothing seems to happen.");
return ECMD_TIME; return ECMD_TIME;
} }
switch (oart->inv_prop) { switch (oart->inv_prop) {
@@ -2000,8 +2014,10 @@ arti_invoke(struct obj *obj)
(void) float_down(I_SPECIAL | TIMEOUT, W_ARTI); (void) float_down(I_SPECIAL | TIMEOUT, W_ARTI);
break; break;
case INVIS: case INVIS:
if (BInvis || Blind) if (BInvis || Blind) {
goto nothing_special; nothing_special(obj);
return ECMD_TIME;
}
newsym(u.ux, u.uy); newsym(u.ux, u.uy);
if (on) if (on)
Your("body takes on a %s transparency...", Your("body takes on a %s transparency...",