issue #531 followup

Set gender before creating monster rather than after the fact
to force display to show it correctly.
This commit is contained in:
PatR
2021-06-08 16:38:43 -07:00
parent 710efe4175
commit cfc4f24c8e
3 changed files with 26 additions and 28 deletions
+3 -3
View File
@@ -1421,9 +1421,9 @@ corpse_xname(
/* avoid "aligned priest"; it just exposes internal details */ /* avoid "aligned priest"; it just exposes internal details */
mnam = "priest"; mnam = "priest";
} else { } else {
int cspe = (otmp->spe & CORPSTAT_GENDER), int cgend = (otmp->spe & CORPSTAT_GENDER),
mgend = (cspe == CORPSTAT_FEMALE) ? FEMALE mgend = (cgend == CORPSTAT_FEMALE) ? FEMALE
: (cspe == CORPSTAT_MALE) ? MALE : (cgend == CORPSTAT_MALE) ? MALE
: NEUTRAL; : NEUTRAL;
mnam = pmname(&mons[omndx], mgend); mnam = pmname(&mons[omndx], mgend);
+12 -12
View File
@@ -597,6 +597,8 @@ animate_statue(
int cause, int cause,
int *fail_reason) int *fail_reason)
{ {
static const char
historic_statue_is_gone[] = "that the historic statue is now gone";
int mnum = statue->corpsenm; int mnum = statue->corpsenm;
struct permonst *mptr = &mons[mnum]; struct permonst *mptr = &mons[mnum];
struct monst *mon = 0, *shkp; struct monst *mon = 0, *shkp;
@@ -607,8 +609,6 @@ animate_statue(
golem_xform = FALSE, use_saved_traits; golem_xform = FALSE, use_saved_traits;
const char *comes_to_life; const char *comes_to_life;
char statuename[BUFSZ], tmpbuf[BUFSZ]; char statuename[BUFSZ], tmpbuf[BUFSZ];
static const char historic_statue_is_gone[] =
"that the historic statue is now gone";
if (cant_revive(&mnum, TRUE, statue)) { if (cant_revive(&mnum, TRUE, statue)) {
/* mnum has changed; we won't be animating this statue as itself */ /* mnum has changed; we won't be animating this statue as itself */
@@ -632,6 +632,11 @@ animate_statue(
if (mon && mon->mtame && !mon->isminion) if (mon && mon->mtame && !mon->isminion)
wary_dog(mon, TRUE); wary_dog(mon, TRUE);
} else { } else {
int sgend = (statue->spe & CORPSTAT_GENDER);
long mmflags = (NO_MINVENT
| ((sgend == CORPSTAT_MALE) ? MM_MALE : 0)
| ((sgend == CORPSTAT_FEMALE) ? MM_FEMALE : 0));
/* statues of unique monsters from bones or wishing end /* statues of unique monsters from bones or wishing end
up here (cant_revive() sets mnum to be doppelganger; up here (cant_revive() sets mnum to be doppelganger;
mptr reflects the original form for use by newcham()) */ mptr reflects the original form for use by newcham()) */
@@ -639,22 +644,17 @@ animate_statue(
/* block quest guards from other roles */ /* block quest guards from other roles */
|| (mptr->msound == MS_GUARDIAN || (mptr->msound == MS_GUARDIAN
&& quest_info(MS_GUARDIAN) != mnum)) { && quest_info(MS_GUARDIAN) != mnum)) {
mon = makemon(&mons[PM_DOPPELGANGER], x, y, mmflags |= MM_NOCOUNTBIRTH | MM_ADJACENTOK;
NO_MINVENT | MM_NOCOUNTBIRTH | MM_ADJACENTOK); mon = makemon(&mons[PM_DOPPELGANGER], x, y, mmflags);
/* if hero has protection from shape changers, cham field will /* if hero has protection from shape changers, cham field will
be NON_PM; otherwise, set form to match the statue */ be NON_PM; otherwise, set form to match the statue */
if (mon && mon->cham >= LOW_PM) if (mon && mon->cham >= LOW_PM)
(void) newcham(mon, mptr, FALSE, FALSE); (void) newcham(mon, mptr, FALSE, FALSE);
} else { } else {
mon = makemon(mptr, x, y, (cause == ANIMATE_SPELL) if (cause == ANIMATE_SPELL)
? (NO_MINVENT | MM_ADJACENTOK) mmflags |= MM_ADJACENTOK;
: NO_MINVENT); mon = makemon(mptr, x, y, mmflags);
} }
/* a non-montraits() statue might specify gender */
if ((statue->spe & CORPSTAT_MALE) != 0)
mon->female = 0;
else if ((statue->spe & CORPSTAT_FEMALE) != 0)
mon->female = 1;
} }
if (!mon) { if (!mon) {
+11 -13
View File
@@ -757,7 +757,8 @@ revive(struct obj *corpse, boolean by_hero)
coord xy; coord xy;
xchar x, y; xchar x, y;
boolean one_of; boolean one_of;
int montype, container_nesting = 0; long mmflags = NO_MINVENT | MM_NOWAIT;
int montype, cgend, container_nesting = 0;
if (corpse->otyp != CORPSE) { if (corpse->otyp != CORPSE) {
impossible("Attempting to revive %s?", xname(corpse)); impossible("Attempting to revive %s?", xname(corpse));
@@ -825,10 +826,17 @@ revive(struct obj *corpse, boolean by_hero)
return (struct monst *) 0; return (struct monst *) 0;
} }
/* applicable when montraits/corpse->oextra->omonst aren't used */
cgend = (corpse->spe & CORPSTAT_GENDER);
if (cgend == CORPSTAT_MALE)
mmflags |= MM_MALE;
else if (cgend == CORPSTAT_FEMALE)
mmflags |= MM_FEMALE;
if (cant_revive(&montype, TRUE, corpse)) { if (cant_revive(&montype, TRUE, corpse)) {
/* make a zombie or doppelganger instead */ /* make a zombie or doppelganger instead */
/* note: montype has changed; mptr keeps old value for newcham() */ /* note: montype has changed; mptr keeps old value for newcham() */
mtmp = makemon(&mons[montype], x, y, NO_MINVENT | MM_NOWAIT); mtmp = makemon(&mons[montype], x, y, mmflags);
if (mtmp) { if (mtmp) {
/* skip ghost handling */ /* skip ghost handling */
if (has_omid(corpse)) if (has_omid(corpse))
@@ -851,21 +859,11 @@ revive(struct obj *corpse, boolean by_hero)
wary_dog(mtmp, TRUE); wary_dog(mtmp, TRUE);
} else { } else {
/* make a new monster */ /* make a new monster */
mtmp = makemon(mptr, x, y, NO_MINVENT | MM_NOWAIT | MM_NOCOUNTBIRTH); mtmp = makemon(mptr, x, y, mmflags | MM_NOCOUNTBIRTH);
} }
if (!mtmp) if (!mtmp)
return (struct monst *) 0; return (struct monst *) 0;
/* if we didn't use montraits, corpse might specify mon's gender */
if (!has_omonst(corpse)) {
int cspe = (corpse->spe & CORPSTAT_GENDER);
if (cspe == CORPSTAT_MALE)
mtmp->female = 0;
else if (cspe == CORPSTAT_FEMALE)
mtmp->female = 1;
}
/* hiders shouldn't already be re-hidden when they revive */ /* hiders shouldn't already be re-hidden when they revive */
if (mtmp->mundetected) { if (mtmp->mundetected) {
mtmp->mundetected = 0; mtmp->mundetected = 0;