From: Jason S. Ninneman Date: Sun, 2 Jul 2017 17:36:51 +0000 (-0700) Subject: Eliminate the global game.blklin. X-Git-Tag: takebird~100 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=6af38a92f60179af2b4eed23e508160a347da432;p=open-adventure.git Eliminate the global game.blklin. --- diff --git a/actions.c b/actions.c index dd6d64b..0a5b8ed 100644 --- a/actions.c +++ b/actions.c @@ -8,7 +8,7 @@ static int fill(token_t, token_t); static void state_change(long obj, long state) { game.prop[obj] = state; - pspeak(obj, change, state); + pspeak(obj, change, state, true); } static int attack(struct command_t *command) @@ -200,7 +200,7 @@ static int bigwords(token_t foo) if (game.loc == objects[EGGS].plac) k = EGGS_HERE; move(EGGS, objects[EGGS].plac); - pspeak(EGGS, look, k); + pspeak(EGGS, look, k, true); return GO_CLEAROBJ; } } @@ -453,7 +453,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) } else if (obj == COINS && HERE(VEND)) { DESTROY(COINS); drop(BATTERY, game.loc); - pspeak(BATTERY, look, FRESH_BATTERIES); + pspeak(BATTERY, look, FRESH_BATTERIES, true); return GO_CLEAROBJ; } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) { rspeak(BIRD_BURNT); @@ -473,7 +473,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) game.prop[VASE] = VASE_BROKEN; if (AT(PILLOW)) game.prop[VASE] = VASE_WHOLE; - pspeak(VASE, look, game.prop[VASE] + 1); + pspeak(VASE, look, game.prop[VASE] + 1, true); if (game.prop[VASE] != VASE_WHOLE) game.fixed[VASE] = -1; } @@ -560,7 +560,7 @@ static int extinguish(token_t verb, int obj) if (game.prop[URN] != URN_EMPTY) { state_change(URN, URN_DARK); } else { - pspeak(URN, change, URN_DARK); + pspeak(URN, change, URN_DARK, true); } } else if (obj == LAMP) { @@ -744,9 +744,7 @@ static int inven(void) continue; if (spk == NO_CARRY) rspeak(NOW_HOLDING); - game.blklin = false; - pspeak(i, touch, -1); - game.blklin = true; + pspeak(i, touch, -1, false); spk = NO_MESSAGE; } if (TOTING(BEAR)) @@ -809,7 +807,7 @@ static int listen(void) if (i == BIRD) mi += 3 * game.blooded; long packed_zzword = token_to_packed(game.zzword); - pspeak(i, hear, mi, packed_zzword); + pspeak(i, hear, mi, true, packed_zzword); spk = NO_MESSAGE; /* FIXME: Magic number, sensitive to bird state logic */ if (i == BIRD && game.prop[i] == 5) @@ -906,7 +904,7 @@ static int pour(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - pspeak(PLANT, look, game.prop[PLANT] + 3); + pspeak(PLANT, look, game.prop[PLANT] + 3, true); game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3); game.prop[PLANT2] = game.prop[PLANT]; return GO_MOVE; @@ -944,7 +942,7 @@ static int read(struct command_t command) } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) { rspeak(actions[command.verb].message); } else - pspeak(command.obj, study, game.prop[command.obj]); + pspeak(command.obj, study, game.prop[command.obj], true); return GO_CLEAROBJ; } @@ -955,7 +953,7 @@ static int reservoir(void) rspeak(NOTHING_HAPPENS); return GO_CLEAROBJ; } else { - pspeak(RESER, look, game.prop[RESER] + 1); + pspeak(RESER, look, game.prop[RESER] + 1, true); game.prop[RESER] = 1 - game.prop[RESER]; if (AT(RESER)) return GO_CLEAROBJ; @@ -1127,7 +1125,7 @@ static int wave(token_t verb, token_t obj) if (HERE(BIRD)) rspeak(spk); game.prop[FISSURE] = 1 - game.prop[FISSURE]; - pspeak(FISSURE, look, 2 - game.prop[FISSURE]); + pspeak(FISSURE, look, 2 - game.prop[FISSURE], true); return GO_CLEAROBJ; } } diff --git a/advent.h b/advent.h index b9b2e0c..c0c6265 100644 --- a/advent.h +++ b/advent.h @@ -106,7 +106,6 @@ typedef long vocab_t; // index into a vocabulary array */ struct game_t { unsigned long lcg_a, lcg_c, lcg_m, lcg_x; long abbnum; // How often to print non-abbreviated descriptions - long blklin; long bonus; long chloc; long chloc2; @@ -190,12 +189,12 @@ extern void* xmalloc(size_t size); extern void packed_to_token(long, char token[]); extern long token_to_packed(const char token[6]); extern void tokenize(char*, long tokens[4]); -extern void vspeak(const char*, va_list); +extern void vspeak(const char*, bool, va_list); extern bool wordeq(token_t, token_t); extern bool wordempty(token_t); extern void wordclear(token_t *); extern void speak(const char*, ...); -extern void pspeak(vocab_t, enum speaktype, int, ...); +extern void pspeak(vocab_t, enum speaktype, int, bool, ...); extern void rspeak(vocab_t, ...); extern void echo_input(FILE*, const char*, const char*); extern int word_count(char*); diff --git a/init.c b/init.c index 87a5161..12f68b6 100644 --- a/init.c +++ b/init.c @@ -33,7 +33,6 @@ struct game_t game = { .abbnum = 5, .clock1 = WARNTIME, .clock2 = FLASHTIME, - .blklin = true, .newloc = LOC_START, .loc = LOC_START, .limit = GAMELIMIT, diff --git a/main.c b/main.c index 7eb21da..2a1f436 100644 --- a/main.c +++ b/main.c @@ -689,7 +689,7 @@ static bool playermove( int motion) * entries check for game.prop(TROLL)=0.) Special * stuff for bear. */ if (game.prop[TROLL] == TROLL_PAIDONCE) { - pspeak(TROLL, look, TROLL_PAIDONCE); + pspeak(TROLL, look, TROLL_PAIDONCE, true); game.prop[TROLL] = TROLL_UNPAID; move(TROLL2, 0); move(TROLL2 + NOBJECTS, 0); @@ -917,7 +917,7 @@ static void listobjects(void) int kk = game.prop[obj]; if (obj == STEPS && game.loc == game.fixed[STEPS]) kk = 1; - pspeak(obj, look, kk); + pspeak(obj, look, kk, true); } } } @@ -1006,7 +1006,7 @@ L2600: * tick game.clock1 unless well into cave (and not at Y2). */ if (game.closed) { if (game.prop[OYSTER] < 0 && TOTING(OYSTER)) - pspeak(OYSTER, look, 1); + pspeak(OYSTER, look, 1, true); for (size_t i = 1; i <= NOBJECTS; i++) { if (TOTING(i) && game.prop[i] < 0) game.prop[i] = -1 - game.prop[i]; diff --git a/misc.c b/misc.c index d601c0d..dc6cec5 100644 --- a/misc.c +++ b/misc.c @@ -155,7 +155,7 @@ void wordclear(token_t *v) /* I/O routines (speak, pspeak, rspeak, get_input, yes) */ -void vspeak(const char* msg, va_list ap) +void vspeak(const char* msg, bool blank, va_list ap) { // Do nothing if we got a null pointer. if (msg == NULL) @@ -165,9 +165,8 @@ void vspeak(const char* msg, va_list ap) if (strlen(msg) == 0) return; - // Print a newline if the global game.blklin says to. - if (game.blklin == true) - printf("\n"); + if (blank == true) + printf("\n"); int msglen = strlen(msg); @@ -253,11 +252,11 @@ void speak(const char* msg, ...) { va_list ap; va_start(ap, msg); - vspeak(msg, ap); + vspeak(msg, true, ap); va_end(ap); } -void pspeak(vocab_t msg, enum speaktype mode, int skip, ...) +void pspeak(vocab_t msg, enum speaktype mode, int skip, bool blank, ...) /* Find the skip+1st message from msg and print it. Modes are: * feel = for inventory, what you can touch * look = the long description for the state the object is in @@ -265,22 +264,22 @@ void pspeak(vocab_t msg, enum speaktype mode, int skip, ...) * study = text on the object. */ { va_list ap; - va_start(ap, skip); + va_start(ap, blank); switch (mode) { case touch: - vspeak(objects[msg].inventory, ap); + vspeak(objects[msg].inventory, blank, ap); break; case look: - vspeak(objects[msg].descriptions[skip], ap); + vspeak(objects[msg].descriptions[skip], blank, ap); break; case hear: - vspeak(objects[msg].sounds[skip], ap); + vspeak(objects[msg].sounds[skip], blank, ap); break; case study: - vspeak(objects[msg].texts[skip], ap); + vspeak(objects[msg].texts[skip], blank, ap); break; case change: - vspeak(objects[msg].changes[skip], ap); + vspeak(objects[msg].changes[skip], blank, ap); break; } va_end(ap); @@ -291,7 +290,7 @@ void rspeak(vocab_t i, ...) { va_list ap; va_start(ap, i); - vspeak(arbitrary_messages[i], ap); + vspeak(arbitrary_messages[i], true, ap); va_end(ap); } @@ -328,9 +327,8 @@ char* get_input() if (!settings.prompt) input_prompt[0] = '\0'; - // Print a blank line if game.blklin tells us to. - if (game.blklin == true) - printf("\n"); + // Print a blank line + printf("\n"); char* input; while (true) {