From: Eric S. Raymond Date: Wed, 21 Jun 2017 11:39:10 +0000 (-0400) Subject: Document the YAML, remove some dead code, fix typos. X-Git-Tag: 1.1~181 X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=commitdiff_plain;h=b37f9f4b2daa51b969a1d0e08cf84f23ca82202b Document the YAML, remove some dead code, fix typos. --- diff --git a/adventure.yaml b/adventure.yaml index fca7676..ec9ce29 100644 --- a/adventure.yaml +++ b/adventure.yaml @@ -1,3 +1,38 @@ +# This YAML file gets processed into a collection of data structure and +# variable initializers describing Colossal Cave. It replaces an ad-hoc +# text database shipped with Adventure versions up to 2.6. The format +# change enabled a lot of use of symbolic names where there were previously +# inscrutable numeric literals. +# +# We define a bunch of YAML structures: +# +# locations: Each item contains a long and short description. Some +# short descriptions are empty. Order of these locations is significant; +# see the macros OUTSID and INDEEP. +# +# arbitrary_messages: These are arguments to RSPEAK(). Some spans of +# these messages need to be kept adjacent and ordered. To see which, +# grep for RSPEAK calls containing expressions with arithmetic. +# +# classes: Each item contains a point threshold and a message +# describing a classification of player. point thresholds must be +# in ascending order. The scoring code 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. +# +# turn_thresholds: Each item contains a number 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. +# +# objects: Each item contains a description for use in the inventory command +# and one or more messages describing the object in different states. +# If the inventory desription begins with "*" the object is dungeon +# furniture that cannot be taken or carried. +# locations: !!omap - LOC_NOWHERE: description: @@ -575,7 +610,7 @@ locations: !!omap description: long: 'You are in a large chamber with passages to the west and north.' short: !!null -- LOC_SOTOREROOM: +- LOC_STOREROOM: description: long: 'You are in the ogre''s storeroom. The only exit is to the south.' short: !!null diff --git a/common.h b/common.h index 0e865c4..942a271 100644 --- a/common.h +++ b/common.h @@ -21,7 +21,6 @@ enum bugtype { LOCATION_HAS_CONDITION_BIT_BEING_SET_TWICE, // 8 INVALID_SECTION_NUMBER_IN_DATABASE, // 9 TOO_MANY_LOCATIONS, // 10 - TOO_MANY_CLASS_OR_TURN_MESSAGES, // 11 SPECIAL_TRAVEL_500_GT_L_GT_300_EXCEEDS_GOTO_LIST = 20, // 20 RAN_OFF_END_OF_VOCABULARY_TABLE, // 21 VOCABULARY_TYPE_N_OVER_1000_NOT_BETWEEN_0_AND_3, // 22 diff --git a/dungeon.c b/dungeon.c index e17e93c..dccda9e 100644 --- a/dungeon.c +++ b/dungeon.c @@ -35,7 +35,6 @@ long TABNDX; long HNTMAX; long PTEXT[NOBJECTS + 1]; long RTEXT[RTXSIZ + 1]; -long CTEXT[CLSMAX + 1]; long OBJSND[NOBJECTS + 1]; long OBJTXT[NOBJECTS + 1]; long STEXT[LOCSIZ + 1]; @@ -217,15 +216,7 @@ static void read_messages(FILE* database, long sect) if (loc == OLDLOC) continue; OLDLOC = loc; LINES[LINUSE] = -KK; - if (sect == 14) { - TRNVLS = TRNVLS + 1; - if (TRNVLS > TRNSIZ) - BUG(TOO_MANY_CLASS_OR_TURN_MESSAGES); - TTEXT[TRNVLS] = LINUSE; - TRNVAL[TRNVLS] = loc; - continue; - } - if (sect == 10) { + if (sect == 10 || sect == 14) { /* now parsed from YAML */ continue; } @@ -360,17 +351,17 @@ static void read_sound_text(FILE* database) static int read_database(FILE* database) { - - /* Clear out the various text-pointer arrays. All text is stored in array - * lines; each line is preceded by a word pointing to the next pointer (i.e. - * the word following the end of the line). The pointer is negative if this is - * first line of a message. The text-pointer arrays contain indices of - * pointer-words in lines. STEXT(N) is short description of location N. - * LTEXT(N) is long description. PTEXT(N) points to message for game.prop(N)=0. - * Successive prop messages are found by chasing pointers. RTEXT contains - * section 6's stuff. CTEXT(N) points to a player-class message. TTEXT is for - * section 14. We also clear COND (see description of section 9 for details). */ - + /* Clear out the various text-pointer arrays. All text is stored + * in array lines; each line is preceded by a word pointing to + * the next pointer (i.e. the word following the end of the + * line). The pointer is negative if this is first line of a + * message. The text-pointer arrays contain indices of + * pointer-words in lines. STEXT(N) is short description of + * location N. LTEXT(N) is long description. PTEXT(N) points to + * message for game.prop(N)=0. Successive prop messages are + * found by chasing pointers. RTEXT contains section 6's stuff. + * TTEXT is for section 14. We also clear COND (see description + * of section 9 for details). */ for (int I = 1; I <= NOBJECTS; I++) { PTEXT[I] = 0; OBJSND[I] = 0; @@ -379,9 +370,6 @@ static int read_database(FILE* database) for (int I = 1; I <= RTXSIZ; I++) { RTEXT[I] = 0; } - for (int I = 1; I <= CLSMAX; I++) { - CTEXT[I] = 0; - } for (int I = 1; I <= LOCSIZ; I++) { STEXT[I] = 0; LTEXT[I] = 0;