From f47dc9f44798e3d03e4760c8b53b44c7de4c92f9 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Fri, 23 Jun 2017 10:10:48 -0400 Subject: [PATCH] Location sounds are now declared by YAML. --- actions.c | 6 +++--- dungeon.c | 7 +------ init.c | 2 +- newdungeon.py | 7 ++++++- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/actions.c b/actions.c index a17abde..5a82a5b 100644 --- a/actions.c +++ b/actions.c @@ -671,10 +671,10 @@ static int light(token_t verb, token_t obj) static int listen(void) /* Listen. Intransitive only. Print stuff based on objsnd/locsnd. */ { - int k; + long k; int spk = ALL_SILENT; - k = LOCSND[game.loc]; - if (k != 0) { + k = locations[game.loc].sound; + if (k != SILENT) { rspeak(labs(k)); if (k < 0) return GO_CLEAROBJ; spk = NO_MESSAGE; diff --git a/dungeon.c b/dungeon.c index 2e5d296..88f632d 100644 --- a/dungeon.c +++ b/dungeon.c @@ -33,7 +33,6 @@ long TABNDX; long OBJSND[NOBJECTS + 1]; long OBJTXT[NOBJECTS + 1]; long KEY[LOCSIZ + 1]; -long LOCSND[LOCSIZ + 1]; long LINES[LINSIZ + 1]; long TRAVEL[TRVSIZ + 1]; long KTAB[TABSIZ + 1]; @@ -301,7 +300,7 @@ static void read_hints(FILE* database) } } -/* Read the sound/text info, store in OBJSND, OBJTXT, LOCSND. */ +/* Read the sound/text info, store in OBJSND, OBJTXT */ static void read_sound_text(FILE* database) { long K; @@ -313,8 +312,6 @@ static void read_sound_text(FILE* database) OBJTXT[K] = (I > 0 ? I : 0); continue; } - - LOCSND[K] = KK; } } @@ -335,7 +332,6 @@ static int read_database(FILE* database) } for (int I = 1; I <= LOCSIZ; I++) { KEY[I] = 0; - LOCSND[I] = 0; } LINUSE = 1; @@ -447,7 +443,6 @@ static void write_file(FILE* header_file) write_1d(header_file, OBJSND, NOBJECTS + 1, "OBJSND"); write_1d(header_file, OBJTXT, NOBJECTS + 1, "OBJTXT"); write_1d(header_file, KEY, LOCSIZ + 1, "KEY"); - write_1d(header_file, LOCSND, LOCSIZ + 1, "LOCSND"); write_1d(header_file, TRAVEL, TRVSIZ + 1, "TRAVEL"); write_1d(header_file, KTAB, TABSIZ + 1, "KTAB"); write_1d(header_file, ATAB, TABSIZ + 1, "ATAB"); diff --git a/init.c b/init.c index dbeac0a..4511aca 100644 --- a/init.c +++ b/init.c @@ -14,7 +14,7 @@ * 12600 words of message text (LINES, LINSIZ). * 885 travel options (TRAVEL, TRVSIZ). * 330 vocabulary words (KTAB, ATAB, TABSIZ). - * 185 locations (KEY, COND, game.abbrev, game.atloc, LOCSND, LOCSIZ). + * 185 locations (KEY, COND, game.abbrev, game.atloc, LOCSIZ). * 100 objects (PLAC, game.place, FIXD, game.fixed, game.link (twice), * ogame.prop, OBJSND, OBJTXT). * 35 "action" verbs (ACTSPK, VRBSIZ). diff --git a/newdungeon.py b/newdungeon.py index 624ea86..4553eea 100755 --- a/newdungeon.py +++ b/newdungeon.py @@ -14,6 +14,8 @@ h_template = """/* Generated from adventure.yaml - do not hand-hack! */ #include +#define SILENT -1 /* no sound */ + typedef struct {{ const char* inventory; const char** longs; @@ -26,6 +28,7 @@ typedef struct {{ typedef struct {{ descriptions_t description; + const long sound; }} location_t; typedef struct {{ @@ -189,13 +192,15 @@ def get_locations(loc): .small = {}, .big = {}, }}, + .sound = {}, }}, """ loc_str = "" for item in loc: short_d = make_c_string(item[1]["description"]["short"]) long_d = make_c_string(item[1]["description"]["long"]) - loc_str += template.format(short_d, long_d) + sound = item[1].get("sound", "SILENT") + loc_str += template.format(short_d, long_d, sound) loc_str = loc_str[:-1] # trim trailing newline return loc_str -- 2.31.1