Change MON(name, ...) to MON(NAM(name), ...) and get rid of MON3(), replacing it with MON(NAMS(malename,femalename,neutername), ...). That eliminates the macro which uses 16 parameters. Standard C allows compilers to impose a limit of 15, rejecting 16 or more while still being in compliance. That necessitated some reformatting since it made the first line of each entry longer. Shorten that by having all entries start with name(s) and symbol on the first line, then LVL() and generation flags on the second line, then attacks start on the third. Reformat attacks to change ATTK(one) + 4 * NO_ATTK on one line plus an orphaned NO_ATTK on the next line to always use ATTK(one) on first line and all 5 NO_ATTKs on the next line. Similarly, change ATTK(1of2) ATTK(2of2) NO_ATTK on one line followed by 3 * NO_ATTK on the next line into ATTK(1of2) ATTK(2of2) followed by 4 NO_ATTKS. For three attacks, list two on the first line then the third and 3 * NO_ATTK on the next. Four or more attacks use a third line; ATTK(1of4+) ATTK(2of4+) on the first, ATTK(3of4+) ATTK(4of4+) on the second, and whatever's left on the third. SIZ() follows on its own line for each of the cases. Split the final line of each entry so that the difficulty value is the first thing on that line, followed by color and enum tag. This may or may not make moving the difficulty into LVL() easier someday (which would have been an alternate way to reduce the 16 args that MON3 had). The file gets stretched out by many lines but entries should be easier to read (matter of taste, I suppose). I didn't attempt to clean up M1_foo, M2_bar, M3_quux; too hard.... I also didn't touch SIZ() or resistances which are less cluttered than the other stuff.
86 lines
2.8 KiB
C
86 lines
2.8 KiB
C
/* NetHack 3.7 monst.c $NHDT-Date: 1705092160 2024/01/12 20:42:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.100 $ */
|
|
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
|
/*-Copyright (c) Michael Allison, 2006. */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
#include "config.h"
|
|
#include "permonst.h"
|
|
#include "wintype.h"
|
|
#include "sym.h"
|
|
|
|
#include "color.h"
|
|
|
|
#define NO_ATTK { 0, 0, 0, 0 }
|
|
|
|
/* monster type with single name */
|
|
#define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \
|
|
flg1, flg2, flg3, d, col, bn) \
|
|
{ \
|
|
nam, PM_##bn, \
|
|
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
|
}
|
|
|
|
/* LVL() and SIZ() collect several fields to cut down on number of args
|
|
* for MON(). Using more than 15 would fail to conform to the C Standard.
|
|
* ATTK() and A() are to avoid braces and commas within args to MON().
|
|
* NAM() and NAMS() are used for both reasons.
|
|
*/
|
|
#define NAM(name) { (const char *) 0, (const char *) 0, name }
|
|
#define NAMS(namm, namf, namn) { namm, namf, namn }
|
|
#define LVL(lvl, mov, ac, mr, aln) lvl, mov, ac, mr, aln
|
|
#define SIZ(wt, nut, snd, siz) wt, nut, snd, siz
|
|
#define ATTK(at, ad, n, d) { at, ad, n, d }
|
|
#define A(a1, a2, a3, a4, a5, a6) { a1, a2, a3, a4, a5, a6 }
|
|
|
|
struct permonst mons_init[NUMMONS + 1] = {
|
|
#include "monsters.h"
|
|
/*
|
|
* Array terminator, added to the end of the entries in monsters.h.
|
|
*
|
|
* mons[NUMMONS] used to be all zero except "" instead of Null for
|
|
* the name field. Then the index field was added and the terminator
|
|
* uses NON_PM for that. Now, a few monster flags also get set.
|
|
*/
|
|
#undef MON
|
|
#define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \
|
|
flg1, flg2, flg3, d, col, bn) \
|
|
{ \
|
|
nam, NON_PM, \
|
|
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
|
}
|
|
MON(NAM(""), 0,
|
|
LVL(0, 0, 0, 0, 0), G_NOGEN | G_NOCORPSE,
|
|
A(NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK, NO_ATTK),
|
|
SIZ(0, 0, 0, 0), 0, 0,
|
|
0L, M2_NOPOLY, 0,
|
|
0, 0, 0),
|
|
};
|
|
|
|
#undef MON
|
|
#undef NAM
|
|
#undef NAMS
|
|
|
|
void monst_globals_init(void); /* in hack.h but we're using config.h */
|
|
|
|
struct permonst mons[SIZE(mons_init)];
|
|
|
|
void
|
|
monst_globals_init(void)
|
|
{
|
|
memcpy(mons, mons_init, sizeof mons);
|
|
return;
|
|
}
|
|
|
|
const struct attack c_sa_yes[NATTK] = SEDUCTION_ATTACKS_YES;
|
|
const struct attack c_sa_no[NATTK] = SEDUCTION_ATTACKS_NO;
|
|
|
|
/* for 'onefile' processing where end of this file isn't necessarily the
|
|
end of the source code seen by the compiler */
|
|
#undef NO_ATTK
|
|
#undef LVL
|
|
#undef SIZ
|
|
#undef ATTK
|
|
#undef A
|
|
|
|
/*monst.c*/
|