Limited cleanup
This commit is contained in:
parent
37373c5277
commit
898348911f
9 changed files with 87 additions and 91 deletions
2
Makefile
2
Makefile
|
@ -74,7 +74,7 @@ newdb.c newdb.h: newdungeon.py adventure.yaml
|
||||||
python3 newdungeon.py
|
python3 newdungeon.py
|
||||||
|
|
||||||
linenoise.o: linenoise/linenoise.h
|
linenoise.o: linenoise/linenoise.h
|
||||||
$(CC) -c linenoise/linenoise.c
|
$(CC) $(CCFLAGS) -c linenoise/linenoise.c
|
||||||
|
|
||||||
dungeon: dungeon.o common.o
|
dungeon: dungeon.o common.o
|
||||||
$(CC) $(CCFLAGS) -o $@ dungeon.o common.o
|
$(CC) $(CCFLAGS) -o $@ dungeon.o common.o
|
||||||
|
|
40
actions.c
40
actions.c
|
@ -14,7 +14,7 @@ static int attack(FILE *input, struct command_t *command)
|
||||||
{
|
{
|
||||||
vocab_t verb = command->verb;
|
vocab_t verb = command->verb;
|
||||||
vocab_t obj = command->obj;
|
vocab_t obj = command->obj;
|
||||||
int spk = actions[verb].message;
|
long spk = actions[verb].message;
|
||||||
if (obj == 0 || obj == INTRANSITIVE) {
|
if (obj == 0 || obj == INTRANSITIVE) {
|
||||||
if (atdwrf(game.loc) > 0)
|
if (atdwrf(game.loc) > 0)
|
||||||
obj = DWARF;
|
obj = DWARF;
|
||||||
|
@ -44,7 +44,7 @@ static int attack(FILE *input, struct command_t *command)
|
||||||
DESTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
spk = BIRD_DEAD;
|
spk = BIRD_DEAD;
|
||||||
} else if (obj == VEND) {
|
} else if (obj == VEND) {
|
||||||
bool blocking = (game.prop[VEND] == VEND_BLOCKS);
|
bool blocking = (game.prop[VEND] == VEND_BLOCKS);
|
||||||
game.prop[VEND] = blocking ? VEND_UNBLOCKS : VEND_BLOCKS;
|
game.prop[VEND] = blocking ? VEND_UNBLOCKS : VEND_BLOCKS;
|
||||||
rspeak(blocking ? MACHINE_SWINGOUT : MACHINE_SWINGBACK);
|
rspeak(blocking ? MACHINE_SWINGOUT : MACHINE_SWINGBACK);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
|
@ -246,7 +246,7 @@ static int vcarry(token_t verb, token_t obj)
|
||||||
return (fill(verb, BOTTLE));
|
return (fill(verb, BOTTLE));
|
||||||
else {
|
else {
|
||||||
if (game.prop[BOTTLE] != EMPTY_BOTTLE)
|
if (game.prop[BOTTLE] != EMPTY_BOTTLE)
|
||||||
spk = BOTTLE_FULL;
|
spk = BOTTLE_FULL;
|
||||||
if (!TOTING(BOTTLE))spk = NO_CONTAINER;
|
if (!TOTING(BOTTLE))spk = NO_CONTAINER;
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
|
@ -385,12 +385,12 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
|
||||||
if (obj == BOTTLE && k != 0)
|
if (obj == BOTTLE && k != 0)
|
||||||
game.place[k] = LOC_NOWHERE;
|
game.place[k] = LOC_NOWHERE;
|
||||||
if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
|
if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
|
||||||
drop(BIRD, game.loc);
|
drop(BIRD, game.loc);
|
||||||
drop(obj, game.loc);
|
drop(obj, game.loc);
|
||||||
if (obj != BIRD) return GO_CLEAROBJ;
|
if (obj != BIRD) return GO_CLEAROBJ;
|
||||||
game.prop[BIRD] = BIRD_UNCAGED;
|
game.prop[BIRD] = BIRD_UNCAGED;
|
||||||
if (FOREST(game.loc))
|
if (FOREST(game.loc))
|
||||||
game.prop[BIRD] = BIRD_FOREST_UNCAGED;
|
game.prop[BIRD] = BIRD_FOREST_UNCAGED;
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +447,7 @@ static int extinguish(token_t verb, int obj)
|
||||||
int spk = actions[verb].message;
|
int spk = actions[verb].message;
|
||||||
if (obj == INTRANSITIVE) {
|
if (obj == INTRANSITIVE) {
|
||||||
if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
|
if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
|
||||||
obj = LAMP;
|
obj = LAMP;
|
||||||
if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
|
if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
|
||||||
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
|
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
@ -554,7 +554,7 @@ int fill(token_t verb, token_t obj)
|
||||||
if (LIQUID() != 0)
|
if (LIQUID() != 0)
|
||||||
spk = BOTTLE_FULL;
|
spk = BOTTLE_FULL;
|
||||||
if (spk == BOTTLED_WATER) {
|
if (spk == BOTTLED_WATER) {
|
||||||
/* FIXME: Arithmetic on property values */
|
/* FIXME: Arithmetic on property values */
|
||||||
game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
|
game.prop[BOTTLE] = MOD(conditions[game.loc], 4) / 2 * 2;
|
||||||
k = LIQUID();
|
k = LIQUID();
|
||||||
if (TOTING(BOTTLE))
|
if (TOTING(BOTTLE))
|
||||||
|
@ -640,7 +640,7 @@ static int light(token_t verb, token_t obj)
|
||||||
int spk = actions[verb].message;
|
int spk = actions[verb].message;
|
||||||
if (obj == INTRANSITIVE) {
|
if (obj == INTRANSITIVE) {
|
||||||
if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
|
if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
|
||||||
obj = LAMP;
|
obj = LAMP;
|
||||||
if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
|
if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
|
||||||
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
|
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
@ -681,20 +681,20 @@ static int listen(void)
|
||||||
if (k != SILENT) {
|
if (k != SILENT) {
|
||||||
rspeak(k);
|
rspeak(k);
|
||||||
if (locations[game.loc].loud)
|
if (locations[game.loc].loud)
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
else
|
else
|
||||||
spk = NO_MESSAGE;
|
spk = NO_MESSAGE;
|
||||||
}
|
}
|
||||||
for (int i = 1; i <= NOBJECTS; i++) {
|
for (int i = 1; i <= NOBJECTS; i++) {
|
||||||
if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
|
if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
|
||||||
continue;
|
continue;
|
||||||
int mi = game.prop[i];
|
int mi = game.prop[i];
|
||||||
if (i == BIRD)
|
if (i == BIRD)
|
||||||
mi += 3 * game.blooded;
|
mi += 3 * game.blooded;
|
||||||
pspeak(i, hear, mi, game.zzword);
|
pspeak(i, hear, mi, game.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)
|
||||||
DESTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
}
|
}
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
|
@ -976,7 +976,7 @@ static int wave(token_t verb, token_t obj)
|
||||||
}
|
}
|
||||||
/* FIXME: Arithemetic on proprty values */
|
/* FIXME: Arithemetic on proprty values */
|
||||||
if (HERE(BIRD))
|
if (HERE(BIRD))
|
||||||
spk = FREE_FLY + MOD(game.prop[BIRD], 2);
|
spk = FREE_FLY + MOD(game.prop[BIRD], 2);
|
||||||
if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
|
if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
|
||||||
drop(JADE, game.loc);
|
drop(JADE, game.loc);
|
||||||
game.prop[JADE] = 0;
|
game.prop[JADE] = 0;
|
||||||
|
@ -1057,7 +1057,7 @@ int action(FILE *input, struct command_t *command)
|
||||||
switch (command->part) {
|
switch (command->part) {
|
||||||
case intransitive:
|
case intransitive:
|
||||||
if (command->wd2 > 0 && command->verb != SAY)
|
if (command->wd2 > 0 && command->verb != SAY)
|
||||||
return GO_WORD2;
|
return GO_WORD2;
|
||||||
if (command->verb == SAY)command->obj = command->wd2;
|
if (command->verb == SAY)command->obj = command->wd2;
|
||||||
if (command->obj == 0 || command->obj == INTRANSITIVE) {
|
if (command->obj == 0 || command->obj == INTRANSITIVE) {
|
||||||
/* Analyse an intransitive verb (ie, no object given yet). */
|
/* Analyse an intransitive verb (ie, no object given yet). */
|
||||||
|
@ -1121,7 +1121,7 @@ int action(FILE *input, struct command_t *command)
|
||||||
case 25: /* BRIEF */
|
case 25: /* BRIEF */
|
||||||
return brief();
|
return brief();
|
||||||
case 26: /* READ */
|
case 26: /* READ */
|
||||||
command->obj = INTRANSITIVE;
|
command->obj = INTRANSITIVE;
|
||||||
return read(*command);
|
return read(*command);
|
||||||
case 27: /* BREAK */
|
case 27: /* BREAK */
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
|
@ -1183,7 +1183,7 @@ int action(FILE *input, struct command_t *command)
|
||||||
case 15: /* RUB */
|
case 15: /* RUB */
|
||||||
return rub(command->verb, command->obj);
|
return rub(command->verb, command->obj);
|
||||||
case 16: /* TOSS */
|
case 16: /* TOSS */
|
||||||
return throw(input, command);
|
return throw (input, command);
|
||||||
case 17: { /* QUIT */
|
case 17: { /* QUIT */
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
|
|
7
cheat.c
7
cheat.c
|
@ -38,13 +38,12 @@ int main(int argc, char *argv[])
|
||||||
game.limit = GAMELIMIT;
|
game.limit = GAMELIMIT;
|
||||||
game.numdie = -1000;
|
game.numdie = -1000;
|
||||||
game.saved = 1;
|
game.saved = 1;
|
||||||
|
|
||||||
fp = fopen("cheat_numdie.adv", WRITE_MODE);
|
fp = fopen("cheat_numdie.adv", WRITE_MODE);
|
||||||
if (fp == NULL)
|
if (fp == NULL) {
|
||||||
{
|
|
||||||
printf("Can't open file. Exiting.\n");
|
printf("Can't open file. Exiting.\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
savefile(fp);
|
savefile(fp);
|
||||||
printf("cheat: tests/cheat_numdie.adv created.\n");
|
printf("cheat: tests/cheat_numdie.adv created.\n");
|
||||||
|
|
28
dungeon.c
28
dungeon.c
|
@ -198,7 +198,7 @@ static long GETNUM(FILE *source)
|
||||||
* scanned). If we're at the end of the line or encounter an illegal
|
* scanned). If we're at the end of the line or encounter an illegal
|
||||||
* character (not a digit, hyphen, or blank), we return 0. */
|
* character (not a digit, hyphen, or blank), we return 0. */
|
||||||
|
|
||||||
long DIGIT, GETNUM, sign;
|
long GETNUM, sign;
|
||||||
|
|
||||||
if (source != NULL) MAPLIN(source);
|
if (source != NULL) MAPLIN(source);
|
||||||
GETNUM = 0;
|
GETNUM = 0;
|
||||||
|
@ -215,7 +215,7 @@ static long GETNUM(FILE *source)
|
||||||
LNPOSN = LNPOSN + 1;
|
LNPOSN = LNPOSN + 1;
|
||||||
}
|
}
|
||||||
while (!(LNPOSN > LNLENG || INLINE[LNPOSN] == 0)) {
|
while (!(LNPOSN > LNLENG || INLINE[LNPOSN] == 0)) {
|
||||||
DIGIT = INLINE[LNPOSN] - 64;
|
long DIGIT = INLINE[LNPOSN] - 64;
|
||||||
if (DIGIT < 0 || DIGIT > 9) {
|
if (DIGIT < 0 || DIGIT > 9) {
|
||||||
GETNUM = 0;
|
GETNUM = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -233,13 +233,13 @@ static long GETNUM(FILE *source)
|
||||||
static void read_messages(FILE* database)
|
static void read_messages(FILE* database)
|
||||||
{
|
{
|
||||||
while (true) {
|
while (true) {
|
||||||
do {
|
do {
|
||||||
if (NULL == fgets(INLINE + 1, sizeof(INLINE) - 1, database)) {
|
if (NULL == fgets(INLINE + 1, sizeof(INLINE) - 1, database)) {
|
||||||
printf("Failed fgets()\n");
|
printf("Failed fgets()\n");
|
||||||
}
|
}
|
||||||
} while (!feof(database) && INLINE[1] == '#');
|
} while (!feof(database) && INLINE[1] == '#');
|
||||||
if (strncmp(INLINE + 1, "-1\n", 3) == 0)
|
if (strncmp(INLINE + 1, "-1\n", 3) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ static void read_initial_locations(FILE* database)
|
||||||
{
|
{
|
||||||
long OBJ;
|
long OBJ;
|
||||||
while ((OBJ = GETNUM(database)) != -1) {
|
while ((OBJ = GETNUM(database)) != -1) {
|
||||||
/* all done from YAML now */
|
/* all done from YAML now */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -298,7 +298,7 @@ static void read_action_verb_message_nr(FILE* database)
|
||||||
{
|
{
|
||||||
long verb;
|
long verb;
|
||||||
while ((verb = GETNUM(database)) != -1) {
|
while ((verb = GETNUM(database)) != -1) {
|
||||||
/* now declared in YAML */
|
/* now declared in YAML */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +309,7 @@ static void read_conditions(FILE* database)
|
||||||
while ((K = GETNUM(database)) != -1) {
|
while ((K = GETNUM(database)) != -1) {
|
||||||
long loc;
|
long loc;
|
||||||
while ((loc = GETNUM(NULL)) != 0) {
|
while ((loc = GETNUM(NULL)) != 0) {
|
||||||
continue; /* COND is no longer used */
|
continue; /* COND is no longer used */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ static void read_hints(FILE* database)
|
||||||
long K;
|
long K;
|
||||||
while ((K = GETNUM(database)) != -1) {
|
while ((K = GETNUM(database)) != -1) {
|
||||||
for (int I = 1; I <= 4; I++) {
|
for (int I = 1; I <= 4; I++) {
|
||||||
/* consume - actual array-building now done in YAML. */
|
/* consume - actual array-building now done in YAML. */
|
||||||
GETNUM(NULL);
|
GETNUM(NULL);
|
||||||
} /* end loop */
|
} /* end loop */
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ static void read_sound_text(FILE* database)
|
||||||
{
|
{
|
||||||
long K;
|
long K;
|
||||||
while ((K = GETNUM(database)) != -1) {
|
while ((K = GETNUM(database)) != -1) {
|
||||||
/* this stuff is in YAML now */
|
/* this stuff is in YAML now */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
12
init.c
12
init.c
|
@ -26,7 +26,7 @@ void initialise(void)
|
||||||
if (!(locations[i].description.big == 0 || TKEY[i] == 0)) {
|
if (!(locations[i].description.big == 0 || TKEY[i] == 0)) {
|
||||||
int k = TKEY[i];
|
int k = TKEY[i];
|
||||||
if (MOD(labs(TRAVEL[k]), 1000) == 1)
|
if (MOD(labs(TRAVEL[k]), 1000) == 1)
|
||||||
conditions[i] |= (1 << COND_FORCED);
|
conditions[i] |= (1 << COND_FORCED);
|
||||||
}
|
}
|
||||||
game.atloc[i] = 0;
|
game.atloc[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -57,11 +57,11 @@ void initialise(void)
|
||||||
* not yet found, so we know when to close the cave. */
|
* not yet found, so we know when to close the cave. */
|
||||||
game.tally = 0;
|
game.tally = 0;
|
||||||
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
||||||
if (objects[treasure].is_treasure) {
|
if (objects[treasure].is_treasure) {
|
||||||
if (objects[treasure].inventory != 0)
|
if (objects[treasure].inventory != 0)
|
||||||
game.prop[treasure] = -1;
|
game.prop[treasure] = -1;
|
||||||
game.tally = game.tally - game.prop[treasure];
|
game.tally = game.tally - game.prop[treasure];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
|
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
|
||||||
|
|
40
main.c
40
main.c
|
@ -291,8 +291,8 @@ static bool spotted_by_pirate(int i)
|
||||||
int snarfed = 0;
|
int snarfed = 0;
|
||||||
bool movechest = false, robplayer = false;
|
bool movechest = false, robplayer = false;
|
||||||
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
||||||
if (!objects[treasure].is_treasure)
|
if (!objects[treasure].is_treasure)
|
||||||
continue;
|
continue;
|
||||||
/* Pirate won't take pyramid from plover room or dark
|
/* Pirate won't take pyramid from plover room or dark
|
||||||
* room (too easy!). */
|
* room (too easy!). */
|
||||||
if (treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac)) {
|
if (treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac)) {
|
||||||
|
@ -326,9 +326,9 @@ static bool spotted_by_pirate(int i)
|
||||||
}
|
}
|
||||||
if (robplayer) {
|
if (robplayer) {
|
||||||
rspeak(PIRATE_POUNCES);
|
rspeak(PIRATE_POUNCES);
|
||||||
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
|
||||||
if (!objects[treasure].is_treasure)
|
if (!objects[treasure].is_treasure)
|
||||||
continue;
|
continue;
|
||||||
if (!(treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac))) {
|
if (!(treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac))) {
|
||||||
if (AT(treasure) && game.fixed[treasure] == 0)
|
if (AT(treasure) && game.fixed[treasure] == 0)
|
||||||
carry(treasure, game.loc);
|
carry(treasure, game.loc);
|
||||||
|
@ -409,7 +409,7 @@ static bool dwarfmove(void)
|
||||||
kk = TKEY[game.dloc[i]];
|
kk = TKEY[game.dloc[i]];
|
||||||
if (kk != 0)
|
if (kk != 0)
|
||||||
do {
|
do {
|
||||||
game.newloc = T_DESTINATION(TRAVEL[kk]);
|
game.newloc = T_DESTINATION(TRAVEL[kk]);
|
||||||
/* Have we avoided a dwarf encounter? */
|
/* Have we avoided a dwarf encounter? */
|
||||||
bool avoided = (SPECIAL(game.newloc) ||
|
bool avoided = (SPECIAL(game.newloc) ||
|
||||||
!INDEEP(game.newloc) ||
|
!INDEEP(game.newloc) ||
|
||||||
|
@ -559,8 +559,8 @@ static bool playermove(token_t verb, int motion)
|
||||||
++kk; /* go to next travel entry for this location */
|
++kk; /* go to next travel entry for this location */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
/* we've reached the end of travel entries for game.loc */
|
/* we've reached the end of travel entries for game.loc */
|
||||||
kk = k2;
|
kk = k2;
|
||||||
if (kk == 0) {
|
if (kk == 0) {
|
||||||
rspeak(NOT_CONNECTED);
|
rspeak(NOT_CONNECTED);
|
||||||
return true;
|
return true;
|
||||||
|
@ -693,7 +693,7 @@ static bool playermove(token_t verb, int motion)
|
||||||
* and block him. (standard travel entries check for
|
* and block him. (standard travel entries check for
|
||||||
* game.prop(TROLL)=0.) Special stuff for bear. */
|
* game.prop(TROLL)=0.) Special stuff for bear. */
|
||||||
if (game.prop[TROLL] == 1) {
|
if (game.prop[TROLL] == 1) {
|
||||||
pspeak(TROLL,look, 1);
|
pspeak(TROLL, look, 1);
|
||||||
game.prop[TROLL] = 0;
|
game.prop[TROLL] = 0;
|
||||||
move(TROLL2, 0);
|
move(TROLL2, 0);
|
||||||
move(TROLL2 + NOBJECTS, 0);
|
move(TROLL2 + NOBJECTS, 0);
|
||||||
|
@ -723,7 +723,7 @@ static bool playermove(token_t verb, int motion)
|
||||||
}
|
}
|
||||||
} while
|
} while
|
||||||
(false);
|
(false);
|
||||||
|
|
||||||
/* Execute a speak rule */
|
/* Execute a speak rule */
|
||||||
rspeak(L_SPEAK(game.newloc));
|
rspeak(L_SPEAK(game.newloc));
|
||||||
game.newloc = game.loc;
|
game.newloc = game.loc;
|
||||||
|
@ -872,7 +872,7 @@ static void lampcheck(void)
|
||||||
int spk = GET_BATTERIES;
|
int spk = GET_BATTERIES;
|
||||||
if (game.place[BATTERY] == LOC_NOWHERE)spk = LAMP_DIM;
|
if (game.place[BATTERY] == LOC_NOWHERE)spk = LAMP_DIM;
|
||||||
if (game.prop[BATTERY] == DEAD_BATTERIES)
|
if (game.prop[BATTERY] == DEAD_BATTERIES)
|
||||||
spk = MISSING_BATTERIES;
|
spk = MISSING_BATTERIES;
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1027,16 +1027,14 @@ L2607:
|
||||||
game.foobar = (game.foobar > 0 ? -game.foobar : 0);
|
game.foobar = (game.foobar > 0 ? -game.foobar : 0);
|
||||||
++game.turns;
|
++game.turns;
|
||||||
|
|
||||||
/* If a turn threshold has been met, apply penalties and tell
|
/* If a turn threshold has been met, apply penalties and tell
|
||||||
* the player about it. */
|
* the player about it. */
|
||||||
for (int i = 0; i < NTHRESHOLDS; ++i)
|
for (int i = 0; i < NTHRESHOLDS; ++i) {
|
||||||
{
|
if (game.turns == turn_thresholds[i].threshold + 1) {
|
||||||
if (game.turns == turn_thresholds[i].threshold + 1)
|
game.trnluz += turn_thresholds[i].point_loss;
|
||||||
{
|
speak(turn_thresholds[i].message);
|
||||||
game.trnluz += turn_thresholds[i].point_loss;
|
}
|
||||||
speak(turn_thresholds[i].message);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (command.verb == SAY && command.wd2 > 0)
|
if (command.verb == SAY && command.wd2 > 0)
|
||||||
command.verb = 0;
|
command.verb = 0;
|
||||||
|
|
41
misc.c
41
misc.c
|
@ -43,13 +43,12 @@ void packed_to_token(long packed, char token[6])
|
||||||
|
|
||||||
void token_to_packed(char token[6], long* packed)
|
void token_to_packed(char token[6], long* packed)
|
||||||
{
|
{
|
||||||
*packed = 0;
|
*packed = 0;
|
||||||
for (size_t i = 0; i < 5; ++i)
|
for (size_t i = 0; i < 5; ++i) {
|
||||||
{
|
if (token[4 - i] == '\0')
|
||||||
if (token[4 - i] == '\0')
|
continue;
|
||||||
continue;
|
char mapped = ascii_to_advent[(int) token[4 - i]];
|
||||||
char mapped = ascii_to_advent[(int) token[4 - i]];
|
*packed |= (mapped << (6 * i));
|
||||||
*packed |= (mapped << (6 * i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,8 +100,8 @@ void vspeak(const char* msg, va_list ap)
|
||||||
size--;
|
size--;
|
||||||
} else {
|
} else {
|
||||||
long arg = va_arg(ap, long);
|
long arg = va_arg(ap, long);
|
||||||
if (arg == -1)
|
if (arg == -1)
|
||||||
arg = 0;
|
arg = 0;
|
||||||
i++;
|
i++;
|
||||||
// Integer specifier. In order to accommodate the fact that PARMS can have both legitimate integers *and* packed tokens, stringify everything. Future work may eliminate the need for this.
|
// Integer specifier. In order to accommodate the fact that PARMS can have both legitimate integers *and* packed tokens, stringify everything. Future work may eliminate the need for this.
|
||||||
if (msg[i] == 'd') {
|
if (msg[i] == 'd') {
|
||||||
|
@ -173,16 +172,16 @@ void pspeak(vocab_t msg, enum speaktype mode, int skip, ...)
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case touch:
|
case touch:
|
||||||
vspeak(objects[msg].inventory, ap);
|
vspeak(objects[msg].inventory, ap);
|
||||||
break;
|
break;
|
||||||
case look:
|
case look:
|
||||||
vspeak(objects[msg].longs[skip], ap);
|
vspeak(objects[msg].longs[skip], ap);
|
||||||
break;
|
break;
|
||||||
case hear:
|
case hear:
|
||||||
vspeak(objects[msg].sounds[skip], ap);
|
vspeak(objects[msg].sounds[skip], ap);
|
||||||
break;
|
break;
|
||||||
case study:
|
case study:
|
||||||
vspeak(objects[msg].texts[skip], ap);
|
vspeak(objects[msg].texts[skip], ap);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +265,7 @@ char* get_input()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input == NULL) // Got EOF; return with it.
|
if (input == NULL) // Got EOF; return with it.
|
||||||
return(input);
|
return (input);
|
||||||
else if (input[0] == '#') // Ignore comments.
|
else if (input[0] == '#') // Ignore comments.
|
||||||
continue;
|
continue;
|
||||||
else // We have a 'normal' line; leave the loop.
|
else // We have a 'normal' line; leave the loop.
|
||||||
|
@ -298,12 +297,12 @@ bool yes(const char* question, const char* yes_response, const char* no_response
|
||||||
speak(question);
|
speak(question);
|
||||||
|
|
||||||
reply = get_input();
|
reply = get_input();
|
||||||
if (reply == NULL) {
|
if (reply == NULL) {
|
||||||
linenoiseFree(reply);
|
linenoiseFree(reply);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* firstword = (char*) xmalloc(strlen(reply)+1);
|
char* firstword = (char*) xmalloc(strlen(reply) + 1);
|
||||||
sscanf(reply, "%s", firstword);
|
sscanf(reply, "%s", firstword);
|
||||||
|
|
||||||
for (int i = 0; i < (int)strlen(firstword); ++i)
|
for (int i = 0; i < (int)strlen(firstword); ++i)
|
||||||
|
@ -538,7 +537,7 @@ long atdwrf(long where)
|
||||||
long setbit(long bit)
|
long setbit(long bit)
|
||||||
/* Returns 2**bit for use in constructing bit-masks. */
|
/* Returns 2**bit for use in constructing bit-masks. */
|
||||||
{
|
{
|
||||||
return (1 << bit);
|
return (1L << bit);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tstbit(long mask, int bit)
|
bool tstbit(long mask, int bit)
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct save_t {
|
||||||
struct save_t save;
|
struct save_t save;
|
||||||
|
|
||||||
int savefile(FILE *fp)
|
int savefile(FILE *fp)
|
||||||
/* Save game to file. No input or output from user. */
|
/* Save game to file. No input or output from user. */
|
||||||
{
|
{
|
||||||
long i, k;
|
long i, k;
|
||||||
datime(&i, &k);
|
datime(&i, &k);
|
||||||
|
@ -38,7 +38,7 @@ int savefile(FILE *fp)
|
||||||
save.version = VRSION;
|
save.version = VRSION;
|
||||||
memcpy(&save.game, &game, sizeof(struct game_t));
|
memcpy(&save.game, &game, sizeof(struct game_t));
|
||||||
IGNORE(fwrite(&save, sizeof(struct save_t), 1, fp));
|
IGNORE(fwrite(&save, sizeof(struct save_t), 1, fp));
|
||||||
return(0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Suspend and resume */
|
/* Suspend and resume */
|
||||||
|
|
4
score.c
4
score.c
|
@ -38,8 +38,8 @@ long score(enum termination mode)
|
||||||
* Give the poor guy 2 points just for finding each treasure. */
|
* Give the poor guy 2 points just for finding each treasure. */
|
||||||
mxscor = 0;
|
mxscor = 0;
|
||||||
for (int i = 1; i <= NOBJECTS; i++) {
|
for (int i = 1; i <= NOBJECTS; i++) {
|
||||||
if (!objects[i].is_treasure)
|
if (!objects[i].is_treasure)
|
||||||
continue;
|
continue;
|
||||||
if (objects[i].inventory != 0) {
|
if (objects[i].inventory != 0) {
|
||||||
long k = 12;
|
long k = 12;
|
||||||
if (i == CHEST)k = 14;
|
if (i == CHEST)k = 14;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue