Location sounds are now declared by YAML.

This commit is contained in:
Eric S. Raymond 2017-06-23 10:10:48 -04:00
parent 98b7434b0b
commit f47dc9f447
4 changed files with 11 additions and 11 deletions

View file

@ -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;

View file

@ -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");

2
init.c
View file

@ -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).

View file

@ -14,6 +14,8 @@ h_template = """/* Generated from adventure.yaml - do not hand-hack! */
#include <stdio.h>
#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