From: Eric S. Raymond Date: Wed, 7 Jun 2017 09:45:51 +0000 (-0400) Subject: Bite the bullet - size siymbols have to be shared. X-Git-Tag: 1.1~585 X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=commitdiff_plain;h=461575ef4c662f65c1042ced78fbaef6d1af6074 Bite the bullet - size siymbols have to be shared. Otherwise we end up duplicating magic sizes and tey can drift apart. --- diff --git a/Makefile b/Makefile index dce6fc0..24759f7 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ ifeq ($(UNAME_S),Linux) endif OBJS=main.o init.o actions1.o actions2.o score.o misc.o -SOURCES=$(OBJS:.o=.c) compile.c advent.h funcs.h adventure.text Makefile control +SOURCES=$(OBJS:.o=.c) compile.c advent.h funcs.h sizes.h adventure.text Makefile control .c.o: $(CC) $(CCFLAGS) $(DBX) -c $< @@ -19,19 +19,19 @@ SOURCES=$(OBJS:.o=.c) compile.c advent.h funcs.h adventure.text Makefile control advent: $(OBJS) database.o $(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) database.o $(LDFLAGS) $(LIBS) -main.o: advent.h funcs.h database.h +main.o: advent.h funcs.h database.h sizes.h -init.o: advent.h funcs.h database.h +init.o: advent.h funcs.h database.h sizes.h -actions1.o: advent.h funcs.h database.h +actions1.o: advent.h funcs.h database.h sizes.h -actions2.o: advent.h funcs.h database.h +actions2.o: advent.h funcs.h database.h sizes.h -score.o: advent.h database.h +score.o: advent.h database.h sizes.h -misc.o: advent.h database.h +misc.o: advent.h database.h sizes.h -database.o: database.h +database.o: database.h sizes.h compile: compile.c $(CC) $(CCFLAGS) -o $@ $< diff --git a/advent.h b/advent.h index 0f06ccc..23f3406 100644 --- a/advent.h +++ b/advent.h @@ -1,6 +1,8 @@ #include #include +#include "sizes.h" + #define LINESIZE 100 #define NDWARVES 6 #define PIRATE NDWARVES /* must be NDWARVES-1 when zero-origin */ @@ -51,7 +53,7 @@ struct game_t { long turns; long wzdark; long zzword; - long abbrev[185+1]; /* FIXME: LOCSIZE in the compiler */ + long abbrev[LOCSIZ+1]; long dseen[NDWARVES+1]; long dloc[NDWARVES+1]; long odloc[NDWARVES+1]; diff --git a/compile.c b/compile.c index c048065..f030656 100644 --- a/compile.c +++ b/compile.c @@ -1,7 +1,13 @@ +/* + * The dungeon compiler. Turns adventure.text into a set of C initializers + * defining (mostly) invariant state. A couple of slots are messed with + * at runtime. + */ +#include "sizes.h" + #define LINESIZE 100 #define RTXSIZ 277 #define CLSMAX 12 -#define LOCSIZ 185 #define LINSIZ 12600 #define TRNSIZ 5 #define TABSIZ 330 @@ -548,10 +554,9 @@ void write_hints(FILE* c_file, FILE* header_file, long matrix[][HINTLEN], long d void write_files(FILE* c_file, FILE* header_file) { // preprocessor defines for the header - fprintf(header_file, "#define NOBJECTS %d\n", NOBJECTS); + fprintf(header_file, "#include \"sizes.h\"\n"); fprintf(header_file, "#define RTXSIZ 277\n"); fprintf(header_file, "#define CLSMAX 12\n"); - fprintf(header_file, "#define LOCSIZ 185\n"); fprintf(header_file, "#define LINSIZ %d\n", LINSIZ); fprintf(header_file, "#define TRNSIZ 5\n"); fprintf(header_file, "#define TABSIZ 330\n"); diff --git a/init.c b/init.c index 5425b7a..879ea08 100644 --- a/init.c +++ b/init.c @@ -33,6 +33,7 @@ /* Note: * - the object count limit has been abstracted as NOBJECTS * - the random message limit has been abstracted as RTXSIZE + * - maximum locations limit has been abstracted as LOCSIZ */ /* Description of the database format diff --git a/sizes.h b/sizes.h new file mode 100644 index 0000000..e59fa86 --- /dev/null +++ b/sizes.h @@ -0,0 +1,4 @@ +/* maximum size limits shared by dungeon compiler and runtime */ + +#define LOCSIZ 185 +#define NOBJECTS 100