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:
@@ -39,10 +39,10 @@ struct shclass {
|
||||
const char *const *shknms; /* list of shopkeeper names for this type */
|
||||
};
|
||||
|
||||
/* the normal rooms on the current level are described in g.rooms[0..n] for
|
||||
/* the normal rooms on the current level are described in gr.rooms[0..n] for
|
||||
* some n<MAXNROFROOMS
|
||||
* the vault, if any, is described by g.rooms[n+1]
|
||||
* the next g.rooms entry has hx -1 as a flag
|
||||
* the vault, if any, is described by gr.rooms[n+1]
|
||||
* the next gr.rooms entry has hx -1 as a flag
|
||||
* there is at most one non-vault special room on a level
|
||||
*/
|
||||
|
||||
@@ -87,7 +87,7 @@ enum roomtype_types {
|
||||
#define SHARED 1 /* indicates normal shared boundary */
|
||||
#define SHARED_PLUS 2 /* indicates shared boundary - extra adjacent-square
|
||||
* searching required */
|
||||
#define ROOMOFFSET 3 /* (levl[x][y].roomno - ROOMOFFSET) gives g.rooms[] index,
|
||||
#define ROOMOFFSET 3 /* (levl[x][y].roomno - ROOMOFFSET) gives gr.rooms[] index,
|
||||
* for inside-squares and non-shared boundaries */
|
||||
|
||||
/* Values for needfill */
|
||||
@@ -98,14 +98,14 @@ enum roomtype_types {
|
||||
#define FILL_LVFLAGS 2 /* special rooms only; set the room's rtype and level
|
||||
flags as appropriate, but do not put anything in it */
|
||||
|
||||
#define IS_ROOM_PTR(x) ((x) >= g.rooms && (x) < g.rooms + MAXNROFROOMS)
|
||||
#define IS_ROOM_PTR(x) ((x) >= gr.rooms && (x) < gr.rooms + MAXNROFROOMS)
|
||||
#define IS_ROOM_INDEX(x) ((x) >= 0 && (x) < MAXNROFROOMS)
|
||||
#define IS_SUBROOM_PTR(x) \
|
||||
((x) >= g.subrooms && (x) < g.subrooms + MAXNROFROOMS)
|
||||
((x) >= gs.subrooms && (x) < gs.subrooms + MAXNROFROOMS)
|
||||
#define IS_SUBROOM_INDEX(x) ((x) > MAXNROFROOMS && (x) <= (MAXNROFROOMS * 2))
|
||||
#define ROOM_INDEX(x) ((x) - g.rooms)
|
||||
#define SUBROOM_INDEX(x) ((x) - g.subrooms)
|
||||
#define IS_LAST_ROOM_PTR(x) (ROOM_INDEX(x) == g.nroom)
|
||||
#define IS_LAST_SUBROOM_PTR(x) (!g.nsubroom || SUBROOM_INDEX(x) == g.nsubroom)
|
||||
#define ROOM_INDEX(x) ((x) - gr.rooms)
|
||||
#define SUBROOM_INDEX(x) ((x) - gs.subrooms)
|
||||
#define IS_LAST_ROOM_PTR(x) (ROOM_INDEX(x) == gn.nroom)
|
||||
#define IS_LAST_SUBROOM_PTR(x) (!gn.nsubroom || SUBROOM_INDEX(x) == gn.nsubroom)
|
||||
|
||||
#endif /* MKROOM_H */
|
||||
|
||||
Reference in New Issue
Block a user