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:
@@ -426,6 +426,8 @@ E void FDECL(adj_abon, (struct obj *,SCHAR_P));
|
||||
|
||||
/* ### dog.c ### */
|
||||
|
||||
E void FDECL(newedog, (struct monst *));
|
||||
E void FDECL(free_edog, (struct monst *));
|
||||
E void FDECL(initedog, (struct monst *));
|
||||
E struct monst *FDECL(make_familiar, (struct obj *,XCHAR_P,XCHAR_P,BOOLEAN_P));
|
||||
E struct monst *NDECL(makedog);
|
||||
@@ -436,7 +438,7 @@ E void FDECL(mon_catchup_elapsed_time, (struct monst *,long));
|
||||
E void FDECL(keepdogs, (BOOLEAN_P));
|
||||
E void FDECL(migrate_to_level, (struct monst *,XCHAR_P,XCHAR_P,coord *));
|
||||
E int FDECL(dogfood, (struct monst *,struct obj *));
|
||||
E struct monst *FDECL(tamedog, (struct monst *,struct obj *));
|
||||
E boolean FDECL(tamedog, (struct monst *,struct obj *));
|
||||
E void FDECL(abuse_dog, (struct monst *));
|
||||
E void FDECL(wary_dog, (struct monst *, BOOLEAN_P));
|
||||
|
||||
@@ -962,6 +964,7 @@ E void FDECL(readmail, (struct obj *));
|
||||
|
||||
/* ### makemon.c ### */
|
||||
|
||||
E void FDECL(dealloc_monst, (struct monst *));
|
||||
E boolean FDECL(is_home_elemental, (struct permonst *));
|
||||
E struct monst *FDECL(clone_mon, (struct monst *,XCHAR_P,XCHAR_P));
|
||||
E int FDECL(monhp_per_lvl, (struct monst *));
|
||||
@@ -1027,6 +1030,8 @@ E int FDECL(doseduce, (struct monst *));
|
||||
|
||||
/* ### minion.c ### */
|
||||
|
||||
E void FDECL(newemin, (struct monst *));
|
||||
E void FDECL(free_emin, (struct monst *));
|
||||
E int FDECL(msummon, (struct monst *));
|
||||
E void FDECL(summon_minion, (ALIGNTYP_P,BOOLEAN_P));
|
||||
E int FDECL(demon_talk, (struct monst *));
|
||||
@@ -1686,6 +1691,8 @@ E void FDECL(ghod_hitsu, (struct monst *));
|
||||
E void NDECL(angry_priest);
|
||||
E void NDECL(clearpriests);
|
||||
E void FDECL(restpriest, (struct monst *,BOOLEAN_P));
|
||||
E void FDECL(newepri, (struct monst *));
|
||||
E void FDECL(free_epri, (struct monst *));
|
||||
|
||||
/* ### quest.c ### */
|
||||
|
||||
@@ -1774,6 +1781,7 @@ E void FDECL(getlev, (int,int,XCHAR_P,BOOLEAN_P));
|
||||
E void FDECL(get_plname_from_file, (int, char *));
|
||||
E void NDECL(minit);
|
||||
E boolean FDECL(lookup_id_mapping, (unsigned, unsigned *));
|
||||
E struct monst *FDECL(buffer_to_mon, (genericptr_t));
|
||||
E void FDECL(mread, (int,genericptr_t,unsigned int));
|
||||
#ifndef GOLDOBJ
|
||||
E void FDECL(put_gold_back, (struct obj **,long *));
|
||||
@@ -1853,6 +1861,7 @@ E void NDECL(co_false);
|
||||
#else
|
||||
E void FDECL(savelev, (int,XCHAR_P,int));
|
||||
#endif
|
||||
E genericptr_t FDECL(mon_to_buffer, (struct monst *, int *));
|
||||
E void FDECL(bufon, (int));
|
||||
E void FDECL(bufoff, (int));
|
||||
E void FDECL(bflush, (int));
|
||||
@@ -1932,6 +1941,8 @@ E char *FDECL(Shk_Your, (char *,struct obj *));
|
||||
|
||||
/* ### shknam.c ### */
|
||||
|
||||
E void FDECL(neweshk, (struct monst *));
|
||||
E void FDECL(free_eshk, (struct monst *));
|
||||
E void FDECL(stock_room, (int,struct mkroom *));
|
||||
E boolean FDECL(saleable, (struct monst *,struct obj *));
|
||||
E int FDECL(get_shop_item, (int));
|
||||
@@ -2207,6 +2218,8 @@ E int FDECL(hide_privileges, (BOOLEAN_P));
|
||||
|
||||
/* ### vault.c ### */
|
||||
|
||||
E void FDECL(newegd, (struct monst *));
|
||||
E void FDECL(free_egd, (struct monst *));
|
||||
E boolean FDECL(grddead, (struct monst *));
|
||||
E char FDECL(vault_occupied, (char *));
|
||||
E void NDECL(invault);
|
||||
|
||||
@@ -163,16 +163,19 @@ NEARDATA extern coord bhitpos; /* place where throw or zap hits or stops */
|
||||
#define NO_SPELL 0
|
||||
|
||||
/* flags to control makemon() */
|
||||
#define NO_MM_FLAGS 0x00 /* use this rather than plain 0 */
|
||||
#define NO_MINVENT 0x01 /* suppress minvent when creating mon */
|
||||
#define MM_NOWAIT 0x02 /* don't set STRAT_WAITMASK flags */
|
||||
#define MM_EDOG 0x04 /* add edog structure */
|
||||
#define MM_EMIN 0x08 /* add emin structure */
|
||||
#define MM_ANGRY 0x10 /* monster is created angry */
|
||||
#define MM_NONAME 0x20 /* monster is not christened */
|
||||
#define MM_NOCOUNTBIRTH 0x40 /* don't increment born counter (for revival) */
|
||||
#define MM_IGNOREWATER 0x80 /* ignore water when positioning */
|
||||
#define MM_ADJACENTOK 0x100 /* it is acceptable to use adjacent coordinates */
|
||||
#define NO_MM_FLAGS 0x00000 /* use this rather than plain 0 */
|
||||
#define NO_MINVENT 0x00001 /* suppress minvent when creating mon */
|
||||
#define MM_NOWAIT 0x00002 /* don't set STRAT_WAITMASK flags */
|
||||
#define MM_NOCOUNTBIRTH 0x00004 /* don't increment born counter (for revival) */
|
||||
#define MM_IGNOREWATER 0x00008 /* ignore water when positioning */
|
||||
#define MM_ADJACENTOK 0x00010 /* it is acceptable to use adjacent coordinates */
|
||||
#define MM_ANGRY 0x00020 /* monster is created angry */
|
||||
#define MM_NONAME 0x00040 /* monster is not christened */
|
||||
#define MM_EGD 0x00100 /* add egd structure */
|
||||
#define MM_EPRI 0x00200 /* add epri structure */
|
||||
#define MM_ESHK 0x00400 /* add eshk structure */
|
||||
#define MM_EMIN 0x00800 /* add emin structure */
|
||||
#define MM_EDOG 0x01000 /* add edog structure */
|
||||
|
||||
/* flags for make_corpse() and mkcorpstat() */
|
||||
#define CORPSTAT_NONE 0x00
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* Incrementing EDITLEVEL can be used to force invalidation of old bones
|
||||
* and save files.
|
||||
*/
|
||||
#define EDITLEVEL 24
|
||||
#define EDITLEVEL 25
|
||||
|
||||
#define COPYRIGHT_BANNER_A \
|
||||
"NetHack, Copyright 1985-2005"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* SCCS Id: @(#)permonst.h 3.5 1999/07/02 */
|
||||
/* SCCS Id: @(#)permonst.h 3.5 2006/01/04 */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -50,7 +50,6 @@ struct permonst {
|
||||
struct attack mattk[NATTK]; /* attacks matrix */
|
||||
unsigned short cwt, /* weight of corpse */
|
||||
cnutrit; /* its nutritional value */
|
||||
short pxlth; /* length of extension */
|
||||
uchar msound; /* noise it makes (6 bits) */
|
||||
uchar msize; /* physical size (3 bits) */
|
||||
uchar mresists; /* resistances */
|
||||
|
||||
Reference in New Issue
Block a user