Merge branch 'master' into actions-arithmetic
This commit is contained in:
commit
d4fc7a88b4
9 changed files with 1549 additions and 15 deletions
2
Makefile
2
Makefile
|
@ -22,7 +22,7 @@
|
||||||
VERS=1.0
|
VERS=1.0
|
||||||
|
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wall -Wpedantic -g
|
CCFLAGS+=-std=c99 -D _DEFAULT_SOURCE -Wall -Wpedantic -Wextra -g
|
||||||
LIBS=
|
LIBS=
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
ifeq ($(UNAME_S),Linux)
|
ifeq ($(UNAME_S),Linux)
|
||||||
|
|
|
@ -614,7 +614,7 @@ static int fly(token_t verb, token_t obj)
|
||||||
return GO_TERMINATE;
|
return GO_TERMINATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int inven(token_t obj)
|
static int inven(void)
|
||||||
/* Inventory. If object, treat same as find. Else report on current burden. */
|
/* Inventory. If object, treat same as find. Else report on current burden. */
|
||||||
{
|
{
|
||||||
int spk=NO_CARRY;
|
int spk=NO_CARRY;
|
||||||
|
@ -1087,7 +1087,7 @@ int action(FILE *input, enum speechpart part, long verb, token_t obj)
|
||||||
case 16: /* TOSS */ return GO_UNKNOWN;
|
case 16: /* TOSS */ return GO_UNKNOWN;
|
||||||
case 17: /* QUIT */ return quit(input);
|
case 17: /* QUIT */ return quit(input);
|
||||||
case 18: /* FIND */ return GO_UNKNOWN;
|
case 18: /* FIND */ return GO_UNKNOWN;
|
||||||
case 19: /* INVEN */ return inven(obj);
|
case 19: /* INVEN */ return inven();
|
||||||
case 20: /* FEED */ return GO_UNKNOWN;
|
case 20: /* FEED */ return GO_UNKNOWN;
|
||||||
case 21: /* FILL */ return fill(verb, obj);
|
case 21: /* FILL */ return fill(verb, obj);
|
||||||
case 22: /* BLAST */ return blast();
|
case 22: /* BLAST */ return blast();
|
||||||
|
|
3
advent.h
3
advent.h
|
@ -12,7 +12,8 @@
|
||||||
#define MAXPARMS 25
|
#define MAXPARMS 25
|
||||||
#define INVLIMIT 7
|
#define INVLIMIT 7
|
||||||
#define INTRANSITIVE -1 /* illegal object number */
|
#define INTRANSITIVE -1 /* illegal object number */
|
||||||
#define SPECIALBASE 300 /* base umber of special rooms */
|
#define SPECIALBASE 300 /* base number of special rooms */
|
||||||
|
#define WARNTIME 30 /* late game starts at game.limit-this */
|
||||||
|
|
||||||
typedef long token_t; /* word token - someday this will be char[TOKLEN+1] */
|
typedef long token_t; /* word token - someday this will be char[TOKLEN+1] */
|
||||||
typedef long vocab_t; /* index into a vocabulary array */
|
typedef long vocab_t; /* index into a vocabulary array */
|
||||||
|
|
10
main.c
10
main.c
|
@ -248,8 +248,8 @@ static void checkhints(FILE *cmdin)
|
||||||
SETPRM(1,HINTS[hint][2],HINTS[hint][2]);
|
SETPRM(1,HINTS[hint][2],HINTS[hint][2]);
|
||||||
RSPEAK(HINT_COST);
|
RSPEAK(HINT_COST);
|
||||||
game.hinted[hint]=YES(cmdin,WANT_HINT,HINTS[hint][4],OK_MAN);
|
game.hinted[hint]=YES(cmdin,WANT_HINT,HINTS[hint][4],OK_MAN);
|
||||||
if (game.hinted[hint] && game.limit > 30)
|
if (game.hinted[hint] && game.limit > WARNTIME)
|
||||||
game.limit=game.limit+30*HINTS[hint][2];
|
game.limit += WARNTIME*HINTS[hint][2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -831,7 +831,7 @@ static void lampcheck(void)
|
||||||
* Second is for other cases of lamp dying. 12400 is when it
|
* Second is for other cases of lamp dying. 12400 is when it
|
||||||
* goes out. Even then, he can explore outside for a while
|
* goes out. Even then, he can explore outside for a while
|
||||||
* if desired. */
|
* if desired. */
|
||||||
if (game.limit<=30 && HERE(BATTER) && game.prop[BATTER]==0 && HERE(LAMP))
|
if (game.limit <= WARNTIME && HERE(BATTER) && game.prop[BATTER]==0 && HERE(LAMP))
|
||||||
{
|
{
|
||||||
RSPEAK(REPLACE_BATTERIES);
|
RSPEAK(REPLACE_BATTERIES);
|
||||||
game.prop[BATTER]=1;
|
game.prop[BATTER]=1;
|
||||||
|
@ -844,7 +844,7 @@ static void lampcheck(void)
|
||||||
game.prop[LAMP]=0;
|
game.prop[LAMP]=0;
|
||||||
if (HERE(LAMP))
|
if (HERE(LAMP))
|
||||||
RSPEAK(LAMP_OUT);
|
RSPEAK(LAMP_OUT);
|
||||||
} else if (game.limit <= 30) {
|
} else if (game.limit <= WARNTIME) {
|
||||||
if (!game.lmwarn && HERE(LAMP)) {
|
if (!game.lmwarn && HERE(LAMP)) {
|
||||||
game.lmwarn=true;
|
game.lmwarn=true;
|
||||||
int spk=GET_BATTERIES;
|
int spk=GET_BATTERIES;
|
||||||
|
@ -1058,7 +1058,7 @@ static bool do_command(FILE *cmdin)
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
/* Gee, I don't understand. */
|
/* Gee, I don't understand. */
|
||||||
if (fallback_handler(rawbuf))
|
if (fallback_handler(rawbuf))
|
||||||
return true;
|
continue;
|
||||||
SETPRM(1,WD1,WD1X);
|
SETPRM(1,WD1,WD1X);
|
||||||
RSPEAK(DONT_KNOW);
|
RSPEAK(DONT_KNOW);
|
||||||
goto L2600;
|
goto L2600;
|
||||||
|
|
6
misc.c
6
misc.c
|
@ -67,7 +67,7 @@ void newspeak(char* msg)
|
||||||
|
|
||||||
// Handle format specifiers (including the custom %C, %L, %S) by adjusting the parameter accordingly, and replacing the specifier with %s.
|
// Handle format specifiers (including the custom %C, %L, %S) by adjusting the parameter accordingly, and replacing the specifier with %s.
|
||||||
int pi = 0; // parameter index
|
int pi = 0; // parameter index
|
||||||
for (int i = 0; i < strlen(msg); ++i)
|
for (int i = 0; i < (int)strlen(msg); ++i)
|
||||||
{
|
{
|
||||||
if (msg[i] == '%')
|
if (msg[i] == '%')
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ void newspeak(char* msg)
|
||||||
{
|
{
|
||||||
copy[i + 1] = 's';
|
copy[i + 1] = 's';
|
||||||
packed_to_token(PARMS[pi], parameters[pi]);
|
packed_to_token(PARMS[pi], parameters[pi]);
|
||||||
for (int j = 0; j < strlen(parameters[pi]); ++j)
|
for (int j = 0; j < (int)strlen(parameters[pi]); ++j)
|
||||||
{
|
{
|
||||||
parameters[pi][j] = tolower(parameters[pi][j]);
|
parameters[pi][j] = tolower(parameters[pi][j]);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ void newspeak(char* msg)
|
||||||
{
|
{
|
||||||
copy[i + 1] = 's';
|
copy[i + 1] = 's';
|
||||||
packed_to_token(PARMS[pi], parameters[pi]);
|
packed_to_token(PARMS[pi], parameters[pi]);
|
||||||
for (int j = 0; j < strlen(parameters[pi]); ++j)
|
for (int j = 0; j < (int)strlen(parameters[pi]); ++j)
|
||||||
{
|
{
|
||||||
parameters[pi][j] = tolower(parameters[pi][j]);
|
parameters[pi][j] = tolower(parameters[pi][j]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ The principal maintainers of this code are Eric S. Raymond and Jason
|
||||||
Ninneman. Eric received Don Woods's encouragement to update and ship
|
Ninneman. Eric received Don Woods's encouragement to update and ship
|
||||||
the game; Jason signed on early in the process to help. The assistance
|
the game; Jason signed on early in the process to help. The assistance
|
||||||
of Peje Nilsson in restructuring some particularly grotty gotos is
|
of Peje Nilsson in restructuring some particularly grotty gotos is
|
||||||
gratefully acknowledged.
|
gratefully acknowledged. Petr Voropaev contributed fuzz testing.
|
||||||
|
|
||||||
== Nomenclature ==
|
== Nomenclature ==
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ ways:
|
||||||
We don't need whatever minor performance gains this might collect,
|
We don't need whatever minor performance gains this might collect,
|
||||||
and the choice to refrain will make forward translation into future
|
and the choice to refrain will make forward translation into future
|
||||||
languages easier.
|
languages easier.
|
||||||
|
|
||||||
* There are a few gotos left that resist restructuring; all of these
|
* There are a few gotos left that resist restructuring; all of these
|
||||||
are in the principal command interpreter function implementing its
|
are in the principal command interpreter function implementing its
|
||||||
state machine.
|
state machine.
|
||||||
|
@ -124,10 +125,13 @@ ways:
|
||||||
compromise forward-portability to other languages.
|
compromise forward-portability to other languages.
|
||||||
|
|
||||||
* The code still has an unfortunately high density of magic numbers - in
|
* The code still has an unfortunately high density of magic numbers - in
|
||||||
particular, numeric object and room IDs. There are plans to fix this.
|
particular, numeric object IDs. There are plans to fix this.
|
||||||
|
|
||||||
* Much of the code still uses FORTRAN-style uppercase names.
|
* Much of the code still uses FORTRAN-style uppercase names.
|
||||||
|
|
||||||
|
* The code still assumes one-origin array indexing. Thus, arrays are
|
||||||
|
a cell larger than they strictly need to be and cell 0 is unused.
|
||||||
|
|
||||||
* The code is still mostly typeless, slinging around machine longs
|
* The code is still mostly typeless, slinging around machine longs
|
||||||
like a FORTRAN or BCPL program. Some (incomplete) effort has been made
|
like a FORTRAN or BCPL program. Some (incomplete) effort has been made
|
||||||
to introduce semantic types.
|
to introduce semantic types.
|
||||||
|
|
2
score.c
2
score.c
|
@ -110,7 +110,7 @@ void score(enum termination mode)
|
||||||
SETPRM(1,score,mxscor);
|
SETPRM(1,score,mxscor);
|
||||||
SETPRM(3,game.turns,game.turns);
|
SETPRM(3,game.turns,game.turns);
|
||||||
RSPEAK(TOTAL_SCORE);
|
RSPEAK(TOTAL_SCORE);
|
||||||
for (long i=1; i<=CLSSES; i++) {
|
for (long i=1; i<=(long)CLSSES; i++) {
|
||||||
if(CVAL[i] >= score) {
|
if(CVAL[i] >= score) {
|
||||||
newspeak(class_messages[i]);
|
newspeak(class_messages[i]);
|
||||||
i=CVAL[i]+1-score;
|
i=CVAL[i]+1-score;
|
||||||
|
|
1304
tests/seedcrash.chk
Normal file
1304
tests/seedcrash.chk
Normal file
File diff suppressed because it is too large
Load diff
225
tests/seedcrash.log
Normal file
225
tests/seedcrash.log
Normal file
|
@ -0,0 +1,225 @@
|
||||||
|
## This crashed advent before the control path after seed was fixed.
|
||||||
|
n
|
||||||
|
seed 1635997320
|
||||||
|
in
|
||||||
|
take lamp
|
||||||
|
xyzzy
|
||||||
|
take rod
|
||||||
|
e
|
||||||
|
take cage
|
||||||
|
w
|
||||||
|
on
|
||||||
|
w
|
||||||
|
w
|
||||||
|
drop rod
|
||||||
|
take bird
|
||||||
|
take rod
|
||||||
|
w
|
||||||
|
free bird
|
||||||
|
wave rod
|
||||||
|
drop rod
|
||||||
|
take bird
|
||||||
|
take jade
|
||||||
|
e
|
||||||
|
e
|
||||||
|
e
|
||||||
|
off
|
||||||
|
xyzzy
|
||||||
|
drop jade
|
||||||
|
xyzzy
|
||||||
|
on
|
||||||
|
w
|
||||||
|
w
|
||||||
|
w
|
||||||
|
take rod
|
||||||
|
d
|
||||||
|
w
|
||||||
|
wave rod
|
||||||
|
drop rod
|
||||||
|
e
|
||||||
|
n
|
||||||
|
free bird
|
||||||
|
take bird
|
||||||
|
s
|
||||||
|
take jewelry
|
||||||
|
n
|
||||||
|
sw
|
||||||
|
w
|
||||||
|
feed dragon
|
||||||
|
kill dragon
|
||||||
|
yes
|
||||||
|
drink blood
|
||||||
|
take rug
|
||||||
|
e
|
||||||
|
e
|
||||||
|
n
|
||||||
|
take silver
|
||||||
|
n
|
||||||
|
off
|
||||||
|
plugh
|
||||||
|
drop jewelry
|
||||||
|
drop rug
|
||||||
|
drop silver
|
||||||
|
out
|
||||||
|
s
|
||||||
|
w
|
||||||
|
n
|
||||||
|
take appendage
|
||||||
|
free bird
|
||||||
|
drop cage
|
||||||
|
listen
|
||||||
|
s
|
||||||
|
s
|
||||||
|
n
|
||||||
|
in
|
||||||
|
take water
|
||||||
|
plugh
|
||||||
|
on
|
||||||
|
plover
|
||||||
|
ne
|
||||||
|
take pyramid
|
||||||
|
s
|
||||||
|
plover
|
||||||
|
s
|
||||||
|
d
|
||||||
|
take axe
|
||||||
|
u
|
||||||
|
s
|
||||||
|
up
|
||||||
|
w
|
||||||
|
w
|
||||||
|
w
|
||||||
|
w
|
||||||
|
throw axe
|
||||||
|
take axe
|
||||||
|
w
|
||||||
|
s
|
||||||
|
sw
|
||||||
|
se
|
||||||
|
s
|
||||||
|
kill machine
|
||||||
|
s
|
||||||
|
s
|
||||||
|
kill ogre
|
||||||
|
n
|
||||||
|
take ruby
|
||||||
|
s
|
||||||
|
w
|
||||||
|
n
|
||||||
|
n
|
||||||
|
n
|
||||||
|
nw
|
||||||
|
d
|
||||||
|
e
|
||||||
|
e
|
||||||
|
e
|
||||||
|
take diamonds
|
||||||
|
e
|
||||||
|
e
|
||||||
|
drop bottle
|
||||||
|
s
|
||||||
|
take gold
|
||||||
|
n
|
||||||
|
n
|
||||||
|
n
|
||||||
|
n
|
||||||
|
off
|
||||||
|
plugh
|
||||||
|
drop gold
|
||||||
|
drop diamonds
|
||||||
|
drop pyramid
|
||||||
|
drop ruby
|
||||||
|
plugh
|
||||||
|
on
|
||||||
|
s
|
||||||
|
s
|
||||||
|
u
|
||||||
|
take water
|
||||||
|
throw axe
|
||||||
|
take axe
|
||||||
|
n
|
||||||
|
n
|
||||||
|
d
|
||||||
|
bedquilt
|
||||||
|
slab
|
||||||
|
s
|
||||||
|
d
|
||||||
|
water plant
|
||||||
|
u
|
||||||
|
w
|
||||||
|
u
|
||||||
|
reservoir
|
||||||
|
F'UNJ
|
||||||
|
n
|
||||||
|
n
|
||||||
|
nw
|
||||||
|
u
|
||||||
|
u
|
||||||
|
u
|
||||||
|
u
|
||||||
|
ne
|
||||||
|
take ebony
|
||||||
|
sw
|
||||||
|
d
|
||||||
|
d
|
||||||
|
d
|
||||||
|
d
|
||||||
|
d
|
||||||
|
take water
|
||||||
|
s
|
||||||
|
s
|
||||||
|
s
|
||||||
|
s
|
||||||
|
d
|
||||||
|
s
|
||||||
|
d
|
||||||
|
water plant
|
||||||
|
u
|
||||||
|
e
|
||||||
|
d
|
||||||
|
get oil
|
||||||
|
u
|
||||||
|
w
|
||||||
|
d
|
||||||
|
climb
|
||||||
|
w
|
||||||
|
n
|
||||||
|
oil door
|
||||||
|
drop bottle
|
||||||
|
drop appendage
|
||||||
|
n
|
||||||
|
take trident
|
||||||
|
w
|
||||||
|
d
|
||||||
|
se
|
||||||
|
n
|
||||||
|
w
|
||||||
|
inven
|
||||||
|
drop trident
|
||||||
|
drop ebony
|
||||||
|
drop axe
|
||||||
|
drop lantern
|
||||||
|
e
|
||||||
|
take emerald
|
||||||
|
w
|
||||||
|
take lamp
|
||||||
|
take axe
|
||||||
|
take ebony
|
||||||
|
take trident
|
||||||
|
nw
|
||||||
|
s
|
||||||
|
take vase
|
||||||
|
se
|
||||||
|
e
|
||||||
|
take pillow
|
||||||
|
w
|
||||||
|
ne
|
||||||
|
e
|
||||||
|
n
|
||||||
|
n
|
||||||
|
seed 1635997320
|
||||||
|
n
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue