1TBS reflow, the bracening.
This commit is contained in:
parent
be429016af
commit
0175344caa
6 changed files with 122 additions and 68 deletions
50
actions.c
50
actions.c
|
@ -66,9 +66,10 @@ static phase_codes_t attack(command_t command) {
|
||||||
++changes;
|
++changes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changes >= 2)
|
if (changes >= 2) {
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (obj == BIRD) {
|
if (obj == BIRD) {
|
||||||
if (game.closed) {
|
if (game.closed) {
|
||||||
|
@ -128,9 +129,10 @@ static phase_codes_t attack(command_t command) {
|
||||||
drop(BLOOD, LOC_SECRET5);
|
drop(BLOOD, LOC_SECRET5);
|
||||||
for (obj_t i = 1; i <= NOBJECTS; i++) {
|
for (obj_t i = 1; i <= NOBJECTS; i++) {
|
||||||
if (game.objects[i].place == objects[DRAGON].plac ||
|
if (game.objects[i].place == objects[DRAGON].plac ||
|
||||||
game.objects[i].place == objects[DRAGON].fixd)
|
game.objects[i].place == objects[DRAGON].fixd) {
|
||||||
move(i, LOC_SECRET5);
|
move(i, LOC_SECRET5);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
game.loc = LOC_SECRET5;
|
game.loc = LOC_SECRET5;
|
||||||
return GO_MOVE;
|
return GO_MOVE;
|
||||||
}
|
}
|
||||||
|
@ -215,8 +217,9 @@ static phase_codes_t bigwords(vocab_t id) {
|
||||||
* before crossing. */
|
* before crossing. */
|
||||||
if (game.objects[EGGS].place == LOC_NOWHERE &&
|
if (game.objects[EGGS].place == LOC_NOWHERE &&
|
||||||
game.objects[TROLL].place == LOC_NOWHERE &&
|
game.objects[TROLL].place == LOC_NOWHERE &&
|
||||||
game.objects[TROLL].prop == TROLL_UNPAID)
|
game.objects[TROLL].prop == TROLL_UNPAID) {
|
||||||
game.objects[TROLL].prop = TROLL_PAIDONCE;
|
game.objects[TROLL].prop = TROLL_PAIDONCE;
|
||||||
|
}
|
||||||
if (HERE(EGGS)) {
|
if (HERE(EGGS)) {
|
||||||
pspeak(EGGS, look, true, EGGS_VANISHED);
|
pspeak(EGGS, look, true, EGGS_VANISHED);
|
||||||
} else if (game.loc == objects[EGGS].plac) {
|
} else if (game.loc == objects[EGGS].plac) {
|
||||||
|
@ -243,9 +246,9 @@ static phase_codes_t bigwords(vocab_t id) {
|
||||||
static void blast(void) {
|
static void blast(void) {
|
||||||
/* Blast. No effect unless you've got dynamite, which is a neat trick!
|
/* Blast. No effect unless you've got dynamite, which is a neat trick!
|
||||||
*/
|
*/
|
||||||
if (PROP_IS_NOTFOUND(ROD2) || !game.closed)
|
if (PROP_IS_NOTFOUND(ROD2) || !game.closed) {
|
||||||
rspeak(REQUIRES_DYNAMITE);
|
rspeak(REQUIRES_DYNAMITE);
|
||||||
else {
|
} else {
|
||||||
if (HERE(ROD2)) {
|
if (HERE(ROD2)) {
|
||||||
game.bonus = splatter;
|
game.bonus = splatter;
|
||||||
rspeak(SPLATTER_MESSAGE);
|
rspeak(SPLATTER_MESSAGE);
|
||||||
|
@ -274,8 +277,9 @@ static phase_codes_t vbreak(verb_t verb, obj_t obj) {
|
||||||
}
|
}
|
||||||
case VASE:
|
case VASE:
|
||||||
if (game.objects[VASE].prop == VASE_WHOLE) {
|
if (game.objects[VASE].prop == VASE_WHOLE) {
|
||||||
if (TOTING(VASE))
|
if (TOTING(VASE)) {
|
||||||
drop(VASE, game.loc);
|
drop(VASE, game.loc);
|
||||||
|
}
|
||||||
state_change(VASE, VASE_BROKEN);
|
state_change(VASE, VASE_BROKEN);
|
||||||
game.objects[VASE].fixed = IS_FIXED;
|
game.objects[VASE].fixed = IS_FIXED;
|
||||||
break;
|
break;
|
||||||
|
@ -435,8 +439,9 @@ static int chain(verb_t verb) {
|
||||||
}
|
}
|
||||||
game.objects[CHAIN].prop = CHAIN_HEAP;
|
game.objects[CHAIN].prop = CHAIN_HEAP;
|
||||||
game.objects[CHAIN].fixed = IS_FREE;
|
game.objects[CHAIN].fixed = IS_FREE;
|
||||||
if (game.objects[BEAR].prop != BEAR_DEAD)
|
if (game.objects[BEAR].prop != BEAR_DEAD) {
|
||||||
game.objects[BEAR].prop = CONTENTED_BEAR;
|
game.objects[BEAR].prop = CONTENTED_BEAR;
|
||||||
|
}
|
||||||
|
|
||||||
switch (game.objects[BEAR].prop) {
|
switch (game.objects[BEAR].prop) {
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
|
@ -465,8 +470,9 @@ static int chain(verb_t verb) {
|
||||||
|
|
||||||
game.objects[CHAIN].prop = CHAIN_FIXED;
|
game.objects[CHAIN].prop = CHAIN_FIXED;
|
||||||
|
|
||||||
if (TOTING(CHAIN))
|
if (TOTING(CHAIN)) {
|
||||||
drop(CHAIN, game.loc);
|
drop(CHAIN, game.loc);
|
||||||
|
}
|
||||||
game.objects[CHAIN].fixed = IS_FIXED;
|
game.objects[CHAIN].fixed = IS_FIXED;
|
||||||
|
|
||||||
rspeak(CHAIN_LOCKED);
|
rspeak(CHAIN_LOCKED);
|
||||||
|
@ -622,8 +628,9 @@ static phase_codes_t eat(verb_t verb, obj_t obj) {
|
||||||
*/
|
*/
|
||||||
switch (obj) {
|
switch (obj) {
|
||||||
case INTRANSITIVE:
|
case INTRANSITIVE:
|
||||||
if (!HERE(FOOD))
|
if (!HERE(FOOD)) {
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
|
}
|
||||||
/* FALLTHRU */
|
/* FALLTHRU */
|
||||||
case FOOD:
|
case FOOD:
|
||||||
DESTROY(FOOD);
|
DESTROY(FOOD);
|
||||||
|
@ -797,8 +804,9 @@ phase_codes_t fill(verb_t verb, obj_t obj) {
|
||||||
speak(actions[verb].message);
|
speak(actions[verb].message);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
if (obj == INTRANSITIVE && !HERE(BOTTLE))
|
if (obj == INTRANSITIVE && !HERE(BOTTLE)) {
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
|
}
|
||||||
|
|
||||||
if (HERE(URN) && game.objects[URN].prop != URN_EMPTY) {
|
if (HERE(URN) && game.objects[URN].prop != URN_EMPTY) {
|
||||||
rspeak(URN_NOPOUR);
|
rspeak(URN_NOPOUR);
|
||||||
|
@ -891,18 +899,21 @@ static phase_codes_t inven(void) {
|
||||||
* burden. */
|
* burden. */
|
||||||
bool empty = true;
|
bool empty = true;
|
||||||
for (obj_t i = 1; i <= NOBJECTS; i++) {
|
for (obj_t i = 1; i <= NOBJECTS; i++) {
|
||||||
if (i == BEAR || !TOTING(i))
|
if (i == BEAR || !TOTING(i)) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (empty) {
|
if (empty) {
|
||||||
rspeak(NOW_HOLDING);
|
rspeak(NOW_HOLDING);
|
||||||
empty = false;
|
empty = false;
|
||||||
}
|
}
|
||||||
pspeak(i, touch, false, -1);
|
pspeak(i, touch, false, -1);
|
||||||
}
|
}
|
||||||
if (TOTING(BEAR))
|
if (TOTING(BEAR)) {
|
||||||
rspeak(TAME_BEAR);
|
rspeak(TAME_BEAR);
|
||||||
if (empty)
|
}
|
||||||
|
if (empty) {
|
||||||
rspeak(NO_CARRY);
|
rspeak(NO_CARRY);
|
||||||
|
}
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -919,9 +930,10 @@ static phase_codes_t light(verb_t verb, obj_t obj) {
|
||||||
obj = URN;
|
obj = URN;
|
||||||
selects++;
|
selects++;
|
||||||
}
|
}
|
||||||
if (selects != 1)
|
if (selects != 1) {
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
switch (obj) {
|
switch (obj) {
|
||||||
case URN:
|
case URN:
|
||||||
|
@ -1181,9 +1193,9 @@ static phase_codes_t reservoir(void) {
|
||||||
state_change(RESER, game.objects[RESER].prop == WATERS_PARTED
|
state_change(RESER, game.objects[RESER].prop == WATERS_PARTED
|
||||||
? WATERS_UNPARTED
|
? WATERS_UNPARTED
|
||||||
: WATERS_PARTED);
|
: WATERS_PARTED);
|
||||||
if (AT(RESER))
|
if (AT(RESER)) {
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
else {
|
} else {
|
||||||
game.oldlc2 = game.loc;
|
game.oldlc2 = game.loc;
|
||||||
game.newloc = LOC_NOWHERE;
|
game.newloc = LOC_NOWHERE;
|
||||||
rspeak(NOT_BRIGHT);
|
rspeak(NOT_BRIGHT);
|
||||||
|
@ -1266,8 +1278,9 @@ static phase_codes_t throwit(command_t command) {
|
||||||
} else {
|
} else {
|
||||||
if (atdwrf(game.loc) <= 0) {
|
if (atdwrf(game.loc) <= 0) {
|
||||||
if (AT(DRAGON) &&
|
if (AT(DRAGON) &&
|
||||||
game.objects[DRAGON].prop == DRAGON_BARS)
|
game.objects[DRAGON].prop == DRAGON_BARS) {
|
||||||
return throw_support(DRAGON_SCALES);
|
return throw_support(DRAGON_SCALES);
|
||||||
|
}
|
||||||
if (AT(TROLL)) {
|
if (AT(TROLL)) {
|
||||||
return throw_support(TROLL_RETURNS);
|
return throw_support(TROLL_RETURNS);
|
||||||
}
|
}
|
||||||
|
@ -1357,10 +1370,11 @@ static phase_codes_t wave(verb_t verb, obj_t obj) {
|
||||||
: FREE_FLY);
|
: FREE_FLY);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
if (HERE(BIRD))
|
if (HERE(BIRD)) {
|
||||||
rspeak((game.objects[BIRD].prop == BIRD_CAGED)
|
rspeak((game.objects[BIRD].prop == BIRD_CAGED)
|
||||||
? CAGE_FLY
|
? CAGE_FLY
|
||||||
: FREE_FLY);
|
: FREE_FLY);
|
||||||
|
}
|
||||||
|
|
||||||
state_change(FISSURE, game.objects[FISSURE].prop == BRIDGED
|
state_change(FISSURE, game.objects[FISSURE].prop == BRIDGED
|
||||||
? UNBRIDGED
|
? UNBRIDGED
|
||||||
|
|
4
advent.h
4
advent.h
|
@ -221,8 +221,8 @@ struct game_t {
|
||||||
/* dflag controls the level of activation of dwarves:
|
/* dflag controls the level of activation of dwarves:
|
||||||
* 0 No dwarf stuff yet (wait until reaches Hall Of Mists)
|
* 0 No dwarf stuff yet (wait until reaches Hall Of Mists)
|
||||||
* 1 Reached Hall Of Mists, but hasn't met first dwarf
|
* 1 Reached Hall Of Mists, but hasn't met first dwarf
|
||||||
* 2 Met first dwarf, others start moving, no knives thrown
|
* 2 Met 1t dwarf, others start moving, no knives thrown yet
|
||||||
*yet 3 A knife has been thrown (first set always misses) 3+
|
* 3 A knife has been thrown (first set always misses) 3+
|
||||||
* Dwarves are mad (increases their accuracy) */
|
* Dwarves are mad (increases their accuracy) */
|
||||||
int32_t dflag;
|
int32_t dflag;
|
||||||
|
|
||||||
|
|
3
init.c
3
init.c
|
@ -27,8 +27,9 @@ struct game_t game = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int initialise(void) {
|
int initialise(void) {
|
||||||
if (settings.oldstyle)
|
if (settings.oldstyle) {
|
||||||
printf("Initialising...\n");
|
printf("Initialising...\n");
|
||||||
|
}
|
||||||
|
|
||||||
srand(time(NULL));
|
srand(time(NULL));
|
||||||
int seedval = (int)rand();
|
int seedval = (int)rand();
|
||||||
|
|
83
main.c
83
main.c
|
@ -31,9 +31,10 @@ void autosave(void) {
|
||||||
// exclude from coverage analysis because it requires interactivity to test
|
// exclude from coverage analysis because it requires interactivity to test
|
||||||
static void sig_handler(int signo) {
|
static void sig_handler(int signo) {
|
||||||
if (signo == SIGINT) {
|
if (signo == SIGINT) {
|
||||||
if (settings.logfp != NULL)
|
if (settings.logfp != NULL) {
|
||||||
fflush(settings.logfp);
|
fflush(settings.logfp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined ADVENT_AUTOSAVE
|
#if defined ADVENT_AUTOSAVE
|
||||||
if (signo == SIGHUP || signo == SIGTERM) {
|
if (signo == SIGHUP || signo == SIGTERM) {
|
||||||
|
@ -145,8 +146,9 @@ static void checkhints(void) {
|
||||||
NO_OBJECT &&
|
NO_OBJECT &&
|
||||||
game.locs[game.oldlc2].atloc ==
|
game.locs[game.oldlc2].atloc ==
|
||||||
NO_OBJECT &&
|
NO_OBJECT &&
|
||||||
game.holdng > 1)
|
game.holdng > 1) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
game.hints[hint].lc = 0;
|
game.hints[hint].lc = 0;
|
||||||
return;
|
return;
|
||||||
case 4: /* dark */
|
case 4: /* dark */
|
||||||
|
@ -170,8 +172,9 @@ static void checkhints(void) {
|
||||||
game.locs[game.oldloc].atloc ==
|
game.locs[game.oldloc].atloc ==
|
||||||
NO_OBJECT &&
|
NO_OBJECT &&
|
||||||
game.locs[game.oldlc2].atloc ==
|
game.locs[game.oldlc2].atloc ==
|
||||||
NO_OBJECT)
|
NO_OBJECT) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
case 8: /* ogre */
|
case 8: /* ogre */
|
||||||
i = atdwrf(game.loc);
|
i = atdwrf(game.loc);
|
||||||
|
@ -323,8 +326,9 @@ static bool dwarfmove(void) {
|
||||||
|
|
||||||
/* Dwarf activity level ratchets up */
|
/* Dwarf activity level ratchets up */
|
||||||
if (game.dflag == 0) {
|
if (game.dflag == 0) {
|
||||||
if (INDEEP(game.loc))
|
if (INDEEP(game.loc)) {
|
||||||
game.dflag = 1;
|
game.dflag = 1;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,33 +377,36 @@ static bool dwarfmove(void) {
|
||||||
/* Fill tk array with all the places this dwarf might go. */
|
/* Fill tk array with all the places this dwarf might go. */
|
||||||
unsigned int j = 1;
|
unsigned int j = 1;
|
||||||
kk = tkey[game.dwarves[i].loc];
|
kk = tkey[game.dwarves[i].loc];
|
||||||
if (kk != 0)
|
if (kk != 0) {
|
||||||
do {
|
do {
|
||||||
enum desttype_t desttype = travel[kk].desttype;
|
enum desttype_t desttype = travel[kk].desttype;
|
||||||
game.newloc = travel[kk].destval;
|
game.newloc = travel[kk].destval;
|
||||||
/* Have we avoided a dwarf encounter? */
|
/* Have we avoided a dwarf encounter? */
|
||||||
if (desttype != dest_goto)
|
if (desttype != dest_goto) {
|
||||||
continue;
|
continue;
|
||||||
else if (!INDEEP(game.newloc))
|
} else if (!INDEEP(game.newloc)) {
|
||||||
continue;
|
continue;
|
||||||
else if (game.newloc == game.dwarves[i].oldloc)
|
} else if (game.newloc ==
|
||||||
|
game.dwarves[i].oldloc) {
|
||||||
continue;
|
continue;
|
||||||
else if (j > 1 && game.newloc == tk[j - 1])
|
} else if (j > 1 && game.newloc == tk[j - 1]) {
|
||||||
continue;
|
continue;
|
||||||
else if (j >= DIM(tk) - 1)
|
} else if (j >= DIM(tk) - 1) {
|
||||||
/* This can't actually happen. */
|
/* This can't actually happen. */
|
||||||
continue; // LCOV_EXCL_LINE
|
continue; // LCOV_EXCL_LINE
|
||||||
else if (game.newloc == game.dwarves[i].loc)
|
} else if (game.newloc == game.dwarves[i].loc) {
|
||||||
continue;
|
continue;
|
||||||
else if (FORCED(game.newloc))
|
} else if (FORCED(game.newloc)) {
|
||||||
continue;
|
continue;
|
||||||
else if (i == PIRATE &&
|
} else if (i == PIRATE &&
|
||||||
CNDBIT(game.newloc, COND_NOARRR))
|
CNDBIT(game.newloc, COND_NOARRR)) {
|
||||||
continue;
|
continue;
|
||||||
else if (travel[kk].nodwarves)
|
} else if (travel[kk].nodwarves) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
tk[j++] = game.newloc;
|
tk[j++] = game.newloc;
|
||||||
} while (!travel[kk++].stop);
|
} while (!travel[kk++].stop);
|
||||||
|
}
|
||||||
tk[j] = game.dwarves[i].oldloc;
|
tk[j] = game.dwarves[i].oldloc;
|
||||||
if (j >= 2) {
|
if (j >= 2) {
|
||||||
--j;
|
--j;
|
||||||
|
@ -502,8 +509,9 @@ static void croak(void) {
|
||||||
* where he died. */
|
* where he died. */
|
||||||
game.objects[WATER].place = game.objects[OIL].place =
|
game.objects[WATER].place = game.objects[OIL].place =
|
||||||
LOC_NOWHERE;
|
LOC_NOWHERE;
|
||||||
if (TOTING(LAMP))
|
if (TOTING(LAMP)) {
|
||||||
game.objects[LAMP].prop = LAMP_DARK;
|
game.objects[LAMP].prop = LAMP_DARK;
|
||||||
|
}
|
||||||
for (int j = 1; j <= NOBJECTS; j++) {
|
for (int j = 1; j <= NOBJECTS; j++) {
|
||||||
int i = NOBJECTS + 1 - j;
|
int i = NOBJECTS + 1 - j;
|
||||||
if (TOTING(i)) {
|
if (TOTING(i)) {
|
||||||
|
@ -521,8 +529,9 @@ static void describe_location(void) {
|
||||||
const char *msg = locations[game.loc].description.small;
|
const char *msg = locations[game.loc].description.small;
|
||||||
|
|
||||||
if (MOD(game.locs[game.loc].abbrev, game.abbnum) == 0 ||
|
if (MOD(game.locs[game.loc].abbrev, game.abbnum) == 0 ||
|
||||||
msg == NO_MESSAGE)
|
msg == NO_MESSAGE) {
|
||||||
msg = locations[game.loc].description.big;
|
msg = locations[game.loc].description.big;
|
||||||
|
}
|
||||||
|
|
||||||
if (!FORCED(game.loc) && DARK(game.loc)) {
|
if (!FORCED(game.loc) && DARK(game.loc)) {
|
||||||
msg = arbitrary_messages[PITCH_DARK];
|
msg = arbitrary_messages[PITCH_DARK];
|
||||||
|
@ -534,9 +543,10 @@ static void describe_location(void) {
|
||||||
|
|
||||||
speak(msg);
|
speak(msg);
|
||||||
|
|
||||||
if (game.loc == LOC_Y2 && PCT(25) && !game.closng)
|
if (game.loc == LOC_Y2 && PCT(25) && !game.closng) {
|
||||||
rspeak(SAYS_PLUGH);
|
rspeak(SAYS_PLUGH);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool traveleq(int a, int b) {
|
static bool traveleq(int a, int b) {
|
||||||
/* Are two travel entries equal for purposes of skip after failed
|
/* Are two travel entries equal for purposes of skip after failed
|
||||||
|
@ -569,8 +579,9 @@ static void playermove(int motion) {
|
||||||
* forced-motion. te_tmp saves entry -> forced loc -> previous
|
* forced-motion. te_tmp saves entry -> forced loc -> previous
|
||||||
* loc. */
|
* loc. */
|
||||||
motion = game.oldloc;
|
motion = game.oldloc;
|
||||||
if (FORCED(motion))
|
if (FORCED(motion)) {
|
||||||
motion = game.oldlc2;
|
motion = game.oldlc2;
|
||||||
|
}
|
||||||
game.oldlc2 = game.oldloc;
|
game.oldlc2 = game.oldloc;
|
||||||
game.oldloc = game.loc;
|
game.oldloc = game.loc;
|
||||||
if (CNDBIT(game.loc, COND_NOBACK)) {
|
if (CNDBIT(game.loc, COND_NOBACK)) {
|
||||||
|
@ -591,9 +602,10 @@ static void playermove(int motion) {
|
||||||
if (desttype == dest_goto) {
|
if (desttype == dest_goto) {
|
||||||
if (FORCED(scratchloc) &&
|
if (FORCED(scratchloc) &&
|
||||||
travel[tkey[scratchloc]].destval ==
|
travel[tkey[scratchloc]].destval ==
|
||||||
motion)
|
motion) {
|
||||||
te_tmp = travel_entry;
|
te_tmp = travel_entry;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!travel[travel_entry].stop) {
|
if (!travel[travel_entry].stop) {
|
||||||
++travel_entry; /* go to next travel
|
++travel_entry; /* go to next travel
|
||||||
entry for this
|
entry for this
|
||||||
|
@ -641,8 +653,9 @@ static void playermove(int motion) {
|
||||||
* indexes the beginning of the motion entries for here (game.loc). */
|
* indexes the beginning of the motion entries for here (game.loc). */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if ((travel[travel_entry].motion == HERE) ||
|
if ((travel[travel_entry].motion == HERE) ||
|
||||||
travel[travel_entry].motion == motion)
|
travel[travel_entry].motion == motion) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (travel[travel_entry].stop) {
|
if (travel[travel_entry].stop) {
|
||||||
/* Couldn't find an entry matching the motion word
|
/* Couldn't find an entry matching the motion word
|
||||||
* passed in. Various messages depending on word given.
|
* passed in. Various messages depending on word given.
|
||||||
|
@ -699,15 +712,17 @@ static void playermove(int motion) {
|
||||||
if (condtype == cond_goto ||
|
if (condtype == cond_goto ||
|
||||||
condtype == cond_pct) {
|
condtype == cond_pct) {
|
||||||
if (condarg1 == 0 ||
|
if (condarg1 == 0 ||
|
||||||
PCT(condarg1))
|
PCT(condarg1)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* else fall through */
|
/* else fall through */
|
||||||
}
|
}
|
||||||
/* YAML [with OBJ] clause */
|
/* YAML [with OBJ] clause */
|
||||||
else if (TOTING(condarg1) ||
|
else if (TOTING(condarg1) ||
|
||||||
(condtype == cond_with &&
|
(condtype == cond_with &&
|
||||||
AT(condarg1)))
|
AT(condarg1))) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
/* else fall through to check [not OBJ
|
/* else fall through to check [not OBJ
|
||||||
* STATE] */
|
* STATE] */
|
||||||
} else if (game.objects[condarg1].prop !=
|
} else if (game.objects[condarg1].prop !=
|
||||||
|
@ -719,8 +734,9 @@ static void playermove(int motion) {
|
||||||
* Skip to next non-matching destination */
|
* Skip to next non-matching destination */
|
||||||
int te_tmp = travel_entry;
|
int te_tmp = travel_entry;
|
||||||
do {
|
do {
|
||||||
if (travel[te_tmp].stop)
|
if (travel[te_tmp].stop) {
|
||||||
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
||||||
|
}
|
||||||
++te_tmp;
|
++te_tmp;
|
||||||
} while (traveleq(travel_entry, te_tmp));
|
} while (traveleq(travel_entry, te_tmp));
|
||||||
travel_entry = te_tmp;
|
travel_entry = te_tmp;
|
||||||
|
@ -771,8 +787,10 @@ static void playermove(int motion) {
|
||||||
{
|
{
|
||||||
int te_tmp = travel_entry;
|
int te_tmp = travel_entry;
|
||||||
do {
|
do {
|
||||||
if (travel[te_tmp].stop)
|
if (travel[te_tmp]
|
||||||
|
.stop) {
|
||||||
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
||||||
|
}
|
||||||
++te_tmp;
|
++te_tmp;
|
||||||
} while (traveleq(travel_entry,
|
} while (traveleq(travel_entry,
|
||||||
te_tmp));
|
te_tmp));
|
||||||
|
@ -814,10 +832,11 @@ static void playermove(int motion) {
|
||||||
objects[TROLL].fixd -
|
objects[TROLL].fixd -
|
||||||
game.loc;
|
game.loc;
|
||||||
if (game.objects[TROLL].prop ==
|
if (game.objects[TROLL].prop ==
|
||||||
TROLL_UNPAID)
|
TROLL_UNPAID) {
|
||||||
game.objects[TROLL]
|
game.objects[TROLL]
|
||||||
.prop =
|
.prop =
|
||||||
TROLL_PAIDONCE;
|
TROLL_PAIDONCE;
|
||||||
|
}
|
||||||
if (!TOTING(BEAR)) {
|
if (!TOTING(BEAR)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -962,8 +981,9 @@ static bool closecheck(void) {
|
||||||
game.clock1 = -1;
|
game.clock1 = -1;
|
||||||
game.closng = true;
|
game.closng = true;
|
||||||
return game.closed;
|
return game.closed;
|
||||||
} else if (game.clock1 < 0)
|
} else if (game.clock1 < 0) {
|
||||||
--game.clock2;
|
--game.clock2;
|
||||||
|
}
|
||||||
if (game.clock2 == 0) {
|
if (game.clock2 == 0) {
|
||||||
/* Once he's panicked, and clock2 has run out, we come here
|
/* Once he's panicked, and clock2 has run out, we come here
|
||||||
* to set up the storage room. The room has two locs,
|
* to set up the storage room. The room has two locs,
|
||||||
|
@ -1159,8 +1179,9 @@ static bool preprocess_command(command_t *command) {
|
||||||
|
|
||||||
/* If no word type is given for the first word, we assume it's a
|
/* If no word type is given for the first word, we assume it's a
|
||||||
* motion. */
|
* motion. */
|
||||||
if (command->word[0].type == NO_WORD_TYPE)
|
if (command->word[0].type == NO_WORD_TYPE) {
|
||||||
command->word[0].type = MOTION;
|
command->word[0].type = MOTION;
|
||||||
|
}
|
||||||
|
|
||||||
command->state = PREPROCESSED;
|
command->state = PREPROCESSED;
|
||||||
return true;
|
return true;
|
||||||
|
@ -1252,11 +1273,12 @@ static bool do_command(void) {
|
||||||
}
|
}
|
||||||
for (size_t i = 1; i <= NOBJECTS; i++) {
|
for (size_t i = 1; i <= NOBJECTS; i++) {
|
||||||
if (TOTING(i) && (PROP_IS_NOTFOUND(i) ||
|
if (TOTING(i) && (PROP_IS_NOTFOUND(i) ||
|
||||||
PROP_IS_STASHED(i)))
|
PROP_IS_STASHED(i))) {
|
||||||
game.objects[i].prop =
|
game.objects[i].prop =
|
||||||
PROP_STASHED(i);
|
PROP_STASHED(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Check to see if the room is dark. If the knife is
|
/* Check to see if the room is dark. If the knife is
|
||||||
* here, and it's dark, the knife permanently disappears
|
* here, and it's dark, the knife permanently disappears
|
||||||
|
@ -1534,8 +1556,9 @@ int main(int argc, char *argv[]) {
|
||||||
game.novice = yes_or_no(arbitrary_messages[WELCOME_YOU],
|
game.novice = yes_or_no(arbitrary_messages[WELCOME_YOU],
|
||||||
arbitrary_messages[CAVE_NEARBY],
|
arbitrary_messages[CAVE_NEARBY],
|
||||||
arbitrary_messages[NO_MESSAGE]);
|
arbitrary_messages[NO_MESSAGE]);
|
||||||
if (game.novice)
|
if (game.novice) {
|
||||||
game.limit = NOVICELIMIT;
|
game.limit = NOVICELIMIT;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (settings.logfp) {
|
if (settings.logfp) {
|
||||||
|
|
42
misc.c
42
misc.c
|
@ -195,7 +195,7 @@ static int word_count(char *str) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int inblanks = true;
|
int inblanks = true;
|
||||||
|
|
||||||
for (char *s = str; *s; s++)
|
for (char *s = str; *s; s++) {
|
||||||
if (inblanks) {
|
if (inblanks) {
|
||||||
if (strchr(delims, *s) == 0) {
|
if (strchr(delims, *s) == 0) {
|
||||||
++count;
|
++count;
|
||||||
|
@ -206,6 +206,7 @@ static int word_count(char *str) {
|
||||||
inblanks = true;
|
inblanks = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (count);
|
return (count);
|
||||||
}
|
}
|
||||||
|
@ -213,8 +214,9 @@ static int word_count(char *str) {
|
||||||
static char *get_input(void) {
|
static char *get_input(void) {
|
||||||
// Set up the prompt
|
// Set up the prompt
|
||||||
char input_prompt[] = PROMPT;
|
char input_prompt[] = PROMPT;
|
||||||
if (!settings.prompt)
|
if (!settings.prompt) {
|
||||||
input_prompt[0] = '\0';
|
input_prompt[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
// Print a blank line
|
// Print a blank line
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
@ -223,8 +225,9 @@ static char *get_input(void) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
input = myreadline(input_prompt);
|
input = myreadline(input_prompt);
|
||||||
|
|
||||||
if (input == NULL) // Got EOF; return with it.
|
if (input == NULL) { // Got EOF; return with it.
|
||||||
return (input);
|
return (input);
|
||||||
|
}
|
||||||
if (input[0] == '#') { // Ignore comments.
|
if (input[0] == '#') { // Ignore comments.
|
||||||
free(input);
|
free(input);
|
||||||
continue;
|
continue;
|
||||||
|
@ -238,11 +241,13 @@ static char *get_input(void) {
|
||||||
|
|
||||||
add_history(input);
|
add_history(input);
|
||||||
|
|
||||||
if (!isatty(0))
|
if (!isatty(0)) {
|
||||||
echo_input(stdout, input_prompt, input);
|
echo_input(stdout, input_prompt, input);
|
||||||
|
}
|
||||||
|
|
||||||
if (settings.logfp)
|
if (settings.logfp) {
|
||||||
echo_input(settings.logfp, "", input);
|
echo_input(settings.logfp, "", input);
|
||||||
|
}
|
||||||
|
|
||||||
return (input);
|
return (input);
|
||||||
}
|
}
|
||||||
|
@ -270,8 +275,9 @@ bool silent_yes_or_no(void) {
|
||||||
|
|
||||||
free(reply);
|
free(reply);
|
||||||
|
|
||||||
for (int i = 0; i < (int)strlen(firstword); ++i)
|
for (int i = 0; i < (int)strlen(firstword); ++i) {
|
||||||
firstword[i] = tolower(firstword[i]);
|
firstword[i] = tolower(firstword[i]);
|
||||||
|
}
|
||||||
|
|
||||||
int yes = strncmp("yes", firstword, sizeof("yes") - 1);
|
int yes = strncmp("yes", firstword, sizeof("yes") - 1);
|
||||||
int y = strncmp("y", firstword, sizeof("y") - 1);
|
int y = strncmp("y", firstword, sizeof("y") - 1);
|
||||||
|
@ -286,9 +292,10 @@ bool silent_yes_or_no(void) {
|
||||||
} else if (no == 0 || n == 0) {
|
} else if (no == 0 || n == 0) {
|
||||||
outcome = false;
|
outcome = false;
|
||||||
break;
|
break;
|
||||||
} else
|
} else {
|
||||||
rspeak(PLEASE_ANSWER);
|
rspeak(PLEASE_ANSWER);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return (outcome);
|
return (outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,9 +347,10 @@ bool yes_or_no(const char *question, const char *yes_response,
|
||||||
speak(no_response);
|
speak(no_response);
|
||||||
outcome = false;
|
outcome = false;
|
||||||
break;
|
break;
|
||||||
} else
|
} else {
|
||||||
rspeak(PLEASE_ANSWER);
|
rspeak(PLEASE_ANSWER);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (outcome);
|
return (outcome);
|
||||||
}
|
}
|
||||||
|
@ -357,10 +365,11 @@ static int get_motion_vocab_id(const char *word) {
|
||||||
TOKLEN) == 0 &&
|
TOKLEN) == 0 &&
|
||||||
(strlen(word) > 1 ||
|
(strlen(word) > 1 ||
|
||||||
strchr(ignore, word[0]) == NULL ||
|
strchr(ignore, word[0]) == NULL ||
|
||||||
!settings.oldstyle))
|
!settings.oldstyle)) {
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// If execution reaches here, we didn't find the word.
|
// If execution reaches here, we didn't find the word.
|
||||||
return (WORD_NOT_FOUND);
|
return (WORD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -372,10 +381,11 @@ static int get_object_vocab_id(const char *word) {
|
||||||
// removed
|
// removed
|
||||||
for (int j = 0; j < objects[i].words.n; ++j) {
|
for (int j = 0; j < objects[i].words.n; ++j) {
|
||||||
if (strncasecmp(word, objects[i].words.strs[j],
|
if (strncasecmp(word, objects[i].words.strs[j],
|
||||||
TOKLEN) == 0)
|
TOKLEN) == 0) {
|
||||||
return (i);
|
return (i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// If execution reaches here, we didn't find the word.
|
// If execution reaches here, we didn't find the word.
|
||||||
return (WORD_NOT_FOUND);
|
return (WORD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
@ -529,8 +539,9 @@ bool get_command_input(command_t *command) {
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
input = get_input();
|
input = get_input();
|
||||||
if (input == NULL)
|
if (input == NULL) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if (word_count(input) > 2) {
|
if (word_count(input) > 2) {
|
||||||
rspeak(TWO_WORDS);
|
rspeak(TWO_WORDS);
|
||||||
free(input);
|
free(input);
|
||||||
|
@ -637,9 +648,10 @@ void carry(obj_t object, loc_t where) {
|
||||||
*
|
*
|
||||||
* Possibly this check should be skipped whwn oldstyle is on.
|
* Possibly this check should be skipped whwn oldstyle is on.
|
||||||
*/
|
*/
|
||||||
if (object != BIRD)
|
if (object != BIRD) {
|
||||||
++game.holdng;
|
++game.holdng;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (game.locs[where].atloc == object) {
|
if (game.locs[where].atloc == object) {
|
||||||
game.locs[where].atloc = game.link[object];
|
game.locs[where].atloc = game.link[object];
|
||||||
return;
|
return;
|
||||||
|
@ -658,8 +670,8 @@ void drop(obj_t object, loc_t where) {
|
||||||
if (object > NOBJECTS) {
|
if (object > NOBJECTS) {
|
||||||
game.objects[object - NOBJECTS].fixed = where;
|
game.objects[object - NOBJECTS].fixed = where;
|
||||||
} else {
|
} else {
|
||||||
if (game.objects[object].place == CARRIED)
|
if (game.objects[object].place == CARRIED) {
|
||||||
if (object != BIRD)
|
if (object != BIRD) {
|
||||||
/* The bird has to be weightless. This ugly
|
/* The bird has to be weightless. This ugly
|
||||||
* hack (and the corresponding code in the carry
|
* hack (and the corresponding code in the carry
|
||||||
* function) brought to you by the fact that
|
* function) brought to you by the fact that
|
||||||
|
@ -668,6 +680,8 @@ void drop(obj_t object, loc_t where) {
|
||||||
* the right thing happen.
|
* the right thing happen.
|
||||||
*/
|
*/
|
||||||
--game.holdng;
|
--game.holdng;
|
||||||
|
}
|
||||||
|
}
|
||||||
game.objects[object].place = where;
|
game.objects[object].place = where;
|
||||||
}
|
}
|
||||||
if (where == LOC_NOWHERE || where == CARRIED) {
|
if (where == LOC_NOWHERE || where == CARRIED) {
|
||||||
|
|
|
@ -127,11 +127,13 @@ int resume(void) {
|
||||||
|
|
||||||
while (fp == NULL) {
|
while (fp == NULL) {
|
||||||
char *name = myreadline("\nFile name: ");
|
char *name = myreadline("\nFile name: ");
|
||||||
if (name == NULL)
|
if (name == NULL) {
|
||||||
return GO_TOP;
|
return GO_TOP;
|
||||||
|
}
|
||||||
name = strip(name);
|
name = strip(name);
|
||||||
if (strlen(name) == 0)
|
if (strlen(name) == 0) {
|
||||||
return GO_TOP; // LCOV_EXCL_LINE
|
return GO_TOP; // LCOV_EXCL_LINE
|
||||||
|
}
|
||||||
fp = fopen(name, READ_MODE);
|
fp = fopen(name, READ_MODE);
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
printf("Can't open file %s, try again.\n", name);
|
printf("Can't open file %s, try again.\n", name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue