Otherwise we end up duplicating magic sizes and tey can drift apart.
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 $<
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 $@ $<
#include <stdio.h>
#include <stdbool.h>
+#include "sizes.h"
+
#define LINESIZE 100
#define NDWARVES 6
#define PIRATE NDWARVES /* must be NDWARVES-1 when zero-origin */
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];
+/*
+ * 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
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");
/* 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
--- /dev/null
+/* maximum size limits shared by dungeon compiler and runtime */
+
+#define LOCSIZ 185
+#define NOBJECTS 100