Remove some hard-coded array dimensions. Generate CLSSES at compile time. 63/head
authorJason S. Ninneman <jsn@mbar.us>
Mon, 12 Jun 2017 18:02:16 +0000 (11:02 -0700)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 12 Jun 2017 21:36:07 +0000 (21:36 +0000)
(How did this ever even work without 'extern'?)

dungeon.c
newdb.c
newdb.h

index 19b55c1652e230b8c2cad44f59f1356f57530a1f..5d1a88d6d9edbb330beea5f04287deef66e1f620 100644 (file)
--- a/dungeon.c
+++ b/dungeon.c
@@ -582,7 +582,6 @@ void write_files(FILE* c_file, FILE* header_file)
   // content variables
   write_0d(c_file, header_file, LINUSE, "LINUSE");
   write_0d(c_file, header_file, TRVS, "TRVS");
-  write_0d(c_file, header_file, CLSSES, "CLSSES");
   write_0d(c_file, header_file, TRNVLS, "TRNVLS");
   write_0d(c_file, header_file, TABNDX, "TABNDX");
   write_0d(c_file, header_file, HNTMAX, "HNTMAX");
diff --git a/newdb.c b/newdb.c
index 05b0eeb1dfa3c6e5329c1a0272505740a9fe0b4e..427661813be5bbc25397c4d2a5045d553f9443c6 100644 (file)
--- a/newdb.c
+++ b/newdb.c
@@ -1298,3 +1298,5 @@ char* turn_threshold_messages[] = {
   "Are you still at it?  Five points off for exceeding 1000 turns!",
   "Good grief, don\'t you *EVER* give up?  Do you realize you\'ve spent\nover 2500 turns at this?  That\'s another ten points off, a total of\ntwenty points lost for taking so long.",
 };
+
+size_t CLSSES = sizeof(class_messages) / sizeof(class_messages[0]);
diff --git a/newdb.h b/newdb.h
index e7461471da5ca165d502864795869efb121d03f9..cf1ec9cfa53ac595dc3192678daee7130745faf6 100644 (file)
--- a/newdb.h
+++ b/newdb.h
@@ -3,9 +3,11 @@ typedef struct {
   char** longs;
 } object_description_s;
 
-char* long_location_descriptions[186];
-char* short_location_descriptions[186];
-object_description_s object_descriptions[101];
-char* arbitrary_messages[278];
-char* class_messages[13];
-char* turn_threshold_messages[6];
+extern char* long_location_descriptions[];
+extern char* short_location_descriptions[];
+extern object_description_s object_descriptions[];
+extern char* arbitrary_messages[];
+extern char* class_messages[];
+extern char* turn_threshold_messages[];
+
+extern size_t CLSSES;