This reorganization is a first step toward handling database compilation separately.
# Makefile for the open-source release of adventure 2.5
LIBS=-lrt
-OBJS=main.o init.o actions1.o actions2.o score.o misc.o
+OBJS=main.o init.o actions1.o actions2.o score.o misc.o database.o
SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO advent.text control
.c.o:
gcc -O $(DBX) -c $<
advent: $(OBJS)
- gcc -std=c99 -O $(DBX) -o advent $(OBJS) $(LIBS)
+ gcc -Wall -std=c99 -O $(DBX) -o advent $(OBJS) $(LIBS)
-main.o: main.h misc.h funcs.h
+main.o: main.h misc.h funcs.h database.h
-init.o: misc.h main.h share.h funcs.h
+init.o: misc.h main.h share.h funcs.h database.h
-actions1.o: misc.h main.h share.h funcs.h
+actions1.o: misc.h main.h share.h funcs.h database.h
actions2.o: misc.h main.h share.h funcs.h
-score.o: misc.h main.h share.h
+score.o: misc.h main.h share.h database.h
-misc.o: misc.h main.h
+misc.o: misc.h main.h database.h
+
+database.o: database.h
clean:
rm -f *.o advent advent.html advent.6 adventure.data
#include "main.h"
#include "share.h"
#include "funcs.h"
+#include "database.h"
/* This stuff was broken off as part of an effort to get the main program
* to compile without running out of memory. We're called with a number
--- /dev/null
+#include "database.h"
+
+const long RTXSIZ = 277;
+const long CLSMAX = 12;
+const long LOCSIZ = 185;
+const long LINSIZ = 12500;
+const long TRNSIZ = 5;
+const long TABSIZ = 330;
+const long VRBSIZ = 35;
+long LINUSE;
+long TRVS;
+long CLSSES;
+long TRNVLS;
+long TABNDX;
+long HNTMAX;
+long PTEXT[101];
+long RTEXT[278];
+long CTEXT[13];
+long OBJSND[101];
+long OBJTXT[101];
+long STEXT[186];
+long LTEXT[186];
+long COND[186];
+long KEY[186];
+long LOCSND[186];
+long LINES[12500];
+long CVAL[13];
+long TTEXT[6];
+long TRNVAL[6];
+long TRAVEL[886];
+long KTAB[331];
+long ATAB[331];
+long PLAC[101];
+long FIXD[101];
+long ACTSPK[36];
+long HINTS[21][5];
--- /dev/null
+extern const long RTXSIZ;
+extern const long CLSMAX;
+extern const long LOCSIZ;
+extern const long LINSIZ;
+extern const long TRNSIZ;
+extern const long TABSIZ;
+extern const long VRBSIZ;
+extern long LINUSE;
+extern long TRVS;
+extern long CLSSES;
+extern long TRNVLS;
+extern long TABNDX;
+extern long HNTMAX;
+extern long PTEXT[101];
+extern long RTEXT[278];
+extern long CTEXT[13];
+extern long OBJSND[101];
+extern long OBJTXT[101];
+extern long STEXT[186];
+extern long LTEXT[186];
+extern long COND[186];
+extern long KEY[186];
+extern long LOCSND[186];
+extern long LINES[12500];
+extern long CVAL[13];
+extern long TTEXT[6];
+extern long TRNVAL[6];
+extern long TRAVEL[886];
+extern long KTAB[331];
+extern long ATAB[331];
+extern long PLAC[101];
+extern long FIXD[101];
+extern long ACTSPK[36];
+extern long HINTS[21][5];
#include <stdbool.h>
+#include "database.h"
/* Statement functions
*
#include "main.h"
#include "share.h"
#include "funcs.h"
+#include "database.h"
/*
* Initialisation
void initialise(void) {
if (oldstyle)
printf("Initialising...\n");
- if(!quick_init()){raw_init(); report(); quick_save();}
+ if(!quick_init()){raw_init(); report(); quick_save();}
finish_init();
}
#include <getopt.h>
#include <signal.h>
#include "main.h"
-
+#include "database.h"
#include "misc.h"
-long ABB[186], ATAB[331], ATLOC[186], BLKLIN = true, DFLAG,
+long ABB[186], ATLOC[186], BLKLIN = true, DFLAG,
DLOC[7], FIXED[101], HOLDNG,
- KTAB[331], *LINES, LINK[201], LNLENG, LNPOSN,
- PARMS[26], PLACE[101], PTEXT[101], RTEXT[278],
- SETUP = 0, TABSIZ = 330;
+ LINK[201], LNLENG, LNPOSN,
+ PARMS[26], PLACE[101],
+ SETUP = 0;
signed char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[129], MAP2[129];
-long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS,
+long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BONUS,
BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
- CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT, CLSMAX = 12, CLSSES,
- COINS, COND[186], CONDS, CTEXT[13], CVAL[13], DALTLC, DETAIL,
+ CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
+ COINS, CONDS, DALTLC, DETAIL,
DKILL, DOOR, DPRSSN, DRAGON, DSEEN[7], DTOTAL, DWARF, EGGS,
- EMRALD, ENTER, ENTRNC, FIND, FISSUR, FIXD[101], FOOBAR, FOOD,
- GRATE, HINT, HINTED[21], HINTLC[21], HINTS[21][5], HNTMAX,
- HNTSIZ = 20, I, INVENT, IGO, IWEST, J, JADE, K, K2, KEY[186], KEYS, KK,
- KNFLOC, KNIFE, KQ, L, LAMP, LIMIT, LINSIZ = 12500, LINUSE, LL,
- LMWARN, LOC, LOCK, LOCSIZ = 185, LOCSND[186], LOOK, LTEXT[186],
+ EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
+ GRATE, HINT, HINTED[21], HINTLC[21],
+ HNTSIZ = 20, I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
+ KNFLOC, KNIFE, KQ, L, LAMP, LIMIT, LL,
+ LMWARN, LOC, LOCK, LOOK,
MAGZIN, MAXDIE, MAXTRS, MESH = 123456789,
MESSAG, MIRROR, MXSCOR,
- NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ, OBJSND[101],
- OBJTXT[101], ODLOC[7], OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
- PANIC, PEARL, PILLOW, PLAC[101], PLANT, PLANT2, PROP[101], PYRAM,
- RESER, ROD, ROD2, RTXSIZ = 277, RUBY, RUG, SAPPH, SAVED, SAY,
- SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STEXT[186], STICK,
- STREAM, TABNDX, TALLY, THRESH, THROW, TK[21], TRAVEL[886], TRIDNT,
- TRNDEX, TRNLUZ, TRNSIZ = 5, TRNVAL[6], TRNVLS, TROLL, TROLL2, TRVS,
- TRVSIZ = 885, TTEXT[6], TURNS, URN, V1, V2, VASE, VEND, VERB,
- VOLCAN, VRBSIZ = 35, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
+ NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
+ ODLOC[7], OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
+ PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[101], PYRAM,
+ RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
+ SCORE, SECT, SIGN, SNAKE, SPK, STEPS, STICK,
+ STREAM, TALLY, THRESH, THROW, TK[21], TRIDNT,
+ TRNDEX, TRNLUZ, TROLL, TROLL2,
+ TRVSIZ = 885, TURNS, URN, V1, V2, VASE, VEND, VERB,
+ VOLCAN, VRSION = 25, WATER, WD1, WD1X, WD2, WD2X,
WZDARK = false, ZZWORD;
FILE *logfp;
bool oldstyle = false;
/* Read the database if we have not yet done so */
- LINES = (long *)calloc(LINSIZ+1,sizeof(long));
- if(!LINES){
- printf("Not enough memory!\n");
- exit(1);
- }
-
MAP2[1] = 0;
if(!SETUP)initialise();
if(SETUP > 0) goto L1;
unsigned long a, c, m, x;
} lcg_state;
-extern long ABB[], ATAB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
- KTAB[], *LINES, LINK[], LNLENG, LNPOSN,
- PARMS[], PLACE[], PTEXT[], RTEXT[], TABSIZ;
+extern long ABB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
+ LINK[], LNLENG, LNPOSN,
+ PARMS[], PLACE[];
extern signed char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[];
extern FILE *logfp;
extern bool oldstyle;
#include "share.h" /* for SETUP */
#include "misc.h"
#include "funcs.h"
+#include "database.h"
/* hack to ignore GCC Unused Result */
#define IGNORE(r) do{if(r){}}while(0)
#include "misc.h"
#include "main.h"
#include "share.h"
+#include "database.h"
/*
* scoring and wrap-up
extern void score(long);
-extern long ABBNUM, ACTSPK[], AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
+extern long ABBNUM, AMBER, ATTACK, AXE, BACK, BATTER, BEAR,
BIRD, BLOOD, BONUS,
BOTTLE, CAGE, CAVE, CAVITY, CHAIN, CHASM, CHEST, CHLOC, CHLOC2,
- CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT, CLSMAX, CLSSES,
- COINS, COND[], CONDS, CTEXT[], CVAL[], DALTLC, DETAIL,
+ CLAM, CLOCK1, CLOCK2, CLOSED, CLOSNG, CLSHNT,
+ COINS, CONDS, DALTLC, DETAIL,
DKILL, DOOR, DPRSSN, DRAGON, DSEEN[], DTOTAL, DWARF, EGGS,
- EMRALD, ENTER, ENTRNC, FIND, FISSUR, FIXD[], FOOBAR, FOOD,
- GRATE, HINT, HINTED[], HINTLC[], HINTS[][5], HNTMAX,
- HNTSIZ, I, INVENT, IGO, IWEST, J, JADE, K, K2, KEY[], KEYS, KK,
- KNFLOC, KNIFE, KQ, L, LAMP, LIMIT, LINSIZ, LINUSE, LL,
- LMWARN, LOC, LOCK, LOCSIZ, LOCSND[], LOOK, LTEXT[],
+ EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
+ GRATE, HINT, HINTED[], HINTLC[],
+ HNTSIZ, I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
+ KNFLOC, KNIFE, KQ, L, LAMP, LIMIT, LL,
+ LMWARN, LOC, LOCK, LOOK,
MAGZIN, MAXDIE, MAXTRS, MESH, MESSAG, MIRROR, MXSCOR,
- NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ, OBJSND[],
- OBJTXT[], ODLOC[], OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
- PANIC, PEARL, PILLOW, PLAC[], PLANT, PLANT2, PROP[], PYRAM,
- RESER, ROD, ROD2, RTXSIZ, RUBY, RUG, SAPPH, SAVED, SAY,
- SCORE, SECT, SETUP, SIGN, SNAKE, SPK, STEPS, STEXT[], STICK,
- STREAM, TABNDX, TALLY, THRESH, THROW, TK[], TRAVEL[], TRIDNT,
- TRNDEX, TRNLUZ, TRNSIZ, TRNVAL[], TRNVLS, TROLL, TROLL2, TRVS,
- TRVSIZ, TTEXT[], TURNS, URN, V1, V2, VASE, VEND, VERB,
- VOLCAN, VRBSIZ, VRSION, WATER, WD1, WD1X, WD2, WD2X,
+ NEWLOC, NOVICE, NUGGET, NUL, NUMDIE, OBJ,
+ ODLOC[], OGRE, OIL, OLDLC2, OLDLOC, OLDOBJ, OYSTER,
+ PANIC, PEARL, PILLOW, PLANT, PLANT2, PROP[], PYRAM,
+ RESER, ROD, ROD2, RUBY, RUG, SAPPH, SAVED, SAY,
+ SCORE, SECT, SETUP, SIGN, SNAKE, SPK, STEPS, STICK,
+ STREAM, TALLY, THRESH, THROW, TK[], TRIDNT,
+ TRNDEX, TRNLUZ, TROLL, TROLL2,
+ TRVSIZ, TURNS, URN, V1, V2, VASE, VEND, VERB,
+ VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
WZDARK, ZZWORD;