fix bz16 - book becoming cursed while being read

Attempting to read a cursed spellbook fails with a nasty effect.  But
a non-cursed book can become cursed while being read (malignant aura
after Wizard has been killed).  Assuming no interruption for other
reasons, the read would finish, the spell be learned, and then the
nasty effect would be given.  This changes things so that if the book
being read becomes cursed and the hero notices (book's bknown flag is
set), the read-in-progress will be interrupted.  Resuming will take
the attempting-to-read-a-cursed-book path.  Unfortunately, if the
hero doesn't notice, the old behavior still applies.  Maybe the new
behavior should happen even if bknown isn't set (but then player
won't be told why the interruption occurred).
This commit is contained in:
PatR
2016-01-31 18:22:31 -08:00
parent 5774804524
commit 54325de339
4 changed files with 37 additions and 12 deletions

View File

@@ -1247,12 +1247,14 @@ void
curse(otmp)
register struct obj *otmp;
{
unsigned already_cursed;
int old_light = 0;
if (otmp->oclass == COIN_CLASS)
return;
if (otmp->lamplit)
old_light = arti_light_radius(otmp);
already_cursed = otmp->cursed;
otmp->blessed = 0;
otmp->cursed = 1;
/* welded two-handed weapon interferes with some armor removal */
@@ -1263,14 +1265,18 @@ register struct obj *otmp;
if (otmp == uswapwep && u.twoweap)
drop_uswapwep();
/* some cursed items need immediate updating */
if (carried(otmp) && confers_luck(otmp))
if (carried(otmp) && confers_luck(otmp)) {
set_moreluck();
else if (otmp->otyp == BAG_OF_HOLDING)
} else if (otmp->otyp == BAG_OF_HOLDING) {
otmp->owt = weight(otmp);
else if (otmp->otyp == FIGURINE) {
} else if (otmp->otyp == FIGURINE) {
if (otmp->corpsenm != NON_PM && !dead_species(otmp->corpsenm, TRUE)
&& (carried(otmp) || mcarried(otmp)))
attach_fig_transform_timeout(otmp);
} else if (otmp->oclass == SPBOOK_CLASS) {
/* if book hero is reading becomes cursed, interrupt */
if (!already_cursed)
book_cursed(otmp);
}
if (otmp->lamplit)
maybe_adjust_light(otmp, old_light);