From: Eric S. Raymond Date: Sat, 24 Jun 2017 15:07:07 +0000 (-0400) Subject: Give generate constant arrays the const specifier. X-Git-Tag: 1.1~132 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=3e19c39f579dacb20c1c9b6fc1a26c8d106f1365;p=open-adventure.git Give generate constant arrays the const specifier. Also, move the adventure.txt format documentation to dungeon.c to be removed when that file is. --- diff --git a/dungeon.c b/dungeon.c index fea3c6d..feb98e7 100644 --- a/dungeon.c +++ b/dungeon.c @@ -1,9 +1,88 @@ /* * 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. + * defining invariant state. */ +/* Current limits: + * 12600 words of message text (LINES, LINSIZ). + * 885 travel options (TRAVEL, TRVSIZ). + * 330 vocabulary words (KTAB, ATAB, TABSIZ). + * 35 "action" verbs (ACTSPK, VRBSIZ). + * There are also limits which cannot be exceeded due to the structure of + * the database. (E.G., The vocabulary uses n/1000 to determine word type, + * so there can't be more than 1000 words.) These upper limits are: + * 1000 non-synonymous vocabulary words + * 300 locations + * 100 objects + */ + +/* Description of the database format + * + * + * The data file contains several sections. Each begins with a line containing + * a number identifying the section, and ends with a line containing "-1". + * + * Section 3: Travel table. Each line contains a location number (X), a second + * location number (Y), and a list of motion numbers (see section 4). + * each motion represents a verb which will go to Y if currently at X. + * Y, in turn, is interpreted as follows. Let M=Y/1000, N=Y mod 1000. + * If N<=300 it is the location to go to. + * If 300500 message N-500 from section 6 is printed, + * and he stays wherever he is. + * Meanwhile, M specifies the conditions on the motion. + * If M=0 it's unconditional. + * If 0500 message N-500 from section 6 is printed, - * and he stays wherever he is. - * Meanwhile, M specifies the conditions on the motion. - * If M=0 it's unconditional. - * If 0$<". (The magic value - * 100 is now mostly abstracted out as NOBJECTS.) - * Section 6: Arbitrary messages. Same format as sections 1, 2, and 5, except - * the numbers bear no relation to anything (except for special verbs - * in section 4). - * Section 7: Object locations. Each line contains an object number and its - * initial location (zero (or omitted) if none). If the object is - * immovable, the location is followed by a "-1". If it has two locations - * (e.g. the grate) the first location is followed with the second, and - * the object is assumed to be immovable. - * Section 8: Action defaults. Each line contains an "action-verb" number and - * the index (in section 6) of the default message for the verb. - * Section 9: Location attributes. Each line contains a number (n) and up to - * 20 location numbers. Bit N (where 0 is the units bit) is set in - * COND(LOC) for each loc given. The cond bits currently assigned are: - * 0 Light - * 1 If bit 2 is on: on for oil, off for water - * 2 Liquid asset, see bit 1 - * 3 Pirate doesn't go here unless following player - * 4 Cannot use "back" to move away - * Bits past 10 indicate areas of interest to "hint" routines: - * 11 Trying to get into cave - * 12 Trying to catch bird - * 13 Trying to deal with snake - * 14 Lost in maze - * 15 Pondering dark room - * 16 At witt's end - * 17 Cliff with urn - * 18 Lost in forest - * 19 Trying to deal with ogre - * 20 Found all treasures except jade - * COND(LOC) is set to 2, overriding all other bits, if loc has forced - * motion. - * Section 10: Class messages. Each line contains a number (n), a tab, and a - * message describing a classification of player. The scoring section - * selects the appropriate message, where each message is considered to - * apply to players whose scores are higher than the previous N but not - * higher than this N. Note that these scores probably change with every - * modification (and particularly expansion) of the program. - * Section 11: Hints. Each line contains a hint number (add 10 to get cond - * bit; see section 9), the number of turns he must be at the right loc(s) - * before triggering the hint, the points deducted for taking the hint, - * the message number (section 6) of the question, and the message number - * of the hint. These values are stashed in the "hints" array. - * Section 12: Unused in this version. - * Section 13: Sounds and text. Each line contains either 2 or 3 numbers. If - * 2 (call them N and S), N is a location and message ABS(S) from section - * 6 is the sound heard there. If S<0, the sound there drowns out all - * other noises. If 3 numbers (call them N, S, and T), N is an object - * number and S+game.prop(N) is the property message (from section 5) if he - * listens to the object, and T+game.prop(N) is the text if he reads it. If - * S or T is -1, the object has no sound or text, respectively. Neither - * S nor T is allowed to be 0. - * Section 14: Turn threshholds. Each line contains a number (N), a tab, and - * a message berating the player for taking so many turns. The messages - * must be in the proper (ascending) order. The message gets printed if - * the player exceeds N % 100000 turns, at which time N/100000 points - * get deducted from his score. - * Section 0: End of database. */ - -/* The various messages (sections 1, 2, 5, 6, etc.) may include certain - * special character sequences to denote that the program must provide - * parameters to insert into a message when the message is printed. These - * sequences are: - * %S = The letter 'S' or nothing (if a given value is exactly 1) - * %W = A word (up to 10 characters) - * %L = A word mapped to lower-case letters - * %U = A word mapped to upper-case letters - * %C = A word mapped to lower-case, first letter capitalised - * %T = Several words of text, ending with a word of -1 - * %1 = A 1-digit number - * %2 = A 2-digit number - * ... - * %9 = A 9-digit number - * %B = Variable number of blanks - * %! = The entire message should be suppressed */ - void initialise(void) { if (oldstyle) diff --git a/newdungeon.py b/newdungeon.py index 21ac9e6..df8b19a 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -62,13 +62,13 @@ typedef struct {{ const char* hint; }} hint_t; -extern location_t locations[]; -extern object_description_t object_descriptions[]; -extern const char* arbitrary_messages[]; -extern const class_t classes[]; -extern turn_threshold_t turn_thresholds[]; -extern obituary_t obituaries[]; -extern hint_t hints[]; +extern const location_t locations[]; +extern const object_description_t object_descriptions[]; +extern const const char* arbitrary_messages[]; +extern const const class_t classes[]; +extern const turn_threshold_t turn_thresholds[]; +extern const obituary_t obituaries[]; +extern const hint_t hints[]; extern long conditions[]; #define NLOCATIONS {} @@ -109,23 +109,23 @@ const class_t classes[] = {{ {} }}; -turn_threshold_t turn_thresholds[] = {{ +const turn_threshold_t turn_thresholds[] = {{ {} }}; -location_t locations[] = {{ +const location_t locations[] = {{ {} }}; -object_description_t object_descriptions[] = {{ +const object_description_t object_descriptions[] = {{ {} }}; -obituary_t obituaries[] = {{ +const obituary_t obituaries[] = {{ {} }}; -hint_t hints[] = {{ +const hint_t hints[] = {{ {} }};