E NEARDATA struct obj *billobjs;
E NEARDATA struct obj *current_wand, *thrownobj, *kickedobj;
-E NEARDATA struct obj zeroobj; /* init'd and defined in decl.c */
+E NEARDATA struct obj zeroobj; /* for init; &zeroobj used as special value */
+
E NEARDATA anything zeroany; /* init'd and defined in decl.c */
#include "you.h"
#include "pm.h"
#endif
-E NEARDATA struct monst youmonst; /* init'd and defined in decl.c */
+E NEARDATA struct monst zeromonst; /* for init of new or temp monsters */
+E NEARDATA struct monst youmonst; /* monster details when hero is poly'd */
E NEARDATA struct monst *mydogs, *migrating_mons;
E NEARDATA struct mvitals {
/* objects not yet paid for */
NEARDATA struct obj *billobjs = (struct obj *) 0;
-/* used to zero all elements of a struct obj */
+/* used to zero all elements of a struct obj and a struct monst */
NEARDATA struct obj zeroobj = DUMMY;
+NEARDATA struct monst zeromonst = DUMMY;
/* used to zero out union any; initializer deliberately omitted */
NEARDATA anything zeroany;
#include <ctype.h>
-STATIC_VAR NEARDATA struct monst zeromonst;
-
/* this assumes that a human quest leader or nemesis is an archetype
of the corresponding role; that isn't so for some roles (tourist
for instance) but is for the priests and monks we use it for... */
STATIC_DCL void FDECL(m_initthrow, (struct monst *, int, int));
STATIC_DCL void FDECL(m_initweap, (struct monst *));
STATIC_DCL void FDECL(m_initinv, (struct monst *));
-STATIC_DCL boolean FDECL(makemon_rnd_goodpos, (struct monst *, unsigned, coord *));
+STATIC_DCL boolean FDECL(makemon_rnd_goodpos, (struct monst *,
+ unsigned, coord *));
extern const int monstr[];
{
if (!otmp->oextra)
otmp->oextra = newoextra();
+
if (!OMONST(otmp)) {
struct monst *m = newmonst();
- /* newmonst() allocates memory but doesn't initialize anything */
- (void) memset((genericptr_t) m, 0, sizeof (struct monst));
- m->mextra = (struct mextra *) 0;
- m->nmon = (struct monst *) 0;
+ *m = zeromonst;
OMONST(otmp) = m;
}
}
int pm, x, y;
struct monst fakemon;
+ fakemon = zeromonst;
while (num) {
int tryct = 0;
/* roll for character class */
pm = PM_ARCHEOLOGIST + rn2(PM_WIZARD - PM_ARCHEOLOGIST + 1);
- fakemon.data = &mons[pm];
+ set_mon_data(&fakemon, &mons[pm], -1);
/* roll for an available location */
do {
/* default to player's original monster type */
mdat = &mons[u.umonster];
}
- fakemon.data = mdat; /* set up for goodpos */
+ fakemon = zeromonst;
+ set_mon_data(&fakemon, mdat, -1); /* set up for goodpos */
+
good_ptr = good;
range = 1;
/*