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
^ ^
39 lines
1.2 KiB
C
39 lines
1.2 KiB
C
/* NetHack 3.7 spell.h $NHDT-Date: 1646838388 2022/03/09 15:06:28 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.14 $ */
|
|
/* Copyright 1986, M. Stephenson */
|
|
/* NetHack may be freely redistributed. See license for details. */
|
|
|
|
#ifndef SPELL_H
|
|
#define SPELL_H
|
|
|
|
#define NO_SPELL 0
|
|
#define UNKNOWN_SPELL (-1)
|
|
|
|
/* spellbook re-use control; used when reading and when polymorphing */
|
|
#define MAX_SPELL_STUDY 3
|
|
|
|
struct spell {
|
|
short sp_id; /* spell id (== object.otyp) */
|
|
xint16 sp_lev; /* power level */
|
|
int sp_know; /* knowledge of spell */
|
|
};
|
|
|
|
enum spellknowledge {
|
|
spe_Forgotten = -1, /* known but no longer castable */
|
|
spe_Unknown = 0, /* not yet known */
|
|
spe_Fresh = 1, /* castable if various casting criteria are met */
|
|
spe_GoingStale = 2 /* still castable but nearly forgotten */
|
|
};
|
|
|
|
/* levels of memory destruction with a scroll of amnesia */
|
|
#define ALL_MAP 0x1
|
|
#define ALL_SPELLS 0x2
|
|
|
|
#define decrnknow(spell) gs.spl_book[spell].sp_know--
|
|
#define spellid(spell) gs.spl_book[spell].sp_id
|
|
#define spellknow(spell) gs.spl_book[spell].sp_know
|
|
|
|
/* how much Pw a spell of level lvl costs to cast? */
|
|
#define SPELL_LEV_PW(lvl) ((lvl) * 5)
|
|
|
|
#endif /* SPELL_H */
|