Eliminate the global game.blklin.
This commit is contained in:
parent
8456b866ff
commit
6af38a92f6
5 changed files with 30 additions and 36 deletions
24
actions.c
24
actions.c
|
@ -8,7 +8,7 @@ static int fill(token_t, token_t);
|
||||||
static void state_change(long obj, long state)
|
static void state_change(long obj, long state)
|
||||||
{
|
{
|
||||||
game.prop[obj] = state;
|
game.prop[obj] = state;
|
||||||
pspeak(obj, change, state);
|
pspeak(obj, change, state, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int attack(struct command_t *command)
|
static int attack(struct command_t *command)
|
||||||
|
@ -200,7 +200,7 @@ static int bigwords(token_t foo)
|
||||||
if (game.loc == objects[EGGS].plac)
|
if (game.loc == objects[EGGS].plac)
|
||||||
k = EGGS_HERE;
|
k = EGGS_HERE;
|
||||||
move(EGGS, objects[EGGS].plac);
|
move(EGGS, objects[EGGS].plac);
|
||||||
pspeak(EGGS, look, k);
|
pspeak(EGGS, look, k, true);
|
||||||
return GO_CLEAROBJ;
|
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)) {
|
} else if (obj == COINS && HERE(VEND)) {
|
||||||
DESTROY(COINS);
|
DESTROY(COINS);
|
||||||
drop(BATTERY, game.loc);
|
drop(BATTERY, game.loc);
|
||||||
pspeak(BATTERY, look, FRESH_BATTERIES);
|
pspeak(BATTERY, look, FRESH_BATTERIES, true);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
} else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
|
} else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) {
|
||||||
rspeak(BIRD_BURNT);
|
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;
|
game.prop[VASE] = VASE_BROKEN;
|
||||||
if (AT(PILLOW))
|
if (AT(PILLOW))
|
||||||
game.prop[VASE] = VASE_WHOLE;
|
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)
|
if (game.prop[VASE] != VASE_WHOLE)
|
||||||
game.fixed[VASE] = -1;
|
game.fixed[VASE] = -1;
|
||||||
}
|
}
|
||||||
|
@ -560,7 +560,7 @@ static int extinguish(token_t verb, int obj)
|
||||||
if (game.prop[URN] != URN_EMPTY) {
|
if (game.prop[URN] != URN_EMPTY) {
|
||||||
state_change(URN, URN_DARK);
|
state_change(URN, URN_DARK);
|
||||||
} else {
|
} else {
|
||||||
pspeak(URN, change, URN_DARK);
|
pspeak(URN, change, URN_DARK, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (obj == LAMP) {
|
} else if (obj == LAMP) {
|
||||||
|
@ -744,9 +744,7 @@ static int inven(void)
|
||||||
continue;
|
continue;
|
||||||
if (spk == NO_CARRY)
|
if (spk == NO_CARRY)
|
||||||
rspeak(NOW_HOLDING);
|
rspeak(NOW_HOLDING);
|
||||||
game.blklin = false;
|
pspeak(i, touch, -1, false);
|
||||||
pspeak(i, touch, -1);
|
|
||||||
game.blklin = true;
|
|
||||||
spk = NO_MESSAGE;
|
spk = NO_MESSAGE;
|
||||||
}
|
}
|
||||||
if (TOTING(BEAR))
|
if (TOTING(BEAR))
|
||||||
|
@ -809,7 +807,7 @@ static int listen(void)
|
||||||
if (i == BIRD)
|
if (i == BIRD)
|
||||||
mi += 3 * game.blooded;
|
mi += 3 * game.blooded;
|
||||||
long packed_zzword = token_to_packed(game.zzword);
|
long packed_zzword = token_to_packed(game.zzword);
|
||||||
pspeak(i, hear, mi, packed_zzword);
|
pspeak(i, hear, mi, true, packed_zzword);
|
||||||
spk = NO_MESSAGE;
|
spk = NO_MESSAGE;
|
||||||
/* FIXME: Magic number, sensitive to bird state logic */
|
/* FIXME: Magic number, sensitive to bird state logic */
|
||||||
if (i == BIRD && game.prop[i] == 5)
|
if (i == BIRD && game.prop[i] == 5)
|
||||||
|
@ -906,7 +904,7 @@ static int pour(token_t verb, token_t obj)
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
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[PLANT] = MOD(game.prop[PLANT] + 1, 3);
|
||||||
game.prop[PLANT2] = game.prop[PLANT];
|
game.prop[PLANT2] = game.prop[PLANT];
|
||||||
return GO_MOVE;
|
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) {
|
} else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
|
||||||
rspeak(actions[command.verb].message);
|
rspeak(actions[command.verb].message);
|
||||||
} else
|
} else
|
||||||
pspeak(command.obj, study, game.prop[command.obj]);
|
pspeak(command.obj, study, game.prop[command.obj], true);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -955,7 +953,7 @@ static int reservoir(void)
|
||||||
rspeak(NOTHING_HAPPENS);
|
rspeak(NOTHING_HAPPENS);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
} else {
|
} else {
|
||||||
pspeak(RESER, look, game.prop[RESER] + 1);
|
pspeak(RESER, look, game.prop[RESER] + 1, true);
|
||||||
game.prop[RESER] = 1 - game.prop[RESER];
|
game.prop[RESER] = 1 - game.prop[RESER];
|
||||||
if (AT(RESER))
|
if (AT(RESER))
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
|
@ -1127,7 +1125,7 @@ static int wave(token_t verb, token_t obj)
|
||||||
if (HERE(BIRD))
|
if (HERE(BIRD))
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
game.prop[FISSURE] = 1 - game.prop[FISSURE];
|
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;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
5
advent.h
5
advent.h
|
@ -106,7 +106,6 @@ typedef long vocab_t; // index into a vocabulary array */
|
||||||
struct game_t {
|
struct game_t {
|
||||||
unsigned long lcg_a, lcg_c, lcg_m, lcg_x;
|
unsigned long lcg_a, lcg_c, lcg_m, lcg_x;
|
||||||
long abbnum; // How often to print non-abbreviated descriptions
|
long abbnum; // How often to print non-abbreviated descriptions
|
||||||
long blklin;
|
|
||||||
long bonus;
|
long bonus;
|
||||||
long chloc;
|
long chloc;
|
||||||
long chloc2;
|
long chloc2;
|
||||||
|
@ -190,12 +189,12 @@ extern void* xmalloc(size_t size);
|
||||||
extern void packed_to_token(long, char token[]);
|
extern void packed_to_token(long, char token[]);
|
||||||
extern long token_to_packed(const char token[6]);
|
extern long token_to_packed(const char token[6]);
|
||||||
extern void tokenize(char*, long tokens[4]);
|
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 wordeq(token_t, token_t);
|
||||||
extern bool wordempty(token_t);
|
extern bool wordempty(token_t);
|
||||||
extern void wordclear(token_t *);
|
extern void wordclear(token_t *);
|
||||||
extern void speak(const char*, ...);
|
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 rspeak(vocab_t, ...);
|
||||||
extern void echo_input(FILE*, const char*, const char*);
|
extern void echo_input(FILE*, const char*, const char*);
|
||||||
extern int word_count(char*);
|
extern int word_count(char*);
|
||||||
|
|
1
init.c
1
init.c
|
@ -33,7 +33,6 @@ struct game_t game = {
|
||||||
.abbnum = 5,
|
.abbnum = 5,
|
||||||
.clock1 = WARNTIME,
|
.clock1 = WARNTIME,
|
||||||
.clock2 = FLASHTIME,
|
.clock2 = FLASHTIME,
|
||||||
.blklin = true,
|
|
||||||
.newloc = LOC_START,
|
.newloc = LOC_START,
|
||||||
.loc = LOC_START,
|
.loc = LOC_START,
|
||||||
.limit = GAMELIMIT,
|
.limit = GAMELIMIT,
|
||||||
|
|
6
main.c
6
main.c
|
@ -689,7 +689,7 @@ static bool playermove( int motion)
|
||||||
* entries check for game.prop(TROLL)=0.) Special
|
* entries check for game.prop(TROLL)=0.) Special
|
||||||
* stuff for bear. */
|
* stuff for bear. */
|
||||||
if (game.prop[TROLL] == TROLL_PAIDONCE) {
|
if (game.prop[TROLL] == TROLL_PAIDONCE) {
|
||||||
pspeak(TROLL, look, TROLL_PAIDONCE);
|
pspeak(TROLL, look, TROLL_PAIDONCE, true);
|
||||||
game.prop[TROLL] = TROLL_UNPAID;
|
game.prop[TROLL] = TROLL_UNPAID;
|
||||||
move(TROLL2, 0);
|
move(TROLL2, 0);
|
||||||
move(TROLL2 + NOBJECTS, 0);
|
move(TROLL2 + NOBJECTS, 0);
|
||||||
|
@ -917,7 +917,7 @@ static void listobjects(void)
|
||||||
int kk = game.prop[obj];
|
int kk = game.prop[obj];
|
||||||
if (obj == STEPS && game.loc == game.fixed[STEPS])
|
if (obj == STEPS && game.loc == game.fixed[STEPS])
|
||||||
kk = 1;
|
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). */
|
* tick game.clock1 unless well into cave (and not at Y2). */
|
||||||
if (game.closed) {
|
if (game.closed) {
|
||||||
if (game.prop[OYSTER] < 0 && TOTING(OYSTER))
|
if (game.prop[OYSTER] < 0 && TOTING(OYSTER))
|
||||||
pspeak(OYSTER, look, 1);
|
pspeak(OYSTER, look, 1, true);
|
||||||
for (size_t i = 1; i <= NOBJECTS; i++) {
|
for (size_t i = 1; i <= NOBJECTS; i++) {
|
||||||
if (TOTING(i) && game.prop[i] < 0)
|
if (TOTING(i) && game.prop[i] < 0)
|
||||||
game.prop[i] = -1 - game.prop[i];
|
game.prop[i] = -1 - game.prop[i];
|
||||||
|
|
26
misc.c
26
misc.c
|
@ -155,7 +155,7 @@ void wordclear(token_t *v)
|
||||||
|
|
||||||
/* I/O routines (speak, pspeak, rspeak, get_input, yes) */
|
/* 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.
|
// Do nothing if we got a null pointer.
|
||||||
if (msg == NULL)
|
if (msg == NULL)
|
||||||
|
@ -165,8 +165,7 @@ void vspeak(const char* msg, va_list ap)
|
||||||
if (strlen(msg) == 0)
|
if (strlen(msg) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Print a newline if the global game.blklin says to.
|
if (blank == true)
|
||||||
if (game.blklin == true)
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
int msglen = strlen(msg);
|
int msglen = strlen(msg);
|
||||||
|
@ -253,11 +252,11 @@ void speak(const char* msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
vspeak(msg, ap);
|
vspeak(msg, true, ap);
|
||||||
va_end(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:
|
/* Find the skip+1st message from msg and print it. Modes are:
|
||||||
* feel = for inventory, what you can touch
|
* feel = for inventory, what you can touch
|
||||||
* look = the long description for the state the object is in
|
* 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. */
|
* study = text on the object. */
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, skip);
|
va_start(ap, blank);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case touch:
|
case touch:
|
||||||
vspeak(objects[msg].inventory, ap);
|
vspeak(objects[msg].inventory, blank, ap);
|
||||||
break;
|
break;
|
||||||
case look:
|
case look:
|
||||||
vspeak(objects[msg].descriptions[skip], ap);
|
vspeak(objects[msg].descriptions[skip], blank, ap);
|
||||||
break;
|
break;
|
||||||
case hear:
|
case hear:
|
||||||
vspeak(objects[msg].sounds[skip], ap);
|
vspeak(objects[msg].sounds[skip], blank, ap);
|
||||||
break;
|
break;
|
||||||
case study:
|
case study:
|
||||||
vspeak(objects[msg].texts[skip], ap);
|
vspeak(objects[msg].texts[skip], blank, ap);
|
||||||
break;
|
break;
|
||||||
case change:
|
case change:
|
||||||
vspeak(objects[msg].changes[skip], ap);
|
vspeak(objects[msg].changes[skip], blank, ap);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
@ -291,7 +290,7 @@ void rspeak(vocab_t i, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, i);
|
va_start(ap, i);
|
||||||
vspeak(arbitrary_messages[i], ap);
|
vspeak(arbitrary_messages[i], true, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,8 +327,7 @@ char* get_input()
|
||||||
if (!settings.prompt)
|
if (!settings.prompt)
|
||||||
input_prompt[0] = '\0';
|
input_prompt[0] = '\0';
|
||||||
|
|
||||||
// Print a blank line if game.blklin tells us to.
|
// Print a blank line
|
||||||
if (game.blklin == true)
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
char* input;
|
char* input;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue