mextra changes

Note: The CVS repository was tagged with NETHACK_PRE_MEXTRA
prior to application of this patch to allow easy withdrawal if necessary.

Adds a new mextra structure type that has a set
of pointers to various types of monster structures
including:
   mname, egd, epri, eshk, emin, edog

Replaces the mextra bits in the monst structure
with a single pointer called mtmp->mextra of type
(struct mextra *).
The pointer can be null if there are no additional
structures attached. The mextra structure is not
adjacent to the monst structure.

Reduces the in-memory footprint of the monst that
has no other structures attached, at the cost
of adding 6 extra long ints per monster to
the save file

The new mextra structure has the mextra fields
independent of each other, not overlapping as was
the case with previous NetHack versions.
This patch doesn't do anything to capitalize on
that difference however.

Consolidates vault.h, epri.h, eshk.h, emin.h and edog.h
into mextra.h

Adds a macro for checking for whether a monster has
a name:
	has_name(monst)

This fixes the magic trap panic
   expels() -> spoteffects() -> dotrap() ->
	domagictrap() -> tamedog()
because the monst no longer varies in size so no
replacement is required.
This commit is contained in:
nethack.allison
2006-01-06 05:46:03 +00:00
parent cfbc5194ae
commit 0dc071bee8
39 changed files with 1015 additions and 625 deletions

View File

@@ -3,7 +3,6 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "edog.h"
static const char tools[] = { TOOL_CLASS, WEAPON_CLASS, WAND_CLASS, 0 };
static const char tools_too[] = { ALL_CLASSES, TOOL_CLASS, POTION_CLASS,

View File

@@ -134,6 +134,7 @@ extern void FDECL(show_borlandc_stats, (winid));
#ifdef DEBUG_MIGRATING_MONS
STATIC_PTR int NDECL(wiz_migrate_mons);
#endif
STATIC_DCL int FDECL(size_monst, (struct monst *));
STATIC_DCL void FDECL(count_obj, (struct obj *, long *, long *, BOOLEAN_P, BOOLEAN_P));
STATIC_DCL void FDECL(obj_chain, (winid, const char *, struct obj *, long *, long *));
STATIC_DCL void FDECL(mon_invent_chain, (winid, const char *, struct monst *, long *, long *));
@@ -1848,6 +1849,22 @@ contained(win, src, total_count, total_size)
putstr(win, 0, buf);
}
STATIC_OVL int
size_monst(mtmp)
struct monst *mtmp;
{
int sz = sizeof(struct monst);
if (mtmp->mextra) {
if (MNAME(mtmp)) sz += strlen(MNAME(mtmp))+1;
if (EGD(mtmp)) sz += sizeof(struct egd);
if (EPRI(mtmp)) sz += sizeof(struct epri);
if (ESHK(mtmp)) sz += sizeof(struct eshk);
if (EMIN(mtmp)) sz += sizeof(struct emin);
if (EDOG(mtmp)) sz += sizeof(struct edog);
}
return sz;
}
STATIC_OVL void
mon_chain(win, src, chain, total_count, total_size)
winid win;
@@ -1862,7 +1879,7 @@ mon_chain(win, src, chain, total_count, total_size)
for (count = size = 0, mon = chain; mon; mon = mon->nmon) {
count++;
size += sizeof(struct monst) + mon->mxlth + mon->mnamelth;
size += size_monst(mon);
}
*total_count += count;
*total_size += size;

View File

@@ -3,7 +3,7 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "edog.h"
/* #define DEBUG */ /* turn on for diagnostics */
static NEARDATA boolean did_dig_msg;

View File

@@ -218,7 +218,6 @@ struct monst *mtmp;
const char *name;
{
int lth;
struct monst *mtmp2;
char buf[PL_PSIZ];
/* dogname & catname are PL_PSIZ arrays; object names have same limit */
@@ -228,19 +227,16 @@ const char *name;
name = strncpy(buf, name, PL_PSIZ - 1);
buf[PL_PSIZ - 1] = '\0';
}
if (lth == mtmp->mnamelth) {
/* don't need to allocate a new monst struct */
if (lth) Strcpy(NAME(mtmp), name);
if (has_name(mtmp) && lth == (int)(strlen(MNAME(mtmp)) + 1)) {
/* don't need to allocate a new mname */
if (lth) Strcpy(MNAME(mtmp), name);
return mtmp;
}
mtmp2 = newmonst(mtmp->mxlth + lth);
*mtmp2 = *mtmp;
(void) memcpy((genericptr_t)mtmp2->mextra,
(genericptr_t)mtmp->mextra, mtmp->mxlth);
mtmp2->mnamelth = lth;
if (lth) Strcpy(NAME(mtmp2), name);
replmon(mtmp,mtmp2);
return(mtmp2);
if (has_name(mtmp)) free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)alloc(lth);
if (lth) Strcpy(MNAME(mtmp), name);
return(mtmp);
}
int
@@ -701,8 +697,8 @@ boolean called;
if (do_hallu) {
Strcat(buf, rndmonnam());
name_at_start = FALSE;
} else if (mtmp->mnamelth) {
char *name = NAME(mtmp);
} else if (has_name(mtmp)) {
char *name = MNAME(mtmp);
if (mdat == &mons[PM_GHOST]) {
Sprintf(eos(buf), "%s ghost", s_suffix(name));
@@ -775,7 +771,7 @@ l_monnam(mtmp)
register struct monst *mtmp;
{
return(x_monnam(mtmp, ARTICLE_NONE, (char *)0,
mtmp->mnamelth ? SUPPRESS_SADDLE : 0, TRUE));
(has_name(mtmp)) ? SUPPRESS_SADDLE : 0, TRUE));
}
char *
@@ -783,7 +779,7 @@ mon_nam(mtmp)
register struct monst *mtmp;
{
return(x_monnam(mtmp, ARTICLE_THE, (char *)0,
mtmp->mnamelth ? SUPPRESS_SADDLE : 0, FALSE));
(has_name(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE));
}
/* print the name as if mon_nam() was called, but assume that the player
@@ -795,7 +791,7 @@ noit_mon_nam(mtmp)
register struct monst *mtmp;
{
return(x_monnam(mtmp, ARTICLE_THE, (char *)0,
mtmp->mnamelth ? (SUPPRESS_SADDLE|SUPPRESS_IT) :
(has_name(mtmp)) ? (SUPPRESS_SADDLE|SUPPRESS_IT) :
SUPPRESS_IT, FALSE));
}
@@ -835,7 +831,7 @@ struct monst *mtmp;
int prefix, suppression_flag;
prefix = mtmp->mtame ? ARTICLE_YOUR : ARTICLE_THE;
suppression_flag = (mtmp->mnamelth
suppression_flag = (has_name(mtmp)
#ifdef STEED
/* "saddled" is redundant when mounted */
|| mtmp == u.usteed
@@ -851,7 +847,7 @@ register struct monst *mtmp;
register const char *adj;
{
register char *bp = x_monnam(mtmp, ARTICLE_THE, adj,
mtmp->mnamelth ? SUPPRESS_SADDLE : 0, FALSE);
(has_name(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE);
*bp = highc(*bp);
return(bp);
@@ -862,7 +858,7 @@ a_monnam(mtmp)
register struct monst *mtmp;
{
return x_monnam(mtmp, ARTICLE_A, (char *)0,
mtmp->mnamelth ? SUPPRESS_SADDLE : 0, FALSE);
(has_name(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE);
}
char *

View File

@@ -1,12 +1,33 @@
/* SCCS Id: @(#)dog.c 3.5 2005/03/17 */
/* SCCS Id: @(#)dog.c 3.5 2006/01/03 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "edog.h"
STATIC_DCL int NDECL(pet_type);
void
newedog(mtmp)
struct monst *mtmp;
{
if (!mtmp->mextra) mtmp->mextra = newmextra();
if (!EDOG(mtmp)) {
EDOG(mtmp) = (struct edog *)alloc(sizeof(struct edog));
(void) memset((genericptr_t) EDOG(mtmp), 0, sizeof(struct edog));
}
}
void
free_edog(mtmp)
struct monst *mtmp;
{
if (mtmp->mextra && EDOG(mtmp)) {
free((genericptr_t) EDOG(mtmp));
EDOG(mtmp) = (struct edog *)0;
}
mtmp->mtame = 0;
}
void
initedog(mtmp)
register struct monst *mtmp;
@@ -764,24 +785,27 @@ register struct obj *obj;
}
}
struct monst *
/*
* With the separate mextra structure added in 3.5.x this always
* operates on the original mtmp. It now returns TRUE if the taming
* succeeded.
*/
boolean
tamedog(mtmp, obj)
register struct monst *mtmp;
register struct obj *obj;
{
register struct monst *mtmp2;
/* The Wiz, Medusa and the quest nemeses aren't even made peaceful. */
if (mtmp->iswiz || mtmp->data == &mons[PM_MEDUSA]
|| (mtmp->data->mflags3 & M3_WANTSARTI))
return((struct monst *)0);
return FALSE;
/* worst case, at least it'll be peaceful. */
mtmp->mpeaceful = 1;
set_malign(mtmp);
if(flags.moonphase == FULL_MOON && night() && rn2(6) && obj
&& mtmp->data->mlet == S_DOG)
return((struct monst *)0);
return FALSE;
/* If we cannot tame it, at least it's no longer afraid. */
mtmp->mflee = 0;
@@ -818,9 +842,9 @@ register struct obj *obj;
/* eating might have killed it, but that doesn't matter here;
a non-null result suppresses "miss" message for thrown
food and also implies that the object has been deleted */
return mtmp;
return TRUE;
} else
return (struct monst *)0;
return FALSE;
}
if (mtmp->mtame || !mtmp->mcanmove ||
@@ -828,35 +852,30 @@ register struct obj *obj;
mtmp->isshk || mtmp->isgd || mtmp->ispriest || mtmp->isminion ||
is_covetous(mtmp->data) || is_human(mtmp->data) ||
(is_demon(mtmp->data) && !is_demon(youmonst.data)) ||
(obj && dogfood(mtmp, obj) >= MANFOOD)) return (struct monst *)0;
(obj && dogfood(mtmp, obj) >= MANFOOD)) return FALSE;
if (mtmp->m_id == quest_status.leader_m_id)
return((struct monst *)0);
return FALSE;
/* make a new monster which has the pet extension */
mtmp2 = newmonst(sizeof(struct edog) + mtmp->mnamelth);
*mtmp2 = *mtmp;
mtmp2->mxlth = sizeof(struct edog);
if (mtmp->mnamelth) Strcpy(NAME(mtmp2), NAME(mtmp));
initedog(mtmp2);
replmon(mtmp, mtmp2);
/* `mtmp' is now obsolete */
/* add the pet extension */
newedog(mtmp);
initedog(mtmp);
if (obj) { /* thrown food */
/* defer eating until the edog extension has been set up */
place_object(obj, mtmp2->mx, mtmp2->my); /* put on floor */
place_object(obj, mtmp->mx, mtmp->my); /* put on floor */
/* devour the food (might grow into larger, genocided monster) */
if (dog_eat(mtmp2, obj, mtmp2->mx, mtmp2->my, TRUE) == 2)
return mtmp2; /* oops, it died... */
if (dog_eat(mtmp, obj, mtmp->mx, mtmp->my, TRUE) == 2)
return TRUE; /* oops, it died... */
/* `obj' is now obsolete */
}
newsym(mtmp2->mx, mtmp2->my);
if (attacktype(mtmp2->data, AT_WEAP)) {
mtmp2->weapon_check = NEED_HTH_WEAPON;
(void) mon_wield_item(mtmp2);
newsym(mtmp->mx, mtmp->my);
if (attacktype(mtmp->data, AT_WEAP)) {
mtmp->weapon_check = NEED_HTH_WEAPON;
(void) mon_wield_item(mtmp);
}
return(mtmp2);
return TRUE;
}
/*

View File

@@ -5,7 +5,6 @@
#include "hack.h"
#include "mfndpos.h"
#include "edog.h"
extern boolean notonhead;

View File

@@ -3,7 +3,6 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "eshk.h"
#define is_bigfoot(x) ((x) == &mons[PM_SASQUATCH])
#define martial() (martial_bonus() || is_bigfoot(youmonst.data) || \

View File

@@ -5,7 +5,6 @@
/* Contains code for 't' (throw) */
#include "hack.h"
#include "edog.h"
STATIC_DCL int FDECL(throw_obj, (struct obj *,int));
STATIC_DCL void NDECL(autoquiver);

View File

@@ -3,7 +3,7 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "edog.h"
/* #define DEBUG */ /* uncomment to enable new eat code debugging */
#ifdef DEBUG

View File

@@ -5,7 +5,6 @@
#define NEED_VARARGS /* comment line for pre-compiled headers */
#include "hack.h"
#include "eshk.h"
#include "lev.h"
#ifndef NO_SIGNAL
#include <signal.h>
@@ -205,7 +204,7 @@ register struct monst *mtmp;
killer.format = KILLED_BY;
}
/* _the_ <invisible> <distorted> ghost of Dudley */
if (mtmp->data == &mons[PM_GHOST] && mtmp->mnamelth) {
if (mtmp->data == &mons[PM_GHOST] && has_name(mtmp)) {
Strcat(buf, "the ");
killer.format = KILLED_BY;
}
@@ -216,7 +215,7 @@ register struct monst *mtmp;
if(mtmp->data == &mons[PM_GHOST]) {
Strcat(buf, "ghost");
if (mtmp->mnamelth) Sprintf(eos(buf), " of %s", NAME(mtmp));
if (has_name(mtmp)) Sprintf(eos(buf), " of %s", MNAME(mtmp));
} else if(mtmp->isshk) {
const char *shknm = shkname(mtmp),
*honorific = shkname_is_pname(mtmp) ? "" :
@@ -230,8 +229,8 @@ register struct monst *mtmp;
Strcat(buf, m_monnam(mtmp));
} else {
Strcat(buf, mtmp->data->mname);
if (mtmp->mnamelth)
Sprintf(eos(buf), " called %s", NAME(mtmp));
if (has_name(mtmp))
Sprintf(eos(buf), " called %s", MNAME(mtmp));
}
if (multi) Strcat(buf, ", while helpless");

View File

@@ -3,14 +3,13 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "epri.h"
#include "emin.h"
#include "edog.h"
#ifdef REINCARNATION
#include <ctype.h>
#endif
STATIC_VAR NEARDATA struct monst zeromonst;
STATIC_VAR NEARDATA struct mextra zeromextra;
/* this assumes that a human quest leader or nemesis is an archetype
of the corresponding role; that isn't so for some roles (tourist
@@ -683,8 +682,9 @@ xchar x, y; /* clone's preferred location or 0 (near mon) */
return (struct monst *)0;
}
}
m2 = newmonst(0);
m2 = newmonst();
*m2 = *mon; /* copy condition of old monster */
m2->mextra = (struct mextra *)0;
m2->nmon = fmon;
fmon = m2;
m2->m_id = context.ident++;
@@ -714,16 +714,14 @@ xchar x, y; /* clone's preferred location or 0 (near mon) */
if (mon->isshk) m2->isshk = FALSE;
if (mon->isgd) m2->isgd = FALSE;
if (mon->ispriest) m2->ispriest = FALSE;
m2->mxlth = 0;
place_monster(m2, m2->mx, m2->my);
if (emits_light(m2->data))
new_light_source(m2->mx, m2->my, emits_light(m2->data),
LS_MONSTER, (genericptr_t)m2);
if (m2->mnamelth) {
m2->mnamelth = 0; /* or it won't get allocated */
m2 = christen_monst(m2, NAME(mon));
if (has_name(mon)) {
m2 = christen_monst(m2, MNAME(mon));
} else if (mon->isshk) {
m2 = christen_monst(m2, shkname(mon));
m2 = christen_monst(m2, shkname(mon));
}
/* not all clones caused by player are tame or peaceful */
@@ -736,24 +734,17 @@ xchar x, y; /* clone's preferred location or 0 (near mon) */
newsym(m2->mx,m2->my); /* display the new monster */
if (m2->mtame) {
struct monst *m3;
if (mon->isminion) {
m3 = newmonst(sizeof(struct epri) + mon->mnamelth);
*m3 = *m2;
m3->mxlth = sizeof(struct epri);
if (m2->mnamelth) Strcpy(NAME(m3), NAME(m2));
*(EPRI(m3)) = *(EPRI(mon));
replmon(m2, m3);
m2 = m3;
newemin(m2);
if (EMIN(mon)) *(EMIN(m2)) = *(EMIN(mon));
if (EPRI(mon)) *(EPRI(m2)) = *(EPRI(mon));
} else {
/* because m2 is a copy of mon it is tame but not init'ed.
* however, tamedog will not re-tame a tame dog, so m2
* must be made non-tame to get initialized properly.
*/
m2->mtame = 0;
if ((m3 = tamedog(m2, (struct obj *)0)) != 0) {
m2 = m3;
if (tamedog(m2, (struct obj *)0)) {
*(EDOG(m2)) = *(EDOG(mon));
}
}
@@ -877,7 +868,7 @@ register int x, y;
register int mmflags;
{
register struct monst *mtmp;
int mndx, mcham, ct, mitem, xlth;
int mndx, mcham, ct, mitem;
boolean anymon = (!ptr);
boolean byyou = (x == u.ux && y == u.uy);
boolean allow_minvent = ((mmflags & NO_MINVENT) == 0);
@@ -948,12 +939,15 @@ register int mmflags;
mndx = monsndx(ptr);
}
(void) propagate(mndx, countbirth, FALSE);
xlth = ptr->pxlth;
if (mmflags & MM_EDOG) xlth += sizeof(struct edog);
else if (mmflags & MM_EMIN) xlth += sizeof(struct emin);
mtmp = newmonst(xlth);
mtmp = newmonst();
*mtmp = zeromonst; /* clear all entries in structure */
(void)memset((genericptr_t)mtmp->mextra, 0, xlth);
if (mmflags & MM_EGD) newegd(mtmp);
if (mmflags & MM_EPRI) newepri(mtmp);
if (mmflags & MM_ESHK) neweshk(mtmp);
if (mmflags & MM_EMIN) newemin(mtmp);
if (mmflags & MM_EDOG) newedog(mtmp);
mtmp->nmon = fmon;
fmon = mtmp;
mtmp->m_id = context.ident++;
@@ -962,7 +956,6 @@ register int mmflags;
if (mtmp->data->msound == MS_LEADER &&
quest_info(MS_LEADER) == mndx)
quest_status.leader_m_id = mtmp->m_id;
mtmp->mxlth = xlth;
mtmp->mnum = mndx;
/* set up level and hit points */
@@ -1102,7 +1095,9 @@ register int mmflags;
types; make sure their extended data is initialized to
something sensible (caller can override these settings) */
if (mndx == PM_ALIGNED_PRIEST || (mndx == PM_ANGEL && !rn2(3))) {
struct emin *eminp = EMIN(mtmp);
struct emin *eminp;
newemin(mtmp);
eminp = EMIN(mtmp);
mtmp->isminion = 1; /* make priest be a roamer */
eminp->min_align = rn2(3) - 1; /* no A_NONE */
@@ -1640,9 +1635,9 @@ struct monst *mtmp;
if (mtmp->ispriest || mtmp->isminion) {
/* some monsters have individual alignments; check them */
if (mtmp->ispriest)
if (mtmp->ispriest && EPRI(mtmp))
mal = EPRI(mtmp)->shralign;
else if (mtmp->isminion)
else if (mtmp->isminion && EMIN(mtmp))
mal = EMIN(mtmp)->min_align;
/* unless alignment is none, set mal to -5,0,5 */
/* (see align.h for valid aligntyp values) */

View File

@@ -4,7 +4,6 @@
#include "hack.h"
#include "artifact.h"
#include "edog.h"
extern boolean notonhead;

View File

@@ -2560,7 +2560,6 @@ register struct attack *mattk;
return 1;
}
#include "edog.h"
struct monst *
cloneu()
{

View File

@@ -1,10 +1,30 @@
/* SCCS Id: @(#)minion.c 3.5 2005/11/01 */
/* SCCS Id: @(#)minion.c 3.5 2006/01/03 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "emin.h"
#include "epri.h"
void
newemin(mtmp)
struct monst *mtmp;
{
if (!mtmp->mextra) mtmp->mextra = newmextra();
if (!EMIN(mtmp)) {
EMIN(mtmp) = (struct emin *)alloc(sizeof(struct emin));
(void) memset((genericptr_t) EMIN(mtmp), 0, sizeof(struct emin));
}
}
void
free_emin(mtmp)
struct monst *mtmp;
{
if (mtmp->mextra && EMIN(mtmp)) {
free((genericptr_t) EMIN(mtmp));
EMIN(mtmp) = (struct emin *)0;
}
mtmp->isminion = 0;
}
int
msummon(mon) /* mon summons a monster */
@@ -73,7 +93,7 @@ struct monst *mon;
}
while (cnt > 0) {
mtmp = makemon(&mons[dtype], u.ux, u.uy, NO_MM_FLAGS);
mtmp = makemon(&mons[dtype], u.ux, u.uy, MM_EMIN);
if (mtmp) {
result++;
/* an angel's alignment should match the summoner */
@@ -117,9 +137,19 @@ boolean talk;
}
if (mnum == NON_PM) {
mon = 0;
} else if (mons[mnum].pxlth == 0 || mnum == PM_ANGEL) {
mon = makemon(&mons[mnum], u.ux, u.uy,
(mnum == PM_ANGEL) ? NO_MM_FLAGS : MM_EMIN);
} else if (mnum == PM_ANGEL) {
mon = makemon(&mons[mnum], u.ux, u.uy, MM_EPRI|MM_EMIN);
if (mon) {
mon->isminion = 1;
EMIN(mon)->min_align = alignment;
EMIN(mon)->renegade = FALSE;
EPRI(mon)->shralign = alignment;
}
} else if (mnum != PM_SHOPKEEPER && mnum != PM_GUARD &&
mnum != PM_ALIGNED_PRIEST && mnum != PM_HIGH_PRIEST) {
/* This was mons[mnum].pxlth == 0 but is this restriction
appropriate or necessary now that the structures are separate? */
mon = makemon(&mons[mnum], u.ux, u.uy, MM_EMIN);
if (mon) {
mon->isminion = 1;
EMIN(mon)->min_align = alignment;

View File

@@ -1070,11 +1070,13 @@ struct obj *obj;
struct monst *mtmp;
{
struct obj *otmp;
genericptr_t buffer;
int lth, namelth;
lth = sizeof(struct monst) + mtmp->mxlth + mtmp->mnamelth;
namelth = obj->onamelth ? strlen(ONAME(obj)) + 1 : 0;
otmp = realloc_obj(obj, lth, (genericptr_t) mtmp, namelth, ONAME(obj));
buffer = mon_to_buffer(mtmp, &lth);
otmp = realloc_obj(obj, lth, buffer, namelth, ONAME(obj));
free(buffer);
if (otmp && otmp->oxlth) {
struct monst *mtmp2 = (struct monst *)otmp->oextra;
if (mtmp->data) mtmp2->mnum = monsndx(mtmp->data);
@@ -1084,6 +1086,7 @@ struct monst *mtmp;
mtmp2->nmon = (struct monst *)0;
mtmp2->data = (struct permonst *)0;
mtmp2->minvent = (struct obj *)0;
/* mon_to_buffer() took care of x and mname */
#ifndef GOLDOBJ
/* not a pointer but is discarded along with minvent */
mtmp2->mgold = 0L;
@@ -1108,11 +1111,7 @@ boolean copyof;
mtmp = (struct monst *)obj->oextra;
if (mtmp) {
if (copyof) {
int lth = mtmp->mxlth + mtmp->mnamelth;
mnew = newmonst(lth);
lth += sizeof(struct monst);
(void) memcpy((genericptr_t)mnew,
(genericptr_t)mtmp, lth);
mnew = buffer_to_mon((genericptr_t)mtmp);
} else {
/* Never insert this returned pointer into mon chains! */
mnew = mtmp;

View File

@@ -9,7 +9,6 @@
#include "hack.h"
#include "mfndpos.h"
#include "edog.h"
#include <ctype.h>
STATIC_DCL boolean FDECL(restrap,(struct monst *));
@@ -19,6 +18,7 @@ STATIC_DCL long FDECL(mm_displacement, (struct monst *,struct monst *));
#endif
STATIC_DCL int NDECL(pick_animal);
STATIC_DCL void FDECL(kill_eggs, (struct obj *));
STATIC_DCL void FDECL(dealloc_mextra, (struct mextra *));
#ifdef REINCARNATION
#define LEVEL_SPECIFIC_NOCORPSE(mdat) \
@@ -232,19 +232,28 @@ unsigned corpseflags;
num = d(2,6);
while (num--)
obj = mksobj_at(IRON_CHAIN, x, y, TRUE, FALSE);
mtmp->mnamelth = 0;
if (has_name(mtmp)) {
free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)0;
}
break;
case PM_GLASS_GOLEM:
num = d(2,4); /* very low chance of creating all glass gems */
while (num--)
obj = mksobj_at((LAST_GEM + rnd(9)), x, y, TRUE, FALSE);
mtmp->mnamelth = 0;
if (has_name(mtmp)) {
free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)0;
}
break;
case PM_CLAY_GOLEM:
obj = mksobj_at(ROCK, x, y, FALSE, FALSE);
obj->quan = (long)(rn2(20) + 50);
obj->owt = weight(obj);
mtmp->mnamelth = 0;
if (has_name(mtmp)) {
free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)0;
}
break;
case PM_STONE_GOLEM:
corpstatflags &= ~CORPSTAT_INIT;
@@ -256,24 +265,36 @@ unsigned corpseflags;
while(num--) {
obj = mksobj_at(QUARTERSTAFF, x, y, TRUE, FALSE);
}
mtmp->mnamelth = 0;
if (has_name(mtmp)) {
free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)0;
}
break;
case PM_LEATHER_GOLEM:
num = d(2,4);
while(num--)
obj = mksobj_at(LEATHER_ARMOR, x, y, TRUE, FALSE);
mtmp->mnamelth = 0;
if (has_name(mtmp)) {
free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)0;
}
break;
case PM_GOLD_GOLEM:
/* Good luck gives more coins */
obj = mkgold((long)(200 - rnl(101)), x, y);
mtmp->mnamelth = 0;
if (has_name(mtmp)) {
free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)0;
}
break;
case PM_PAPER_GOLEM:
num = rnd(4);
while (num--)
obj = mksobj_at(SCR_BLANK_PAPER, x, y, TRUE, FALSE);
mtmp->mnamelth = 0;
if (has_name(mtmp)) {
free((genericptr_t)MNAME(mtmp));
MNAME(mtmp) = (char *)0;
}
break;
default_1:
default:
@@ -298,8 +319,8 @@ unsigned corpseflags;
prevent the same attack beam from hitting its corpse */
if (context.bypasses) bypass_obj(obj);
if (mtmp->mnamelth)
obj = oname(obj, NAME(mtmp));
if (has_name(mtmp))
obj = oname(obj, MNAME(mtmp));
/* Avoid "It was hidden under a green mold corpse!"
* during Blind combat. An unseen monster referred to as "it"
@@ -1347,6 +1368,29 @@ register struct monst *mon;
}
}
void
dealloc_mextra(x)
struct mextra *x;
{
if (x) {
if (x->mname) free((genericptr_t)x->mname);
if (x->egd) free((genericptr_t)x->egd);
if (x->epri) free((genericptr_t)x->epri);
if (x->eshk) free((genericptr_t)x->eshk);
if (x->emin) free((genericptr_t)x->emin);
if (x->edog) free((genericptr_t)x->edog);
}
free((genericptr_t)x);
}
void
dealloc_monst(mon)
struct monst *mon;
{
if (mon->mextra) dealloc_mextra(mon->mextra);
free((genericptr_t)mon);
}
/* remove effects of mtmp from other data structures */
STATIC_OVL void
m_detach(mtmp, mptr)
@@ -1704,7 +1748,7 @@ register struct monst *mdef;
so that saved monster traits won't retain any stale
item-conferred attributes */
otmp = mkcorpstat(STATUE, mdef, mdef->data, x, y, CORPSTAT_NONE);
if (mdef->mnamelth) otmp = oname(otmp, NAME(mdef));
if (has_name(mdef)) otmp = oname(otmp, MNAME(mdef));
while ((obj = oldminvent) != 0) {
oldminvent = obj->nobj;
(void) add_to_container(otmp, obj);
@@ -1825,9 +1869,9 @@ int dest;
You("%s %s!", verb,
!mtmp->mtame ? mon_nam(mtmp) :
x_monnam(mtmp,
mtmp->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(has_name(mtmp)) ? ARTICLE_NONE : ARTICLE_THE,
"poor",
mtmp->mnamelth ? SUPPRESS_SADDLE : 0,
(has_name(mtmp)) ? SUPPRESS_SADDLE : 0,
FALSE));
}
}
@@ -2485,17 +2529,16 @@ boolean msg; /* "The oldmon turns into a newmon!" */
if(!rn2(10)) mtmp->female = !mtmp->female;
}
if (In_endgame(&u.uz) && is_mplayer(olddata)) {
if (In_endgame(&u.uz) && is_mplayer(olddata) && has_name(mtmp)) {
/* mplayers start out as "Foo the Bar", but some of the
* titles are inappropriate when polymorphed, particularly
* into the opposite sex. players don't use ranks when
* polymorphed, so dropping the rank for mplayers seems
* reasonable.
*/
char *p = index(NAME(mtmp), ' ');
char *p = index(MNAME(mtmp), ' ');
if (p) {
*p = '\0';
mtmp->mnamelth = p - NAME(mtmp) + 1;
}
}
@@ -2579,8 +2622,8 @@ boolean msg; /* "The oldmon turns into a newmon!" */
newsym(mtmp->mx,mtmp->my);
if (msg) {
uchar save_mnamelth = mtmp->mnamelth;
mtmp->mnamelth = 0;
char *save_mname = (has_name(mtmp)) ? MNAME(mtmp) : (char *)0;
if (mtmp->mextra) MNAME(mtmp) = (char *)0;
Strcpy(newname,
(mdat == &mons[PM_GREEN_SLIME]) ? "slime" :
x_monnam(mtmp, ARTICLE_A, (char *)0,SUPPRESS_SADDLE, FALSE));
@@ -2588,7 +2631,7 @@ boolean msg; /* "The oldmon turns into a newmon!" */
(void) usmellmon(mdat);
else
pline("%s turns into %s!", oldname, newname);
mtmp->mnamelth = save_mnamelth;
if(mtmp->mextra) MNAME(mtmp) = save_mname;
}
possibly_unwield(mtmp, polyspot); /* might lose use of weapon */

File diff suppressed because it is too large Load Diff

View File

@@ -50,8 +50,9 @@ dev_name()
i = rn2(n);
for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if(!is_mplayer(mtmp->data)) continue;
if(!strncmp(developers[i], NAME(mtmp),
strlen(developers[i]))) {
if(!strncmp(developers[i],
(has_name(mtmp)) ? MNAME(mtmp) : "",
strlen(developers[i]))) {
match = TRUE;
break;
}

View File

@@ -7,7 +7,6 @@
*/
#include "hack.h"
#include "edog.h"
extern const int monstr[];

View File

@@ -321,7 +321,7 @@ do_pit: chasm = maketrap(x,y,PIT);
else {
You("destroy %s!", mtmp->mtame ?
x_monnam(mtmp, ARTICLE_THE, "poor",
mtmp->mnamelth ? SUPPRESS_SADDLE : 0, FALSE):
(has_name(mtmp)) ? SUPPRESS_SADDLE : 0, FALSE):
mon_nam(mtmp));
}
xkilled(mtmp,0);

View File

@@ -4,9 +4,6 @@
#define NEED_VARARGS /* Uses ... */ /* comment line for pre-compiled headers */
#include "hack.h"
#ifdef WIZARD
#include "edog.h"
#endif
static boolean no_repeat = FALSE;

View File

@@ -3,7 +3,6 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "epri.h"
STATIC_PTR int NDECL(prayer_done);
STATIC_DCL struct obj *NDECL(worst_cursed_item);

View File

@@ -1,12 +1,9 @@
/* SCCS Id: @(#)priest.c 3.5 2005/11/02 */
/* SCCS Id: @(#)priest.c 3.5 2006/01/03 */
/* Copyright (c) Izchak Miller, Steve Linhart, 1989. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "mfndpos.h"
#include "eshk.h"
#include "epri.h"
#include "emin.h"
/* this matches the categorizations shown by enlightenment */
#define ALGN_SINNED (-4) /* worse than strayed */
@@ -14,6 +11,28 @@
STATIC_DCL boolean FDECL(histemple_at,(struct monst *,XCHAR_P,XCHAR_P));
STATIC_DCL boolean FDECL(has_shrine,(struct monst *));
void
newepri(mtmp)
struct monst *mtmp;
{
if (!mtmp->mextra) mtmp->mextra = newmextra();
if (!EPRI(mtmp)) {
EPRI(mtmp) = (struct epri *)alloc(sizeof(struct epri));
(void) memset((genericptr_t) EPRI(mtmp), 0, sizeof(struct epri));
}
}
void
free_epri(mtmp)
struct monst *mtmp;
{
if (mtmp->mextra && EPRI(mtmp)) {
free((genericptr_t) EPRI(mtmp));
EPRI(mtmp) = (struct epri *)0;
}
mtmp->ispriest = 0;
}
/*
* Move for priests and shopkeepers. Called from shk_move() and pri_move().
* Valid returns are 1: moved 0: didn't -1: let m_move do it -2: died.
@@ -189,7 +208,7 @@ boolean sanctum; /* is it the seat of the high priest? */
(void) rloc(m_at(sx+1, sy), FALSE); /* insurance */
priest = makemon(&mons[sanctum ? PM_HIGH_PRIEST : PM_ALIGNED_PRIEST],
sx + 1, sy, NO_MM_FLAGS);
sx + 1, sy, MM_EPRI);
if (priest) {
EPRI(priest)->shroom = (sroom - rooms) + ROOMOFFSET;
EPRI(priest)->shralign = Amask2align(levl[sx][sy].altarmask);
@@ -549,7 +568,7 @@ boolean peaceful;
if (MON_AT(x, y)) (void) rloc(m_at(x, y), FALSE); /* insurance */
if (!(roamer = makemon(ptr, x, y, MM_ADJACENTOK)))
if (!(roamer = makemon(ptr, x, y, MM_ADJACENTOK|MM_EMIN)))
return((struct monst *)0);
EMIN(roamer)->min_align = alignment;
@@ -683,9 +702,15 @@ angry_priest()
if (!IS_ALTAR(lev->typ) ||
((aligntyp)Amask2align(lev->altarmask & AM_MASK) !=
EPRI(priest)->shralign)) {
priest->ispriest = 0; /* now a roamer */
priest->isminion = 1; /* but still aligned */
/* this overloads EPRI's shroom field, which is now clobbered */
if (EPRI(priest)) {
if (!EMIN(priest)) newemin(priest);
priest->ispriest = 0; /* roamer */
/* but still aligned */
priest->isminion = 1;
EMIN(priest)->min_align = EPRI(priest)->shralign;
}
/* this used to overload EPRI's shroom field, which was then clobbered
* but not since adding the separate mextra structure */
EMIN(priest)->renegade = FALSE;
}
}

View File

@@ -277,6 +277,80 @@ boolean ghostly, frozen;
return(first);
}
/*
* used by get_mtraits() in mkobj.c
* to retrieve the bundled up OATTACHED_MONST info.
*/
struct monst *
buffer_to_mon(buffer)
genericptr_t buffer;
{
int lth;
struct monst *mtmp;
char *spot = (char *)buffer;
mtmp = newmonst();
(void) memcpy((genericptr_t)mtmp, (genericptr_t)spot, sizeof(struct monst));
spot += sizeof(struct monst);
/* obtain the stored length of the monster name */
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
if (!mtmp->mextra) mtmp->mextra = newmextra();
MNAME(mtmp) = (char *)alloc(lth);
(void) memcpy((genericptr_t)MNAME(mtmp),
(genericptr_t)spot, lth);
spot += lth;
}
/* obtain the length of the egd (guard) structure */
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
newegd(mtmp);
(void) memcpy((genericptr_t)EGD(mtmp),
(genericptr_t)spot, lth);
spot += lth;
}
/* obtain the length of the epri (priest) structure */
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
newepri(mtmp);
(void) memcpy((genericptr_t)EPRI(mtmp),
(genericptr_t)spot, lth);
spot += lth;
}
/* obtain the length of the eshk (shopkeeper) structure */
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
neweshk(mtmp);
(void) memcpy((genericptr_t)ESHK(mtmp),
(genericptr_t)spot, lth);
spot += lth;
}
/* obtain the length of the emin (minion) structure */
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
newemin(mtmp);
(void) memcpy((genericptr_t)EMIN(mtmp),
(genericptr_t)spot, lth);
spot += lth;
}
/* obtain the length of the edog (mtame) structure */
(void) memcpy((genericptr_t)&lth, (genericptr_t)spot, sizeof(int));
spot += sizeof(int);
if (lth) {
newedog(mtmp);
(void) memcpy((genericptr_t)EDOG(mtmp),
(genericptr_t)spot, lth);
spot += lth; /* actually not necessary */
}
return mtmp;
}
STATIC_OVL struct monst *
restmonchn(fd, ghostly)
register int fd;
@@ -284,15 +358,66 @@ boolean ghostly;
{
register struct monst *mtmp, *mtmp2 = 0;
register struct monst *first = (struct monst *)0;
int xl, offset;
int offset, buflen;
while(1) {
mread(fd, (genericptr_t) &xl, sizeof(xl));
if(xl == -1) break;
mtmp = newmonst(xl);
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if(buflen == -1) break;
mtmp = newmonst();
mread(fd, (genericptr_t) mtmp, sizeof(struct monst));
/* any saved mextra pointer is invalid */
mtmp->mextra = (struct mextra *)0;
/* read the length of the name and the name */
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if (buflen > 0) {
if (!mtmp->mextra) mtmp->mextra = newmextra();
MNAME(mtmp) = (char *)alloc(buflen);
mread(fd, (genericptr_t) MNAME(mtmp), buflen);
}
/* egd */
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if (buflen > 0) {
newegd(mtmp);
mread(fd, (genericptr_t) EGD(mtmp),
sizeof(struct egd));
}
/* epri */
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if (buflen > 0) {
newepri(mtmp);
mread(fd, (genericptr_t) EPRI(mtmp),
sizeof(struct epri));
}
/* eshk */
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if (buflen > 0) {
neweshk(mtmp);
mread(fd, (genericptr_t) ESHK(mtmp),
sizeof(struct eshk));
}
/* emin */
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if (buflen > 0) {
newemin(mtmp);
mread(fd, (genericptr_t) EMIN(mtmp),
sizeof(struct emin));
}
/* edog */
mread(fd, (genericptr_t) &buflen, sizeof(buflen));
if (buflen > 0) {
newedog(mtmp);
mread(fd, (genericptr_t) EDOG(mtmp),
sizeof(struct edog));
}
if(!first) first = mtmp;
else mtmp2->nmon = mtmp;
mread(fd, (genericptr_t) mtmp, (unsigned) xl + sizeof(struct monst));
if (ghostly) {
unsigned nid = context.ident++;
add_id_mapping(mtmp->m_id, nid);

View File

@@ -1004,21 +1004,97 @@ register struct obj *otmp;
bwrite(fd, (genericptr_t) &minusone, sizeof(int));
}
/*
* Used by save_mtraits() in mkobj.c to ensure
* that all the monst related information is stored in
* an OATTACHED_MONST structure.
*/
genericptr_t
mon_to_buffer(mtmp,isize)
struct monst *mtmp;
int *isize;
{
char *spot;
int lth, k, xlth[6];
genericptr_t buffer, xptr[6];
struct monst *mbuf;
lth = sizeof(struct monst);
/* there is always one sizeof(int) for the name
and one for each of the 5 potential mextra fields */
for (k = 0; k < 6; ++k) {
xlth[k] = 0;
xptr[k] = (genericptr_t)0;
}
if (mtmp->mextra) {
if (MNAME(mtmp)) {
xlth[0] = strlen(MNAME(mtmp)) + 1;
xptr[0] = (genericptr_t)MNAME(mtmp);
}
if (EGD(mtmp)) {
xlth[1] = sizeof(struct egd);
xptr[1] = (genericptr_t)EGD(mtmp);
}
if (EPRI(mtmp)) {
xlth[2] = sizeof(struct epri);
xptr[2] = (genericptr_t)EPRI(mtmp);
}
if (ESHK(mtmp)) {
xlth[3] = sizeof(struct eshk);
xptr[3] = (genericptr_t)ESHK(mtmp);
}
if (EMIN(mtmp)) {
xlth[4] = sizeof(struct emin);
xptr[4] = (genericptr_t)EMIN(mtmp);
}
if (EDOG(mtmp)) {
xlth[5] = sizeof(struct edog);
xptr[5] = (genericptr_t)EDOG(mtmp);
}
}
for (k = 0; k < 6; ++k) {
lth += sizeof(int);
lth += xlth[k];
}
if (isize) *isize = lth;
buffer = alloc(lth);
spot = (char *)buffer;
(void) memcpy((genericptr_t)spot, (genericptr_t)mtmp,
sizeof(struct monst));
spot += sizeof(struct monst);
mbuf = (struct monst *)buffer;
mbuf->mextra = (struct mextra *)0;
for (k = 0; k < 6; ++k) {
lth = xlth[k];
(void) memcpy((genericptr_t)spot,
(genericptr_t)&lth, sizeof(lth));
spot += sizeof(lth);
if (lth > 0 && xptr[k] != 0) {
(void) memcpy((genericptr_t)spot, xptr[k], lth);
spot += lth;
}
}
return (genericptr_t)buffer;
}
STATIC_OVL void
savemonchn(fd, mtmp, mode)
register int fd, mode;
register struct monst *mtmp;
{
register struct monst *mtmp2;
unsigned int xl;
int minusone = -1;
int buflen, minusone = -1, zerobuf = 0;
genericptr_t buffer = (genericptr_t)0;
while (mtmp) {
mtmp2 = mtmp->nmon;
if (perform_bwrite(mode)) {
mtmp->mnum = monsndx(mtmp->data);
xl = mtmp->mxlth + mtmp->mnamelth;
bwrite(fd, (genericptr_t) &xl, sizeof(int));
#ifndef GOLDOBJ
if (mtmp->mgold) {
struct obj *goldobj = mksobj(GOLD_PIECE, FALSE, FALSE);
@@ -1030,7 +1106,58 @@ register struct monst *mtmp;
mtmp->minvent = goldobj;
}
#endif
bwrite(fd, (genericptr_t) mtmp, xl + sizeof(struct monst));
buflen = sizeof(struct monst);
bwrite(fd, (genericptr_t) &buflen, sizeof(int));
#if 0
buffer = mon_to_buffer(mtmp, &buflen);
bwrite(fd, buffer, buflen);
#else
bwrite(fd, (genericptr_t) mtmp, buflen);
if (!mtmp->mextra) {
bwrite(fd, (genericptr_t) &zerobuf, sizeof(int));
bwrite(fd, (genericptr_t) &zerobuf, sizeof(int));
bwrite(fd, (genericptr_t) &zerobuf, sizeof(int));
bwrite(fd, (genericptr_t) &zerobuf, sizeof(int));
bwrite(fd, (genericptr_t) &zerobuf, sizeof(int));
bwrite(fd, (genericptr_t) &zerobuf, sizeof(int));
} else {
if (MNAME(mtmp)) buflen = strlen(MNAME(mtmp)) + 1;
else buflen = 0;
bwrite(fd, (genericptr_t) &buflen, sizeof(int));
if (buflen > 0)
bwrite(fd, (genericptr_t) MNAME(mtmp), buflen);
if (EGD(mtmp)) buflen = sizeof(struct egd);
else buflen = 0;
bwrite(fd, (genericptr_t) &buflen, sizeof(int));
if (buflen > 0)
bwrite(fd, (genericptr_t) EGD(mtmp), buflen);
if (EPRI(mtmp)) buflen = sizeof(struct epri);
else buflen = 0;
bwrite(fd, (genericptr_t) &buflen, sizeof(int));
if (buflen > 0)
bwrite(fd, (genericptr_t) EPRI(mtmp), buflen);
if (ESHK(mtmp)) buflen = sizeof(struct eshk);
else buflen = 0;
bwrite(fd, (genericptr_t) &buflen, sizeof(int));
if (buflen > 0)
bwrite(fd, (genericptr_t) ESHK(mtmp), buflen);
if (EMIN(mtmp)) buflen = sizeof(struct emin);
else buflen = 0;
bwrite(fd, (genericptr_t) &buflen, sizeof(int));
if (buflen > 0)
bwrite(fd, (genericptr_t) EMIN(mtmp), buflen);
if (EDOG(mtmp)) buflen = sizeof(struct edog);
else buflen = 0;
bwrite(fd, (genericptr_t) &buflen, sizeof(int));
if (buflen > 0)
bwrite(fd, (genericptr_t) EDOG(mtmp), buflen);
}
#endif
}
if (mtmp->minvent)
saveobjchn(fd,mtmp->minvent,mode);

View File

@@ -3,7 +3,6 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "eshk.h"
/*#define DEBUG*/

View File

@@ -1,11 +1,10 @@
/* SCCS Id: @(#)shknam.c 3.5 2005/12/14 */
/* SCCS Id: @(#)shknam.c 3.5 2006/01/03 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
/* shknam.c -- initialize a shop */
#include "hack.h"
#include "eshk.h"
STATIC_DCL boolean FDECL(veggy_item, (struct obj *obj,int));
STATIC_DCL int NDECL(shkveg);
@@ -450,6 +449,28 @@ const char * const *nlp;
ESHK(shk)->shknam[PL_NSIZ-1] = 0;
}
void
neweshk(mtmp)
struct monst *mtmp;
{
if (!mtmp->mextra) mtmp->mextra = newmextra();
if (!ESHK(mtmp)) {
ESHK(mtmp) = (struct eshk *)alloc(sizeof(struct eshk));
(void) memset((genericptr_t) ESHK(mtmp), 0, sizeof(struct eshk));
}
}
void
free_eshk(mtmp)
struct monst *mtmp;
{
if (mtmp->mextra && ESHK(mtmp)) {
free((genericptr_t) ESHK(mtmp));
ESHK(mtmp) = (struct eshk *)0;
}
mtmp->isshk = 0;
}
STATIC_OVL int
shkinit(shp, sroom) /* create a new shopkeeper in the given room */
const struct shclass *shp;
@@ -507,7 +528,7 @@ struct mkroom *sroom;
if(MON_AT(sx, sy)) (void) rloc(m_at(sx, sy), FALSE); /* insurance */
/* now initialize the shopkeeper monster structure */
if(!(shk = makemon(&mons[PM_SHOPKEEPER], sx, sy, NO_MM_FLAGS)))
if(!(shk = makemon(&mons[PM_SHOPKEEPER], sx, sy, MM_ESHK)))
return(-1);
shk->isshk = shk->mpeaceful = 1;
set_malign(shk);

View File

@@ -3,7 +3,7 @@
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "edog.h"
#ifdef USER_SOUNDS
# ifdef USER_SOUNDS_REGEX
#include <sys/types.h>

View File

@@ -512,7 +512,7 @@ dismount_steed(reason)
You("can't. There isn't anywhere for you to stand.");
return;
}
if (!mtmp->mnamelth) {
if (!has_name(mtmp)) {
pline("You've been through the dungeon on %s with no name.",
an(mtmp->data->mname));
if (Hallucination)

View File

@@ -470,10 +470,9 @@ long timeout;
while it's in your inventory */
if ((yours && !silent) ||
(carried(egg) && mon->data->mlet == S_DRAGON)) {
if ((mon2 = tamedog(mon, (struct obj *)0)) != 0) {
mon = mon2;
if (tamedog(mon, (struct obj *)0)) {
if (carried(egg) && mon->data->mlet != S_DRAGON)
mon->mtame = 20;
mon->mtame = 20;
}
}
if (mvitals[mnum].mvflags & G_EXTINCT)
@@ -680,7 +679,7 @@ slip_or_trip()
pline("%s %s%s on the ice.",
#ifdef STEED
u.usteed ? upstart(x_monnam(u.usteed,
u.usteed->mnamelth ? ARTICLE_NONE : ARTICLE_THE,
(has_name(u.usteed)) ? ARTICLE_NONE : ARTICLE_THE,
(char *)0, SUPPRESS_SADDLE, FALSE)) :
#endif
"You", rn2(2) ? "slip" : "slide", on_foot ? "" : "s");

View File

@@ -675,7 +675,7 @@ unsigned trflags;
u.usteed->mtrapseen |= (1 << (ttype - 1));
/* suppress article in various steed messages when using its
name (which won't occur when hallucinating) */
if (u.usteed->mnamelth && !Hallucination)
if (has_name(u.usteed) && !Hallucination)
steed_article = ARTICLE_NONE;
}
#endif

View File

@@ -1,9 +1,8 @@
/* SCCS Id: @(#)vault.c 3.5 2005/10/28 */
/* SCCS Id: @(#)vault.c 3.5 2006/01/03 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#include "vault.h"
STATIC_DCL struct monst *NDECL(findgd);
@@ -16,6 +15,28 @@ STATIC_DCL boolean FDECL(in_fcorridor, (struct monst *,int,int));
STATIC_DCL void FDECL(move_gold,(struct obj *,int));
STATIC_DCL void FDECL(wallify_vault,(struct monst *));
void
newegd(mtmp)
struct monst *mtmp;
{
if (!mtmp->mextra) mtmp->mextra = newmextra();
if (!EGD(mtmp)) {
EGD(mtmp) = (struct egd *)alloc(sizeof(struct egd));
(void) memset((genericptr_t) EGD(mtmp), 0, sizeof(struct egd));
}
}
void
free_egd(mtmp)
struct monst *mtmp;
{
if (mtmp->mextra && EGD(mtmp)) {
free((genericptr_t) EGD(mtmp));
EGD(mtmp) = (struct egd *)0;
}
mtmp->isgd = 0;
}
STATIC_OVL boolean
clear_fcorr(grd, forceshow)
struct monst *grd;
@@ -222,7 +243,7 @@ fnd:
}
/* make something interesting happen */
if(!(guard = makemon(&mons[PM_GUARD], x, y, NO_MM_FLAGS))) return;
if(!(guard = makemon(&mons[PM_GUARD], x, y, MM_EGD))) return;
guard->isgd = 1;
guard->mpeaceful = 1;
set_malign(guard);

View File

@@ -685,7 +685,7 @@ boolean by_hero;
/* handle recorporealization of an active ghost */
if (corpse->oxlth && corpse->oattached == OATTACHED_M_ID) {
unsigned m_id;
struct monst *ghost, *mtmp2;
struct monst *ghost;
struct obj *otmp;
(void) memcpy((genericptr_t)&m_id,
@@ -702,11 +702,9 @@ boolean by_hero;
}
/* tame the revived monster if its ghost was tame */
if (ghost->mtame && !mtmp->mtame) {
mtmp2 = tamedog(mtmp, (struct obj *)0);
if (mtmp2) {
if (tamedog(mtmp, (struct obj *)0)) {
/* ghost's edog data is ignored */
mtmp2->mtame = ghost->mtame;
mtmp = mtmp2;
mtmp->mtame = ghost->mtame;
}
}
/* was ghost, now alive, it's all very confusing */