Even less magic
This commit is contained in:
parent
18a9be501f
commit
e9aff2568f
7 changed files with 89 additions and 88 deletions
15
actions.c
15
actions.c
|
@ -134,7 +134,7 @@ static int bigwords(long foo)
|
|||
} else {
|
||||
/* Bring back troll if we steal the eggs back from him before
|
||||
* crossing. */
|
||||
if (game.place[EGGS] == 0 && game.place[TROLL] == 0 && game.prop[TROLL] == 0)
|
||||
if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == 0)
|
||||
game.prop[TROLL] = 1;
|
||||
k = 2;
|
||||
if (HERE(EGGS))k = 1;
|
||||
|
@ -389,7 +389,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
|
|||
int k = LIQUID();
|
||||
if (k == obj)obj = BOTTLE;
|
||||
if (obj == BOTTLE && k != 0)
|
||||
game.place[k] = NOWHERE;
|
||||
game.place[k] = LOC_NOWHERE;
|
||||
if (obj == CAGE && game.prop[BIRD] == 1)DROP(BIRD, game.loc);
|
||||
DROP(obj, game.loc);
|
||||
if (obj != BIRD) return GO_CLEAROBJ;
|
||||
|
@ -409,7 +409,7 @@ static int drink(token_t verb, token_t obj)
|
|||
if (obj != 0 && obj != WATER)spk = RIDICULOUS_ATTEMPT;
|
||||
if (spk != RIDICULOUS_ATTEMPT && LIQUID() == WATER && HERE(BOTTLE)) {
|
||||
game.prop[BOTTLE] = 1;
|
||||
game.place[WATER] = NOWHERE;
|
||||
game.place[WATER] = LOC_NOWHERE;
|
||||
spk = BOTTLE_EMPTY;
|
||||
}
|
||||
} else {
|
||||
|
@ -539,7 +539,7 @@ int fill(token_t verb, token_t obj)
|
|||
RSPEAK(spk);
|
||||
return GO_CLEAROBJ;
|
||||
}
|
||||
game.place[k] = NOWHERE;
|
||||
game.place[k] = LOC_NOWHERE;
|
||||
game.prop[BOTTLE] = 1;
|
||||
if (k == OIL)game.prop[URN] = 1;
|
||||
spk = WATER_URN + game.prop[URN];
|
||||
|
@ -764,7 +764,7 @@ static int pour(token_t verb, token_t obj)
|
|||
if (HERE(URN) && game.prop[URN] == 0)
|
||||
return fill(verb, URN);
|
||||
game.prop[BOTTLE] = 1;
|
||||
game.place[obj] = NOWHERE;
|
||||
game.place[obj] = LOC_NOWHERE;
|
||||
spk = GROUND_WET;
|
||||
if (!(AT(PLANT) || AT(DOOR))) {
|
||||
RSPEAK(spk);
|
||||
|
@ -800,7 +800,6 @@ static int quit(void)
|
|||
static int read(token_t verb, token_t obj)
|
||||
/* Read. Print stuff based on objtxt. Oyster (?) is special case. */
|
||||
{
|
||||
int spk = ACTSPK[verb];
|
||||
if (obj == INTRANSITIVE) {
|
||||
obj = 0;
|
||||
for (int i = 1; i <= NOBJECTS; i++) {
|
||||
|
@ -816,7 +815,7 @@ static int read(token_t verb, token_t obj)
|
|||
return GO_CLEAROBJ;
|
||||
}
|
||||
if (OBJTXT[obj] == 0 || game.prop[obj] < 0) {
|
||||
RSPEAK(spk);
|
||||
RSPEAK(ACTSPK[verb]);
|
||||
return GO_CLEAROBJ;
|
||||
}
|
||||
if (obj == OYSTER && !game.clshnt) {
|
||||
|
@ -891,7 +890,7 @@ static int throw_support(long spk)
|
|||
return GO_MOVE;
|
||||
}
|
||||
|
||||
static int throw(FILE *cmdin, long verb, token_t obj)
|
||||
static int throw (FILE *cmdin, long verb, token_t obj)
|
||||
/* Throw. Same as discard unless axe. Then same as attack except
|
||||
* ignore bird, and if dwarf is present then one might be killed.
|
||||
* (Only way to do so!) Axe also special for dragon, bear, and
|
||||
|
|
53
advent.h
53
advent.h
|
@ -14,6 +14,8 @@
|
|||
#define INVLIMIT 7 /* inverntory limit (# of objects) */
|
||||
#define INTRANSITIVE -1 /* illegal object number */
|
||||
#define SPECIALBASE 300 /* base number of special rooms */
|
||||
#define GAMELIMIT 330 /* base limit of turns */
|
||||
#define NOVICELIMIT 1000 /* limit of turns for novice */
|
||||
#define WARNTIME 30 /* late game starts at game.limit-this */
|
||||
#define PANICTIME 15 /* time left after closing */
|
||||
#define BATTERYLIFE 2500 /* turn limit increment from batteries */
|
||||
|
@ -60,23 +62,23 @@ struct game_t {
|
|||
long turns;
|
||||
long wzdark;
|
||||
long zzword;
|
||||
long abbrev[LOCSIZ+1];
|
||||
long atloc[LOCSIZ+1];
|
||||
long dseen[NDWARVES+1];
|
||||
long dloc[NDWARVES+1];
|
||||
long odloc[NDWARVES+1];
|
||||
long fixed[NOBJECTS+1];
|
||||
long link[NOBJECTS*2 + 1];
|
||||
long place[NOBJECTS+1];
|
||||
long hinted[HNTSIZ+1];
|
||||
long hintlc[HNTSIZ+1];
|
||||
long prop[NOBJECTS+1];
|
||||
long abbrev[LOCSIZ + 1];
|
||||
long atloc[LOCSIZ + 1];
|
||||
long dseen[NDWARVES + 1];
|
||||
long dloc[NDWARVES + 1];
|
||||
long odloc[NDWARVES + 1];
|
||||
long fixed[NOBJECTS + 1];
|
||||
long link[NOBJECTS * 2 + 1];
|
||||
long place[NOBJECTS + 1];
|
||||
long hinted[HNTSIZ + 1];
|
||||
long hintlc[HNTSIZ + 1];
|
||||
long prop[NOBJECTS + 1];
|
||||
};
|
||||
|
||||
extern struct game_t game;
|
||||
|
||||
extern long LNLENG, LNPOSN, PARMS[];
|
||||
extern char rawbuf[LINESIZE], INLINE[LINESIZE+1];
|
||||
extern char rawbuf[LINESIZE], INLINE[LINESIZE + 1];
|
||||
extern const char ascii_to_advent[];
|
||||
extern const char advent_to_ascii[];
|
||||
extern FILE *logfp;
|
||||
|
@ -89,25 +91,25 @@ extern void* xmalloc(size_t size);
|
|||
extern char* xstrdup(const char*);
|
||||
extern void packed_to_token(long, char token[]);
|
||||
extern void speak(const char*);
|
||||
extern void PSPEAK(vocab_t,int);
|
||||
extern void PSPEAK(vocab_t, int);
|
||||
extern void RSPEAK(vocab_t);
|
||||
extern void SETPRM(long,long,long);
|
||||
extern bool GETIN(FILE *,token_t*,token_t*,token_t*,token_t*);
|
||||
extern void SETPRM(long, long, long);
|
||||
extern bool GETIN(FILE *, token_t*, token_t*, token_t*, token_t*);
|
||||
extern void echo_input(FILE*, char*, char*);
|
||||
extern char* get_input(void);
|
||||
extern bool YES(const char*, const char*, const char*);
|
||||
extern long GETTXT(bool,bool,bool);
|
||||
extern long GETTXT(bool, bool, bool);
|
||||
extern token_t MAKEWD(long);
|
||||
extern long VOCAB(long,long);
|
||||
extern long VOCAB(long, long);
|
||||
extern void JUGGLE(long);
|
||||
extern void MOVE(long,long);
|
||||
extern long PUT(long,long,long);
|
||||
extern void CARRY(long,long);
|
||||
extern void DROP(long,long);
|
||||
extern void MOVE(long, long);
|
||||
extern long PUT(long, long, long);
|
||||
extern void CARRY(long, long);
|
||||
extern void DROP(long, long);
|
||||
extern long ATDWRF(long);
|
||||
extern long SETBIT(long);
|
||||
extern bool TSTBIT(long,int);
|
||||
extern long RNDVOC(long,long);
|
||||
extern bool TSTBIT(long, int);
|
||||
extern long RNDVOC(long, long);
|
||||
extern bool MAPLIN(FILE *);
|
||||
extern void DATIME(long*, long*);
|
||||
|
||||
|
@ -136,7 +138,7 @@ extern int restore(FILE *);
|
|||
* PCT(N) = true N% of the time (N integer from 0 to 100)
|
||||
* TOTING(OBJ) = true if the OBJ is being carried */
|
||||
|
||||
#define DESTROY(N) MOVE(N, NOWHERE)
|
||||
#define DESTROY(N) MOVE(N, LOC_NOWHERE)
|
||||
#define MOD(N,M) ((N) % (M))
|
||||
#define TOTING(OBJ) (game.place[OBJ] == CARRIED)
|
||||
#define AT(OBJ) (game.place[OBJ] == game.loc || game.fixed[OBJ] == game.loc)
|
||||
|
@ -203,7 +205,7 @@ int action(FILE *input, enum speechpart part, long verb, token_t obj);
|
|||
#define NOARRR 3 /* Pirate doesn't go here unless following player */
|
||||
#define NOBACK 4 /* Cannot use "back" to move away */
|
||||
/* Bits past 10 indicate areas of interest to "hint" routines */
|
||||
#define HBASE 10 /* Base for location hint bitss */
|
||||
#define HBASE 10 /* Base for location hint bits */
|
||||
#define HCAVE 11 /* Trying to get into cave */
|
||||
#define HBIRD 12 /* Trying to catch bird */
|
||||
#define HSNAKE 13 /* Trying to deal with snake */
|
||||
|
@ -217,7 +219,6 @@ int action(FILE *input, enum speechpart part, long verb, token_t obj);
|
|||
|
||||
/* Special object statuses in game.place - can also be a location number (> 0) */
|
||||
#define CARRIED -1 /* Player is toting it */
|
||||
#define NOWHERE 0 /* It's destroyed */
|
||||
|
||||
/* hack to ignore GCC Unused Result */
|
||||
#define IGNORE(r) do{if (r){}}while(0)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
locations: !!omap
|
||||
- LOC_0:
|
||||
- LOC_NOWHERE:
|
||||
description:
|
||||
long: !!null
|
||||
short: !!null
|
||||
|
|
2
init.c
2
init.c
|
@ -176,7 +176,7 @@ void initialise(void)
|
|||
printf("Initialising...\n");
|
||||
|
||||
for (int i = 1; i <= NOBJECTS; i++) {
|
||||
game.place[i] = NOWHERE;
|
||||
game.place[i] = LOC_NOWHERE;
|
||||
game.prop[i] = 0;
|
||||
game.link[i + NOBJECTS] = game.link[i] = 0;
|
||||
}
|
||||
|
|
21
main.c
21
main.c
|
@ -78,11 +78,11 @@ int main(int argc, char *argv[])
|
|||
/* Options. */
|
||||
|
||||
#ifndef ADVENT_NOSAVE
|
||||
char* opts = "l:or:s";
|
||||
char* usage = "Usage: %s [-l logfilename] [-o] [-r restorefilename] [-s] \n";
|
||||
const char* opts = "l:or:s";
|
||||
const char* usage = "Usage: %s [-l logfilename] [-o] [-r restorefilename] [-s] \n";
|
||||
#else
|
||||
char* opts = "l:os";
|
||||
char* usage = "Usage: %s [-l logfilename] [-o] [-s] \n";
|
||||
const char* opts = "l:os";
|
||||
const char* usage = "Usage: %s [-l logfilename] [-o] [-s] \n";
|
||||
#endif
|
||||
while ((ch = getopt(argc, argv, opts)) != EOF) {
|
||||
switch (ch) {
|
||||
|
@ -157,10 +157,11 @@ int main(int argc, char *argv[])
|
|||
game.zzword = RNDVOC(3, 0);
|
||||
game.newloc = LOC_START;
|
||||
game.loc = LOC_START;
|
||||
game.limit = 330;
|
||||
game.limit = GAMELIMIT;
|
||||
if (!rfp) {
|
||||
game.novice = YES(arbitrary_messages[WELCOME_YOU], arbitrary_messages[CAVE_NEARBY], arbitrary_messages[NO_MESSAGE]);
|
||||
if (game.novice)game.limit = 1000;
|
||||
if (game.novice)
|
||||
game.limit = NOVICELIMIT;
|
||||
} else {
|
||||
restore(rfp);
|
||||
}
|
||||
|
@ -295,7 +296,7 @@ static bool spotted_by_pirate(int i)
|
|||
/* The pirate's spotted him. He leaves him alone once we've
|
||||
* found chest. K counts if a treasure is here. If not, and
|
||||
* tally=1 for an unseen chest, let the pirate be spotted. Note
|
||||
* that game.place[CHEST] = NOWHERE might mean that he's thrown
|
||||
* that game.place[CHEST] = LOC_NOWHERE might mean that he's thrown
|
||||
* it to the troll, but in that case he's seen the chest
|
||||
* (game.prop=0). */
|
||||
if (game.loc == game.chloc || game.prop[CHEST] >= 0)
|
||||
|
@ -316,7 +317,7 @@ static bool spotted_by_pirate(int i)
|
|||
}
|
||||
}
|
||||
/* Force chest placement before player finds last treasure */
|
||||
if (game.tally == 1 && snarfed == 0 && game.place[CHEST] == NOWHERE && HERE(LAMP) && game.prop[LAMP] == 1) {
|
||||
if (game.tally == 1 && snarfed == 0 && game.place[CHEST] == LOC_NOWHERE && HERE(LAMP) && game.prop[LAMP] == 1) {
|
||||
RSPEAK(PIRATE_SPOTTED);
|
||||
movechest = true;
|
||||
}
|
||||
|
@ -512,7 +513,7 @@ static void croak(void)
|
|||
} else if (game.numdie == maximum_deaths || !YES(query, yes_response, arbitrary_messages[OK_MAN]))
|
||||
terminate(endgame);
|
||||
else {
|
||||
game.place[WATER] = game.place[OIL] = NOWHERE;
|
||||
game.place[WATER] = game.place[OIL] = LOC_NOWHERE;
|
||||
if (TOTING(LAMP))
|
||||
game.prop[LAMP] = 0;
|
||||
for (int j = 1; j <= NOBJECTS; j++) {
|
||||
|
@ -878,7 +879,7 @@ static void lampcheck(void)
|
|||
if (!game.lmwarn && HERE(LAMP)) {
|
||||
game.lmwarn = true;
|
||||
int spk = GET_BATTERIES;
|
||||
if (game.place[BATTERY] == NOWHERE)spk = LAMP_DIM;
|
||||
if (game.place[BATTERY] == LOC_NOWHERE)spk = LAMP_DIM;
|
||||
if (game.prop[BATTERY] == 1)spk = MISSING_BATTERYIES;
|
||||
RSPEAK(spk);
|
||||
}
|
||||
|
|
2
misc.c
2
misc.c
|
@ -417,7 +417,7 @@ void MOVE(long object, long where)
|
|||
from = game.fixed[object - NOBJECTS];
|
||||
else
|
||||
from = game.place[object];
|
||||
if (from != NOWHERE && from != CARRIED && !SPECIAL(from))
|
||||
if (from != LOC_NOWHERE && from != CARRIED && !SPECIAL(from))
|
||||
CARRY(object, from);
|
||||
DROP(object, where);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue