split g into multiple structures
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
^ ^
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
#define HSick_resistance u.uprops[SICK_RES].intrinsic
|
||||
#define ESick_resistance u.uprops[SICK_RES].extrinsic
|
||||
#define Sick_resistance (HSick_resistance || ESick_resistance \
|
||||
|| defended(&g.youmonst, AD_DISE))
|
||||
|| defended(&gy.youmonst, AD_DISE))
|
||||
|
||||
/* Intrinsics only */
|
||||
#define Invulnerable u.uprops[INVULNERABLE].intrinsic /* [Tom] */
|
||||
@@ -88,13 +88,13 @@
|
||||
/* ...means blind because of a cover */
|
||||
#define Blind \
|
||||
((u.uroleplay.blind || Blinded || Blindfolded \
|
||||
|| !haseyes(g.youmonst.data)) \
|
||||
|| !haseyes(gy.youmonst.data)) \
|
||||
&& !(ublindf && ublindf->oartifact == ART_EYES_OF_THE_OVERWORLD))
|
||||
/* ...the Eyes operate even when you really are blind
|
||||
or don't have any eyes */
|
||||
#define Blindfolded_only \
|
||||
(Blindfolded && ublindf->oartifact != ART_EYES_OF_THE_OVERWORLD \
|
||||
&& !u.uroleplay.blind && !Blinded && haseyes(g.youmonst.data))
|
||||
&& !u.uroleplay.blind && !Blinded && haseyes(gy.youmonst.data))
|
||||
/* ...blind because of a blindfold, and *only* that */
|
||||
|
||||
#define Sick u.uprops[SICK].intrinsic
|
||||
@@ -255,11 +255,11 @@
|
||||
#define HMagical_breathing u.uprops[MAGICAL_BREATHING].intrinsic
|
||||
#define EMagical_breathing u.uprops[MAGICAL_BREATHING].extrinsic
|
||||
#define Amphibious \
|
||||
(HMagical_breathing || EMagical_breathing || amphibious(g.youmonst.data))
|
||||
(HMagical_breathing || EMagical_breathing || amphibious(gy.youmonst.data))
|
||||
/* Get wet, may go under surface */
|
||||
|
||||
#define Breathless \
|
||||
(HMagical_breathing || EMagical_breathing || breathless(g.youmonst.data))
|
||||
(HMagical_breathing || EMagical_breathing || breathless(gy.youmonst.data))
|
||||
|
||||
#define Underwater (u.uinwater)
|
||||
/* Note that Underwater and u.uinwater are both used in code.
|
||||
@@ -377,9 +377,9 @@
|
||||
|
||||
/* unconscious() includes u.usleep but not is_fainted(); the multi test is
|
||||
redundant but allows the function calls to be skipped most of the time */
|
||||
#define Unaware (g.multi < 0 && (unconscious() || is_fainted()))
|
||||
#define Unaware (gm.multi < 0 && (unconscious() || is_fainted()))
|
||||
|
||||
#define Hate_silver (u.ulycn >= LOW_PM || hates_silver(g.youmonst.data))
|
||||
#define Hate_silver (u.ulycn >= LOW_PM || hates_silver(gy.youmonst.data))
|
||||
|
||||
/* _Hitchhikers_Guide_to_the_Galaxy_ on uses for 'towel': "wrap it round
|
||||
your head to ward off noxious fumes" [we require it to be damp or wet] */
|
||||
|
||||
Reference in New Issue
Block a user