#include "hack.h"
-STATIC_OVL NEARDATA long takeoff_mask = 0L;
-static NEARDATA long taking_off = 0L;
-
-static NEARDATA int todelay;
-static boolean cancelled_don = FALSE;
-
static NEARDATA const char see_yourself[] = "see yourself";
static NEARDATA const char unknown_type[] = "Unknown type of %s (%d)";
static NEARDATA const char c_armor[] = "armor",
setworn((struct obj *)0, W_ARMF);
switch (otyp) {
case SPEED_BOOTS:
- if (!Very_fast && !cancelled_don) {
+ if (!Very_fast && !context.takeoff.cancelled_don) {
makeknown(otyp);
You_feel("yourself slow down%s.",
Fast ? " a bit" : "");
break;
case WATER_WALKING_BOOTS:
if (is_pool(u.ux,u.uy) && !Levitation && !Flying &&
- !is_clinger(youmonst.data) && !cancelled_don) {
+ !is_clinger(youmonst.data) && !context.takeoff.cancelled_don) {
makeknown(otyp);
/* make boots known in case you survive the drowning */
spoteffects(TRUE);
}
break;
case ELVEN_BOOTS:
- if (!oldprop && !HStealth && !BStealth && !cancelled_don) {
+ if (!oldprop && !HStealth && !BStealth && !context.takeoff.cancelled_don) {
makeknown(otyp);
You("sure are noisy.");
}
HFumbling = EFumbling = 0;
break;
case LEVITATION_BOOTS:
- if (!oldprop && !HLevitation && !cancelled_don) {
+ if (!oldprop && !HLevitation && !context.takeoff.cancelled_don) {
(void) float_down(0L, 0L);
makeknown(otyp);
}
break;
default: impossible(unknown_type, c_boots, otyp);
}
- cancelled_don = FALSE;
+ context.takeoff.cancelled_don = FALSE;
return 0;
}
context.botl = 1;
break;
case CORNUTHAUM:
- if (!cancelled_don) {
+ if (!context.takeoff.cancelled_don) {
ABON(A_CHA) += (Role_if(PM_WIZARD) ? -1 : 1);
context.botl = 1;
}
see_monsters();
return 0;
case HELM_OF_BRILLIANCE:
- if (!cancelled_don) adj_abon(uarmh, -uarmh->spe);
+ if (!context.takeoff.cancelled_don) adj_abon(uarmh, -uarmh->spe);
break;
case HELM_OF_OPPOSITE_ALIGNMENT:
u.ualign.type = u.ualignbase[A_CURRENT];
default: impossible(unknown_type, c_helmet, uarmh->otyp);
}
setworn((struct obj *)0, W_ARMH);
- cancelled_don = FALSE;
+ context.takeoff.cancelled_don = FALSE;
return 0;
}
context.botl = 1; /* taken care of in attrib.c */
break;
case GAUNTLETS_OF_DEXTERITY:
- if (!cancelled_don) adj_abon(uarmg, -uarmg->spe);
+ if (!context.takeoff.cancelled_don) adj_abon(uarmg, -uarmg->spe);
break;
default: impossible(unknown_type, c_gloves, uarmg->otyp);
}
setworn((struct obj *)0, W_ARMG);
- cancelled_don = FALSE;
+ context.takeoff.cancelled_don = FALSE;
(void) encumber_msg(); /* immediate feedback for GoP */
/* Prevent wielding cockatrice when not wearing gloves */
Armor_off()
{
setworn((struct obj *)0, W_ARM);
- cancelled_don = FALSE;
+ context.takeoff.cancelled_don = FALSE;
return 0;
}
Armor_gone()
{
setnotworn(uarm);
- cancelled_don = FALSE;
+ context.takeoff.cancelled_don = FALSE;
return 0;
}
* wasting time on it (and don't dereference it when donning would
* otherwise finish)
*/
- cancelled_don = (afternmv == Boots_on || afternmv == Helmet_on ||
+ context.takeoff.cancelled_don = (afternmv == Boots_on || afternmv == Helmet_on ||
afternmv == Gloves_on || afternmv == Armor_on);
afternmv = 0;
nomovemsg = (char *)0;
return 0;
}
- reset_remarm(); /* clear takeoff_mask and taking_off */
+ reset_remarm(); /* clear context.takeoff.mask and context.takeoff.what */
(void) select_off(otmp);
- if (!takeoff_mask) return 0;
- reset_remarm(); /* armoroff() doesn't use takeoff_mask */
+ if (!context.takeoff.mask) return 0;
+ reset_remarm(); /* armoroff() doesn't use context.takeoff.mask */
(void) armoroff(otmp);
return(1);
return(0);
}
- reset_remarm(); /* clear takeoff_mask and taking_off */
+ reset_remarm(); /* clear context.takeoff.mask and context.takeoff.what */
(void) select_off(otmp);
- if (!takeoff_mask) return 0;
+ if (!context.takeoff.mask) return 0;
reset_remarm(); /* not used by Ring_/Amulet_/Blindf_off() */
if (otmp == uright || otmp == uleft) {
else setworn((struct obj *)0, otmp->owornmask & W_ARMOR);
off_msg(otmp);
}
- takeoff_mask = taking_off = 0L;
+ context.takeoff.mask = context.takeoff.what = 0L;
return(1);
}
/* if(is_shield(otmp)) (void) Shield_on(); */
on_msg(otmp);
}
- takeoff_mask = taking_off = 0L;
+ context.takeoff.mask = context.takeoff.what = 0L;
return(1);
}
if (cursed(otmp)) return 0;
}
- if(otmp == uarm) takeoff_mask |= WORN_ARMOR;
- else if(otmp == uarmc) takeoff_mask |= WORN_CLOAK;
- else if(otmp == uarmf) takeoff_mask |= WORN_BOOTS;
- else if(otmp == uarmg) takeoff_mask |= WORN_GLOVES;
- else if(otmp == uarmh) takeoff_mask |= WORN_HELMET;
- else if(otmp == uarms) takeoff_mask |= WORN_SHIELD;
+ if(otmp == uarm) context.takeoff.mask |= WORN_ARMOR;
+ else if(otmp == uarmc) context.takeoff.mask |= WORN_CLOAK;
+ else if(otmp == uarmf) context.takeoff.mask |= WORN_BOOTS;
+ else if(otmp == uarmg) context.takeoff.mask |= WORN_GLOVES;
+ else if(otmp == uarmh) context.takeoff.mask |= WORN_HELMET;
+ else if(otmp == uarms) context.takeoff.mask |= WORN_SHIELD;
#ifdef TOURIST
- else if(otmp == uarmu) takeoff_mask |= WORN_SHIRT;
+ else if(otmp == uarmu) context.takeoff.mask |= WORN_SHIRT;
#endif
- else if(otmp == uleft) takeoff_mask |= LEFT_RING;
- else if(otmp == uright) takeoff_mask |= RIGHT_RING;
- else if(otmp == uamul) takeoff_mask |= WORN_AMUL;
- else if(otmp == ublindf) takeoff_mask |= WORN_BLINDF;
- else if(otmp == uwep) takeoff_mask |= W_WEP;
- else if(otmp == uswapwep) takeoff_mask |= W_SWAPWEP;
- else if(otmp == uquiver) takeoff_mask |= W_QUIVER;
+ else if(otmp == uleft) context.takeoff.mask |= LEFT_RING;
+ else if(otmp == uright) context.takeoff.mask |= RIGHT_RING;
+ else if(otmp == uamul) context.takeoff.mask |= WORN_AMUL;
+ else if(otmp == ublindf) context.takeoff.mask |= WORN_BLINDF;
+ else if(otmp == uwep) context.takeoff.mask |= W_WEP;
+ else if(otmp == uswapwep) context.takeoff.mask |= W_SWAPWEP;
+ else if(otmp == uquiver) context.takeoff.mask |= W_QUIVER;
else impossible("select_off: %s???", doname(otmp));
{
register struct obj *otmp = (struct obj *)0;
- if (taking_off == W_WEP) {
+ if (context.takeoff.what == W_WEP) {
if(!cursed(uwep)) {
setuwep((struct obj *) 0);
You("are empty %s.", body_part(HANDED));
u.twoweap = FALSE;
}
- } else if (taking_off == W_SWAPWEP) {
+ } else if (context.takeoff.what == W_SWAPWEP) {
setuswapwep((struct obj *) 0);
You("no longer have a second weapon readied.");
u.twoweap = FALSE;
- } else if (taking_off == W_QUIVER) {
+ } else if (context.takeoff.what == W_QUIVER) {
setuqwep((struct obj *) 0);
You("no longer have ammunition readied.");
- } else if (taking_off == WORN_ARMOR) {
+ } else if (context.takeoff.what == WORN_ARMOR) {
otmp = uarm;
if(!cursed(otmp)) (void) Armor_off();
- } else if (taking_off == WORN_CLOAK) {
+ } else if (context.takeoff.what == WORN_CLOAK) {
otmp = uarmc;
if(!cursed(otmp)) (void) Cloak_off();
- } else if (taking_off == WORN_BOOTS) {
+ } else if (context.takeoff.what == WORN_BOOTS) {
otmp = uarmf;
if(!cursed(otmp)) (void) Boots_off();
- } else if (taking_off == WORN_GLOVES) {
+ } else if (context.takeoff.what == WORN_GLOVES) {
otmp = uarmg;
if(!cursed(otmp)) (void) Gloves_off();
- } else if (taking_off == WORN_HELMET) {
+ } else if (context.takeoff.what == WORN_HELMET) {
otmp = uarmh;
if(!cursed(otmp)) (void) Helmet_off();
- } else if (taking_off == WORN_SHIELD) {
+ } else if (context.takeoff.what == WORN_SHIELD) {
otmp = uarms;
if(!cursed(otmp)) (void) Shield_off();
#ifdef TOURIST
- } else if (taking_off == WORN_SHIRT) {
+ } else if (context.takeoff.what == WORN_SHIRT) {
otmp = uarmu;
if(!cursed(otmp))
setworn((struct obj *)0, uarmu->owornmask & W_ARMOR);
#endif
- } else if (taking_off == WORN_AMUL) {
+ } else if (context.takeoff.what == WORN_AMUL) {
otmp = uamul;
if(!cursed(otmp)) Amulet_off();
- } else if (taking_off == LEFT_RING) {
+ } else if (context.takeoff.what == LEFT_RING) {
otmp = uleft;
if(!cursed(otmp)) Ring_off(uleft);
- } else if (taking_off == RIGHT_RING) {
+ } else if (context.takeoff.what == RIGHT_RING) {
otmp = uright;
if(!cursed(otmp)) Ring_off(uright);
- } else if (taking_off == WORN_BLINDF) {
+ } else if (context.takeoff.what == WORN_BLINDF) {
if (!cursed(ublindf)) Blindf_off(ublindf);
- } else impossible("do_takeoff: taking off %lx", taking_off);
+ } else impossible("do_takeoff: taking off %lx", context.takeoff.what);
return(otmp);
}
-static const char *disrobing = "";
-
STATIC_PTR
int
take_off()
register int i;
register struct obj *otmp;
- if (taking_off) {
- if (todelay > 0) {
- todelay--;
+ if (context.takeoff.what) {
+ if (context.takeoff.delay > 0) {
+ context.takeoff.delay--;
return(1); /* still busy */
} else {
if ((otmp = do_takeoff())) off_msg(otmp);
}
- takeoff_mask &= ~taking_off;
- taking_off = 0L;
+ context.takeoff.mask &= ~context.takeoff.what;
+ context.takeoff.what = 0L;
}
for(i = 0; takeoff_order[i]; i++)
- if(takeoff_mask & takeoff_order[i]) {
- taking_off = takeoff_order[i];
+ if(context.takeoff.mask & takeoff_order[i]) {
+ context.takeoff.what = takeoff_order[i];
break;
}
otmp = (struct obj *) 0;
- todelay = 0;
+ context.takeoff.delay = 0;
- if (taking_off == 0L) {
- You("finish %s.", disrobing);
+ if (context.takeoff.what == 0L) {
+ You("finish %s.", context.takeoff.disrobing);
return 0;
- } else if (taking_off == W_WEP) {
- todelay = 1;
- } else if (taking_off == W_SWAPWEP) {
- todelay = 1;
- } else if (taking_off == W_QUIVER) {
- todelay = 1;
- } else if (taking_off == WORN_ARMOR) {
+ } else if (context.takeoff.what == W_WEP) {
+ context.takeoff.delay = 1;
+ } else if (context.takeoff.what == W_SWAPWEP) {
+ context.takeoff.delay = 1;
+ } else if (context.takeoff.what == W_QUIVER) {
+ context.takeoff.delay = 1;
+ } else if (context.takeoff.what == WORN_ARMOR) {
otmp = uarm;
/* If a cloak is being worn, add the time to take it off and put
* it back on again. Kludge alert! since that time is 0 for all
* known cloaks, add 1 so that it actually matters...
*/
- if (uarmc) todelay += 2 * objects[uarmc->otyp].oc_delay + 1;
- } else if (taking_off == WORN_CLOAK) {
+ if (uarmc) context.takeoff.delay += 2 * objects[uarmc->otyp].oc_delay + 1;
+ } else if (context.takeoff.what == WORN_CLOAK) {
otmp = uarmc;
- } else if (taking_off == WORN_BOOTS) {
+ } else if (context.takeoff.what == WORN_BOOTS) {
otmp = uarmf;
- } else if (taking_off == WORN_GLOVES) {
+ } else if (context.takeoff.what == WORN_GLOVES) {
otmp = uarmg;
- } else if (taking_off == WORN_HELMET) {
+ } else if (context.takeoff.what == WORN_HELMET) {
otmp = uarmh;
- } else if (taking_off == WORN_SHIELD) {
+ } else if (context.takeoff.what == WORN_SHIELD) {
otmp = uarms;
#ifdef TOURIST
- } else if (taking_off == WORN_SHIRT) {
+ } else if (context.takeoff.what == WORN_SHIRT) {
otmp = uarmu;
/* add the time to take off and put back on armor and/or cloak */
- if (uarm) todelay += 2 * objects[uarm->otyp].oc_delay;
- if (uarmc) todelay += 2 * objects[uarmc->otyp].oc_delay + 1;
+ if (uarm) context.takeoff.delay += 2 * objects[uarm->otyp].oc_delay;
+ if (uarmc) context.takeoff.delay += 2 * objects[uarmc->otyp].oc_delay + 1;
#endif
- } else if (taking_off == WORN_AMUL) {
- todelay = 1;
- } else if (taking_off == LEFT_RING) {
- todelay = 1;
- } else if (taking_off == RIGHT_RING) {
- todelay = 1;
- } else if (taking_off == WORN_BLINDF) {
- todelay = 2;
+ } else if (context.takeoff.what == WORN_AMUL) {
+ context.takeoff.delay = 1;
+ } else if (context.takeoff.what == LEFT_RING) {
+ context.takeoff.delay = 1;
+ } else if (context.takeoff.what == RIGHT_RING) {
+ context.takeoff.delay = 1;
+ } else if (context.takeoff.what == WORN_BLINDF) {
+ context.takeoff.delay = 2;
} else {
- impossible("take_off: taking off %lx", taking_off);
+ impossible("take_off: taking off %lx", context.takeoff.what);
return 0; /* force done */
}
- if (otmp) todelay += objects[otmp->otyp].oc_delay;
+ if (otmp) context.takeoff.delay += objects[otmp->otyp].oc_delay;
/* Since setting the occupation now starts the counter next move, that
* would always produce a delay 1 too big per item unless we subtract
* 1 here to account for it.
*/
- if (todelay>0) todelay--;
+ if (context.takeoff.delay>0) context.takeoff.delay--;
- set_occupation(take_off, disrobing, 0);
+ set_occupation(take_off,
+ (context.takeoff.disrobing[0]) ?
+ context.takeoff.disrobing : (char *)0, 0);
return(1); /* get busy */
}
void
reset_remarm()
{
- taking_off = takeoff_mask = 0L;
- disrobing = nul;
+ context.takeoff.what = context.takeoff.mask = 0L;
+ context.takeoff.disrobing[0] = '\0';
}
/* the 'A' command */
{
int result = 0;
- if (taking_off || takeoff_mask) {
- You("continue %s.", disrobing);
- set_occupation(take_off, disrobing, 0);
+ if (context.takeoff.what || context.takeoff.mask) {
+ You("continue %s.", context.takeoff.disrobing);
+ set_occupation(take_off, context.takeoff.disrobing, 0);
(void) take_off();
return 0;
} else if (!uwep && !uswapwep && !uquiver && !uamul && !ublindf &&
(result = ggetobj("take off", select_off, 0, FALSE, (unsigned *)0)) < -1)
result = menu_remarm(result);
- if (takeoff_mask) {
+ if (context.takeoff.mask) {
/* default activity for armor and/or accessories,
possibly combined with weapons */
- disrobing = "disrobing";
+ (void)strncpy(context.takeoff.disrobing, "disrobing", CONTEXTVERBSZ);
/* specific activity when handling weapons only */
- if (!(takeoff_mask & ~(W_WEP|W_SWAPWEP|W_QUIVER)))
- disrobing = "disarming";
+ if (!(context.takeoff.mask & ~(W_WEP|W_SWAPWEP|W_QUIVER)))
+ (void)strncpy(context.takeoff.disrobing, "disarming", CONTEXTVERBSZ);
(void) take_off();
}
/* The time to perform the command is already completely accounted for
#include "hack.h"
-static NEARDATA schar delay; /* moves left for this spell */
-static NEARDATA struct obj *book; /* last/current book being xscribed */
-
/* spellmenu arguments; 0 thru n-1 used as spl_book[] index when swapping */
#define SPELLMENU_CAST (-2)
#define SPELLMENU_VIEW (-1)
gone = TRUE;
} else {
You("find yourself reading the %s line over and over again.",
- spellbook == book ? "next" : "first");
+ spellbook == context.spbook.book ? "next" : "first");
}
return gone;
}
boolean costly = TRUE;
/* JDS: lenses give 50% faster reading; 33% smaller read time */
- if (delay && ublindf && ublindf->otyp == LENSES && rn2(2)) delay++;
+ if (context.spbook.delay && ublindf && ublindf->otyp == LENSES && rn2(2)) context.spbook.delay++;
if (Confusion) { /* became confused while learning */
- (void) confused_book(book);
- book = 0; /* no longer studying */
- nomul(delay); /* remaining delay is uninterrupted */
- delay = 0;
+ (void) confused_book(context.spbook.book);
+ context.spbook.book = 0; /* no longer studying */
+ context.spbook.o_id = 0;
+ nomul(context.spbook.delay); /* remaining delay is uninterrupted */
+ context.spbook.delay = 0;
return(0);
}
- if (delay) { /* not if (delay++), so at end delay == 0 */
- delay++;
+ if (context.spbook.delay) { /* not if (context.spbook.delay++), so at end delay == 0 */
+ context.spbook.delay++;
return(1); /* still busy */
}
exercise(A_WIS, TRUE); /* you're studying. */
- booktype = book->otyp;
+ booktype = context.spbook.book->otyp;
if(booktype == SPE_BOOK_OF_THE_DEAD) {
- deadbook(book);
+ deadbook(context.spbook.book);
return(0);
}
OBJ_NAME(objects[booktype]));
for (i = 0; i < MAXSPELL; i++) {
if (spellid(i) == booktype) {
- if (book->spestudied > MAX_SPELL_STUDY) {
+ if (context.spbook.book->spestudied > MAX_SPELL_STUDY) {
pline("This spellbook is too faint to be read any more.");
- book->otyp = booktype = SPE_BLANK_PAPER;
+ context.spbook.book->otyp = booktype = SPE_BLANK_PAPER;
} else if (spellknow(i) <= 1000) {
Your("knowledge of %s is keener.", splname);
incrnknow(i);
- book->spestudied++;
+ context.spbook.book->spestudied++;
exercise(A_WIS,TRUE); /* extra study */
} else { /* 1000 < spellknow(i) <= MAX_SPELL_STUDY */
You("know %s quite well already.", splname);
spl_book[i].sp_id = booktype;
spl_book[i].sp_lev = objects[booktype].oc_level;
incrnknow(i);
- book->spestudied++;
+ context.spbook.book->spestudied++;
You(i > 0 ? "add %s to your repertoire." : "learn %s.",
splname);
makeknown((int)booktype);
}
if (i == MAXSPELL) impossible("Too many spells memorized!");
- if (book->cursed) { /* maybe a demon cursed it */
- if (cursed_book(book)) {
- useup(book);
- book = 0;
+ if (context.spbook.book->cursed) { /* maybe a demon cursed it */
+ if (cursed_book(context.spbook.book)) {
+ useup(context.spbook.book);
+ context.spbook.book = 0;
+ context.spbook.o_id = 0;
return 0;
}
}
- if (costly) check_unpaid(book);
- book = 0;
+ if (costly) check_unpaid(context.spbook.book);
+ context.spbook.book = 0;
+ context.spbook.o_id = 0;
return(0);
}
register boolean confused = (Confusion != 0);
boolean too_hard = FALSE;
- if (delay && !confused && spellbook == book &&
+ if (context.spbook.delay && !confused && spellbook == context.spbook.book &&
/* handle the sequence: start reading, get interrupted,
- have book become erased somehow, resume reading it */
+ have context.spbook.book become erased somehow, resume reading it */
booktype != SPE_BLANK_PAPER) {
You("continue your efforts to memorize the spell.");
} else {
switch (objects[booktype].oc_level) {
case 1:
case 2:
- delay = -objects[booktype].oc_delay;
+ context.spbook.delay = -objects[booktype].oc_delay;
break;
case 3:
case 4:
- delay = -(objects[booktype].oc_level - 1) *
+ context.spbook.delay = -(objects[booktype].oc_level - 1) *
objects[booktype].oc_delay;
break;
case 5:
case 6:
- delay = -objects[booktype].oc_level *
+ context.spbook.delay = -objects[booktype].oc_level *
objects[booktype].oc_delay;
break;
case 7:
- delay = -8 * objects[booktype].oc_delay;
+ context.spbook.delay = -8 * objects[booktype].oc_delay;
break;
default:
impossible("Unknown spellbook level %d, book %d;",
if (too_hard) {
boolean gone = cursed_book(spellbook);
- nomul(delay); /* study time */
- delay = 0;
+ nomul(context.spbook.delay); /* study time */
+ context.spbook.delay = 0;
if(gone || !rn2(3)) {
if (!gone) pline_The("spellbook crumbles to dust!");
if (!objects[spellbook->otyp].oc_name_known &&
if (!confused_book(spellbook)) {
spellbook->in_use = FALSE;
}
- nomul(delay);
- delay = 0;
+ nomul(context.spbook.delay);
+ context.spbook.delay = 0;
return(1);
}
spellbook->in_use = FALSE;
"memorize");
}
- book = spellbook;
+ context.spbook.book = spellbook;
+ if (context.spbook.book)
+ context.spbook.o_id = context.spbook.book->o_id;
set_occupation(learn, "studying", 0);
return(1);
}
book_disappears(obj)
struct obj *obj;
{
- if (obj == book) book = (struct obj *)0;
+ if (obj == context.spbook.book) {
+ context.spbook.book = (struct obj *)0;
+ context.spbook.o_id = 0;
+ }
}
/* renaming an object usually results in it having a different address;
book_substitution(old_obj, new_obj)
struct obj *old_obj, *new_obj;
{
- if (old_obj == book) book = new_obj;
+ if (old_obj == context.spbook.book) {
+ context.spbook.book = new_obj;
+ if (context.spbook.book)
+ context.spbook.o_id = context.spbook.book->o_id;
+ }
}
/* called from moveloop() */
boolean confused = (Confusion != 0);
int n, nzap, i;
- book = 0;
+ context.spbook.book = 0;
+ context.spbook.o_id = 0;
for (n = 0; n < MAXSPELL && spellid(n) != NO_SPELL; n++)
continue;
if (n) {