Mostly confine assumptions about what token_t is to misc.c
The token_t things like WD* are presently longs and will someday be char[6]. By introducing some trivial functions - wordeq(), wordempty(), and wordclear() - we mostly hide the difference. All runtime knowledge about packing now lives only in misc.c and the list of magic WORD_* defines in advent.h. Outside this, literals are now accessed through #define names that could expand to either longs or strings. Still to be done: WD* values are sometiimes compated to zero in ways implying they can be negative. Must figure out wat thus means.
This commit is contained in:
parent
87961483a2
commit
a678b68b39
5 changed files with 28 additions and 6 deletions
9
main.c
9
main.c
|
@ -1057,8 +1057,9 @@ L2607:
|
|||
if (V1 == ENTER && WD2 > 0) {
|
||||
WD1 = WD2;
|
||||
WD1X = WD2X;
|
||||
WD2 = 0;
|
||||
wordclear(&WD2);
|
||||
} else {
|
||||
/* FIXME: Magic numbers */
|
||||
if (!((V1 != 1000 + WATER && V1 != 1000 + OIL) ||
|
||||
(V2 != 1000 + PLANT && V2 != 1000 + DOOR))) {
|
||||
if (AT(V2 - 1000))
|
||||
|
@ -1068,12 +1069,12 @@ L2607:
|
|||
WD1 = MAKEWD(WORD_CATCH);
|
||||
}
|
||||
L2620:
|
||||
if (WD1 == MAKEWD(WORD_WEST)) {
|
||||
if (wordeq(WD1, MAKEWD(WORD_WEST))) {
|
||||
++game.iwest;
|
||||
if (game.iwest == 10)
|
||||
RSPEAK(W_IS_WEST);
|
||||
}
|
||||
if (WD1 == MAKEWD(WORD_GO) && WD2 != 0) {
|
||||
if (wordeq(WD1, MAKEWD(WORD_GO)) && !wordempty(WD2)) {
|
||||
if (++igo == 10)
|
||||
RSPEAK(GO_UNNEEDED);
|
||||
}
|
||||
|
@ -1130,7 +1131,7 @@ Laction:
|
|||
/* Get second word for analysis. */
|
||||
WD1 = WD2;
|
||||
WD1X = WD2X;
|
||||
WD2 = 0;
|
||||
wordclear(&WD2);
|
||||
goto L2620;
|
||||
case GO_UNKNOWN:
|
||||
/* Random intransitive verbs come here. Clear obj just in case
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue