split "finishi_splitting" into a separate function
This commit is contained in:
34
src/wield.c
34
src/wield.c
@@ -56,6 +56,7 @@ staticfn boolean cant_wield_corpse(struct obj *) NONNULLARG1;
|
|||||||
staticfn int ready_weapon(struct obj *) NO_NNARGS;
|
staticfn int ready_weapon(struct obj *) NO_NNARGS;
|
||||||
staticfn int ready_ok(struct obj *) NO_NNARGS;
|
staticfn int ready_ok(struct obj *) NO_NNARGS;
|
||||||
staticfn int wield_ok(struct obj *) NO_NNARGS;
|
staticfn int wield_ok(struct obj *) NO_NNARGS;
|
||||||
|
staticfn void finish_splitting(struct obj *);
|
||||||
|
|
||||||
/* used by will_weld() */
|
/* used by will_weld() */
|
||||||
/* probably should be renamed */
|
/* probably should be renamed */
|
||||||
@@ -336,13 +337,20 @@ wield_ok(struct obj *obj)
|
|||||||
return GETOBJ_DOWNPLAY;
|
return GETOBJ_DOWNPLAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
staticfn void
|
||||||
|
finish_splitting(struct obj *obj)
|
||||||
|
{
|
||||||
|
/* obj was split off from something; give it its own invlet */
|
||||||
|
freeinv(obj);
|
||||||
|
addinv_nomerge(obj);
|
||||||
|
}
|
||||||
|
|
||||||
/* the #wield command - wield a weapon */
|
/* the #wield command - wield a weapon */
|
||||||
int
|
int
|
||||||
dowield(void)
|
dowield(void)
|
||||||
{
|
{
|
||||||
char qbuf[QBUFSZ];
|
char qbuf[QBUFSZ];
|
||||||
struct obj *wep, *oldwep;
|
struct obj *wep, *oldwep;
|
||||||
boolean finish_splitting = FALSE;
|
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
/* May we attempt this? */
|
/* May we attempt this? */
|
||||||
@@ -384,7 +392,7 @@ dowield(void)
|
|||||||
wep = uwep;
|
wep = uwep;
|
||||||
goto already_wielded;
|
goto already_wielded;
|
||||||
}
|
}
|
||||||
finish_splitting = TRUE;
|
finish_splitting(wep);
|
||||||
goto wielding;
|
goto wielding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -405,7 +413,7 @@ dowield(void)
|
|||||||
case 'y':
|
case 'y':
|
||||||
/* leave N-1 quivered, split off 1 to wield */
|
/* leave N-1 quivered, split off 1 to wield */
|
||||||
wep = splitobj(uquiver, 1L);
|
wep = splitobj(uquiver, 1L);
|
||||||
finish_splitting = TRUE;
|
finish_splitting(wep);
|
||||||
goto wielding;
|
goto wielding;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -433,12 +441,6 @@ dowield(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
wielding:
|
wielding:
|
||||||
if (finish_splitting) {
|
|
||||||
/* wep was split off from something; give it its own invlet */
|
|
||||||
freeinv(wep);
|
|
||||||
addinv_nomerge(wep);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set your new primary weapon */
|
/* Set your new primary weapon */
|
||||||
oldwep = uwep;
|
oldwep = uwep;
|
||||||
result = ready_weapon(wep);
|
result = ready_weapon(wep);
|
||||||
@@ -507,8 +509,7 @@ doquiver_core(const char *verb) /* "ready" or "fire" */
|
|||||||
char qbuf[QBUFSZ];
|
char qbuf[QBUFSZ];
|
||||||
struct obj *newquiver;
|
struct obj *newquiver;
|
||||||
int res;
|
int res;
|
||||||
boolean finish_splitting = FALSE,
|
boolean was_uwep = FALSE, was_twoweap = u.twoweap;
|
||||||
was_uwep = FALSE, was_twoweap = u.twoweap;
|
|
||||||
|
|
||||||
/* Since the quiver isn't in your hands, don't check cantwield(),
|
/* Since the quiver isn't in your hands, don't check cantwield(),
|
||||||
will_weld(), touch_petrifies(), etc. */
|
will_weld(), touch_petrifies(), etc. */
|
||||||
@@ -551,7 +552,7 @@ doquiver_core(const char *verb) /* "ready" or "fire" */
|
|||||||
unsplitobj(newquiver);
|
unsplitobj(newquiver);
|
||||||
return ECMD_OK;
|
return ECMD_OK;
|
||||||
}
|
}
|
||||||
finish_splitting = TRUE;
|
finish_splitting(newquiver);
|
||||||
} else if (newquiver == uquiver) {
|
} else if (newquiver == uquiver) {
|
||||||
already_quivered:
|
already_quivered:
|
||||||
pline("That ammunition is already readied!");
|
pline("That ammunition is already readied!");
|
||||||
@@ -578,7 +579,7 @@ doquiver_core(const char *verb) /* "ready" or "fire" */
|
|||||||
case 'y':
|
case 'y':
|
||||||
/* leave 1 wielded, split rest off and put into quiver */
|
/* leave 1 wielded, split rest off and put into quiver */
|
||||||
newquiver = splitobj(uwep, uwep->quan - 1L);
|
newquiver = splitobj(uwep, uwep->quan - 1L);
|
||||||
finish_splitting = TRUE;
|
finish_splitting(newquiver);
|
||||||
goto quivering;
|
goto quivering;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -616,7 +617,7 @@ doquiver_core(const char *verb) /* "ready" or "fire" */
|
|||||||
case 'y':
|
case 'y':
|
||||||
/* leave 1 alt-wielded, split rest off and put into quiver */
|
/* leave 1 alt-wielded, split rest off and put into quiver */
|
||||||
newquiver = splitobj(uswapwep, uswapwep->quan - 1L);
|
newquiver = splitobj(uswapwep, uswapwep->quan - 1L);
|
||||||
finish_splitting = TRUE;
|
finish_splitting(newquiver);
|
||||||
goto quivering;
|
goto quivering;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -644,11 +645,6 @@ doquiver_core(const char *verb) /* "ready" or "fire" */
|
|||||||
}
|
}
|
||||||
|
|
||||||
quivering:
|
quivering:
|
||||||
if (finish_splitting) {
|
|
||||||
freeinv(newquiver);
|
|
||||||
addinv_nomerge(newquiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(verb, "ready")) {
|
if (!strcmp(verb, "ready")) {
|
||||||
/* place item in quiver before printing so that inventory feedback
|
/* place item in quiver before printing so that inventory feedback
|
||||||
includes "(at the ready)" */
|
includes "(at the ready)" */
|
||||||
|
|||||||
Reference in New Issue
Block a user