Rationalize names of structure array sizes.
Everything that camn be #define become one, in all caps to signify that it's a constant.
This commit is contained in:
parent
07207420a2
commit
985137d9c7
5 changed files with 21 additions and 24 deletions
4
advent.h
4
advent.h
|
@ -72,8 +72,8 @@ struct game_t {
|
||||||
long fixed[NOBJECTS + 1];
|
long fixed[NOBJECTS + 1];
|
||||||
long link[NOBJECTS * 2 + 1];
|
long link[NOBJECTS * 2 + 1];
|
||||||
long place[NOBJECTS + 1];
|
long place[NOBJECTS + 1];
|
||||||
long hinted[HINT_COUNT];
|
long hinted[NHINTS];
|
||||||
long hintlc[HINT_COUNT];
|
long hintlc[NHINTS];
|
||||||
long prop[NOBJECTS + 1];
|
long prop[NOBJECTS + 1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
4
init.c
4
init.c
|
@ -223,7 +223,7 @@ void initialise(void)
|
||||||
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
|
/* Clear the hint stuff. game.hintlc[i] is how long he's been at LOC
|
||||||
* with cond bit i. game.hinted[i] is true iff hint i has been
|
* with cond bit i. game.hinted[i] is true iff hint i has been
|
||||||
* used. */
|
* used. */
|
||||||
for (int i = 0; i < HINT_COUNT; i++) {
|
for (int i = 0; i < NHINTS; i++) {
|
||||||
game.hinted[i] = false;
|
game.hinted[i] = false;
|
||||||
game.hintlc[i] = 0;
|
game.hintlc[i] = 0;
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ void initialise(void)
|
||||||
* game.iwest How many times he's said "west" instead of "w"
|
* game.iwest How many times he's said "west" instead of "w"
|
||||||
* game.knfloc 0 if no knife here, loc if knife here, -1 after caveat
|
* game.knfloc 0 if no knife here, loc if knife here, -1 after caveat
|
||||||
* game.limit Lifetime of lamp (not set here)
|
* game.limit Lifetime of lamp (not set here)
|
||||||
* maximum_deaths Number of reincarnation messages available (up to 5)
|
* NDEATHS Number of reincarnation messages available (up to 5)
|
||||||
* game.numdie Number of times killed so far
|
* game.numdie Number of times killed so far
|
||||||
* game.trnluz # points lost so far due to number of turns used
|
* game.trnluz # points lost so far due to number of turns used
|
||||||
* game.turns Tallies how many commands he's given (ignores yes/no)
|
* game.turns Tallies how many commands he's given (ignores yes/no)
|
||||||
|
|
8
main.c
8
main.c
|
@ -189,7 +189,7 @@ static bool fallback_handler(char *buf)
|
||||||
static void checkhints(void)
|
static void checkhints(void)
|
||||||
{
|
{
|
||||||
if (conditions[game.loc] >= game.conds) {
|
if (conditions[game.loc] >= game.conds) {
|
||||||
for (int hint = 0; hint < HINT_COUNT; hint++) {
|
for (int hint = 0; hint < NHINTS; hint++) {
|
||||||
if (game.hinted[hint])
|
if (game.hinted[hint])
|
||||||
continue;
|
continue;
|
||||||
if (!CNDBIT(game.loc, hint + 1 + COND_HBASE))
|
if (!CNDBIT(game.loc, hint + 1 + COND_HBASE))
|
||||||
|
@ -468,7 +468,7 @@ static bool dwarfmove(void)
|
||||||
/* "You're dead, Jim."
|
/* "You're dead, Jim."
|
||||||
*
|
*
|
||||||
* If the current loc is zero, it means the clown got himself killed.
|
* If the current loc is zero, it means the clown got himself killed.
|
||||||
* We'll allow this maxdie times. maximum_deaths is automatically set based
|
* We'll allow this maxdie times. NDEATHS is automatically set based
|
||||||
* on the number of snide messages available. Each death results in
|
* on the number of snide messages available. Each death results in
|
||||||
* a message (81, 83, etc.) which offers reincarnation; if accepted,
|
* a message (81, 83, etc.) which offers reincarnation; if accepted,
|
||||||
* this results in message 82, 84, etc. The last time, if he wants
|
* this results in message 82, 84, etc. The last time, if he wants
|
||||||
|
@ -496,7 +496,7 @@ static void croak(void)
|
||||||
* death and exit. */
|
* death and exit. */
|
||||||
rspeak(DEATH_CLOSING);
|
rspeak(DEATH_CLOSING);
|
||||||
terminate(endgame);
|
terminate(endgame);
|
||||||
} else if (game.numdie == maximum_deaths || !YES(query, yes_response, arbitrary_messages[OK_MAN]))
|
} else if (game.numdie == NDEATHS || !YES(query, yes_response, arbitrary_messages[OK_MAN]))
|
||||||
terminate(endgame);
|
terminate(endgame);
|
||||||
else {
|
else {
|
||||||
game.place[WATER] = game.place[OIL] = LOC_NOWHERE;
|
game.place[WATER] = game.place[OIL] = LOC_NOWHERE;
|
||||||
|
@ -1022,7 +1022,7 @@ L2607:
|
||||||
|
|
||||||
/* If a turn threshold has been met, apply penalties and tell
|
/* If a turn threshold has been met, apply penalties and tell
|
||||||
* the player about it. */
|
* the player about it. */
|
||||||
for (int i = 0; i < turn_threshold_count; ++i)
|
for (int i = 0; i < NTHRESHOLDS; ++i)
|
||||||
{
|
{
|
||||||
if (game.turns == turn_thresholds[i].threshold + 1)
|
if (game.turns == turn_thresholds[i].threshold + 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,10 +69,11 @@ extern turn_threshold_t turn_thresholds[];
|
||||||
extern obituary_t obituaries[];
|
extern obituary_t obituaries[];
|
||||||
extern hint_t hints[];
|
extern hint_t hints[];
|
||||||
extern long conditions[];
|
extern long conditions[];
|
||||||
extern const size_t CLSSES;
|
|
||||||
extern const int maximum_deaths;
|
#define NHINTS {}
|
||||||
extern const int turn_threshold_count;
|
#define NCLASSES {}
|
||||||
#define HINT_COUNT {}
|
#define NDEATHS {}
|
||||||
|
#define NTHRESHOLDS {}
|
||||||
|
|
||||||
enum arbitrary_messages_refs {{
|
enum arbitrary_messages_refs {{
|
||||||
{}
|
{}
|
||||||
|
@ -129,10 +130,6 @@ long conditions[] = {{
|
||||||
{}
|
{}
|
||||||
}};
|
}};
|
||||||
|
|
||||||
const size_t CLSSES = {};
|
|
||||||
const int maximum_deaths = {};
|
|
||||||
const int turn_threshold_count = {};
|
|
||||||
|
|
||||||
/* end */
|
/* end */
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@ -338,13 +335,13 @@ if __name__ == "__main__":
|
||||||
get_obituaries(db["obituaries"]),
|
get_obituaries(db["obituaries"]),
|
||||||
get_hints(db["hints"], db["arbitrary_messages"]),
|
get_hints(db["hints"], db["arbitrary_messages"]),
|
||||||
get_condbits(db["locations"]),
|
get_condbits(db["locations"]),
|
||||||
len(db["classes"]),
|
|
||||||
len(db["obituaries"]),
|
|
||||||
len(db["turn_thresholds"]),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
h = h_template.format(
|
h = h_template.format(
|
||||||
len(db["hints"]),
|
len(db["hints"]),
|
||||||
|
len(db["classes"]),
|
||||||
|
len(db["obituaries"]),
|
||||||
|
len(db["turn_thresholds"]),
|
||||||
get_refs(db["arbitrary_messages"]),
|
get_refs(db["arbitrary_messages"]),
|
||||||
get_refs(db["locations"]),
|
get_refs(db["locations"]),
|
||||||
get_refs(db["object_descriptions"]),
|
get_refs(db["object_descriptions"]),
|
||||||
|
|
10
score.c
10
score.c
|
@ -50,14 +50,14 @@ long score(enum termination mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now look at how he finished and how far he got. maximum_deaths and
|
/* Now look at how he finished and how far he got. NDEATHS and
|
||||||
* game.numdie tell us how well he survived. game.dflag will tell us
|
* game.numdie tell us how well he survived. game.dflag will tell us
|
||||||
* if he ever got suitably deep into the cave. game.closng still
|
* if he ever got suitably deep into the cave. game.closng still
|
||||||
* indicates whether he reached the endgame. And if he got as far as
|
* indicates whether he reached the endgame. And if he got as far as
|
||||||
* "cave closed" (indicated by "game.closed"), then bonus is zero for
|
* "cave closed" (indicated by "game.closed"), then bonus is zero for
|
||||||
* mundane exits or 133, 134, 135 if he blew it (so to speak). */
|
* mundane exits or 133, 134, 135 if he blew it (so to speak). */
|
||||||
score += (maximum_deaths - game.numdie) * 10;
|
score += (NDEATHS - game.numdie) * 10;
|
||||||
mxscor += maximum_deaths * 10;
|
mxscor += NDEATHS * 10;
|
||||||
if (mode == endgame)
|
if (mode == endgame)
|
||||||
score += 4;
|
score += 4;
|
||||||
mxscor += 4;
|
mxscor += 4;
|
||||||
|
@ -87,7 +87,7 @@ long score(enum termination mode)
|
||||||
mxscor += 2;
|
mxscor += 2;
|
||||||
|
|
||||||
/* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
|
/* Deduct for hints/turns/saves. Hints < 4 are special; see database desc. */
|
||||||
for (long i = 0; i < HINT_COUNT; i++) {
|
for (long i = 0; i < NHINTS; i++) {
|
||||||
if (game.hinted[i])
|
if (game.hinted[i])
|
||||||
score = score - hints[i].penalty;
|
score = score - hints[i].penalty;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ void terminate(enum termination mode)
|
||||||
if (points + game.saved + 1 >= mxscor && game.saved != 0)
|
if (points + game.saved + 1 >= mxscor && game.saved != 0)
|
||||||
rspeak(WITHOUT_SUSPENDS);
|
rspeak(WITHOUT_SUSPENDS);
|
||||||
rspeak(TOTAL_SCORE, points, mxscor, game.turns, game.turns);
|
rspeak(TOTAL_SCORE, points, mxscor, game.turns, game.turns);
|
||||||
for (long i = 1; i <= (long)CLSSES; i++) {
|
for (long i = 1; i <= (long)NCLASSES; i++) {
|
||||||
if (classes[i].threshold >= points) {
|
if (classes[i].threshold >= points) {
|
||||||
speak(classes[i].message);
|
speak(classes[i].message);
|
||||||
i = classes[i].threshold + 1 - points;
|
i = classes[i].threshold + 1 - points;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue