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:
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)monst.h 3.5 2005/07/13 */
|
||||
/* SCCS Id: @(#)monst.h 3.5 2006/01/02 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -33,8 +33,8 @@
|
||||
#define MINV_NOLET 0x01
|
||||
#define MINV_ALL 0x02
|
||||
|
||||
#ifndef ALIGN_H
|
||||
#include "align.h"
|
||||
#ifndef MEXTRA_H
|
||||
#include "mextra.h"
|
||||
#endif
|
||||
|
||||
struct monst {
|
||||
@@ -138,40 +138,16 @@ struct monst {
|
||||
long misc_worn_check;
|
||||
xchar weapon_check;
|
||||
|
||||
uchar mnamelth; /* length of name (following mxlth) */
|
||||
short mxlth; /* length of following data */
|
||||
/* in order to prevent alignment problems mextra should
|
||||
be (or follow) a long int */
|
||||
int meating; /* monster is eating timeout */
|
||||
long mextra[1]; /* monster dependent info */
|
||||
struct mextra *mextra; /* point to mextra struct */
|
||||
};
|
||||
|
||||
/*
|
||||
* Note that mextra[] may correspond to any of a number of structures, which
|
||||
* are indicated by some of the other fields.
|
||||
* isgd -> struct egd
|
||||
* ispriest -> struct epri
|
||||
* isshk -> struct eshk
|
||||
* isminion -> struct emin
|
||||
* (struct epri for roaming priests and angels, which is
|
||||
* compatible with emin for polymorph purposes)
|
||||
* mtame -> struct edog
|
||||
* (struct epri for guardian angels, which do not eat
|
||||
* or do other doggy things)
|
||||
* Since at most one structure can be indicated in this manner, it is not
|
||||
* possible to tame any creatures using the other structures (the only
|
||||
* exception being the guardian angels which are tame on creation).
|
||||
*/
|
||||
|
||||
#define newmonst(xl) (struct monst *)alloc((unsigned)(xl) + sizeof(struct monst))
|
||||
#define dealloc_monst(mon) free((genericptr_t)(mon))
|
||||
#define newmonst() (struct monst *)alloc(sizeof(struct monst))
|
||||
|
||||
/* these are in mspeed */
|
||||
#define MSLOW 1 /* slow monster */
|
||||
#define MFAST 2 /* speeded monster */
|
||||
|
||||
#define NAME(mtmp) (((char *)(mtmp)->mextra) + (mtmp)->mxlth)
|
||||
|
||||
#define MON_WEP(mon) ((mon)->mw)
|
||||
#define MON_NOWEP(mon) ((mon)->mw = (struct obj *)0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user