Unshadowed k2 into k3 in main.c
Reindented everything
This commit is contained in:
parent
5f44fccf4d
commit
bf2fa227f0
7 changed files with 323 additions and 342 deletions
107
actions.c
107
actions.c
|
@ -28,7 +28,7 @@ static int attack(struct command_t *command)
|
||||||
if (AT(TROLL))obj = obj * NOBJECTS + TROLL;
|
if (AT(TROLL))obj = obj * NOBJECTS + TROLL;
|
||||||
if (AT(OGRE))obj = obj * NOBJECTS + OGRE;
|
if (AT(OGRE))obj = obj * NOBJECTS + OGRE;
|
||||||
if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR)
|
if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR)
|
||||||
obj = obj * NOBJECTS + BEAR;
|
obj = obj * NOBJECTS + BEAR;
|
||||||
if (obj > NOBJECTS) return GO_UNKNOWN;
|
if (obj > NOBJECTS) return GO_UNKNOWN;
|
||||||
if (obj == 0) {
|
if (obj == 0) {
|
||||||
/* Can't attack bird or machine by throwing axe. */
|
/* Can't attack bird or machine by throwing axe. */
|
||||||
|
@ -50,8 +50,8 @@ static int attack(struct command_t *command)
|
||||||
DESTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
spk = BIRD_DEAD;
|
spk = BIRD_DEAD;
|
||||||
} else if (obj == VEND) {
|
} else if (obj == VEND) {
|
||||||
state_change(VEND,
|
state_change(VEND,
|
||||||
game.prop[VEND]==VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
|
game.prop[VEND] == VEND_BLOCKS ? VEND_UNBLOCKS : VEND_BLOCKS);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,17 +85,14 @@ static int attack(struct command_t *command)
|
||||||
* fixed), move rug there (not fixed), and move him there,
|
* fixed), move rug there (not fixed), and move him there,
|
||||||
* too. Then do a null motion to get new description. */
|
* too. Then do a null motion to get new description. */
|
||||||
rspeak(BARE_HANDS_QUERY);
|
rspeak(BARE_HANDS_QUERY);
|
||||||
if(silent_yes())
|
if (silent_yes()) {
|
||||||
{
|
// FIXME: setting wd1 is a workaround for broken logic
|
||||||
// FIXME: setting wd1 is a workaround for broken logic
|
command->wd1 = token_to_packed("Y");
|
||||||
command->wd1 = token_to_packed("Y");
|
} else {
|
||||||
}
|
// FIXME: setting wd1 is a workaround for broken logic
|
||||||
else
|
command->wd1 = token_to_packed("N");
|
||||||
{
|
return GO_CHECKFOO;
|
||||||
// FIXME: setting wd1 is a workaround for broken logic
|
}
|
||||||
command->wd1 = token_to_packed("N");
|
|
||||||
return GO_CHECKFOO;
|
|
||||||
}
|
|
||||||
pspeak(DRAGON, look, 3);
|
pspeak(DRAGON, look, 3);
|
||||||
game.prop[DRAGON] = 1;
|
game.prop[DRAGON] = 1;
|
||||||
game.prop[RUG] = 0;
|
game.prop[RUG] = 0;
|
||||||
|
@ -241,9 +238,9 @@ static int vcarry(token_t verb, token_t obj)
|
||||||
spk = YOU_JOKING;
|
spk = YOU_JOKING;
|
||||||
if (obj == PLANT && game.prop[PLANT] <= 0)spk = DEEP_ROOTS;
|
if (obj == PLANT && game.prop[PLANT] <= 0)spk = DEEP_ROOTS;
|
||||||
if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
|
if (obj == BEAR && game.prop[BEAR] == SITTING_BEAR)
|
||||||
spk = BEAR_CHAINED;
|
spk = BEAR_CHAINED;
|
||||||
if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
|
if (obj == CHAIN && game.prop[BEAR] != UNTAMED_BEAR)
|
||||||
spk = STILL_LOCKED;
|
spk = STILL_LOCKED;
|
||||||
if (obj == URN)spk = URN_NOBUDGE;
|
if (obj == URN)spk = URN_NOBUDGE;
|
||||||
if (obj == CAVITY)spk = DOUGHNUT_HOLES;
|
if (obj == CAVITY)spk = DOUGHNUT_HOLES;
|
||||||
if (obj == BLOOD)spk = FEW_DROPS;
|
if (obj == BLOOD)spk = FEW_DROPS;
|
||||||
|
@ -264,7 +261,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;
|
||||||
|
@ -311,9 +308,9 @@ static int chain(token_t verb)
|
||||||
if (verb != LOCK) {
|
if (verb != LOCK) {
|
||||||
spk = CHAIN_UNLOCKED;
|
spk = CHAIN_UNLOCKED;
|
||||||
if (game.prop[BEAR] == UNTAMED_BEAR)
|
if (game.prop[BEAR] == UNTAMED_BEAR)
|
||||||
spk = BEAR_BLOCKS;
|
spk = BEAR_BLOCKS;
|
||||||
if (game.prop[CHAIN] == 0)
|
if (game.prop[CHAIN] == 0)
|
||||||
spk = ALREADY_UNLOCKED;
|
spk = ALREADY_UNLOCKED;
|
||||||
if (spk != CHAIN_UNLOCKED) {
|
if (spk != CHAIN_UNLOCKED) {
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
|
@ -321,22 +318,22 @@ static int chain(token_t verb)
|
||||||
game.prop[CHAIN] = 0;
|
game.prop[CHAIN] = 0;
|
||||||
game.fixed[CHAIN] = 0;
|
game.fixed[CHAIN] = 0;
|
||||||
if (game.prop[BEAR] != BEAR_DEAD)
|
if (game.prop[BEAR] != BEAR_DEAD)
|
||||||
game.prop[BEAR] = CONTENTED_BEAR;
|
game.prop[BEAR] = CONTENTED_BEAR;
|
||||||
/* FIXME: Arithmetic on state numbers */
|
/* FIXME: Arithmetic on state numbers */
|
||||||
game.fixed[BEAR] = 2 - game.prop[BEAR];
|
game.fixed[BEAR] = 2 - game.prop[BEAR];
|
||||||
} else {
|
} else {
|
||||||
spk = CHAIN_LOCKED;
|
spk = CHAIN_LOCKED;
|
||||||
if (game.prop[CHAIN] != 0)
|
if (game.prop[CHAIN] != 0)
|
||||||
spk = ALREADY_LOCKED;
|
spk = ALREADY_LOCKED;
|
||||||
if (game.loc != objects[CHAIN].plac)
|
if (game.loc != objects[CHAIN].plac)
|
||||||
spk = NO_LOCKSITE;
|
spk = NO_LOCKSITE;
|
||||||
if (spk != CHAIN_LOCKED) {
|
if (spk != CHAIN_LOCKED) {
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
game.prop[CHAIN] = 2;
|
game.prop[CHAIN] = 2;
|
||||||
if (TOTING(CHAIN))
|
if (TOTING(CHAIN))
|
||||||
drop(CHAIN, game.loc);
|
drop(CHAIN, game.loc);
|
||||||
game.fixed[CHAIN] = -1;
|
game.fixed[CHAIN] = -1;
|
||||||
}
|
}
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
|
@ -410,12 +407,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -472,7 +469,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;
|
||||||
}
|
}
|
||||||
|
@ -481,7 +478,7 @@ static int extinguish(token_t verb, int obj)
|
||||||
game.prop[URN] = game.prop[URN] / 2;
|
game.prop[URN] = game.prop[URN] / 2;
|
||||||
spk = URN_DARK;
|
spk = URN_DARK;
|
||||||
} else if (obj == LAMP) {
|
} else if (obj == LAMP) {
|
||||||
state_change(LAMP, LAMP_DARK);
|
state_change(LAMP, LAMP_DARK);
|
||||||
spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
|
spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
|
||||||
} else if (obj == DRAGON || obj == VOLCANO)
|
} else if (obj == DRAGON || obj == VOLCANO)
|
||||||
spk = BEYOND_POWER;
|
spk = BEYOND_POWER;
|
||||||
|
@ -512,9 +509,9 @@ static int feed(token_t verb, token_t obj)
|
||||||
}
|
}
|
||||||
} else if (obj == BEAR) {
|
} else if (obj == BEAR) {
|
||||||
if (game.prop[BEAR] == UNTAMED_BEAR)
|
if (game.prop[BEAR] == UNTAMED_BEAR)
|
||||||
spk = NOTHING_EDIBLE;
|
spk = NOTHING_EDIBLE;
|
||||||
if (game.prop[BEAR] == BEAR_DEAD)
|
if (game.prop[BEAR] == BEAR_DEAD)
|
||||||
spk = RIDICULOUS_ATTEMPT;
|
spk = RIDICULOUS_ATTEMPT;
|
||||||
if (HERE(FOOD)) {
|
if (HERE(FOOD)) {
|
||||||
DESTROY(FOOD);
|
DESTROY(FOOD);
|
||||||
game.prop[BEAR] = SITTING_BEAR;
|
game.prop[BEAR] = SITTING_BEAR;
|
||||||
|
@ -580,7 +577,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))
|
||||||
|
@ -666,7 +663,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;
|
||||||
}
|
}
|
||||||
|
@ -689,7 +686,7 @@ static int light(token_t verb, token_t obj)
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
state_change(LAMP, LAMP_BRIGHT);
|
state_change(LAMP, LAMP_BRIGHT);
|
||||||
if (game.wzdark)
|
if (game.wzdark)
|
||||||
return GO_TOP;
|
return GO_TOP;
|
||||||
else
|
else
|
||||||
|
@ -706,21 +703,21 @@ 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;
|
||||||
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, 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)
|
||||||
DESTROY(BIRD);
|
DESTROY(BIRD);
|
||||||
}
|
}
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
|
@ -763,8 +760,8 @@ static int lock(token_t verb, token_t obj)
|
||||||
if (!game.panic)game.clock2 = PANICTIME;
|
if (!game.panic)game.clock2 = PANICTIME;
|
||||||
game.panic = true;
|
game.panic = true;
|
||||||
} else {
|
} else {
|
||||||
state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
|
state_change(GRATE, (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1005,7 +1002,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;
|
||||||
|
@ -1086,7 +1083,7 @@ int action(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). */
|
||||||
|
@ -1150,7 +1147,7 @@ int action(struct command_t *command)
|
||||||
case BRIEF:
|
case BRIEF:
|
||||||
return brief();
|
return brief();
|
||||||
case READ:
|
case READ:
|
||||||
command->obj = INTRANSITIVE;
|
command->obj = INTRANSITIVE;
|
||||||
return read(*command);
|
return read(*command);
|
||||||
case BREAK:
|
case BREAK:
|
||||||
return GO_UNKNOWN;
|
return GO_UNKNOWN;
|
||||||
|
@ -1166,8 +1163,8 @@ int action(struct command_t *command)
|
||||||
return listen();
|
return listen();
|
||||||
case PART:
|
case PART:
|
||||||
return reservoir();
|
return reservoir();
|
||||||
default:
|
default:
|
||||||
BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
|
BUG(INTRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* FALLTHRU */
|
/* FALLTHRU */
|
||||||
|
@ -1198,7 +1195,7 @@ int action(struct command_t *command)
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
case GO: {
|
case GO: {
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
@ -1213,7 +1210,7 @@ int action(struct command_t *command)
|
||||||
case RUB:
|
case RUB:
|
||||||
return rub(command->verb, command->obj);
|
return rub(command->verb, command->obj);
|
||||||
case THROW:
|
case THROW:
|
||||||
return throw(command);
|
return throw (command);
|
||||||
case QUIT: {
|
case QUIT: {
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
|
@ -1261,11 +1258,11 @@ int action(struct command_t *command)
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
case PART:
|
case PART:
|
||||||
return reservoir();
|
return reservoir();
|
||||||
default:
|
default:
|
||||||
BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
|
BUG(TRANSITIVE_ACTION_VERB_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
case unknown:
|
case unknown:
|
||||||
/* Unknown verb, couldn't deduce object - might need hint */
|
/* Unknown verb, couldn't deduce object - might need hint */
|
||||||
rspeak(WHAT_DO, command->wd1, command->wd1x);
|
rspeak(WHAT_DO, command->wd1, command->wd1x);
|
||||||
|
|
16
cheat.c
16
cheat.c
|
@ -58,9 +58,8 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (savefilename == NULL)
|
if (savefilename == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
usage, argv[0]);
|
usage, argv[0]);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -84,21 +83,20 @@ int main(int argc, char *argv[])
|
||||||
game.newloc = LOC_START;
|
game.newloc = LOC_START;
|
||||||
game.loc = LOC_START;
|
game.loc = LOC_START;
|
||||||
game.limit = GAMELIMIT;
|
game.limit = GAMELIMIT;
|
||||||
|
|
||||||
// apply cheats
|
// apply cheats
|
||||||
game.numdie = numdie;
|
game.numdie = numdie;
|
||||||
game.saved = saved;
|
game.saved = saved;
|
||||||
|
|
||||||
fp = fopen(savefilename, WRITE_MODE);
|
fp = fopen(savefilename, WRITE_MODE);
|
||||||
if (fp == NULL)
|
if (fp == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Can't open file %s. Exiting.\n", savefilename);
|
"Can't open file %s. Exiting.\n", savefilename);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
savefile(fp, version);
|
savefile(fp, version);
|
||||||
|
|
||||||
printf("cheat: %s created.\n", savefilename);
|
printf("cheat: %s created.\n", savefilename);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
12
init.c
12
init.c
|
@ -25,7 +25,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 (T_TERMINATE(travel[k]))
|
if (T_TERMINATE(travel[k]))
|
||||||
conditions[i] |= (1 << COND_FORCED);
|
conditions[i] |= (1 << COND_FORCED);
|
||||||
}
|
}
|
||||||
game.atloc[i] = 0;
|
game.atloc[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -56,11 +56,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
|
||||||
|
|
141
main.c
141
main.c
|
@ -170,7 +170,7 @@ static bool fallback_handler(char *buf)
|
||||||
// autogenerated, so don't charge user time for it.
|
// autogenerated, so don't charge user time for it.
|
||||||
--game.turns;
|
--game.turns;
|
||||||
// here we reconfigure any global game state that uses random numbers
|
// here we reconfigure any global game state that uses random numbers
|
||||||
make_zzword(game.zzword);
|
make_zzword(game.zzword);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -283,8 +283,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)) {
|
||||||
|
@ -318,9 +318,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);
|
||||||
|
@ -401,7 +401,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) ||
|
||||||
|
@ -417,7 +417,7 @@ static bool dwarfmove(void)
|
||||||
}
|
}
|
||||||
++kk;
|
++kk;
|
||||||
} while
|
} while
|
||||||
(!travel[kk - 1].stop);
|
(!travel[kk - 1].stop);
|
||||||
tk[j] = game.odloc[i];
|
tk[j] = game.odloc[i];
|
||||||
if (j >= 2)
|
if (j >= 2)
|
||||||
--j;
|
--j;
|
||||||
|
@ -551,8 +551,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;
|
||||||
|
@ -619,43 +619,43 @@ static bool playermove(token_t verb, int motion)
|
||||||
long cond = T_CONDITION(travel[kk]);
|
long cond = T_CONDITION(travel[kk]);
|
||||||
long arg = MOD(cond, 100);
|
long arg = MOD(cond, 100);
|
||||||
if (!SPECIAL(cond)) {
|
if (!SPECIAL(cond)) {
|
||||||
/* YAML N and [pct N] conditionals */
|
/* YAML N and [pct N] conditionals */
|
||||||
if (cond <= 100) {
|
if (cond <= 100) {
|
||||||
if (cond == 0 || PCT(cond))
|
if (cond == 0 || PCT(cond))
|
||||||
break;
|
break;
|
||||||
/* else fall through */
|
/* else fall through */
|
||||||
}
|
}
|
||||||
/* YAML [with OBJ] clause */
|
/* YAML [with OBJ] clause */
|
||||||
if (TOTING(arg) || (cond > 200 && AT(arg)))
|
if (TOTING(arg) || (cond > 200 && AT(arg)))
|
||||||
break;
|
break;
|
||||||
/* else fall through to check [not OBJ STATE] */
|
/* else fall through to check [not OBJ STATE] */
|
||||||
} else if (game.prop[arg] != cond / 100 - 3)
|
} else if (game.prop[arg] != cond / 100 - 3)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* We arrive here on conditional failure.
|
/* We arrive here on conditional failure.
|
||||||
* Skip to next non-matching destination */
|
* Skip to next non-matching destination */
|
||||||
long k2 = kk;
|
long k3 = kk;
|
||||||
do {
|
do {
|
||||||
if (travel[k2].stop)
|
if (travel[k3].stop)
|
||||||
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
||||||
++k2;
|
++k3;
|
||||||
} while
|
} while
|
||||||
(T_HIGH(travel[kk]) == T_HIGH(travel[k2]));
|
(T_HIGH(travel[kk]) == T_HIGH(travel[k3]));
|
||||||
kk = k2;
|
kk = k3;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Found an eligible rule, now execute it */
|
/* Found an eligible rule, now execute it */
|
||||||
game.newloc = T_DESTINATION(travel[kk]);
|
game.newloc = T_DESTINATION(travel[kk]);
|
||||||
if (!SPECIAL(game.newloc))
|
if (!SPECIAL(game.newloc))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (game.newloc > 500) {
|
if (game.newloc > 500) {
|
||||||
/* 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;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
game.newloc -= SPECIALBASE;
|
game.newloc -= SPECIALBASE;
|
||||||
switch (game.newloc) {
|
switch (game.newloc) {
|
||||||
case 1:
|
case 1:
|
||||||
/* Travel 301. Plover-alcove passage. Can carry only
|
/* Travel 301. Plover-alcove passage. Can carry only
|
||||||
|
@ -676,13 +676,13 @@ static bool playermove(token_t verb, int motion)
|
||||||
* to get it out. Having dropped it, go back and
|
* to get it out. Having dropped it, go back and
|
||||||
* pretend he wasn't carrying it after all. */
|
* pretend he wasn't carrying it after all. */
|
||||||
drop(EMERALD, game.loc);
|
drop(EMERALD, game.loc);
|
||||||
k2 = kk;
|
k2 = kk;
|
||||||
do {
|
do {
|
||||||
if (travel[k2].stop)
|
if (travel[k2].stop)
|
||||||
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION); // LCOV_EXCL_LINE
|
||||||
++k2;
|
++k2;
|
||||||
} while
|
} while
|
||||||
(T_HIGH(travel[kk]) == T_HIGH(travel[k2]));
|
(T_HIGH(travel[kk]) == T_HIGH(travel[k2]));
|
||||||
kk = k2;
|
kk = k2;
|
||||||
continue; /* goto L12 */
|
continue; /* goto L12 */
|
||||||
case 3:
|
case 3:
|
||||||
|
@ -696,7 +696,7 @@ static bool playermove(token_t verb, 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] == 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);
|
||||||
|
@ -719,8 +719,8 @@ static bool playermove(token_t verb, int motion)
|
||||||
croak();
|
croak();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
BUG(SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
|
BUG(SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break; /* Leave L12 loop */
|
break; /* Leave L12 loop */
|
||||||
|
@ -778,7 +778,7 @@ static bool closecheck(void)
|
||||||
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
|
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
|
||||||
juggle(CHASM);
|
juggle(CHASM);
|
||||||
if (game.prop[BEAR] != BEAR_DEAD)
|
if (game.prop[BEAR] != BEAR_DEAD)
|
||||||
DESTROY(BEAR);
|
DESTROY(BEAR);
|
||||||
game.prop[CHAIN] = 0;
|
game.prop[CHAIN] = 0;
|
||||||
game.fixed[CHAIN] = 0;
|
game.fixed[CHAIN] = 0;
|
||||||
game.prop[AXE] = 0;
|
game.prop[AXE] = 0;
|
||||||
|
@ -871,7 +871,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1016,22 +1016,21 @@ L2600:
|
||||||
game.knfloc = 0;
|
game.knfloc = 0;
|
||||||
|
|
||||||
/* This is where we get a new command from the user */
|
/* This is where we get a new command from the user */
|
||||||
char* input;
|
char* input;
|
||||||
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);
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (strcmp(input, "") != 0)
|
||||||
if (strcmp(input, "") != 0)
|
break;
|
||||||
break;
|
}
|
||||||
}
|
long tokens[4];
|
||||||
long tokens[4];
|
tokenize(input, tokens);
|
||||||
tokenize(input, tokens);
|
command.wd1 = tokens[0];
|
||||||
command.wd1 = tokens[0];
|
|
||||||
command.wd1x = tokens[1];
|
command.wd1x = tokens[1];
|
||||||
command.wd2 = tokens[2];
|
command.wd2 = tokens[2];
|
||||||
command.wd2x = tokens[3];
|
command.wd2x = tokens[3];
|
||||||
|
@ -1043,16 +1042,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;
|
||||||
|
@ -1066,12 +1063,12 @@ L2607:
|
||||||
} else
|
} else
|
||||||
lampcheck();
|
lampcheck();
|
||||||
|
|
||||||
char word1[6];
|
char word1[6];
|
||||||
char word2[6];
|
char word2[6];
|
||||||
packed_to_token(command.wd1, word1);
|
packed_to_token(command.wd1, word1);
|
||||||
packed_to_token(command.wd2, word2);
|
packed_to_token(command.wd2, word2);
|
||||||
V1 = get_vocab_id(word1);
|
V1 = get_vocab_id(word1);
|
||||||
V2 = get_vocab_id(word2);
|
V2 = get_vocab_id(word2);
|
||||||
if (V1 == ENTER && (V2 == STREAM || V2 == 1000 + WATER)) {
|
if (V1 == ENTER && (V2 == STREAM || V2 == 1000 + WATER)) {
|
||||||
if (LIQLOC(game.loc) == WATER) {
|
if (LIQLOC(game.loc) == WATER) {
|
||||||
rspeak(FEET_WET);
|
rspeak(FEET_WET);
|
||||||
|
@ -1089,10 +1086,10 @@ L2607:
|
||||||
if (!((V1 != 1000 + WATER && V1 != 1000 + OIL) ||
|
if (!((V1 != 1000 + WATER && V1 != 1000 + OIL) ||
|
||||||
(V2 != 1000 + PLANT && V2 != 1000 + DOOR))) {
|
(V2 != 1000 + PLANT && V2 != 1000 + DOOR))) {
|
||||||
if (AT(V2 - 1000))
|
if (AT(V2 - 1000))
|
||||||
command.wd2 = token_to_packed("POUR");
|
command.wd2 = token_to_packed("POUR");
|
||||||
}
|
}
|
||||||
if (V1 == 1000 + CAGE && V2 == 1000 + BIRD && HERE(CAGE) && HERE(BIRD))
|
if (V1 == 1000 + CAGE && V2 == 1000 + BIRD && HERE(CAGE) && HERE(BIRD))
|
||||||
command.wd1 = token_to_packed("CATCH");
|
command.wd1 = token_to_packed("CATCH");
|
||||||
}
|
}
|
||||||
L2620:
|
L2620:
|
||||||
if (wordeq(command.wd1, token_to_packed("WEST"))) {
|
if (wordeq(command.wd1, token_to_packed("WEST"))) {
|
||||||
|
@ -1105,8 +1102,8 @@ L2620:
|
||||||
rspeak(GO_UNNEEDED);
|
rspeak(GO_UNNEEDED);
|
||||||
}
|
}
|
||||||
Lookup:
|
Lookup:
|
||||||
packed_to_token(command.wd1, word1);
|
packed_to_token(command.wd1, word1);
|
||||||
defn = get_vocab_id(word1);
|
defn = get_vocab_id(word1);
|
||||||
if (defn == -1) {
|
if (defn == -1) {
|
||||||
/* Gee, I don't understand. */
|
/* Gee, I don't understand. */
|
||||||
if (fallback_handler(input))
|
if (fallback_handler(input))
|
||||||
|
@ -1172,7 +1169,7 @@ Laction:
|
||||||
default:
|
default:
|
||||||
BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH); // LCOV_EXCL_LINE
|
BUG(ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH); // LCOV_EXCL_LINE
|
||||||
}
|
}
|
||||||
linenoiseFree(input);
|
linenoiseFree(input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
375
misc.c
375
misc.c
|
@ -11,47 +11,47 @@
|
||||||
#include "dungeon.h"
|
#include "dungeon.h"
|
||||||
|
|
||||||
const char new_advent_to_ascii[] = {
|
const char new_advent_to_ascii[] = {
|
||||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||||
'X', 'Y', 'Z', '\0', '\0', '\0', '\0', '\0',
|
'X', 'Y', 'Z', '\0', '\0', '\0', '\0', '\0',
|
||||||
};
|
};
|
||||||
|
|
||||||
const char new_ascii_to_advent[] = {
|
const char new_ascii_to_advent[] = {
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
|
|
||||||
0, 1, 2, 3, 4, 5, 6, 7,
|
0, 1, 2, 3, 4, 5, 6, 7,
|
||||||
8, 9, 10, 11, 12, 13, 14, 15,
|
8, 9, 10, 11, 12, 13, 14, 15,
|
||||||
16, 17, 18, 19, 20, 21, 22, 23,
|
16, 17, 18, 19, 20, 21, 22, 23,
|
||||||
24, 25, 26, 27, 28, 29, 30, 31,
|
24, 25, 26, 27, 28, 29, 30, 31,
|
||||||
32, 33, 34, 35, 36, 37, 38, 39,
|
32, 33, 34, 35, 36, 37, 38, 39,
|
||||||
40, 41, 42, 43, 44, 45, 46, 47,
|
40, 41, 42, 43, 44, 45, 46, 47,
|
||||||
48, 49, 50, 51, 52, 53, 54, 55,
|
48, 49, 50, 51, 52, 53, 54, 55,
|
||||||
56, 57, 58, 59, 60, 61, 62, 63,
|
56, 57, 58, 59, 60, 61, 62, 63,
|
||||||
|
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
63, 63, 63, 63, 63, 63, 63, 63,
|
63, 63, 63, 63, 63, 63, 63, 63,
|
||||||
};
|
};
|
||||||
|
|
||||||
char* xstrdup(const char* s)
|
char* xstrdup(const char* s)
|
||||||
{
|
{
|
||||||
char* ptr = strdup(s);
|
char* ptr = strdup(s);
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
// exclude from coverage analysis because we can't simulate an out of memory error in testing
|
// exclude from coverage analysis because we can't simulate an out of memory error in testing
|
||||||
fprintf(stderr, "Out of memory!\n");
|
fprintf(stderr, "Out of memory!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return(ptr);
|
return (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* xmalloc(size_t size)
|
void* xmalloc(size_t size)
|
||||||
|
@ -62,7 +62,7 @@ void* xmalloc(size_t size)
|
||||||
// exclude from coverage analysis because we can't simulate an out of memory error in testing
|
// exclude from coverage analysis because we can't simulate an out of memory error in testing
|
||||||
fprintf(stderr, "Out of memory!\n");
|
fprintf(stderr, "Out of memory!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
return (ptr);
|
return (ptr);
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ void packed_to_token(long packed, char token[6])
|
||||||
{
|
{
|
||||||
// Unpack and map back to ASCII.
|
// Unpack and map back to ASCII.
|
||||||
for (int i = 0; i < 5; ++i) {
|
for (int i = 0; i < 5; ++i) {
|
||||||
char advent = (packed >> i * 6) & 63;
|
char advent = (packed >> i * 6) & 63;
|
||||||
token[i] = new_advent_to_ascii[(int) advent];
|
token[i] = new_advent_to_ascii[(int) advent];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,51 +89,50 @@ void packed_to_token(long packed, char token[6])
|
||||||
|
|
||||||
long token_to_packed(const char token[6])
|
long token_to_packed(const char token[6])
|
||||||
{
|
{
|
||||||
size_t t_len = strlen(token);
|
size_t t_len = strlen(token);
|
||||||
long packed = 0;
|
long packed = 0;
|
||||||
for (size_t i = 0; i < t_len; ++i)
|
for (size_t i = 0; i < t_len; ++i) {
|
||||||
{
|
char mapped = new_ascii_to_advent[(int) token[i]];
|
||||||
char mapped = new_ascii_to_advent[(int) token[i]];
|
packed |= (mapped << (6 * i));
|
||||||
packed |= (mapped << (6 * i));
|
|
||||||
}
|
}
|
||||||
return(packed);
|
return (packed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tokenize(char* raw, long tokens[4])
|
void tokenize(char* raw, long tokens[4])
|
||||||
{
|
{
|
||||||
// set each token to 0
|
// set each token to 0
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
tokens[i] = 0;
|
tokens[i] = 0;
|
||||||
|
|
||||||
// grab the first two words
|
|
||||||
char* words[2];
|
|
||||||
words[0] = (char*) xmalloc(strlen(raw));
|
|
||||||
words[1] = (char*) xmalloc(strlen(raw));
|
|
||||||
int word_count = sscanf(raw, "%s%s", words[0], words[1]);
|
|
||||||
|
|
||||||
// make space for substrings and zero it out
|
// grab the first two words
|
||||||
char chunk_data[][6] = {
|
char* words[2];
|
||||||
{"\0\0\0\0\0"},
|
words[0] = (char*) xmalloc(strlen(raw));
|
||||||
{"\0\0\0\0\0"},
|
words[1] = (char*) xmalloc(strlen(raw));
|
||||||
{"\0\0\0\0\0"},
|
int word_count = sscanf(raw, "%s%s", words[0], words[1]);
|
||||||
{"\0\0\0\0\0"},
|
|
||||||
};
|
|
||||||
|
|
||||||
// break the words into up to 4 5-char substrings
|
// make space for substrings and zero it out
|
||||||
sscanf(words[0], "%5s%5s", chunk_data[0], chunk_data[1]);
|
char chunk_data[][6] = {
|
||||||
if (word_count == 2)
|
{"\0\0\0\0\0"},
|
||||||
sscanf(words[1], "%5s%5s", chunk_data[2], chunk_data[3]);
|
{"\0\0\0\0\0"},
|
||||||
free(words[0]);
|
{"\0\0\0\0\0"},
|
||||||
free(words[1]);
|
{"\0\0\0\0\0"},
|
||||||
|
};
|
||||||
|
|
||||||
// uppercase all the substrings
|
// break the words into up to 4 5-char substrings
|
||||||
for (int i = 0; i < 4; ++i)
|
sscanf(words[0], "%5s%5s", chunk_data[0], chunk_data[1]);
|
||||||
for (unsigned int j = 0; j < strlen(chunk_data[i]); ++j)
|
if (word_count == 2)
|
||||||
chunk_data[i][j] = (char) toupper(chunk_data[i][j]);
|
sscanf(words[1], "%5s%5s", chunk_data[2], chunk_data[3]);
|
||||||
|
free(words[0]);
|
||||||
|
free(words[1]);
|
||||||
|
|
||||||
// pack the substrings
|
// uppercase all the substrings
|
||||||
for (int i = 0; i < 4; ++i)
|
for (int i = 0; i < 4; ++i)
|
||||||
tokens[i] = token_to_packed(chunk_data[i]);
|
for (unsigned int j = 0; j < strlen(chunk_data[i]); ++j)
|
||||||
|
chunk_data[i][j] = (char) toupper(chunk_data[i][j]);
|
||||||
|
|
||||||
|
// pack the substrings
|
||||||
|
for (int i = 0; i < 4; ++i)
|
||||||
|
tokens[i] = token_to_packed(chunk_data[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hide the fact that wods are corrently packed longs */
|
/* Hide the fact that wods are corrently packed longs */
|
||||||
|
@ -184,8 +183,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') {
|
||||||
|
@ -256,19 +255,19 @@ 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].descriptions[skip], ap);
|
vspeak(objects[msg].descriptions[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;
|
||||||
case change:
|
case change:
|
||||||
vspeak(objects[msg].changes[skip], ap);
|
vspeak(objects[msg].changes[skip], ap);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
@ -294,19 +293,18 @@ void echo_input(FILE* destination, char* input_prompt, char* input)
|
||||||
|
|
||||||
int word_count(char* s)
|
int word_count(char* s)
|
||||||
{
|
{
|
||||||
char* copy = xstrdup(s);
|
char* copy = xstrdup(s);
|
||||||
char delims[] = " \t";
|
char delims[] = " \t";
|
||||||
int count = 0;
|
int count = 0;
|
||||||
char* word;
|
char* word;
|
||||||
|
|
||||||
word = strtok(copy, delims);
|
word = strtok(copy, delims);
|
||||||
while(word != NULL)
|
while (word != NULL) {
|
||||||
{
|
word = strtok(NULL, delims);
|
||||||
word = strtok(NULL, delims);
|
++count;
|
||||||
++count;
|
|
||||||
}
|
}
|
||||||
free(copy);
|
free(copy);
|
||||||
return(count);
|
return (count);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* get_input()
|
char* get_input()
|
||||||
|
@ -328,17 +326,17 @@ char* get_input()
|
||||||
input = NULL;
|
input = NULL;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (isatty(0))
|
if (isatty(0))
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
// Should be unreachable in tests, as they will use a non-interactive shell.
|
// Should be unreachable in tests, as they will use a non-interactive shell.
|
||||||
printf("%s", input_prompt);
|
printf("%s", input_prompt);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
ssize_t numread = getline(&input, &n, stdin);
|
ssize_t numread = getline(&input, &n, stdin);
|
||||||
if (numread == -1) // Got EOF; return with it.
|
if (numread == -1) // Got EOF; return with it.
|
||||||
return(NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
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.
|
||||||
|
@ -361,43 +359,43 @@ char* get_input()
|
||||||
|
|
||||||
bool silent_yes()
|
bool silent_yes()
|
||||||
{
|
{
|
||||||
char* reply;
|
char* reply;
|
||||||
bool outcome;
|
bool outcome;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
reply = get_input();
|
reply = get_input();
|
||||||
if (reply == NULL) {
|
if (reply == NULL) {
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
// Should be unreachable. Reply should never be NULL
|
// Should be unreachable. Reply should never be NULL
|
||||||
linenoiseFree(reply);
|
linenoiseFree(reply);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
}
|
||||||
|
|
||||||
|
char* firstword = (char*) xmalloc(strlen(reply) + 1);
|
||||||
|
sscanf(reply, "%s", firstword);
|
||||||
|
|
||||||
|
for (int i = 0; i < (int)strlen(firstword); ++i)
|
||||||
|
firstword[i] = tolower(firstword[i]);
|
||||||
|
|
||||||
|
int yes = strncmp("yes", firstword, sizeof("yes") - 1);
|
||||||
|
int y = strncmp("y", firstword, sizeof("y") - 1);
|
||||||
|
int no = strncmp("no", firstword, sizeof("no") - 1);
|
||||||
|
int n = strncmp("n", firstword, sizeof("n") - 1);
|
||||||
|
|
||||||
|
free(firstword);
|
||||||
|
|
||||||
|
if (yes == 0 || y == 0) {
|
||||||
|
outcome = true;
|
||||||
|
break;
|
||||||
|
} else if (no == 0 || n == 0) {
|
||||||
|
outcome = false;
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
rspeak(PLEASE_ANSWER);
|
||||||
}
|
}
|
||||||
|
linenoiseFree(reply);
|
||||||
char* firstword = (char*) xmalloc(strlen(reply)+1);
|
return (outcome);
|
||||||
sscanf(reply, "%s", firstword);
|
|
||||||
|
|
||||||
for (int i = 0; i < (int)strlen(firstword); ++i)
|
|
||||||
firstword[i] = tolower(firstword[i]);
|
|
||||||
|
|
||||||
int yes = strncmp("yes", firstword, sizeof("yes") - 1);
|
|
||||||
int y = strncmp("y", firstword, sizeof("y") - 1);
|
|
||||||
int no = strncmp("no", firstword, sizeof("no") - 1);
|
|
||||||
int n = strncmp("n", firstword, sizeof("n") - 1);
|
|
||||||
|
|
||||||
free(firstword);
|
|
||||||
|
|
||||||
if (yes == 0 || y == 0) {
|
|
||||||
outcome = true;
|
|
||||||
break;
|
|
||||||
} else if (no == 0 || n == 0) {
|
|
||||||
outcome = false;
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
rspeak(PLEASE_ANSWER);
|
|
||||||
}
|
|
||||||
linenoiseFree(reply);
|
|
||||||
return (outcome);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -417,10 +415,10 @@ bool yes(const char* question, const char* yes_response, const char* no_response
|
||||||
// Should be unreachable. Reply should never be NULL
|
// Should be unreachable. Reply should never be NULL
|
||||||
linenoiseFree(reply);
|
linenoiseFree(reply);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
@ -434,7 +432,7 @@ bool yes(const char* question, const char* yes_response, const char* no_response
|
||||||
free(firstword);
|
free(firstword);
|
||||||
|
|
||||||
if (yes == 0 || y == 0) {
|
if (yes == 0 || y == 0) {
|
||||||
speak(yes_response);
|
speak(yes_response);
|
||||||
outcome = true;
|
outcome = true;
|
||||||
break;
|
break;
|
||||||
} else if (no == 0 || n == 0) {
|
} else if (no == 0 || n == 0) {
|
||||||
|
@ -453,89 +451,81 @@ bool yes(const char* question, const char* yes_response, const char* no_response
|
||||||
int get_motion_vocab_id(const char* word)
|
int get_motion_vocab_id(const char* word)
|
||||||
// Return the first motion number that has 'word' as one of its words.
|
// Return the first motion number that has 'word' as one of its words.
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NMOTIONS; ++i)
|
for (int i = 0; i < NMOTIONS; ++i) {
|
||||||
{
|
for (int j = 0; j < motions[i].words.n; ++j) {
|
||||||
for (int j = 0; j < motions[i].words.n; ++j)
|
if (strcasecmp(word, motions[i].words.strs[j]) == 0)
|
||||||
{
|
return (i);
|
||||||
if (strcasecmp(word, motions[i].words.strs[j]) == 0)
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_object_vocab_id(const char* word)
|
int get_object_vocab_id(const char* word)
|
||||||
// Return the first object number that has 'word' as one of its words.
|
// Return the first object number that has 'word' as one of its words.
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NOBJECTS + 1; ++i) // FIXME: the + 1 should go when 1-indexing for objects is removed
|
for (int i = 0; i < NOBJECTS + 1; ++i) { // FIXME: the + 1 should go when 1-indexing for objects is removed
|
||||||
{
|
for (int j = 0; j < objects[i].words.n; ++j) {
|
||||||
for (int j = 0; j < objects[i].words.n; ++j)
|
if (strcasecmp(word, objects[i].words.strs[j]) == 0)
|
||||||
{
|
return (i);
|
||||||
if (strcasecmp(word, objects[i].words.strs[j]) == 0)
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_action_vocab_id(const char* word)
|
int get_action_vocab_id(const char* word)
|
||||||
// Return the first motion number that has 'word' as one of its words.
|
// Return the first motion number that has 'word' as one of its words.
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NACTIONS; ++i)
|
for (int i = 0; i < NACTIONS; ++i) {
|
||||||
{
|
for (int j = 0; j < actions[i].words.n; ++j) {
|
||||||
for (int j = 0; j < actions[i].words.n; ++j)
|
if (strcasecmp(word, actions[i].words.strs[j]) == 0)
|
||||||
{
|
return (i);
|
||||||
if (strcasecmp(word, actions[i].words.strs[j]) == 0)
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_special_vocab_id(const char* word)
|
int get_special_vocab_id(const char* word)
|
||||||
// Return the first special number that has 'word' as one of its words.
|
// Return the first special number that has 'word' as one of its words.
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NSPECIALS; ++i)
|
for (int i = 0; i < NSPECIALS; ++i) {
|
||||||
{
|
for (int j = 0; j < specials[i].words.n; ++j) {
|
||||||
for (int j = 0; j < specials[i].words.n; ++j)
|
if (strcasecmp(word, specials[i].words.strs[j]) == 0)
|
||||||
{
|
return (i);
|
||||||
if (strcasecmp(word, specials[i].words.strs[j]) == 0)
|
}
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
long get_vocab_id(const char* word)
|
long get_vocab_id(const char* word)
|
||||||
// Search the vocab categories in order for the supplied word.
|
// Search the vocab categories in order for the supplied word.
|
||||||
{
|
{
|
||||||
long ref_num;
|
long ref_num;
|
||||||
|
|
||||||
ref_num = get_motion_vocab_id(word);
|
|
||||||
if (ref_num != WORD_NOT_FOUND)
|
|
||||||
return(ref_num + 0); // FIXME: replace with a proper hash
|
|
||||||
|
|
||||||
ref_num = get_object_vocab_id(word);
|
ref_num = get_motion_vocab_id(word);
|
||||||
if (ref_num != WORD_NOT_FOUND)
|
if (ref_num != WORD_NOT_FOUND)
|
||||||
return(ref_num + 1000); // FIXME: replace with a proper hash
|
return (ref_num + 0); // FIXME: replace with a proper hash
|
||||||
|
|
||||||
ref_num = get_action_vocab_id(word);
|
ref_num = get_object_vocab_id(word);
|
||||||
if (ref_num != WORD_NOT_FOUND)
|
if (ref_num != WORD_NOT_FOUND)
|
||||||
return(ref_num + 2000); // FIXME: replace with a proper hash
|
return (ref_num + 1000); // FIXME: replace with a proper hash
|
||||||
|
|
||||||
ref_num = get_special_vocab_id(word);
|
ref_num = get_action_vocab_id(word);
|
||||||
if (ref_num != WORD_NOT_FOUND)
|
if (ref_num != WORD_NOT_FOUND)
|
||||||
return(ref_num + 3000); // FIXME: replace with a proper hash
|
return (ref_num + 2000); // FIXME: replace with a proper hash
|
||||||
|
|
||||||
// Check for the reservoir magic word.
|
ref_num = get_special_vocab_id(word);
|
||||||
if (strcasecmp(word, game.zzword) == 0)
|
if (ref_num != WORD_NOT_FOUND)
|
||||||
return(PART + 2000); // FIXME: replace with a proper hash
|
return (ref_num + 3000); // FIXME: replace with a proper hash
|
||||||
|
|
||||||
return(WORD_NOT_FOUND);
|
// Check for the reservoir magic word.
|
||||||
|
if (strcasecmp(word, game.zzword) == 0)
|
||||||
|
return (PART + 2000); // FIXME: replace with a proper hash
|
||||||
|
|
||||||
|
return (WORD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
void juggle(long object)
|
void juggle(long object)
|
||||||
|
@ -673,12 +663,11 @@ long randrange(long range)
|
||||||
|
|
||||||
void make_zzword(char zzword[6])
|
void make_zzword(char zzword[6])
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 5; ++i)
|
for (int i = 0; i < 5; ++i) {
|
||||||
{
|
zzword[i] = 'A' + randrange(26);
|
||||||
zzword[i] = 'A' + randrange(26);
|
|
||||||
}
|
}
|
||||||
zzword[1] = '\''; // force second char to apostrophe
|
zzword[1] = '\''; // force second char to apostrophe
|
||||||
zzword[5] = '\0';
|
zzword[5] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
void datime(long* d, long* t)
|
void datime(long* d, long* t)
|
||||||
|
|
10
saveresume.c
10
saveresume.c
|
@ -27,19 +27,19 @@ struct save_t {
|
||||||
struct save_t save;
|
struct save_t save;
|
||||||
|
|
||||||
int savefile(FILE *fp, long version)
|
int savefile(FILE *fp, long version)
|
||||||
/* 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);
|
||||||
k = i + 650 * k;
|
k = i + 650 * k;
|
||||||
save.savetime = k;
|
save.savetime = k;
|
||||||
save.mode = -1;
|
save.mode = -1;
|
||||||
|
|
||||||
save.version = (version == 0) ? VRSION : version;
|
save.version = (version == 0) ? VRSION : version;
|
||||||
|
|
||||||
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 */
|
||||||
|
@ -119,7 +119,7 @@ int restore(FILE* fp)
|
||||||
} else {
|
} else {
|
||||||
memcpy(&game, &save.game, sizeof(struct game_t));
|
memcpy(&game, &save.game, sizeof(struct game_t));
|
||||||
//game.zzword = rndvoc(3, game.zzword);
|
//game.zzword = rndvoc(3, game.zzword);
|
||||||
make_zzword(game.zzword);
|
make_zzword(game.zzword);
|
||||||
}
|
}
|
||||||
return GO_TOP;
|
return GO_TOP;
|
||||||
}
|
}
|
||||||
|
|
4
score.c
4
score.c
|
@ -37,8 +37,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