Bite the bullet - size siymbols have to be shared.

Otherwise we end up duplicating magic sizes and tey can drift apart.
This commit is contained in:
Eric S. Raymond 2017-06-07 05:45:51 -04:00
parent 7f4cff1188
commit 461575ef4c
5 changed files with 24 additions and 12 deletions

View file

@ -11,7 +11,7 @@ ifeq ($(UNAME_S),Linux)
endif endif
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
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: .c.o:
$(CC) $(CCFLAGS) $(DBX) -c $< $(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 advent: $(OBJS) database.o
$(CC) $(CCFLAGS) $(DBX) -o advent $(OBJS) database.o $(LDFLAGS) $(LIBS) $(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 compile: compile.c
$(CC) $(CCFLAGS) -o $@ $< $(CC) $(CCFLAGS) -o $@ $<

View file

@ -1,6 +1,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdbool.h> #include <stdbool.h>
#include "sizes.h"
#define LINESIZE 100 #define LINESIZE 100
#define NDWARVES 6 #define NDWARVES 6
#define PIRATE NDWARVES /* must be NDWARVES-1 when zero-origin */ #define PIRATE NDWARVES /* must be NDWARVES-1 when zero-origin */
@ -51,7 +53,7 @@ struct game_t {
long turns; long turns;
long wzdark; long wzdark;
long zzword; long zzword;
long abbrev[185+1]; /* FIXME: LOCSIZE in the compiler */ long abbrev[LOCSIZ+1];
long dseen[NDWARVES+1]; long dseen[NDWARVES+1];
long dloc[NDWARVES+1]; long dloc[NDWARVES+1];
long odloc[NDWARVES+1]; long odloc[NDWARVES+1];

View file

@ -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 LINESIZE 100
#define RTXSIZ 277 #define RTXSIZ 277
#define CLSMAX 12 #define CLSMAX 12
#define LOCSIZ 185
#define LINSIZ 12600 #define LINSIZ 12600
#define TRNSIZ 5 #define TRNSIZ 5
#define TABSIZ 330 #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) void write_files(FILE* c_file, FILE* header_file)
{ {
// preprocessor defines for the header // 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 RTXSIZ 277\n");
fprintf(header_file, "#define CLSMAX 12\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 LINSIZ %d\n", LINSIZ);
fprintf(header_file, "#define TRNSIZ 5\n"); fprintf(header_file, "#define TRNSIZ 5\n");
fprintf(header_file, "#define TABSIZ 330\n"); fprintf(header_file, "#define TABSIZ 330\n");

1
init.c
View file

@ -33,6 +33,7 @@
/* Note: /* Note:
* - the object count limit has been abstracted as NOBJECTS * - the object count limit has been abstracted as NOBJECTS
* - the random message limit has been abstracted as RTXSIZE * - the random message limit has been abstracted as RTXSIZE
* - maximum locations limit has been abstracted as LOCSIZ
*/ */
/* Description of the database format /* Description of the database format

4
sizes.h Normal file
View file

@ -0,0 +1,4 @@
/* maximum size limits shared by dungeon compiler and runtime */
#define LOCSIZ 185
#define NOBJECTS 100