trap setting bit

Treat a trap object that has become the focus of trap setting
occupation as if it had already been used up.  (No discernable change
in behavior unless someone adds an artifact bear trap or landmine
that talks.)

Shouldn't 'trapinfo' be part of 'context' and be saved and restored?
(If so, it will need to include o_id and undergo pointer fixup during
restore.)  When trap arming is in progress hero will be too busy for
player to issue S(ave) command but a hangup save could take place.
This commit is contained in:
PatR
2023-05-23 15:34:58 -07:00
parent 8385d0a10e
commit 6586cc84b2
2 changed files with 8 additions and 6 deletions

View File

@@ -640,7 +640,7 @@ stop_occupation(void)
if (go.occupation) {
if (!maybe_finished_meal(TRUE))
You("stop %s.", go.occtxt);
go.occupation = 0;
go.occupation = (int (*)(void)) 0;
gc.context.botl = TRUE; /* in case u.uhs changed */
nomul(0);
} else if (gm.multi >= 0) {

View File

@@ -2834,6 +2834,7 @@ use_trap(struct obj *otmp)
return;
}
/* occupation routine called each turn while arming a beartrap or landmine */
static int
set_trap(void)
{
@@ -2841,9 +2842,8 @@ set_trap(void)
struct trap *ttmp;
int ttyp;
if (!otmp || !carried(otmp) || u.ux != gt.trapinfo.tx
|| u.uy != gt.trapinfo.ty) {
/* ?? */
if (!otmp || !carried(otmp) || !u_at(gt.trapinfo.tx, gt.trapinfo.ty)) {
/* trap object might have been stolen or hero teleported */
reset_trapset();
return 0;
}
@@ -4171,6 +4171,8 @@ doapply(void)
case LAND_MINE:
case BEARTRAP:
use_trap(obj);
if (go.occupation == set_trap)
obj = (struct obj *) 0; /* not gone yet but behave as if it was */
break;
case FLINT:
case LUCKSTONE:
@@ -4190,8 +4192,8 @@ doapply(void)
pline("Sorry, I don't know how to use that.");
return ECMD_FAIL;
}
/* This assumes that anything that potentially destroyed obj has kept track
* of it and set obj to null before this point. */
/* This assumes that anything that potentially destroyed obj has kept
* track of it and set obj to null before this point. */
if (obj && obj->oartifact) {
res |= arti_speak(obj); /* sets ECMD_TIME bit if artifact speaks */
}