Express word type with an enum instead of magic numbers.
* Make a cleaner function for getting vocab metadata. * Get rid of magic numbers. * Purge get_vocab_id(). * Abolish the *_WORD() macros. * Add FIXME comment on some ugliness.
This commit is contained in:
parent
b5badcacc8
commit
50efa22849
4 changed files with 89 additions and 68 deletions
13
advent.h
13
advent.h
|
@ -69,13 +69,6 @@
|
|||
#define INDEEP(LOC) ((LOC) >= LOC_MISTHALL && !OUTSID(LOC))
|
||||
#define BUG(x) bug(x, #x)
|
||||
|
||||
#define MOTION_WORD(n) ((n) + 0)
|
||||
#define OBJECT_WORD(n) ((n) + 1000)
|
||||
#define ACTION_WORD(n) ((n) + 2000)
|
||||
#define SPECIAL_WORD(n) ((n) + 3000)
|
||||
#define PROMOTE_WORD(n) ((n) + 1000)
|
||||
#define DEMOTE_WORD(n) ((n) - 1000)
|
||||
|
||||
enum bugtype {
|
||||
SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST,
|
||||
VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3,
|
||||
|
@ -94,6 +87,8 @@ enum termination {endgame, quitgame, scoregame};
|
|||
|
||||
enum speechpart {unknown, intransitive, transitive};
|
||||
|
||||
enum wordtype {NO_WORD_TYPE, MOTION, OBJECT, ACTION, SPECIAL};
|
||||
|
||||
/* Phase codes for action returns.
|
||||
* These were at one time FORTRAN line numbers.
|
||||
* The values don't matter, but perturb their order at your peril.
|
||||
|
@ -200,6 +195,8 @@ struct command_t {
|
|||
long id1;
|
||||
long id2;
|
||||
char raw1[LINESIZE], raw2[LINESIZE];
|
||||
enum wordtype type1;
|
||||
enum wordtype type2;
|
||||
};
|
||||
|
||||
extern struct game_t game;
|
||||
|
@ -225,7 +222,7 @@ extern int get_motion_vocab_id(const char*);
|
|||
extern int get_object_vocab_id(const char*);
|
||||
extern int get_action_vocab_id(const char*);
|
||||
extern int get_special_vocab_id(const char*);
|
||||
extern long get_vocab_id(const char*);
|
||||
extern void get_vocab_metadata(const char*, long*, enum wordtype*);
|
||||
extern void juggle(obj_t);
|
||||
extern void move(obj_t, loc_t);
|
||||
extern long put(obj_t, long, long);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue