split discarding broken wand into separate function
This commit is contained in:
32
src/apply.c
32
src/apply.c
@@ -37,6 +37,7 @@ static int use_royal_jelly(struct obj **);
|
||||
static int grapple_range(void);
|
||||
static boolean can_grapple_location(coordxy, coordxy);
|
||||
static int use_grapple(struct obj *);
|
||||
static void discard_broken_wand(void);
|
||||
static int do_break_wand(struct obj *);
|
||||
static int apply_ok(struct obj *);
|
||||
static int flip_through_book(struct obj *);
|
||||
@@ -3713,6 +3714,18 @@ use_grapple(struct obj *obj)
|
||||
return ECMD_TIME;
|
||||
}
|
||||
|
||||
static void
|
||||
discard_broken_wand(void)
|
||||
{
|
||||
struct obj *obj;
|
||||
|
||||
obj = gc.current_wand; /* [see dozap() and destroy_item()] */
|
||||
gc.current_wand = 0;
|
||||
if (obj)
|
||||
delobj(obj);
|
||||
nomul(0);
|
||||
}
|
||||
|
||||
/* return 1 if the wand is broken, hence some time elapsed */
|
||||
static int
|
||||
do_break_wand(struct obj *obj)
|
||||
@@ -3763,7 +3776,8 @@ do_break_wand(struct obj *obj)
|
||||
|
||||
if (!zappable(obj)) {
|
||||
pline(nothing_else_happens);
|
||||
goto discard_broken_wand;
|
||||
discard_broken_wand();
|
||||
return ECMD_TIME;
|
||||
}
|
||||
/* successful call to zappable() consumes a charge; put it back */
|
||||
obj->spe++;
|
||||
@@ -3786,7 +3800,8 @@ do_break_wand(struct obj *obj)
|
||||
release_hold();
|
||||
if (obj->dknown)
|
||||
makeknown(WAN_OPENING);
|
||||
goto discard_broken_wand;
|
||||
discard_broken_wand();
|
||||
return ECMD_TIME;
|
||||
}
|
||||
/*FALLTHRU*/
|
||||
case WAN_WISHING:
|
||||
@@ -3796,7 +3811,8 @@ do_break_wand(struct obj *obj)
|
||||
case WAN_ENLIGHTENMENT:
|
||||
case WAN_SECRET_DOOR_DETECTION:
|
||||
pline(nothing_else_happens);
|
||||
goto discard_broken_wand;
|
||||
discard_broken_wand();
|
||||
return ECMD_TIME;
|
||||
case WAN_DEATH:
|
||||
case WAN_LIGHTNING:
|
||||
dmg *= 4;
|
||||
@@ -3813,7 +3829,8 @@ do_break_wand(struct obj *obj)
|
||||
wanexpl:
|
||||
explode(u.ux, u.uy, -(obj->otyp), dmg, WAND_CLASS, expltype);
|
||||
makeknown(obj->otyp); /* explode describes the effect */
|
||||
goto discard_broken_wand;
|
||||
discard_broken_wand();
|
||||
return ECMD_TIME;
|
||||
case WAN_STRIKING:
|
||||
/* we want this before the explosion instead of at the very end */
|
||||
Soundeffect(se_wall_of_force, 65);
|
||||
@@ -3942,12 +3959,7 @@ do_break_wand(struct obj *obj)
|
||||
if (obj->otyp == WAN_LIGHT)
|
||||
litroom(TRUE, obj); /* only needs to be done once */
|
||||
|
||||
discard_broken_wand:
|
||||
obj = gc.current_wand; /* [see dozap() and destroy_item()] */
|
||||
gc.current_wand = 0;
|
||||
if (obj)
|
||||
delobj(obj);
|
||||
nomul(0);
|
||||
discard_broken_wand();
|
||||
return ECMD_TIME;
|
||||
#undef BY_OBJECT
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user