OSDN Git Service

fix #37913
[jnethack/source.git] / include / mextra.h
1 /* NetHack 3.6  mextra.h        $NHDT-Date: 1432512781 2015/05/25 00:13:01 $  $NHDT-Branch: master $:$NHDT-Revision: 1.16 $ */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 #ifndef MEXTRA_H
6 #define MEXTRA_H
7
8 #ifndef ALIGN_H
9 #include "align.h"
10 #endif
11
12 /*
13  *  Adding new mextra structures:
14  *
15  *       1. Add the structure definition and any required macros in this file
16  *          above the mextra struct.
17  *       2. Add a pointer to your new struct to the mextra struct in this
18  *file.
19  *       3. Add a referencing macro at the bottom of this file after the
20  *mextra
21  *          struct (see MNAME, EGD, EPRI, ESHK, EMIN, or EDOG for examples).
22  *       4. Create a newXX(mtmp) function and possibly a free_XX(mtmp)
23  *function
24  *          in an appropriate new or existing source file and add a prototype
25  *          for it to include/extern.h.
26  *
27  *              void FDECL(newXX, (struct monst *));
28  *              void FDECL(free_XX, (struct monst *));
29  *
30  *                void
31  *                newXX(mtmp)
32  *                struct monst *mtmp;
33  *                {
34  *                    if (!mtmp->mextra) mtmp->mextra = newmextra();
35  *                    if (!XX(mtmp)) {
36  *                        XX(mtmp) = (struct XX *)alloc(sizeof(struct XX));
37  *                        (void) memset((genericptr_t) XX(mtmp),
38  *                                   0, sizeof(struct XX));
39  *                    }
40  *                }
41  *
42  *       5. Consider adding a new makemon flag MM_XX flag to include/hack.h
43  *and
44  *          a corresponding change to makemon() if you require your structure
45  *          to be added at monster creation time. Initialize your struct
46  *          after a successful return from makemon().
47  *
48  *           src/makemon.c:  if (mmflags & MM_XX) newXX(mtmp);
49  *           your new code:  mon = makemon(&mons[mnum], x, y, MM_XX);
50  *
51  *       6. Adjust size_monst() in src/cmd.c appropriately.
52  *       7. Adjust dealloc_mextra() in src/mon.c to clean up
53  *          properly during monst deallocation.
54  *       8. Adjust copy_mextra() in src/mon.c to make duplicate
55  *          copies of your struct or data on another monst struct.
56  *       9. Adjust restmon() in src/restore.c to deal with your
57  *          struct or data during a restore.
58  *      10. Adjust savemon() in src/save.c to deal with your
59  *          struct or data during a save.
60  */
61
62 /***
63  **     formerly vault.h -- vault guard extension
64  */
65 #define FCSIZ (ROWNO + COLNO)
66 #define GD_EATGOLD 0x01
67 #define GD_DESTROYGOLD 0x02
68
69 struct fakecorridor {
70     xchar fx, fy, ftyp;
71 };
72
73 struct egd {
74     int fcbeg, fcend;     /* fcend: first unused pos */
75     int vroom;            /* room number of the vault */
76     xchar gdx, gdy;       /* goal of guard's walk */
77     xchar ogx, ogy;       /* guard's last position */
78     d_level gdlevel;      /* level (& dungeon) guard was created in */
79     xchar warncnt;        /* number of warnings to follow */
80     Bitfield(gddone, 1);  /* true iff guard has released player */
81     Bitfield(witness, 2); /* the guard saw you do something */
82     Bitfield(unused, 5);
83     struct fakecorridor fakecorr[FCSIZ];
84 };
85
86 /***
87  **     formerly epri.h -- temple priest extension
88  */
89 struct epri {
90     aligntyp shralign; /* alignment of priest's shrine */
91     schar shroom;      /* index in rooms */
92     coord shrpos;      /* position of shrine */
93     d_level shrlevel;  /* level (& dungeon) of shrine */
94     long intone_time,  /* used to limit verbosity  +*/
95         enter_time,    /*+ of temple entry messages */
96         hostile_time,  /* forbidding feeling */
97         peaceful_time; /* sense of peace */
98 };
99 /* note: roaming priests (no shrine) switch from ispriest to isminion
100    (and emin extension) */
101
102 /***
103  **     formerly eshk.h -- shopkeeper extension
104  */
105 #define REPAIR_DELAY 5 /* minimum delay between shop damage & repair */
106 #define BILLSZ 200
107
108 struct bill_x {
109     unsigned bo_id;
110     boolean useup;
111     long price; /* price per unit */
112     long bquan; /* amount used up */
113 };
114
115 struct eshk {
116     long robbed;          /* amount stolen by most recent customer */
117     long credit;          /* amount credited to customer */
118     long debit;           /* amount of debt for using unpaid items */
119     long loan;            /* shop-gold picked (part of debit) */
120     int shoptype;         /* the value of rooms[shoproom].rtype */
121     schar shoproom;       /* index in rooms; set by inshop() */
122     schar unused;         /* to force alignment for stupid compilers */
123     boolean following;    /* following customer since he owes us sth */
124     boolean surcharge;    /* angry shk inflates prices */
125     boolean dismiss_kops; /* pacified shk sends kops away */
126     coord shk;            /* usual position shopkeeper */
127     coord shd;            /* position shop door */
128     d_level shoplevel;    /* level (& dungeon) of his shop */
129     int billct;           /* no. of entries of bill[] in use */
130     struct bill_x bill[BILLSZ];
131     struct bill_x *bill_p;
132     int visitct;            /* nr of visits by most recent customer */
133     char customer[PL_NSIZ]; /* most recent customer */
134     char shknam[PL_NSIZ];
135 };
136
137 /***
138  **     formerly emin.h -- minion extension
139  */
140 struct emin {
141     aligntyp min_align; /* alignment of minion */
142     boolean renegade;   /* hostile co-aligned priest or Angel */
143 };
144
145 /***
146  **     formerly edog.h -- pet extension
147  */
148 /*      various types of pet food, the lower, the better liked */
149 #define DOGFOOD 0
150 #define CADAVER 1
151 #define ACCFOOD 2
152 #define MANFOOD 3
153 #define APPORT 4
154 #define POISON 5
155 #define UNDEF 6
156 #define TABU 7
157
158 struct edog {
159     long droptime;            /* moment dog dropped object */
160     unsigned dropdist;        /* dist of dropped obj from @ */
161     int apport;               /* amount of training */
162     long whistletime;         /* last time he whistled */
163     long hungrytime;          /* will get hungry at this time */
164     coord ogoal;              /* previous goal location */
165     int abuse;                /* track abuses to this pet */
166     int revivals;             /* count pet deaths */
167     int mhpmax_penalty;       /* while starving, points reduced */
168     Bitfield(killed_by_u, 1); /* you attempted to kill him */
169 };
170
171 /***
172  **     mextra.h -- collection of all monster extensions
173  */
174 struct mextra {
175     char *mname;
176     struct egd *egd;
177     struct epri *epri;
178     struct eshk *eshk;
179     struct emin *emin;
180     struct edog *edog;
181     int mcorpsenm; /* obj->corpsenm for mimic posing as statue or corpse */
182 };
183
184 #define MNAME(mon) ((mon)->mextra->mname)
185 #define EGD(mon) ((mon)->mextra->egd)
186 #define EPRI(mon) ((mon)->mextra->epri)
187 #define ESHK(mon) ((mon)->mextra->eshk)
188 #define EMIN(mon) ((mon)->mextra->emin)
189 #define EDOG(mon) ((mon)->mextra->edog)
190 #define MCORPSENM(mon) ((mon)->mextra->mcorpsenm)
191
192 #define has_mname(mon) ((mon)->mextra && MNAME(mon))
193 #define has_mcorpsenm(mon) ((mon)->mextra && MCORPSENM(mon) != NON_PM)
194
195 #endif /* MEXTRA_H */