redo monsters.h
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.
This commit is contained in:
3347
include/monsters.h
3347
include/monsters.h
File diff suppressed because it is too large
Load Diff
37
src/monst.c
37
src/monst.c
@@ -15,27 +15,20 @@
|
||||
/* monster type with single name */
|
||||
#define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \
|
||||
flg1, flg2, flg3, d, col, bn) \
|
||||
{ \
|
||||
{ (const char *) 0, (const char *) 0, nam }, \
|
||||
PM_##bn, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
||||
}
|
||||
|
||||
/* monster type with distinct male, female, neuter names */
|
||||
#define MON3(namm, namf, namn, sym, lvl, gen, atk, siz, mr1, mr2, \
|
||||
flg1, flg2, flg3, d, col, bn) \
|
||||
{ \
|
||||
{ namm, namf, namn }, \
|
||||
PM_##bn, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
||||
{ \
|
||||
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()/MON3().
|
||||
* 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
|
||||
/* ATTK() and A() are to avoid braces and commas within args to MON() */
|
||||
#define ATTK(at, ad, n, d) { at, ad, n, d }
|
||||
#define A(a1, a2, a3, a4, a5, a6) { a1, a2, a3, a4, a5, a6 }
|
||||
|
||||
@@ -51,13 +44,12 @@ struct permonst mons_init[NUMMONS + 1] = {
|
||||
#undef MON
|
||||
#define MON(nam, sym, lvl, gen, atk, siz, mr1, mr2, \
|
||||
flg1, flg2, flg3, d, col, bn) \
|
||||
{ \
|
||||
{ (const char *) 0, (const char *) 0, nam }, \
|
||||
NON_PM, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
||||
{ \
|
||||
nam, NON_PM, \
|
||||
sym, lvl, gen, atk, siz, mr1, mr2, flg1, flg2, flg3, d, col \
|
||||
}
|
||||
MON("", 0, LVL(0, 0, 0, 0, 0),
|
||||
G_NOGEN | G_NOCORPSE,
|
||||
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,
|
||||
@@ -65,7 +57,8 @@ struct permonst mons_init[NUMMONS + 1] = {
|
||||
};
|
||||
|
||||
#undef MON
|
||||
#undef MON3
|
||||
#undef NAM
|
||||
#undef NAMS
|
||||
|
||||
void monst_globals_init(void); /* in hack.h but we're using config.h */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user