From: Eric S. Raymond Date: Fri, 2 Jun 2017 19:01:52 +0000 (-0400) Subject: Header consolidation - main.h, misc.h, and share.h merge to advent.h. X-Git-Tag: 0.90~30 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=d402e0941196131533b92b51243fda9268fa6069;p=open-adventure.git 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. --- diff --git a/Makefile b/Makefile index c2f34d4..bdd19de 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ ifeq ($(UNAME_S),Linux) endif 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: $(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 $(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 diff --git a/actions1.c b/actions1.c index 5ef0953..791e0c2 100644 --- a/actions1.c +++ b/actions1.c @@ -1,8 +1,6 @@ #include #include -#include "misc.h" -#include "main.h" -#include "share.h" +#include "advent.h" #include "funcs.h" #include "database.h" diff --git a/actions2.c b/actions2.c index 6b28895..f208a49 100644 --- a/actions2.c +++ b/actions2.c @@ -1,6 +1,4 @@ -#include "misc.h" -#include "main.h" -#include "share.h" +#include "advent.h" #include "funcs.h" /* Carry an object. Special cases for bird and cage (if bird in cage, can't diff --git a/advent.h b/advent.h new file mode 100644 index 0000000..421c481 --- /dev/null +++ b/advent.h @@ -0,0 +1,117 @@ +#include +#include + +#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 */ +#define READ_MODE "rb" +#define WRITE_MODE "wb" + +extern void fSPEAK(long); +#define SPEAK(N) fSPEAK(N) +extern void fPSPEAK(long,long); +#define PSPEAK(MSG,SKIP) fPSPEAK(MSG,SKIP) +extern void fRSPEAK(long); +#define RSPEAK(I) fRSPEAK(I) +extern void fSETPRM(long,long,long); +#define SETPRM(FIRST,P1,P2) fSETPRM(FIRST,P1,P2) +extern bool fGETIN(FILE *,long*,long*,long*,long*); +#define GETIN(input,WORD1,WORD1X,WORD2,WORD2X) fGETIN(input,&WORD1,&WORD1X,&WORD2,&WORD2X) +extern long fYES(FILE *,long,long,long); +#define YES(input,X,Y,Z) fYES(input,X,Y,Z) +extern long fGETNUM(FILE *); +#define GETNUM(K) fGETNUM(K) +extern long fGETTXT(long,long,long); +#define GETTXT(SKIP,ONEWRD,UPPER) fGETTXT(SKIP,ONEWRD,UPPER) +extern long fMAKEWD(long); +#define MAKEWD(LETTRS) fMAKEWD(LETTRS) +extern void fPUTTXT(long,long*,long); +#define PUTTXT(WORD,STATE,CASE) fPUTTXT(WORD,&STATE,CASE) +extern void fSHFTXT(long,long); +#define SHFTXT(FROM,DELTA) fSHFTXT(FROM,DELTA) +extern void fTYPE0(); +#define TYPE0() fTYPE0() +extern void fSAVWDS(long*,long*,long*,long*,long*,long*,long*); +#define SAVWDS(W1,W2,W3,W4,W5,W6,W7) fSAVWDS(&W1,&W2,&W3,&W4,&W5,&W6,&W7) +extern void fSAVARR(long*,long); +#define SAVARR(ARR,N) fSAVARR(ARR,N) +extern void fSAVWRD(long,long*); +#define SAVWRD(OP,WORD) fSAVWRD(OP,&WORD) +extern long fVOCAB(long,long); +#define VOCAB(ID,INIT) fVOCAB(ID,INIT) +extern void fDSTROY(long); +#define DSTROY(OBJECT) fDSTROY(OBJECT) +extern void fJUGGLE(long); +#define JUGGLE(OBJECT) fJUGGLE(OBJECT) +extern void fMOVE(long,long); +#define MOVE(OBJECT,WHERE) fMOVE(OBJECT,WHERE) +extern long fPUT(long,long,long); +#define PUT(OBJECT,WHERE,PVAL) fPUT(OBJECT,WHERE,PVAL) +extern void fCARRY(long,long); +#define CARRY(OBJECT,WHERE) fCARRY(OBJECT,WHERE) +extern void fDROP(long,long); +#define DROP(OBJECT,WHERE) fDROP(OBJECT,WHERE) +extern long fATDWRF(long); +#define ATDWRF(WHERE) fATDWRF(WHERE) +extern long fSETBIT(long); +#define SETBIT(BIT) fSETBIT(BIT) +extern long fTSTBIT(long,long); +#define TSTBIT(MASK,BIT) fTSTBIT(MASK,BIT) +extern long fRNDVOC(long,long); +#define RNDVOC(CHAR,FORCE) fRNDVOC(CHAR,FORCE) +extern void fBUG(long); +#define BUG(NUM) fBUG(NUM) +extern void fMAPLIN(FILE *); +#define MAPLIN(FIL) fMAPLIN(FIL) +extern void fTYPE(); +#define TYPE() fTYPE() +extern void fMPINIT(); +#define MPINIT() fMPINIT() +extern void fSAVEIO(long,long,long*); +#define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR) +extern void DATIME(long*, long*); +extern long fIABS(long); +#define IABS(N) fIABS(N) +extern long fMOD(long,long); +#define MOD(N,M) fMOD(N,M) +extern void set_seed(long); +extern unsigned long get_next_lcg_value(void); +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; + diff --git a/init.c b/init.c index 69901c1..c5486cf 100644 --- a/init.c +++ b/init.c @@ -3,9 +3,7 @@ #include #include -#include "misc.h" -#include "main.h" -#include "share.h" +#include "advent.h" #include "funcs.h" #include "database.h" diff --git a/main.c b/main.c index 400abd8..6c55127 100644 --- a/main.c +++ b/main.c @@ -9,9 +9,8 @@ #include #include #include -#include "main.h" +#include "advent.h" #include "database.h" -#include "misc.h" long ABB[186], ATLOC[186], BLKLIN = true, DFLAG, DLOC[7], FIXED[101], HOLDNG, diff --git a/main.h b/main.h deleted file mode 100644 index 259170a..0000000 --- a/main.h +++ /dev/null @@ -1,16 +0,0 @@ -#include - -#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; diff --git a/misc.c b/misc.c index 3aca465..adbccdb 100644 --- a/misc.c +++ b/misc.c @@ -3,9 +3,7 @@ #include #include #include -#include "main.h" -#include "share.h" /* for SETUP */ -#include "misc.h" +#include "advent.h" #include "funcs.h" #include "database.h" diff --git a/misc.h b/misc.h deleted file mode 100644 index e16c308..0000000 --- a/misc.h +++ /dev/null @@ -1,77 +0,0 @@ -#include -#include - -/* b is not needed for POSIX but harmless */ -#define READ_MODE "rb" -#define WRITE_MODE "wb" - -extern void fSPEAK(long); -#define SPEAK(N) fSPEAK(N) -extern void fPSPEAK(long,long); -#define PSPEAK(MSG,SKIP) fPSPEAK(MSG,SKIP) -extern void fRSPEAK(long); -#define RSPEAK(I) fRSPEAK(I) -extern void fSETPRM(long,long,long); -#define SETPRM(FIRST,P1,P2) fSETPRM(FIRST,P1,P2) -extern bool fGETIN(FILE *,long*,long*,long*,long*); -#define GETIN(input,WORD1,WORD1X,WORD2,WORD2X) fGETIN(input,&WORD1,&WORD1X,&WORD2,&WORD2X) -extern long fYES(FILE *,long,long,long); -#define YES(input,X,Y,Z) fYES(input,X,Y,Z) -extern long fGETNUM(FILE *); -#define GETNUM(K) fGETNUM(K) -extern long fGETTXT(long,long,long); -#define GETTXT(SKIP,ONEWRD,UPPER) fGETTXT(SKIP,ONEWRD,UPPER) -extern long fMAKEWD(long); -#define MAKEWD(LETTRS) fMAKEWD(LETTRS) -extern void fPUTTXT(long,long*,long); -#define PUTTXT(WORD,STATE,CASE) fPUTTXT(WORD,&STATE,CASE) -extern void fSHFTXT(long,long); -#define SHFTXT(FROM,DELTA) fSHFTXT(FROM,DELTA) -extern void fTYPE0(); -#define TYPE0() fTYPE0() -extern void fSAVWDS(long*,long*,long*,long*,long*,long*,long*); -#define SAVWDS(W1,W2,W3,W4,W5,W6,W7) fSAVWDS(&W1,&W2,&W3,&W4,&W5,&W6,&W7) -extern void fSAVARR(long*,long); -#define SAVARR(ARR,N) fSAVARR(ARR,N) -extern void fSAVWRD(long,long*); -#define SAVWRD(OP,WORD) fSAVWRD(OP,&WORD) -extern long fVOCAB(long,long); -#define VOCAB(ID,INIT) fVOCAB(ID,INIT) -extern void fDSTROY(long); -#define DSTROY(OBJECT) fDSTROY(OBJECT) -extern void fJUGGLE(long); -#define JUGGLE(OBJECT) fJUGGLE(OBJECT) -extern void fMOVE(long,long); -#define MOVE(OBJECT,WHERE) fMOVE(OBJECT,WHERE) -extern long fPUT(long,long,long); -#define PUT(OBJECT,WHERE,PVAL) fPUT(OBJECT,WHERE,PVAL) -extern void fCARRY(long,long); -#define CARRY(OBJECT,WHERE) fCARRY(OBJECT,WHERE) -extern void fDROP(long,long); -#define DROP(OBJECT,WHERE) fDROP(OBJECT,WHERE) -extern long fATDWRF(long); -#define ATDWRF(WHERE) fATDWRF(WHERE) -extern long fSETBIT(long); -#define SETBIT(BIT) fSETBIT(BIT) -extern long fTSTBIT(long,long); -#define TSTBIT(MASK,BIT) fTSTBIT(MASK,BIT) -extern long fRNDVOC(long,long); -#define RNDVOC(CHAR,FORCE) fRNDVOC(CHAR,FORCE) -extern void fBUG(long); -#define BUG(NUM) fBUG(NUM) -extern void fMAPLIN(FILE *); -#define MAPLIN(FIL) fMAPLIN(FIL) -extern void fTYPE(); -#define TYPE() fTYPE() -extern void fMPINIT(); -#define MPINIT() fMPINIT() -extern void fSAVEIO(long,long,long*); -#define SAVEIO(OP,IN,ARR) fSAVEIO(OP,IN,ARR) -extern void DATIME(long*, long*); -extern long fIABS(long); -#define IABS(N) fIABS(N) -extern long fMOD(long,long); -#define MOD(N,M) fMOD(N,M) -extern void set_seed(long); -extern unsigned long get_next_lcg_value(void); -extern long randrange(long); diff --git a/score.c b/score.c index 4ef68ad..31994c2 100644 --- a/score.c +++ b/score.c @@ -1,7 +1,5 @@ #include -#include "misc.h" -#include "main.h" -#include "share.h" +#include "advent.h" #include "database.h" /* diff --git a/share.h b/share.h deleted file mode 100644 index 4fd867c..0000000 --- a/share.h +++ /dev/null @@ -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; -