more set_corpsenm (trunk only)
Use set_corpsenm() in a few more places.
This commit is contained in:
+1
-1
@@ -2115,7 +2115,7 @@ E void FDECL(substitute_tiles, (d_level *));
|
|||||||
E void NDECL(burn_away_slime);
|
E void NDECL(burn_away_slime);
|
||||||
E void NDECL(nh_timeout);
|
E void NDECL(nh_timeout);
|
||||||
E void FDECL(fall_asleep, (int, BOOLEAN_P));
|
E void FDECL(fall_asleep, (int, BOOLEAN_P));
|
||||||
E void FDECL(attach_egg_hatch_timeout, (struct obj *));
|
E void FDECL(attach_egg_hatch_timeout, (struct obj *, long));
|
||||||
E void FDECL(attach_fig_transform_timeout, (struct obj *));
|
E void FDECL(attach_fig_transform_timeout, (struct obj *));
|
||||||
E void FDECL(kill_egg, (struct obj *));
|
E void FDECL(kill_egg, (struct obj *));
|
||||||
E void FDECL(hatch_egg, (ANY_P *, long));
|
E void FDECL(hatch_egg, (ANY_P *, long));
|
||||||
|
|||||||
+1
-1
@@ -137,7 +137,7 @@ boolean restore;
|
|||||||
would behave as if it remains unique */
|
would behave as if it remains unique */
|
||||||
if (mnum == PM_DOPPELGANGER &&
|
if (mnum == PM_DOPPELGANGER &&
|
||||||
otmp->otyp == CORPSE)
|
otmp->otyp == CORPSE)
|
||||||
otmp->corpsenm = mnum;
|
set_corpsenm(otmp, mnum);
|
||||||
}
|
}
|
||||||
} else if (otmp->otyp == AMULET_OF_YENDOR) {
|
} else if (otmp->otyp == AMULET_OF_YENDOR) {
|
||||||
/* no longer the real Amulet */
|
/* no longer the real Amulet */
|
||||||
|
|||||||
+31
-9
@@ -648,10 +648,10 @@ boolean artif;
|
|||||||
mndx = can_be_hatched(rndmonnum());
|
mndx = can_be_hatched(rndmonnum());
|
||||||
if (mndx != NON_PM && !dead_species(mndx, TRUE)) {
|
if (mndx != NON_PM && !dead_species(mndx, TRUE)) {
|
||||||
otmp->corpsenm = mndx; /* typed egg */
|
otmp->corpsenm = mndx; /* typed egg */
|
||||||
attach_egg_hatch_timeout(otmp);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* timer set below */
|
||||||
break;
|
break;
|
||||||
case TIN:
|
case TIN:
|
||||||
otmp->corpsenm = NON_PM; /* empty (so far) */
|
otmp->corpsenm = NON_PM; /* empty (so far) */
|
||||||
@@ -846,7 +846,9 @@ boolean artif;
|
|||||||
/* Some things must get done (timers) even if init = 0 */
|
/* Some things must get done (timers) even if init = 0 */
|
||||||
switch (otmp->otyp) {
|
switch (otmp->otyp) {
|
||||||
case CORPSE:
|
case CORPSE:
|
||||||
start_corpse_timeout(otmp);
|
case EGG:
|
||||||
|
case FIGURINE:
|
||||||
|
set_corpsenm(otmp, otmp->corpsenm);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -871,27 +873,49 @@ boolean artif;
|
|||||||
* - ensure that you don't end up with some other
|
* - ensure that you don't end up with some other
|
||||||
* corpse type which resurrects from the dead.
|
* corpse type which resurrects from the dead.
|
||||||
*
|
*
|
||||||
* Re-calculate the weight of the object to suit the
|
* Re-calculates the weight of figurines and corpses to suit the
|
||||||
* new species.
|
* new species.
|
||||||
*
|
*
|
||||||
|
* Existing timeout value for egg hatch is preserved.
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
set_corpsenm(obj, id)
|
set_corpsenm(obj, id)
|
||||||
struct obj *obj;
|
struct obj *obj;
|
||||||
int id;
|
int id;
|
||||||
{
|
{
|
||||||
|
long when = 0L;
|
||||||
|
|
||||||
if (obj->timed) obj_stop_timers(obj); /* corpse or figurine */
|
if (obj->timed) {
|
||||||
|
if (obj->otyp == EGG)
|
||||||
|
when = stop_timer(HATCH_EGG, obj_to_any(obj));
|
||||||
|
else {
|
||||||
|
when = 0L;
|
||||||
|
obj_stop_timers(obj); /* corpse or figurine */
|
||||||
|
}
|
||||||
|
}
|
||||||
obj->corpsenm = id;
|
obj->corpsenm = id;
|
||||||
if (obj->otyp == CORPSE) {
|
switch(obj->otyp) {
|
||||||
|
case CORPSE:
|
||||||
start_corpse_timeout(obj);
|
start_corpse_timeout(obj);
|
||||||
} else if (obj->otyp == FIGURINE) {
|
obj->owt = weight(obj);
|
||||||
|
break;
|
||||||
|
case FIGURINE:
|
||||||
if (obj->corpsenm != NON_PM
|
if (obj->corpsenm != NON_PM
|
||||||
&& !dead_species(obj->corpsenm,TRUE)
|
&& !dead_species(obj->corpsenm,TRUE)
|
||||||
&& (carried(obj) || mcarried(obj)))
|
&& (carried(obj) || mcarried(obj)))
|
||||||
attach_fig_transform_timeout(obj);
|
attach_fig_transform_timeout(obj);
|
||||||
}
|
|
||||||
obj->owt = weight(obj);
|
obj->owt = weight(obj);
|
||||||
|
break;
|
||||||
|
case EGG:
|
||||||
|
if (obj->corpsenm != NON_PM
|
||||||
|
&& !dead_species(obj->corpsenm,TRUE))
|
||||||
|
attach_egg_hatch_timeout(obj, when);
|
||||||
|
break;
|
||||||
|
default: /* tin, etc. */
|
||||||
|
obj->owt = weight(obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1469,7 +1493,6 @@ int force; /* 0 = no force so do checks, <0 = force off, >0 force on */
|
|||||||
if (tleft != 0L) {
|
if (tleft != 0L) {
|
||||||
long age;
|
long age;
|
||||||
|
|
||||||
tleft = tleft - monstermoves;
|
|
||||||
/* mark the corpse as being on ice */
|
/* mark the corpse as being on ice */
|
||||||
otmp->on_ice = 1;
|
otmp->on_ice = 1;
|
||||||
#ifdef DEBUG_EFFECTS
|
#ifdef DEBUG_EFFECTS
|
||||||
@@ -1495,7 +1518,6 @@ int force; /* 0 = no force so do checks, <0 = force off, >0 force on */
|
|||||||
if (tleft != 0L) {
|
if (tleft != 0L) {
|
||||||
long age;
|
long age;
|
||||||
|
|
||||||
tleft = tleft - monstermoves;
|
|
||||||
otmp->on_ice = 0;
|
otmp->on_ice = 0;
|
||||||
#ifdef DEBUG_EFFECTS
|
#ifdef DEBUG_EFFECTS
|
||||||
pline("%s is no longer on ice at %d,%d.", The(xname(otmp)),x,y);
|
pline("%s is no longer on ice at %d,%d.", The(xname(otmp)),x,y);
|
||||||
|
|||||||
+4
-14
@@ -2787,14 +2787,9 @@ typfnd:
|
|||||||
case CORPSE:
|
case CORPSE:
|
||||||
if (!(mons[mntmp].geno & G_UNIQ) &&
|
if (!(mons[mntmp].geno & G_UNIQ) &&
|
||||||
!(mvitals[mntmp].mvflags & G_NOCORPSE)) {
|
!(mvitals[mntmp].mvflags & G_NOCORPSE)) {
|
||||||
/* beware of random troll or lizard corpse,
|
|
||||||
or of ordinary one being forced to such */
|
|
||||||
if (otmp->timed) obj_stop_timers(otmp);
|
|
||||||
if (mons[mntmp].msound == MS_GUARDIAN)
|
if (mons[mntmp].msound == MS_GUARDIAN)
|
||||||
otmp->corpsenm = genus(mntmp,1);
|
mntmp = genus(mntmp,1);
|
||||||
else
|
set_corpsenm(otmp, mntmp);
|
||||||
otmp->corpsenm = mntmp;
|
|
||||||
start_corpse_timeout(otmp);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FIGURINE:
|
case FIGURINE:
|
||||||
@@ -2808,13 +2803,8 @@ typfnd:
|
|||||||
break;
|
break;
|
||||||
case EGG:
|
case EGG:
|
||||||
mntmp = can_be_hatched(mntmp);
|
mntmp = can_be_hatched(mntmp);
|
||||||
if (mntmp != NON_PM) {
|
/* this also sets hatch timer if appropriate */
|
||||||
otmp->corpsenm = mntmp;
|
set_corpsenm(otmp, mntmp);
|
||||||
if (!dead_species(mntmp, TRUE))
|
|
||||||
attach_egg_hatch_timeout(otmp);
|
|
||||||
else
|
|
||||||
kill_egg(otmp);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case STATUE: otmp->corpsenm = mntmp;
|
case STATUE: otmp->corpsenm = mntmp;
|
||||||
if (Has_contents(otmp) && verysmall(&mons[mntmp]))
|
if (Has_contents(otmp) && verysmall(&mons[mntmp]))
|
||||||
|
|||||||
@@ -303,9 +303,9 @@ dosit()
|
|||||||
uegg->spe = 1;
|
uegg->spe = 1;
|
||||||
uegg->quan = 1L;
|
uegg->quan = 1L;
|
||||||
uegg->owt = weight(uegg);
|
uegg->owt = weight(uegg);
|
||||||
uegg->corpsenm = egg_type_from_parent(u.umonnum, FALSE);
|
/* this sets hatch timers if appropriate */
|
||||||
|
set_corpsenm(uegg, egg_type_from_parent(u.umonnum, FALSE));
|
||||||
uegg->known = uegg->dknown = 1;
|
uegg->known = uegg->dknown = 1;
|
||||||
attach_egg_hatch_timeout(uegg);
|
|
||||||
You("lay an egg.");
|
You("lay an egg.");
|
||||||
dropy(uegg);
|
dropy(uegg);
|
||||||
stackobj(uegg);
|
stackobj(uegg);
|
||||||
|
|||||||
+1
-9
@@ -985,15 +985,7 @@ struct mkroom *croom;
|
|||||||
set_corpsenm(otmp, rndmonnum());
|
set_corpsenm(otmp, rndmonnum());
|
||||||
else set_corpsenm(otmp, o->corpsenm);
|
else set_corpsenm(otmp, o->corpsenm);
|
||||||
}
|
}
|
||||||
|
/* set_corpsenm() took care of egg hatch and corpse timers */
|
||||||
/* assume we wouldn't be given an egg corpsenm unless it was
|
|
||||||
hatchable */
|
|
||||||
if (otmp->otyp == EGG && otmp->corpsenm != NON_PM) {
|
|
||||||
if (dead_species(otmp->otyp, TRUE))
|
|
||||||
kill_egg(otmp); /* make sure nothing hatches */
|
|
||||||
else
|
|
||||||
attach_egg_hatch_timeout(otmp); /* attach new hatch timeout */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (named)
|
if (named)
|
||||||
otmp = oname(otmp, o->name.str);
|
otmp = oname(otmp, o->name.str);
|
||||||
|
|||||||
+17
-13
@@ -397,10 +397,14 @@ boolean wakeup_msg;
|
|||||||
nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again;
|
nomovemsg = wakeup_msg ? "You wake up." : You_can_move_again;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attach an egg hatch timeout to the given egg. */
|
/* Attach an egg hatch timeout to the given egg.
|
||||||
|
* when = Time to hatch, usually only passed if re-creating an
|
||||||
|
* existing hatch timer. Pass 0L for random hatch time.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
attach_egg_hatch_timeout(egg)
|
attach_egg_hatch_timeout(egg, when)
|
||||||
struct obj *egg;
|
struct obj *egg;
|
||||||
|
long when;
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -413,14 +417,19 @@ struct obj *egg;
|
|||||||
* a number x, 1<=x<=age, where x>150. This yields a chance of
|
* a number x, 1<=x<=age, where x>150. This yields a chance of
|
||||||
* hatching > 99.9993%. Mimic that here.
|
* hatching > 99.9993%. Mimic that here.
|
||||||
*/
|
*/
|
||||||
|
if (!when) {
|
||||||
for (i = (MAX_EGG_HATCH_TIME-50)+1; i <= MAX_EGG_HATCH_TIME; i++)
|
for (i = (MAX_EGG_HATCH_TIME-50)+1; i <= MAX_EGG_HATCH_TIME; i++)
|
||||||
if (rnd(i) > 150) {
|
if (rnd(i) > 150) {
|
||||||
/* egg will hatch */
|
/* egg will hatch */
|
||||||
(void) start_timer((long)i, TIMER_OBJECT,
|
when = (long)i;
|
||||||
HATCH_EGG, obj_to_any(egg));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (when) {
|
||||||
|
(void) start_timer(when, TIMER_OBJECT,
|
||||||
|
HATCH_EGG, obj_to_any(egg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* prevent an egg from ever hatching */
|
/* prevent an egg from ever hatching */
|
||||||
void
|
void
|
||||||
@@ -584,13 +593,8 @@ long timeout;
|
|||||||
|
|
||||||
if (egg->quan > 0) {
|
if (egg->quan > 0) {
|
||||||
/* still some eggs left */
|
/* still some eggs left */
|
||||||
attach_egg_hatch_timeout(egg);
|
/* Instead of ordinary egg timeout use a short one */
|
||||||
if (egg->timed) {
|
attach_egg_hatch_timeout(egg, (long)rnd(12));
|
||||||
/* replace ordinary egg timeout with a short one */
|
|
||||||
(void) stop_timer(HATCH_EGG, obj_to_any(egg));
|
|
||||||
(void) start_timer((long)rnd(12), TIMER_OBJECT,
|
|
||||||
HATCH_EGG, obj_to_any(egg));
|
|
||||||
}
|
|
||||||
} else if (carried(egg)) {
|
} else if (carried(egg)) {
|
||||||
useup(egg);
|
useup(egg);
|
||||||
} else {
|
} else {
|
||||||
@@ -1492,7 +1496,7 @@ anything *arg;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Remove the timer from the current list and free it up. Return the time
|
* Remove the timer from the current list and free it up. Return the time
|
||||||
* it would have gone off, 0 if not found.
|
* remaining until it would have gone off, 0 if not found.
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
stop_timer(func_index, arg)
|
stop_timer(func_index, arg)
|
||||||
@@ -1511,7 +1515,7 @@ anything *arg;
|
|||||||
if (timeout_funcs[doomed->func_index].cleanup)
|
if (timeout_funcs[doomed->func_index].cleanup)
|
||||||
(*timeout_funcs[doomed->func_index].cleanup)(arg, timeout);
|
(*timeout_funcs[doomed->func_index].cleanup)(arg, timeout);
|
||||||
free((genericptr_t) doomed);
|
free((genericptr_t) doomed);
|
||||||
return timeout;
|
return (timeout - monstermoves);
|
||||||
}
|
}
|
||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -820,7 +820,7 @@ struct obj *obj;
|
|||||||
*/
|
*/
|
||||||
if (obj->otyp != EGG) return;
|
if (obj->otyp != EGG) return;
|
||||||
if (obj->corpsenm != NON_PM && !dead_species(obj->corpsenm, TRUE))
|
if (obj->corpsenm != NON_PM && !dead_species(obj->corpsenm, TRUE))
|
||||||
attach_egg_hatch_timeout(obj);
|
attach_egg_hatch_timeout(obj, 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try to revive all corpses and eggs carried by `mon' */
|
/* try to revive all corpses and eggs carried by `mon' */
|
||||||
@@ -1323,8 +1323,7 @@ poly_obj(obj, id)
|
|||||||
mnum = can_be_hatched(random_monster());
|
mnum = can_be_hatched(random_monster());
|
||||||
if (mnum != NON_PM && !dead_species(mnum, TRUE)) {
|
if (mnum != NON_PM && !dead_species(mnum, TRUE)) {
|
||||||
otmp->spe = 1; /* layed by hero */
|
otmp->spe = 1; /* layed by hero */
|
||||||
otmp->corpsenm = mnum;
|
set_corpsenm(otmp, mnum); /* also sets hatch timer */
|
||||||
attach_egg_hatch_timeout(otmp);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user