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

@@ -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;
}
}