The consolidation of global variables from scattered source
files into decl.c and declared in decl.h was begun in 3.7.0.
Their placement in common files was done for centralized
initialization and potential re-initialization during a
"play again" scenario.
It wasn't really necessary for all of them to be housed in a
single huge structure to meet the "play again" requirement,
and the single huge structure has been a little unwieldy when
it comes to maintenance.
Following this commit, instead of one single extremely large structure
named 'g' to house all of the relocated global variables, they
are distributed into several ga through gz.
To make things easy for the developer, each variable is placed
into the struct corresponding to the starting letter of the variable.
That way, no lookup is required in order to know which struct houses
a particular variable, it is a simple match to the starting letter
for all the centralized global variables.
A global variable named 'amulets', would be found in ga.
ga.amulets
^ ^
A global varable named 'move', would be found in gm.
gm.moves
^ ^
A global variable named 'val_for_n_or_more' would be found in gv.
gv.val_for_n_or_more
^ ^
A global variable named 'youmonst' would be found in gy.
gy.youmonst
^ ^
48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
/* NetHack 3.7 attrib.h $NHDT-Date: 1596498527 2020/08/03 23:48:47 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.12 $ */
|
|
/* Copyright 1988, Mike Stephenson */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
/* attrib.h - Header file for character class processing. */
|
|
|
|
#ifndef ATTRIB_H
|
|
#define ATTRIB_H
|
|
|
|
enum attrib_types {
|
|
A_STR = 0,
|
|
A_INT,
|
|
A_WIS,
|
|
A_DEX,
|
|
A_CON,
|
|
A_CHA,
|
|
|
|
A_MAX /* used in rn2() selection of attrib */
|
|
};
|
|
|
|
#define ABASE(x) (u.acurr.a[x])
|
|
#define ABON(x) (u.abon.a[x])
|
|
#define AEXE(x) (u.aexe.a[x])
|
|
#define ACURR(x) (acurr(x))
|
|
#define ACURRSTR (acurrstr())
|
|
/* should be: */
|
|
/* #define ACURR(x) (ABON(x) + ATEMP(x) + (Upolyd ? MBASE(x) : ABASE(x)) */
|
|
#define MCURR(x) (u.macurr.a[x])
|
|
#define AMAX(x) (u.amax.a[x])
|
|
#define MMAX(x) (u.mamax.a[x])
|
|
|
|
#define ATEMP(x) (u.atemp.a[x])
|
|
#define ATIME(x) (u.atime.a[x])
|
|
|
|
/* KMH -- Conveniences when dealing with strength constants */
|
|
#define STR18(x) (18 + (x)) /* 18/xx */
|
|
#define STR19(x) (100 + (x)) /* For 19 and above */
|
|
|
|
struct attribs {
|
|
schar a[A_MAX];
|
|
};
|
|
|
|
#define ATTRMAX(x) \
|
|
((x == A_STR && Upolyd) ? uasmon_maxStr() : gu.urace.attrmax[x])
|
|
#define ATTRMIN(x) (gu.urace.attrmin[x])
|
|
|
|
#endif /* ATTRIB_H */
|