'struct former' -> 'struct ebones'
Some variants were already using a similar approach using a struct called 'ebones', so adopt the same naming so NetHack-3.7, hardfought, and some variants are using the same name. As before there are fields in the struct that are not currently used by NetHack-3.7, but the intent is that hardfought save and bones files can be loaded by NetHack-3.7 without code modification, for debugging bug reports. This invalidates existing save and bones files.
This commit is contained in:
59
src/bones.c
59
src/bones.c
@@ -502,16 +502,39 @@ savebones(int how, time_t when, struct obj *corpse)
|
||||
(void) obj_attach_mid(corpse, mtmp->m_id);
|
||||
}
|
||||
if (mtmp) {
|
||||
int i;
|
||||
|
||||
mtmp->m_lev = (u.ulevel ? u.ulevel : 1);
|
||||
mtmp->mhp = mtmp->mhpmax = u.uhpmax;
|
||||
mtmp->female = flags.female;
|
||||
mtmp->msleeping = 1;
|
||||
if (!has_former(mtmp))
|
||||
newformer(mtmp);
|
||||
if (has_former(mtmp)) {
|
||||
FORMER(mtmp)->rank.lev = mtmp->m_lev;
|
||||
FORMER(mtmp)->rank.mnum = Role_switch;
|
||||
FORMER(mtmp)->rank.female = flags.female;
|
||||
|
||||
if (!has_ebones(mtmp))
|
||||
newebones(mtmp);
|
||||
if (has_ebones(mtmp)) {
|
||||
for (i = 0; i <= NUM_ROLES; ++i) {
|
||||
if (!strcmp(gu.urole.name.m, roles[i].name.m)) {
|
||||
EBONES(mtmp)->role = i;
|
||||
break;
|
||||
}
|
||||
/* impossible("savebones: bad gu.urole.name.m \"%s\"",
|
||||
gu.urole.name.m); */
|
||||
}
|
||||
for (i = 0; i <= NUM_RACES; ++i) {
|
||||
if (!strcmp(gu.urace.noun, races[i].noun)) {
|
||||
EBONES(mtmp)->race = i;
|
||||
break;
|
||||
}
|
||||
/* impossible("savebones: bad gu.urace.noun \"%s\"",
|
||||
gu.urace.noun); */
|
||||
}
|
||||
EBONES(mtmp)->oldalign = u.ualign;
|
||||
EBONES(mtmp)->deathlevel = u.ulevel;
|
||||
EBONES(mtmp)->luck = u.uluck; /* moreluck not included */
|
||||
EBONES(mtmp)->mnum = Role_switch;
|
||||
EBONES(mtmp)->female = flags.female;
|
||||
EBONES(mtmp)->demigod = u.uevent.udemigod;
|
||||
EBONES(mtmp)->crowned = u.uevent.uhand_of_elbereth;
|
||||
}
|
||||
}
|
||||
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
|
||||
@@ -783,4 +806,28 @@ fix_ghostly_obj(struct obj *obj)
|
||||
obj->ghostly = 0;
|
||||
}
|
||||
|
||||
void
|
||||
newebones(struct monst *mtmp)
|
||||
{
|
||||
if (!mtmp->mextra)
|
||||
mtmp->mextra = newmextra();
|
||||
if (!EBONES(mtmp)) {
|
||||
EBONES(mtmp) = (struct ebones *) alloc(
|
||||
sizeof(struct ebones *));
|
||||
(void) memset((genericptr_t) EBONES(mtmp), 0,
|
||||
sizeof(struct ebones *));
|
||||
EBONES(mtmp)->parentmid = mtmp->m_id;
|
||||
}
|
||||
}
|
||||
|
||||
/* this is not currently used */
|
||||
void
|
||||
free_ebones(struct monst *mtmp)
|
||||
{
|
||||
if (mtmp->mextra && EBONES(mtmp)) {
|
||||
free((genericptr_t) EBONES(mtmp));
|
||||
EBONES(mtmp) = (struct ebones *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
/*bones.c*/
|
||||
|
||||
@@ -273,7 +273,7 @@ do_mgivenname(void)
|
||||
verbalize("I'm %s, not %s.", shkname(mtmp), buf);
|
||||
}
|
||||
} else if (mtmp->ispriest || mtmp->isminion || mtmp->isshk
|
||||
|| mtmp->data == &mons[PM_GHOST]) {
|
||||
|| mtmp->data == &mons[PM_GHOST] || has_ebones(mtmp)) {
|
||||
if (!alreadynamed(mtmp, monnambuf, buf))
|
||||
pline("%s will not accept the name %s.", upstart(monnambuf), buf);
|
||||
} else {
|
||||
@@ -956,7 +956,7 @@ x_monnam(
|
||||
|
||||
#if 0
|
||||
/* hardfought */
|
||||
if (has_former(mtmp) && FORMER(mtmp)->rank.mnum != NON_PM) {
|
||||
if (has_ebones(mtmp)) {
|
||||
#endif
|
||||
if (mdat == &mons[PM_GHOST]) {
|
||||
Sprintf(eos(buf), "%s ghost", s_suffix(name));
|
||||
|
||||
11
src/end.c
11
src/end.c
@@ -206,7 +206,7 @@ done_in_by(struct monst *mtmp, int how)
|
||||
/* _the_ <invisible> <distorted> ghost of Dudley */
|
||||
#if 0
|
||||
/* hardfought */
|
||||
if (has_former(mtmp) && FORMER(mtmp)->rank.mnum != NON_PM) {
|
||||
if (has_ebones(mtmp) && EBONES(mtmp)->rank.mnum != NON_PM) {
|
||||
#else
|
||||
if (mptr == &mons[PM_GHOST] && has_mgivenname(mtmp)) {
|
||||
#endif
|
||||
@@ -253,7 +253,7 @@ done_in_by(struct monst *mtmp, int how)
|
||||
realnm, shape);
|
||||
mptr = mtmp->data; /* reset for mimicker case */
|
||||
#if 0 /* hardfought */
|
||||
} else if (has_former(mtmp) && FORMER(mtmp)->rank.mnum != NON_PM)
|
||||
} else if (has_ebones(mtmp) && EBONES(mtmp)->rank.mnum != NON_PM)
|
||||
Strcpy(buf, m_monnam(mtmp));
|
||||
#endif
|
||||
} else if (mptr == &mons[PM_GHOST]) {
|
||||
@@ -273,8 +273,11 @@ done_in_by(struct monst *mtmp, int how)
|
||||
Strcat(buf, m_monnam(mtmp));
|
||||
} else {
|
||||
Strcat(buf, pmname(mptr, Mgender(mtmp)));
|
||||
if (has_mgivenname(mtmp))
|
||||
Sprintf(eos(buf), " called %s", MGIVENNAME(mtmp));
|
||||
if (has_mgivenname(mtmp)) {
|
||||
Sprintf(eos(buf), " %s %s",
|
||||
has_ebones(mtmp) ? "of" : "called",
|
||||
MGIVENNAME(mtmp));
|
||||
}
|
||||
}
|
||||
|
||||
Strcpy(svk.killer.name, buf);
|
||||
|
||||
@@ -1070,29 +1070,6 @@ newmextra(void)
|
||||
return mextra;
|
||||
}
|
||||
|
||||
void
|
||||
newformer(struct monst *mtmp)
|
||||
{
|
||||
if (!mtmp->mextra)
|
||||
mtmp->mextra = newmextra();
|
||||
if (!FORMER(mtmp)) {
|
||||
FORMER(mtmp) = (struct former_incarnation *) alloc(
|
||||
sizeof(struct former_incarnation *));
|
||||
(void) memset((genericptr_t) FORMER(mtmp), 0,
|
||||
sizeof(struct former_incarnation *));
|
||||
FORMER(mtmp)->parentmid = mtmp->m_id;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
free_former(struct monst *mtmp)
|
||||
{
|
||||
if (mtmp->mextra && FORMER(mtmp)) {
|
||||
free((genericptr_t) FORMER(mtmp));
|
||||
FORMER(mtmp) = (struct former_incarnation *) 0;
|
||||
}
|
||||
}
|
||||
|
||||
staticfn boolean
|
||||
makemon_rnd_goodpos(
|
||||
struct monst *mon,
|
||||
|
||||
22
src/mon.c
22
src/mon.c
@@ -2567,11 +2567,11 @@ copy_mextra(struct monst *mtmp2, struct monst *mtmp1)
|
||||
assert(has_edog(mtmp2));
|
||||
*EDOG(mtmp2) = *EDOG(mtmp1);
|
||||
}
|
||||
if (FORMER(mtmp1)) {
|
||||
if (!FORMER(mtmp2))
|
||||
newformer(mtmp2);
|
||||
assert(has_former(mtmp2));
|
||||
*FORMER(mtmp2) = *FORMER(mtmp1);
|
||||
if (EBONES(mtmp1)) {
|
||||
if (!EBONES(mtmp2))
|
||||
newebones(mtmp2);
|
||||
assert(has_ebones(mtmp2));
|
||||
*EBONES(mtmp2) = *EBONES(mtmp1);
|
||||
}
|
||||
if (has_mcorpsenm(mtmp1))
|
||||
MCORPSENM(mtmp2) = MCORPSENM(mtmp1);
|
||||
@@ -2595,8 +2595,8 @@ dealloc_mextra(struct monst *m)
|
||||
free((genericptr_t) x->emin), x->emin = 0;
|
||||
if (x->edog)
|
||||
free((genericptr_t) x->edog), x->edog = 0;
|
||||
if (x->former)
|
||||
free((genericptr_t) x->former), x->former = 0;
|
||||
if (x->ebones)
|
||||
free((genericptr_t) x->ebones), x->ebones = 0;
|
||||
x->mcorpsenm = NON_PM; /* no allocation to release */
|
||||
|
||||
free((genericptr_t) x);
|
||||
@@ -3644,13 +3644,13 @@ xkilled(
|
||||
|
||||
#if 0 /* HARDFOUGHT-only at present */
|
||||
#ifdef LIVELOG
|
||||
if (has_former(mtmp) && FORMER(mtmp)->rank.mnum != NON_PM) {
|
||||
if (has_ebones(mtmp)) {
|
||||
livelog_printf(LL_UMONST, "destroyed %s, %s former %s",
|
||||
livelog_mon_nam(mtmp),
|
||||
(mtmp->data == &mons[PM_GHOST]) ? "the" : "and",
|
||||
rank_of(FORMER(mtmp)->rank.lev,
|
||||
FORMER(mtmp)->rank.mnum,
|
||||
FORMER(mtmp)->rank.female));
|
||||
rank_of(EBONES(mtmp)->deathlevel,
|
||||
EBONES(mtmp)->mnum,
|
||||
EBONES(mtmp)->female));
|
||||
}
|
||||
#endif /* LIVELOG */
|
||||
#endif
|
||||
|
||||
@@ -370,14 +370,14 @@ restmon(NHFILE *nhfp, struct monst *mtmp)
|
||||
EDOG(mtmp)->apport = 1;
|
||||
}
|
||||
}
|
||||
/* former - info about former self, primarily for bones files */
|
||||
/* ebones */
|
||||
if (nhfp->structlevel)
|
||||
Mread(nhfp->fd, &buflen, sizeof buflen);
|
||||
if (buflen > 0) {
|
||||
newformer(mtmp);
|
||||
newebones(mtmp);
|
||||
if (nhfp->structlevel)
|
||||
Mread(nhfp->fd, FORMER(mtmp),
|
||||
sizeof (struct former_incarnation));
|
||||
Mread(nhfp->fd, EBONES(mtmp),
|
||||
sizeof (struct ebones));
|
||||
}
|
||||
/* mcorpsenm - obj->corpsenm for mimic posing as corpse or
|
||||
statue (inline int rather than pointer to something) */
|
||||
|
||||
@@ -24,6 +24,9 @@
|
||||
*
|
||||
* God names use a leading underscore to flag goddesses.
|
||||
*/
|
||||
|
||||
/* NUM_ROLES is defined in hack.h */
|
||||
|
||||
const struct Role roles[NUM_ROLES+1] = {
|
||||
{ { "Archeologist", 0 },
|
||||
{ { "Digger", 0 },
|
||||
@@ -573,7 +576,9 @@ const struct Role roles[NUM_ROLES+1] = {
|
||||
};
|
||||
|
||||
/* Table of all races */
|
||||
const struct Race races[] = {
|
||||
|
||||
/* NUM_RACES is defined in hack.h */
|
||||
const struct Race races[NUM_RACES + 1] = {
|
||||
{
|
||||
"human",
|
||||
"human",
|
||||
|
||||
@@ -943,12 +943,12 @@ savemon(NHFILE *nhfp, struct monst *mtmp)
|
||||
if (nhfp->structlevel)
|
||||
bwrite(nhfp->fd, (genericptr_t) EDOG(mtmp), buflen);
|
||||
}
|
||||
buflen = FORMER(mtmp) ? (int) sizeof (struct former_incarnation) : 0;
|
||||
buflen = EBONES(mtmp) ? (int) sizeof (struct ebones) : 0;
|
||||
if (nhfp->structlevel)
|
||||
bwrite(nhfp->fd, (genericptr_t) &buflen, sizeof (int));
|
||||
if (buflen > 0) {
|
||||
if (nhfp->structlevel)
|
||||
bwrite(nhfp->fd, (genericptr_t) FORMER(mtmp), buflen);
|
||||
bwrite(nhfp->fd, (genericptr_t) EBONES(mtmp), buflen);
|
||||
}
|
||||
/* mcorpsenm is inline int rather than pointer to something,
|
||||
so doesn't need to be preceded by a length field */
|
||||
|
||||
@@ -1246,8 +1246,8 @@ size_monst(struct monst *mtmp, boolean incl_wsegs)
|
||||
sz += (int) sizeof (struct emin);
|
||||
if (EDOG(mtmp))
|
||||
sz += (int) sizeof (struct edog);
|
||||
if (FORMER(mtmp))
|
||||
sz += (int) sizeof (struct former_incarnation);
|
||||
if (EBONES(mtmp))
|
||||
sz += (int) sizeof (struct ebones);
|
||||
/* mextra->mcorpsenm doesn't point to more memory */
|
||||
}
|
||||
return sz;
|
||||
|
||||
Reference in New Issue
Block a user