object_descriptions[] is now objects[].

This commit is contained in:
Jason S. Ninneman 2017-06-26 09:42:43 -07:00
parent d40085ce6f
commit 2fac8d1aef
7 changed files with 48 additions and 48 deletions

View file

@ -86,14 +86,14 @@ static int attack(FILE *input, struct command_t *command)
pspeak(DRAGON, look, 3);
game.prop[DRAGON] = 1;
game.prop[RUG] = 0;
int k = (object_descriptions[DRAGON].plac + object_descriptions[DRAGON].fixd) / 2;
int k = (objects[DRAGON].plac + objects[DRAGON].fixd) / 2;
move(DRAGON + NOBJECTS, -1);
move(RUG + NOBJECTS, 0);
move(DRAGON, k);
move(RUG, k);
drop(BLOOD, k);
for (obj = 1; obj <= NOBJECTS; obj++) {
if (game.place[obj] == object_descriptions[DRAGON].plac || game.place[obj] == object_descriptions[DRAGON].fixd)
if (game.place[obj] == objects[DRAGON].plac || game.place[obj] == objects[DRAGON].fixd)
move(obj, k);
}
game.loc = k;
@ -122,7 +122,7 @@ static int bigwords(token_t foo)
return GO_CLEAROBJ;
}
game.foobar = 0;
if (game.place[EGGS] == object_descriptions[EGGS].plac || (TOTING(EGGS) && game.loc == object_descriptions[EGGS].plac)) {
if (game.place[EGGS] == objects[EGGS].plac || (TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
rspeak(spk);
return GO_CLEAROBJ;
} else {
@ -132,8 +132,8 @@ static int bigwords(token_t foo)
game.prop[TROLL] = 1;
k = 2;
if (HERE(EGGS))k = 1;
if (game.loc == object_descriptions[EGGS].plac)k = 0;
move(EGGS, object_descriptions[EGGS].plac);
if (game.loc == objects[EGGS].plac)k = 0;
move(EGGS, objects[EGGS].plac);
pspeak(EGGS, look, k);
return GO_CLEAROBJ;
}
@ -305,7 +305,7 @@ static int chain(token_t verb)
} else {
spk = CHAIN_LOCKED;
if (game.prop[CHAIN] != 0)spk = ALREADY_LOCKED;
if (game.loc != object_descriptions[CHAIN].plac)spk = NO_LOCKSITE;
if (game.loc != objects[CHAIN].plac)spk = NO_LOCKSITE;
if (spk != CHAIN_LOCKED) {
rspeak(spk);
return GO_CLEAROBJ;
@ -350,7 +350,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
if (spk != RUG_WIGGLES) {
int k = 2 - game.prop[RUG];
game.prop[RUG] = k;
if (k == 2) k = object_descriptions[SAPPH].plac;
if (k == 2) k = objects[SAPPH].plac;
move(RUG + NOBJECTS, k);
}
}
@ -367,11 +367,11 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
rspeak(TROLL_SCAMPERS);
move(TROLL, 0);
move(TROLL + NOBJECTS, 0);
move(TROLL2, object_descriptions[TROLL].plac);
move(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
game.prop[TROLL] = 2;
} else if (obj != VASE || game.loc == object_descriptions[PILLOW].plac) {
} else if (obj != VASE || game.loc == objects[PILLOW].plac) {
rspeak(OK_MAN);
} else {
game.prop[VASE] = 2;
@ -686,7 +686,7 @@ static int listen(void)
spk = NO_MESSAGE;
}
for (int i = 1; i <= NOBJECTS; i++) {
if (!HERE(i) || object_descriptions[i].sounds[0] == NULL || game.prop[i] < 0)
if (!HERE(i) || objects[i].sounds[0] == NULL || game.prop[i] < 0)
continue;
int mi = game.prop[i];
if (i == BIRD)
@ -804,7 +804,7 @@ static int read(struct command_t command)
if (command.obj == INTRANSITIVE) {
command.obj = 0;
for (int i = 1; i <= NOBJECTS; i++) {
if (HERE(i) && object_descriptions[i].texts[0] != NULL && game.prop[i] >= 0)
if (HERE(i) && objects[i].texts[0] != NULL && game.prop[i] >= 0)
command.obj = command.obj * NOBJECTS + i;
}
if (command.obj > NOBJECTS || command.obj == 0 || DARK(game.loc))
@ -815,7 +815,7 @@ static int read(struct command_t command)
rspeak(NO_SEE, command.wd1, command.wd1x);
} else if (command.obj == OYSTER && !game.clshnt && game.closed) {
game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]);
} else if (object_descriptions[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
} else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) {
rspeak(actspk[command.verb]);
} else
pspeak(command.obj, study, game.prop[command.obj]);
@ -899,14 +899,14 @@ static int throw (FILE *cmdin, struct command_t *command)
rspeak(spk);
return GO_CLEAROBJ;
}
if (object_descriptions[command->obj].is_treasure && AT(TROLL)) {
if (objects[command->obj].is_treasure && AT(TROLL)) {
spk = TROLL_SATISFIED;
/* Snarf a treasure for the troll. */
drop(command->obj, 0);
move(TROLL, 0);
move(TROLL + NOBJECTS, 0);
drop(TROLL2, object_descriptions[TROLL].plac);
drop(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
drop(TROLL2, objects[TROLL].plac);
drop(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
rspeak(spk);
return GO_CLEAROBJ;

View file

@ -2871,7 +2871,7 @@ turn_thresholds:
point_loss: 10
message: '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.'
object_descriptions: !!omap
objects: !!omap
- OBJ_0:
inventory: !!null
longs: !!null

16
init.c
View file

@ -39,17 +39,17 @@ void initialise(void)
* "FIXD". Also, since two-placed objects are typically best
* described last, we'll drop them first. */
for (int i = NOBJECTS; i >= 1; i--) {
if (object_descriptions[i].fixd > 0) {
drop(i + NOBJECTS, object_descriptions[i].fixd);
drop(i, object_descriptions[i].plac);
if (objects[i].fixd > 0) {
drop(i + NOBJECTS, objects[i].fixd);
drop(i, objects[i].plac);
}
}
for (int i = 1; i <= NOBJECTS; i++) {
int k = NOBJECTS + 1 - i;
game.fixed[k] = object_descriptions[k].fixd;
if (object_descriptions[k].plac != 0 && object_descriptions[k].fixd <= 0)
drop(k, object_descriptions[k].plac);
game.fixed[k] = objects[k].fixd;
if (objects[k].plac != 0 && objects[k].fixd <= 0)
drop(k, objects[k].plac);
}
/* Treasure props are initially -1, and are set to 0 the first time
@ -57,8 +57,8 @@ void initialise(void)
* not yet found, so we know when to close the cave. */
game.tally = 0;
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
if (object_descriptions[treasure].is_treasure) {
if (object_descriptions[treasure].inventory != 0)
if (objects[treasure].is_treasure) {
if (objects[treasure].inventory != 0)
game.prop[treasure] = -1;
game.tally = game.tally - game.prop[treasure];
}

18
main.c
View file

@ -303,11 +303,11 @@ static bool spotted_by_pirate(int i)
int snarfed = 0;
bool movechest = false, robplayer = false;
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
if (!object_descriptions[treasure].is_treasure)
if (!objects[treasure].is_treasure)
continue;
/* Pirate won't take pyramid from plover room or dark
* room (too easy!). */
if (treasure == PYRAMID && (game.loc == object_descriptions[PYRAMID].plac || game.loc == object_descriptions[EMERALD].plac)) {
if (treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac)) {
continue;
}
if (TOTING(treasure) || HERE(treasure))
@ -339,9 +339,9 @@ static bool spotted_by_pirate(int i)
if (robplayer) {
rspeak(PIRATE_POUNCES);
for (int treasure = 1; treasure <= NOBJECTS; treasure++) {
if (!object_descriptions[treasure].is_treasure)
if (!objects[treasure].is_treasure)
continue;
if (!(treasure == PYRAMID && (game.loc == object_descriptions[PYRAMID].plac || game.loc == object_descriptions[EMERALD].plac))) {
if (!(treasure == PYRAMID && (game.loc == objects[PYRAMID].plac || game.loc == objects[EMERALD].plac))) {
if (AT(treasure) && game.fixed[treasure] == 0)
carry(treasure, game.loc);
if (TOTING(treasure))
@ -709,13 +709,13 @@ static bool playermove(token_t verb, int motion)
game.prop[TROLL] = 0;
move(TROLL2, 0);
move(TROLL2 + NOBJECTS, 0);
move(TROLL, object_descriptions[TROLL].plac);
move(TROLL + NOBJECTS, object_descriptions[TROLL].fixd);
move(TROLL, objects[TROLL].plac);
move(TROLL + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
game.newloc = game.loc;
return true;
} else {
game.newloc = object_descriptions[TROLL].plac + object_descriptions[TROLL].fixd - game.loc;
game.newloc = objects[TROLL].plac + objects[TROLL].fixd - game.loc;
if (game.prop[TROLL] == 0)game.prop[TROLL] = 1;
if (!TOTING(BEAR)) return true;
rspeak(BRIDGE_COLLAPSE);
@ -788,8 +788,8 @@ static bool closecheck(void)
}
move(TROLL, 0);
move(TROLL + NOBJECTS, 0);
move(TROLL2, object_descriptions[TROLL].plac);
move(TROLL2 + NOBJECTS, object_descriptions[TROLL].fixd);
move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
if (game.prop[BEAR] != 3)DESTROY(BEAR);
game.prop[CHAIN] = 0;

8
misc.c
View file

@ -172,16 +172,16 @@ void pspeak(vocab_t msg, enum speaktype mode, int skip, ...)
va_start(ap, skip);
switch (mode) {
case touch:
vspeak(object_descriptions[msg].inventory, ap);
vspeak(objects[msg].inventory, ap);
break;
case look:
vspeak(object_descriptions[msg].longs[skip], ap);
vspeak(objects[msg].longs[skip], ap);
break;
case hear:
vspeak(object_descriptions[msg].sounds[skip], ap);
vspeak(objects[msg].sounds[skip], ap);
break;
case study:
vspeak(object_descriptions[msg].texts[skip], ap);
vspeak(objects[msg].texts[skip], ap);
break;
}
va_end(ap);

View file

@ -51,7 +51,7 @@ typedef struct {{
const char** longs;
const char** sounds;
const char** texts;
}} object_description_t;
}} object_t;
typedef struct {{
const char* small;
@ -95,7 +95,7 @@ typedef struct {{
}} vocabulary_t;
extern const location_t locations[];
extern const object_description_t object_descriptions[];
extern const object_t objects[];
extern const char* arbitrary_messages[];
extern const class_t classes[];
extern const turn_threshold_t turn_thresholds[];
@ -122,7 +122,7 @@ enum locations_refs {{
{}
}};
enum object_descriptions_refs {{
enum object_refs {{
{}
}};
@ -153,7 +153,7 @@ const location_t locations[] = {{
{}
}};
const object_description_t object_descriptions[] = {{
const object_t objects[] = {{
{}
}};
@ -259,7 +259,7 @@ def get_locations(loc):
loc_str = loc_str[:-1] # trim trailing newline
return loc_str
def get_object_descriptions(obj):
def get_objects(obj):
template = """ {{ // {}
.inventory = {},
.plac = {},
@ -430,7 +430,7 @@ if __name__ == "__main__":
get_class_messages(db["classes"]),
get_turn_thresholds(db["turn_thresholds"]),
get_locations(db["locations"]),
get_object_descriptions(db["object_descriptions"]),
get_objects(db["objects"]),
get_obituaries(db["obituaries"]),
get_hints(db["hints"], db["arbitrary_messages"]),
get_condbits(db["locations"]),
@ -440,7 +440,7 @@ if __name__ == "__main__":
h = h_template.format(
len(db["locations"])-1,
len(db["object_descriptions"])-1,
len(db["objects"])-1,
len(db["hints"]),
len(db["classes"]),
len(db["obituaries"]),
@ -449,7 +449,7 @@ if __name__ == "__main__":
len(db["vocabulary"]),
get_refs(db["arbitrary_messages"]),
get_refs(db["locations"]),
get_refs(db["object_descriptions"]),
get_refs(db["objects"]),
statedefines,
)

View file

@ -38,9 +38,9 @@ long score(enum termination mode)
* Give the poor guy 2 points just for finding each treasure. */
mxscor = 0;
for (int i = 1; i <= NOBJECTS; i++) {
if (!object_descriptions[i].is_treasure)
if (!objects[i].is_treasure)
continue;
if (object_descriptions[i].inventory != 0) {
if (objects[i].inventory != 0) {
long k = 12;
if (i == CHEST)k = 14;
if (i > CHEST)k = 16;