Header consolidation - main.h, misc.h, and share.h merge to advent.h.
For a project this small size with a small type ontology, it's better C style to have one header where all the assumptions about types and structures are immediately visible. This is a first step towards turning all that global state into a handful of structures - probably just two, one saveable as a binary game state.
This commit is contained in:
parent
4209b82c5a
commit
d402e09411
10 changed files with 53 additions and 64 deletions
14
Makefile
14
Makefile
|
@ -9,7 +9,7 @@ ifeq ($(UNAME_S),Linux)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OBJS=main.o init.o actions1.o actions2.o score.o misc.o database.o
|
OBJS=main.o init.o actions1.o actions2.o score.o misc.o database.o
|
||||||
SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO adventure.text advent.text control misc.h main.h share.h funcs.h
|
SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO adventure.text advent.text control advent.h funcs.h
|
||||||
|
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(CCFLAGS) -O $(DBX) -c $<
|
$(CC) $(CCFLAGS) -O $(DBX) -c $<
|
||||||
|
@ -17,17 +17,17 @@ SOURCES=$(OBJS:.o=.c) COPYING NEWS README TODO adventure.text advent.text contro
|
||||||
advent: $(OBJS) database.o
|
advent: $(OBJS) database.o
|
||||||
$(CC) $(CCFLAGS) -O $(DBX) -o advent $(OBJS) $(LIBS)
|
$(CC) $(CCFLAGS) -O $(DBX) -o advent $(OBJS) $(LIBS)
|
||||||
|
|
||||||
main.o: main.h misc.h funcs.h database.h
|
main.o: advent.h funcs.h database.h
|
||||||
|
|
||||||
init.o: misc.h main.h share.h funcs.h database.h
|
init.o: advent.h funcs.h database.h
|
||||||
|
|
||||||
actions1.o: misc.h main.h share.h funcs.h database.h
|
actions1.o: advent.h funcs.h database.h
|
||||||
|
|
||||||
actions2.o: misc.h main.h share.h funcs.h
|
actions2.o: advent.h funcs.h
|
||||||
|
|
||||||
score.o: misc.h main.h share.h database.h
|
score.o: advent.h database.h
|
||||||
|
|
||||||
misc.o: misc.h main.h database.h
|
misc.o: advent.h database.h
|
||||||
|
|
||||||
database.o: database.h
|
database.o: database.h
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "misc.h"
|
#include "advent.h"
|
||||||
#include "main.h"
|
|
||||||
#include "share.h"
|
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
#include "misc.h"
|
#include "advent.h"
|
||||||
#include "main.h"
|
|
||||||
#include "share.h"
|
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
|
|
||||||
/* Carry an object. Special cases for bird and cage (if bird in cage, can't
|
/* Carry an object. Special cases for bird and cage (if bird in cage, can't
|
||||||
|
|
|
@ -1,6 +1,21 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
#define LINESIZE 100
|
||||||
|
|
||||||
|
typedef struct lcg_state
|
||||||
|
{
|
||||||
|
unsigned long a, c, m, x;
|
||||||
|
} lcg_state;
|
||||||
|
|
||||||
|
extern long ABB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
|
||||||
|
LINK[], LNLENG, LNPOSN,
|
||||||
|
PARMS[], PLACE[];
|
||||||
|
extern char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[];
|
||||||
|
extern FILE *logfp;
|
||||||
|
extern bool oldstyle;
|
||||||
|
extern lcg_state lcgstate;
|
||||||
|
|
||||||
/* b is not needed for POSIX but harmless */
|
/* b is not needed for POSIX but harmless */
|
||||||
#define READ_MODE "rb"
|
#define READ_MODE "rb"
|
||||||
#define WRITE_MODE "wb"
|
#define WRITE_MODE "wb"
|
||||||
|
@ -75,3 +90,28 @@ extern long fMOD(long,long);
|
||||||
extern void set_seed(long);
|
extern void set_seed(long);
|
||||||
extern unsigned long get_next_lcg_value(void);
|
extern unsigned long get_next_lcg_value(void);
|
||||||
extern long randrange(long);
|
extern long randrange(long);
|
||||||
|
|
||||||
|
extern void score(long);
|
||||||
|
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,
|
||||||
|
COINS, CONDS, DALTLC, DETAIL,
|
||||||
|
DKILL, DOOR, DPRSSN, DRAGON, DSEEN[], DTOTAL, DWARF, EGGS,
|
||||||
|
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
|
||||||
|
GRATE, HINT, HINTED[], HINTLC[],
|
||||||
|
I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
|
||||||
|
KNFLOC, KNIFE, KQ, L, LAMP, LIMIT, LL,
|
||||||
|
LMWARN, LOC, LOCK, LOOK,
|
||||||
|
MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR,
|
||||||
|
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,
|
||||||
|
TURNS, URN, V1, V2, VASE, VEND, VERB,
|
||||||
|
VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
|
||||||
|
WZDARK, ZZWORD;
|
||||||
|
|
4
init.c
4
init.c
|
@ -3,9 +3,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "misc.h"
|
#include "advent.h"
|
||||||
#include "main.h"
|
|
||||||
#include "share.h"
|
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
|
|
3
main.c
3
main.c
|
@ -9,9 +9,8 @@
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "main.h"
|
#include "advent.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
long ABB[186], ATLOC[186], BLKLIN = true, DFLAG,
|
long ABB[186], ATLOC[186], BLKLIN = true, DFLAG,
|
||||||
DLOC[7], FIXED[101], HOLDNG,
|
DLOC[7], FIXED[101], HOLDNG,
|
||||||
|
|
16
main.h
16
main.h
|
@ -1,16 +0,0 @@
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#define LINESIZE 100
|
|
||||||
|
|
||||||
typedef struct lcg_state
|
|
||||||
{
|
|
||||||
unsigned long a, c, m, x;
|
|
||||||
} lcg_state;
|
|
||||||
|
|
||||||
extern long ABB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG,
|
|
||||||
LINK[], LNLENG, LNPOSN,
|
|
||||||
PARMS[], PLACE[];
|
|
||||||
extern char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[];
|
|
||||||
extern FILE *logfp;
|
|
||||||
extern bool oldstyle;
|
|
||||||
extern lcg_state lcgstate;
|
|
4
misc.c
4
misc.c
|
@ -3,9 +3,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "main.h"
|
#include "advent.h"
|
||||||
#include "share.h" /* for SETUP */
|
|
||||||
#include "misc.h"
|
|
||||||
#include "funcs.h"
|
#include "funcs.h"
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
|
|
4
score.c
4
score.c
|
@ -1,7 +1,5 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "misc.h"
|
#include "advent.h"
|
||||||
#include "main.h"
|
|
||||||
#include "share.h"
|
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
24
share.h
24
share.h
|
@ -1,24 +0,0 @@
|
||||||
extern void score(long);
|
|
||||||
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,
|
|
||||||
COINS, CONDS, DALTLC, DETAIL,
|
|
||||||
DKILL, DOOR, DPRSSN, DRAGON, DSEEN[], DTOTAL, DWARF, EGGS,
|
|
||||||
EMRALD, ENTER, ENTRNC, FIND, FISSUR, FOOBAR, FOOD,
|
|
||||||
GRATE, HINT, HINTED[], HINTLC[],
|
|
||||||
I, INVENT, IGO, IWEST, J, JADE, K, K2, KEYS, KK,
|
|
||||||
KNFLOC, KNIFE, KQ, L, LAMP, LIMIT, LL,
|
|
||||||
LMWARN, LOC, LOCK, LOOK,
|
|
||||||
MAGZIN, MAXDIE, MAXTRS, MESSAG, MIRROR, MXSCOR,
|
|
||||||
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,
|
|
||||||
TURNS, URN, V1, V2, VASE, VEND, VERB,
|
|
||||||
VOLCAN, VRSION, WATER, WD1, WD1X, WD2, WD2X,
|
|
||||||
WZDARK, ZZWORD;
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue