litroom() vs Blind
An item from the "A few bugs" mail was that reading a scroll of light when swallowed didn't light the surrounding area--which is intended-- but that doing so while blind *did*. The logic in litroom()--which the report was based on--was wrong, but do_clear_area() prevented the light was escaping the engulfer. So there was no bug from the player's perspective, but only because the vision code has special handling for being swallowed. This fixes litroom()'s logic and does some formatting cleanup.
This commit is contained in:
132
src/read.c
132
src/read.c
@@ -1,4 +1,4 @@
|
|||||||
/* NetHack 3.6 read.c $NHDT-Date: 1431192759 2015/05/09 17:32:39 $ $NHDT-Branch: master $:$NHDT-Revision: 1.111 $ */
|
/* NetHack 3.6 read.c $NHDT-Date: 1444352700 2015/10/09 01:05:00 $ $NHDT-Branch: master $:$NHDT-Revision: 1.116 $ */
|
||||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||||
/* NetHack may be freely redistributed. See license for details. */
|
/* NetHack may be freely redistributed. See license for details. */
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ STATIC_DCL void FDECL(forget, (int));
|
|||||||
STATIC_DCL int FDECL(maybe_tame, (struct monst *, struct obj *));
|
STATIC_DCL int FDECL(maybe_tame, (struct monst *, struct obj *));
|
||||||
STATIC_DCL boolean FDECL(is_valid_stinking_cloud_pos, (int, int, BOOLEAN_P));
|
STATIC_DCL boolean FDECL(is_valid_stinking_cloud_pos, (int, int, BOOLEAN_P));
|
||||||
STATIC_DCL void FDECL(display_stinking_cloud_positions, (int));
|
STATIC_DCL void FDECL(display_stinking_cloud_positions, (int));
|
||||||
STATIC_PTR void FDECL(set_lit, (int, int, genericptr_t));
|
STATIC_PTR void FDECL(set_lit, (int, int, genericptr));
|
||||||
|
|
||||||
STATIC_OVL boolean
|
STATIC_OVL boolean
|
||||||
learnscrolltyp(scrolltyp)
|
learnscrolltyp(scrolltyp)
|
||||||
@@ -118,6 +118,7 @@ char *buf;
|
|||||||
"I'm not wearing any pants", "Down with the living!",
|
"I'm not wearing any pants", "Down with the living!",
|
||||||
"Pudding farmer", "Vegetarian",
|
"Pudding farmer", "Vegetarian",
|
||||||
};
|
};
|
||||||
|
|
||||||
Strcpy(buf, shirt_msgs[tshirt->o_id % SIZE(shirt_msgs)]);
|
Strcpy(buf, shirt_msgs[tshirt->o_id % SIZE(shirt_msgs)]);
|
||||||
return erode_obj_text(tshirt, buf);
|
return erode_obj_text(tshirt, buf);
|
||||||
}
|
}
|
||||||
@@ -135,6 +136,7 @@ char *buf;
|
|||||||
"If we weren't meant to eat animals, why are they made out of meat?",
|
"If we weren't meant to eat animals, why are they made out of meat?",
|
||||||
"If you don't like the food, I'll stab you",
|
"If you don't like the food, I'll stab you",
|
||||||
};
|
};
|
||||||
|
|
||||||
Strcpy(buf, apron_msgs[apron->o_id % SIZE(apron_msgs)]);
|
Strcpy(buf, apron_msgs[apron->o_id % SIZE(apron_msgs)]);
|
||||||
return erode_obj_text(apron, buf);
|
return erode_obj_text(apron, buf);
|
||||||
}
|
}
|
||||||
@@ -196,6 +198,7 @@ doread()
|
|||||||
"Yendorian Express - Mithril Card",
|
"Yendorian Express - Mithril Card",
|
||||||
"Yendorian Express - Platinum Card", /* must be last */
|
"Yendorian Express - Platinum Card", /* must be last */
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Blind) {
|
if (Blind) {
|
||||||
You("feel the embossed numbers:");
|
You("feel the embossed numbers:");
|
||||||
} else {
|
} else {
|
||||||
@@ -252,6 +255,7 @@ doread()
|
|||||||
"Fruity Oaty", /* Serenity */
|
"Fruity Oaty", /* Serenity */
|
||||||
"Wonka Bar" /* Charlie and the Chocolate Factory */
|
"Wonka Bar" /* Charlie and the Chocolate Factory */
|
||||||
};
|
};
|
||||||
|
|
||||||
if (Blind) {
|
if (Blind) {
|
||||||
You_cant("feel any Braille writing.");
|
You_cant("feel any Braille writing.");
|
||||||
return 0;
|
return 0;
|
||||||
@@ -309,9 +313,9 @@ doread()
|
|||||||
if (scroll->otyp != SCR_BLANK_PAPER) {
|
if (scroll->otyp != SCR_BLANK_PAPER) {
|
||||||
/* a few scroll feedback messages describe something happening
|
/* a few scroll feedback messages describe something happening
|
||||||
to the scroll itself, so avoid "it disappears" for those */
|
to the scroll itself, so avoid "it disappears" for those */
|
||||||
nodisappear =
|
nodisappear = (scroll->otyp == SCR_FIRE
|
||||||
(scroll->otyp == SCR_FIRE
|
|| (scroll->otyp == SCR_REMOVE_CURSE
|
||||||
|| (scroll->otyp == SCR_REMOVE_CURSE && scroll->cursed));
|
&& scroll->cursed));
|
||||||
if (Blind)
|
if (Blind)
|
||||||
pline(nodisappear
|
pline(nodisappear
|
||||||
? "You %s the formula on the scroll."
|
? "You %s the formula on the scroll."
|
||||||
@@ -340,7 +344,7 @@ doread()
|
|||||||
if (scroll->otyp != SCR_BLANK_PAPER)
|
if (scroll->otyp != SCR_BLANK_PAPER)
|
||||||
useup(scroll);
|
useup(scroll);
|
||||||
}
|
}
|
||||||
return (1);
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
@@ -375,8 +379,8 @@ register const char *color;
|
|||||||
Blind ? "" : " ", Blind ? "" : hcolor(color));
|
Blind ? "" : " ", Blind ? "" : hcolor(color));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is the object chargeable? For purposes of inventory display; it is */
|
/* Is the object chargeable? For purposes of inventory display; it is
|
||||||
/* possible to be able to charge things for which this returns FALSE. */
|
possible to be able to charge things for which this returns FALSE. */
|
||||||
boolean
|
boolean
|
||||||
is_chargeable(obj)
|
is_chargeable(obj)
|
||||||
struct obj *obj;
|
struct obj *obj;
|
||||||
@@ -385,21 +389,19 @@ struct obj *obj;
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
/* known && !oc_name_known is possible after amnesia/mind flayer */
|
/* known && !oc_name_known is possible after amnesia/mind flayer */
|
||||||
if (obj->oclass == RING_CLASS)
|
if (obj->oclass == RING_CLASS)
|
||||||
return (boolean)(
|
return (boolean) (objects[obj->otyp].oc_charged
|
||||||
objects[obj->otyp].oc_charged
|
&& (obj->known
|
||||||
&& (obj->known
|
|| (obj->dknown
|
||||||
|| (obj->dknown && objects[obj->otyp].oc_name_known)));
|
&& objects[obj->otyp].oc_name_known)));
|
||||||
if (is_weptool(obj)) /* specific check before general tools */
|
if (is_weptool(obj)) /* specific check before general tools */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (obj->oclass == TOOL_CLASS)
|
if (obj->oclass == TOOL_CLASS)
|
||||||
return (boolean)(objects[obj->otyp].oc_charged);
|
return (boolean) objects[obj->otyp].oc_charged;
|
||||||
return FALSE; /* why are weapons/armor considered charged anyway? */
|
return FALSE; /* why are weapons/armor considered charged anyway? */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/* recharge an object; curse_bless is -1 if the recharging implement
|
||||||
* recharge an object; curse_bless is -1 if the recharging implement
|
was cursed, +1 if blessed, 0 otherwise. */
|
||||||
* was cursed, +1 if blessed, 0 otherwise.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
recharge(obj, curse_bless)
|
recharge(obj, curse_bless)
|
||||||
struct obj *obj;
|
struct obj *obj;
|
||||||
@@ -422,17 +424,17 @@ int curse_bless;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Recharging might cause wands to explode.
|
* Recharging might cause wands to explode.
|
||||||
* v = number of previous recharges
|
* v = number of previous recharges
|
||||||
* v = percentage chance to explode on this attempt
|
* v = percentage chance to explode on this attempt
|
||||||
* v = cumulative odds for exploding
|
* v = cumulative odds for exploding
|
||||||
* 0 : 0 0
|
* 0 : 0 0
|
||||||
* 1 : 0.29 0.29
|
* 1 : 0.29 0.29
|
||||||
* 2 : 2.33 2.62
|
* 2 : 2.33 2.62
|
||||||
* 3 : 7.87 10.28
|
* 3 : 7.87 10.28
|
||||||
* 4 : 18.66 27.02
|
* 4 : 18.66 27.02
|
||||||
* 5 : 36.44 53.62
|
* 5 : 36.44 53.62
|
||||||
* 6 : 62.97 82.83
|
* 6 : 62.97 82.83
|
||||||
* 7 : 100 100
|
* 7 : 100 100
|
||||||
*/
|
*/
|
||||||
n = (int) obj->recharged;
|
n = (int) obj->recharged;
|
||||||
if (n > 0 && (obj->otyp == WAN_WISHING
|
if (n > 0 && (obj->otyp == WAN_WISHING
|
||||||
@@ -464,8 +466,9 @@ int curse_bless;
|
|||||||
else
|
else
|
||||||
p_glow1(obj);
|
p_glow1(obj);
|
||||||
#if 0 /*[shop price doesn't vary by charge count]*/
|
#if 0 /*[shop price doesn't vary by charge count]*/
|
||||||
/* update shop bill to reflect new higher price */
|
/* update shop bill to reflect new higher price */
|
||||||
if (obj->unpaid) alter_cost(obj, 0L);
|
if (obj->unpaid)
|
||||||
|
alter_cost(obj, 0L);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -485,6 +488,7 @@ int curse_bless;
|
|||||||
losehp(Maybe_Half_Phys(s), "exploding ring", KILLED_BY_AN);
|
losehp(Maybe_Half_Phys(s), "exploding ring", KILLED_BY_AN);
|
||||||
} else {
|
} else {
|
||||||
long mask = is_on ? (obj == uleft ? LEFT_RING : RIGHT_RING) : 0L;
|
long mask = is_on ? (obj == uleft ? LEFT_RING : RIGHT_RING) : 0L;
|
||||||
|
|
||||||
pline("%s spins %sclockwise for a moment.", Yname2(obj),
|
pline("%s spins %sclockwise for a moment.", Yname2(obj),
|
||||||
s < 0 ? "counter" : "");
|
s < 0 ? "counter" : "");
|
||||||
if (s < 0)
|
if (s < 0)
|
||||||
@@ -584,9 +588,9 @@ int curse_bless;
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CRYSTAL_BALL:
|
case CRYSTAL_BALL:
|
||||||
if (is_cursed)
|
if (is_cursed) {
|
||||||
stripspe(obj);
|
stripspe(obj);
|
||||||
else if (is_blessed) {
|
} else if (is_blessed) {
|
||||||
obj->spe = 6;
|
obj->spe = 6;
|
||||||
p_glow2(obj, NH_BLUE);
|
p_glow2(obj, NH_BLUE);
|
||||||
} else {
|
} else {
|
||||||
@@ -600,9 +604,9 @@ int curse_bless;
|
|||||||
case HORN_OF_PLENTY:
|
case HORN_OF_PLENTY:
|
||||||
case BAG_OF_TRICKS:
|
case BAG_OF_TRICKS:
|
||||||
case CAN_OF_GREASE:
|
case CAN_OF_GREASE:
|
||||||
if (is_cursed)
|
if (is_cursed) {
|
||||||
stripspe(obj);
|
stripspe(obj);
|
||||||
else if (is_blessed) {
|
} else if (is_blessed) {
|
||||||
if (obj->spe <= 10)
|
if (obj->spe <= 10)
|
||||||
obj->spe += rn1(10, 6);
|
obj->spe += rn1(10, 6);
|
||||||
else
|
else
|
||||||
@@ -648,7 +652,7 @@ int curse_bless;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Forget known information about this object class. */
|
/* Forget known information about this object type. */
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
forget_single_object(obj_id)
|
forget_single_object(obj_id)
|
||||||
int obj_id;
|
int obj_id;
|
||||||
@@ -668,13 +672,13 @@ int obj_id;
|
|||||||
/* Forget everything known about a particular object class. */
|
/* Forget everything known about a particular object class. */
|
||||||
STATIC_OVL void
|
STATIC_OVL void
|
||||||
forget_objclass(oclass)
|
forget_objclass(oclass)
|
||||||
int oclass;
|
int oclass;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i=bases[oclass];
|
for (i = bases[oclass];
|
||||||
i < NUM_OBJECTS && objects[i].oc_class==oclass; i++)
|
i < NUM_OBJECTS && objects[i].oc_class == oclass; i++)
|
||||||
forget_single_object(i);
|
forget_single_object(i);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -811,13 +815,11 @@ int percent;
|
|||||||
/*
|
/*
|
||||||
* Forget some things (e.g. after reading a scroll of amnesia). When called,
|
* Forget some things (e.g. after reading a scroll of amnesia). When called,
|
||||||
* the following are always forgotten:
|
* the following are always forgotten:
|
||||||
*
|
|
||||||
* - felt ball & chain
|
* - felt ball & chain
|
||||||
* - traps
|
* - traps
|
||||||
* - part (6 out of 7) of the map
|
* - part (6 out of 7) of the map
|
||||||
*
|
*
|
||||||
* Other things are subject to flags:
|
* Other things are subject to flags:
|
||||||
*
|
|
||||||
* howmuch & ALL_MAP = forget whole map
|
* howmuch & ALL_MAP = forget whole map
|
||||||
* howmuch & ALL_SPELLS = forget all spells
|
* howmuch & ALL_SPELLS = forget all spells
|
||||||
*/
|
*/
|
||||||
@@ -900,6 +902,7 @@ int state;
|
|||||||
} else if (state == 1) {
|
} else if (state == 1) {
|
||||||
int x, y, dx, dy;
|
int x, y, dx, dy;
|
||||||
int dist = 6;
|
int dist = 6;
|
||||||
|
|
||||||
for (dx = -dist; dx <= dist; dx++)
|
for (dx = -dist; dx <= dist; dx++)
|
||||||
for (dy = -dist; dy <= dist; dy++) {
|
for (dy = -dist; dy <= dist; dy++) {
|
||||||
x = u.ux + dx;
|
x = u.ux + dx;
|
||||||
@@ -1604,10 +1607,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
|
|||||||
|
|
||||||
void
|
void
|
||||||
drop_boulder_on_player(confused, helmet_protects, byu, skip_uswallow)
|
drop_boulder_on_player(confused, helmet_protects, byu, skip_uswallow)
|
||||||
boolean confused;
|
boolean confused, helmet_protects, byu, skip_uswallow;
|
||||||
boolean helmet_protects;
|
|
||||||
boolean byu;
|
|
||||||
boolean skip_uswallow;
|
|
||||||
{
|
{
|
||||||
int dmg;
|
int dmg;
|
||||||
struct obj *otmp2;
|
struct obj *otmp2;
|
||||||
@@ -1651,8 +1651,7 @@ boolean skip_uswallow;
|
|||||||
boolean
|
boolean
|
||||||
drop_boulder_on_monster(x, y, confused, byu)
|
drop_boulder_on_monster(x, y, confused, byu)
|
||||||
int x, y;
|
int x, y;
|
||||||
boolean confused;
|
boolean confused, byu;
|
||||||
boolean byu;
|
|
||||||
{
|
{
|
||||||
register struct obj *otmp2;
|
register struct obj *otmp2;
|
||||||
register struct monst *mtmp;
|
register struct monst *mtmp;
|
||||||
@@ -1830,13 +1829,11 @@ struct obj *obj;
|
|||||||
for (otmp = invent; otmp; otmp = otmp->nobj)
|
for (otmp = invent; otmp; otmp = otmp->nobj)
|
||||||
if (otmp->lamplit)
|
if (otmp->lamplit)
|
||||||
(void) snuff_lit(otmp);
|
(void) snuff_lit(otmp);
|
||||||
if (Blind)
|
} else { /* on */
|
||||||
goto do_it;
|
|
||||||
} else {
|
|
||||||
if (Blind)
|
|
||||||
goto do_it;
|
|
||||||
if (u.uswallow) {
|
if (u.uswallow) {
|
||||||
if (is_animal(u.ustuck->data))
|
if (Blind)
|
||||||
|
; /* no feedback */
|
||||||
|
else if (is_animal(u.ustuck->data))
|
||||||
pline("%s %s is lit.", s_suffix(Monnam(u.ustuck)),
|
pline("%s %s is lit.", s_suffix(Monnam(u.ustuck)),
|
||||||
mbodypart(u.ustuck, STOMACH));
|
mbodypart(u.ustuck, STOMACH));
|
||||||
else if (is_whirly(u.ustuck->data))
|
else if (is_whirly(u.ustuck->data))
|
||||||
@@ -1845,10 +1842,10 @@ struct obj *obj;
|
|||||||
pline("%s glistens.", Monnam(u.ustuck));
|
pline("%s glistens.", Monnam(u.ustuck));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pline("A lit field surrounds you!");
|
if (!Blind)
|
||||||
|
pline("A lit field surrounds you!");
|
||||||
}
|
}
|
||||||
|
|
||||||
do_it:
|
|
||||||
/* No-op in water - can only see the adjacent squares and that's it! */
|
/* No-op in water - can only see the adjacent squares and that's it! */
|
||||||
if (Underwater || Is_waterlevel(&u.uz))
|
if (Underwater || Is_waterlevel(&u.uz))
|
||||||
return;
|
return;
|
||||||
@@ -1865,19 +1862,20 @@ do_it:
|
|||||||
/* rogue lighting must light the entire room */
|
/* rogue lighting must light the entire room */
|
||||||
int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET;
|
int rnum = levl[u.ux][u.uy].roomno - ROOMOFFSET;
|
||||||
int rx, ry;
|
int rx, ry;
|
||||||
|
|
||||||
if (rnum >= 0) {
|
if (rnum >= 0) {
|
||||||
for (rx = rooms[rnum].lx - 1; rx <= rooms[rnum].hx + 1; rx++)
|
for (rx = rooms[rnum].lx - 1; rx <= rooms[rnum].hx + 1; rx++)
|
||||||
for (ry = rooms[rnum].ly - 1; ry <= rooms[rnum].hy + 1; ry++)
|
for (ry = rooms[rnum].ly - 1; ry <= rooms[rnum].hy + 1; ry++)
|
||||||
set_lit(rx, ry,
|
set_lit(rx, ry,
|
||||||
(genericptr_t)(on ? &is_lit : (char *) 0));
|
(genericptr_t) (on ? &is_lit : (char *) 0));
|
||||||
rooms[rnum].rlit = on;
|
rooms[rnum].rlit = on;
|
||||||
}
|
}
|
||||||
/* hallways remain dark on the rogue level */
|
/* hallways remain dark on the rogue level */
|
||||||
} else
|
} else
|
||||||
do_clear_area(
|
do_clear_area(u.ux, u.uy,
|
||||||
u.ux, u.uy,
|
(obj && obj->oclass == SCROLL_CLASS && obj->blessed)
|
||||||
(obj && obj->oclass == SCROLL_CLASS && obj->blessed) ? 9 : 5,
|
? 9 : 5,
|
||||||
set_lit, (genericptr_t)(on ? &is_lit : (char *) 0));
|
set_lit, (genericptr_t) (on ? &is_lit : (char *) 0));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we are not blind, then force a redraw on all positions in sight
|
* If we are not blind, then force a redraw on all positions in sight
|
||||||
@@ -2221,8 +2219,9 @@ void
|
|||||||
punish(sobj)
|
punish(sobj)
|
||||||
register struct obj *sobj;
|
register struct obj *sobj;
|
||||||
{
|
{
|
||||||
struct obj *reuse_ball =
|
struct obj *reuse_ball = (sobj && sobj->otyp == HEAVY_IRON_BALL)
|
||||||
(sobj && sobj->otyp == HEAVY_IRON_BALL) ? sobj : (struct obj *) 0;
|
? sobj : (struct obj *) 0;
|
||||||
|
|
||||||
/* KMH -- Punishment is still okay when you are riding */
|
/* KMH -- Punishment is still okay when you are riding */
|
||||||
if (!reuse_ball)
|
if (!reuse_ball)
|
||||||
You("are being punished for your misbehavior!");
|
You("are being punished for your misbehavior!");
|
||||||
@@ -2307,7 +2306,12 @@ struct obj *from_obj;
|
|||||||
*
|
*
|
||||||
* Note: when creating a monster by class letter, specifying the
|
* Note: when creating a monster by class letter, specifying the
|
||||||
* "strange object" (']') symbol produces a random monster rather
|
* "strange object" (']') symbol produces a random monster rather
|
||||||
* than a mimic; this behavior quirk is useful so don't "fix" it...
|
* than a mimic. This behavior quirk is useful so don't "fix" it
|
||||||
|
* (use 'm'--or "mimic"--to create a random mimic).
|
||||||
|
*
|
||||||
|
* Used in wizard mode only (for ^G command and for scroll or spell
|
||||||
|
* of create monster). Once upon a time, an earlier incarnation of
|
||||||
|
* this code was also used for the scroll/spell in explore mode.
|
||||||
*/
|
*/
|
||||||
boolean
|
boolean
|
||||||
create_particular()
|
create_particular()
|
||||||
|
|||||||
Reference in New Issue
Block a user