Abolish as many undifferentiated long variables as possible.
Simple counter become ints.
This commit is contained in:
parent
7c3f834bca
commit
609159ad6d
6 changed files with 27 additions and 26 deletions
|
@ -176,7 +176,7 @@ static int attack(struct command_t *command)
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bigwords(long id)
|
static int bigwords(vocab_t id)
|
||||||
/* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
|
/* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order.
|
||||||
* Look up foo in special section of vocab to determine which word we've got.
|
* Look up foo in special section of vocab to determine which word we've got.
|
||||||
* Last word zips the eggs back to the giant room (unless already there). */
|
* Last word zips the eggs back to the giant room (unless already there). */
|
||||||
|
@ -910,7 +910,7 @@ static int light(verb_t verb, obj_t obj)
|
||||||
static int listen(void)
|
static int listen(void)
|
||||||
/* Listen. Intransitive only. Print stuff based on object sound proprties. */
|
/* Listen. Intransitive only. Print stuff based on object sound proprties. */
|
||||||
{
|
{
|
||||||
long sound = locations[game.loc].sound;
|
vocab_t sound = locations[game.loc].sound;
|
||||||
if (sound != SILENT) {
|
if (sound != SILENT) {
|
||||||
rspeak(sound);
|
rspeak(sound);
|
||||||
if (!locations[game.loc].loud)
|
if (!locations[game.loc].loud)
|
||||||
|
@ -1163,7 +1163,7 @@ static int say(struct command_t *command)
|
||||||
return GO_CLEAROBJ;
|
return GO_CLEAROBJ;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int throw_support(long spk)
|
static int throw_support(vocab_t spk)
|
||||||
{
|
{
|
||||||
rspeak(spk);
|
rspeak(spk);
|
||||||
drop(AXE, game.loc);
|
drop(AXE, game.loc);
|
||||||
|
@ -1221,7 +1221,7 @@ static int throw (struct command_t *command)
|
||||||
if (randrange(NDWARVES + 1) < game.dflag) {
|
if (randrange(NDWARVES + 1) < game.dflag) {
|
||||||
return throw_support(DWARF_DODGES);
|
return throw_support(DWARF_DODGES);
|
||||||
} else {
|
} else {
|
||||||
long i = atdwrf(game.loc);
|
int i = atdwrf(game.loc);
|
||||||
game.dseen[i] = false;
|
game.dseen[i] = false;
|
||||||
game.dloc[i] = LOC_NOWHERE;
|
game.dloc[i] = LOC_NOWHERE;
|
||||||
return throw_support((++game.dkill == 1) ?
|
return throw_support((++game.dkill == 1) ?
|
||||||
|
|
11
advent.h
11
advent.h
|
@ -114,6 +114,7 @@ typedef long vocab_t; // index into a vocabulary array */
|
||||||
typedef long verb_t; // index into an actions array */
|
typedef long verb_t; // index into an actions array */
|
||||||
typedef long obj_t; // index into the object array */
|
typedef long obj_t; // index into the object array */
|
||||||
typedef long loc_t; // index into the locations array */
|
typedef long loc_t; // index into the locations array */
|
||||||
|
typedef long turn_t; // turn counter or threshold */
|
||||||
|
|
||||||
struct game_t {
|
struct game_t {
|
||||||
unsigned long lcg_a, lcg_c, lcg_m, lcg_x;
|
unsigned long lcg_a, lcg_c, lcg_m, lcg_x;
|
||||||
|
@ -157,9 +158,9 @@ struct game_t {
|
||||||
long saved; // point penalty for saves
|
long saved; // point penalty for saves
|
||||||
long tally; // count of treasures gained
|
long tally; // count of treasures gained
|
||||||
long thresh; // current threshold for endgame scoring tier
|
long thresh; // current threshold for endgame scoring tier
|
||||||
long trndex; // FIXME: not used, remove on next format bump
|
turn_t trndex; // FIXME: not used, remove on next format bump
|
||||||
long trnluz; // # points lost so far due to turns used
|
turn_t trnluz; // # points lost so far due to turns used
|
||||||
long turns; // counts commands given (ignores yes/no)
|
turn_t turns; // counts commands given (ignores yes/no)
|
||||||
bool wzdark; // whether the loc he's leaving was dark
|
bool wzdark; // whether the loc he's leaving was dark
|
||||||
char zzword[TOKLEN + 1]; // randomly generated magic word from bird
|
char zzword[TOKLEN + 1]; // randomly generated magic word from bird
|
||||||
bool blooded; // has player drunk of dragon's blood?
|
bool blooded; // has player drunk of dragon's blood?
|
||||||
|
@ -203,7 +204,7 @@ extern struct settings_t settings;
|
||||||
extern bool get_command_input(struct command_t *);
|
extern bool get_command_input(struct command_t *);
|
||||||
extern void wordclear(token_t *);
|
extern void wordclear(token_t *);
|
||||||
extern void speak(const char*, ...);
|
extern void speak(const char*, ...);
|
||||||
extern void sspeak(long msg, ...);
|
extern void sspeak(int msg, ...);
|
||||||
extern void pspeak(vocab_t, enum speaktype, int, bool, ...);
|
extern void pspeak(vocab_t, enum speaktype, int, bool, ...);
|
||||||
extern void rspeak(vocab_t, ...);
|
extern void rspeak(vocab_t, ...);
|
||||||
extern void echo_input(FILE*, const char*, const char*);
|
extern void echo_input(FILE*, const char*, const char*);
|
||||||
|
@ -211,7 +212,7 @@ extern bool silent_yes(void);
|
||||||
extern bool yes(const char*, const char*, const char*);
|
extern bool yes(const char*, const char*, const char*);
|
||||||
extern void juggle(obj_t);
|
extern void juggle(obj_t);
|
||||||
extern void move(obj_t, loc_t);
|
extern void move(obj_t, loc_t);
|
||||||
extern long put(obj_t, long, long);
|
extern loc_t put(obj_t, long, long);
|
||||||
extern void carry(obj_t, loc_t);
|
extern void carry(obj_t, loc_t);
|
||||||
extern void drop(obj_t, loc_t);
|
extern void drop(obj_t, loc_t);
|
||||||
extern long atdwrf(loc_t);
|
extern long atdwrf(loc_t);
|
||||||
|
|
10
cheat.c
10
cheat.c
|
@ -14,7 +14,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ch;
|
int ch;
|
||||||
char *savefilename = NULL;
|
char *savefilename = NULL;
|
||||||
long version = 0;
|
int version = 0;
|
||||||
FILE *fp = NULL;
|
FILE *fp = NULL;
|
||||||
|
|
||||||
// Initialize game variables
|
// Initialize game variables
|
||||||
|
@ -42,7 +42,7 @@ int main(int argc, char *argv[])
|
||||||
printf("cheat: game.numdie = %ld\n", game.numdie);
|
printf("cheat: game.numdie = %ld\n", game.numdie);
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
game.limit = (long)atoi(optarg);
|
game.limit = (turn_t)atoi(optarg);
|
||||||
printf("cheat: game.limit = %ld\n", game.limit);
|
printf("cheat: game.limit = %ld\n", game.limit);
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -50,12 +50,12 @@ int main(int argc, char *argv[])
|
||||||
printf("cheat: game.saved = %ld\n", game.saved);
|
printf("cheat: game.saved = %ld\n", game.saved);
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
game.turns = (long)atoi(optarg);
|
game.turns = (turn_t)atoi(optarg);
|
||||||
printf("cheat: game.turns = %ld\n", game.turns);
|
printf("cheat: game.turns = %ld\n", game.turns);
|
||||||
break;
|
break;
|
||||||
case 'v':
|
case 'v':
|
||||||
version = (long)atoi(optarg);
|
version = atoi(optarg);
|
||||||
printf("cheat: version = %ld\n", version);
|
printf("cheat: version = %d\n", version);
|
||||||
break;
|
break;
|
||||||
case 'o':
|
case 'o':
|
||||||
savefilename = optarg;
|
savefilename = optarg;
|
||||||
|
|
6
main.c
6
main.c
|
@ -318,7 +318,7 @@ static bool dwarfmove(void)
|
||||||
/* Dwarves move. Return true if player survives, false if he dies. */
|
/* Dwarves move. Return true if player survives, false if he dies. */
|
||||||
{
|
{
|
||||||
int kk, stick, attack;
|
int kk, stick, attack;
|
||||||
long tk[21];
|
loc_t tk[21];
|
||||||
|
|
||||||
/* Dwarf stuff. See earlier comments for description of
|
/* Dwarf stuff. See earlier comments for description of
|
||||||
* variables. Remember sixth dwarf is pirate and is thus
|
* variables. Remember sixth dwarf is pirate and is thus
|
||||||
|
@ -508,7 +508,7 @@ static void croak(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool traveleq(long a, long b)
|
static bool traveleq(int a, int b)
|
||||||
/* Are two travel entries equal for purposes of skip after failed condition? */
|
/* Are two travel entries equal for purposes of skip after failed condition? */
|
||||||
{
|
{
|
||||||
return (travel[a].condtype == travel[b].condtype)
|
return (travel[a].condtype == travel[b].condtype)
|
||||||
|
@ -947,7 +947,7 @@ static void listobjects(void)
|
||||||
if (!DARK(game.loc)) {
|
if (!DARK(game.loc)) {
|
||||||
++game.abbrev[game.loc];
|
++game.abbrev[game.loc];
|
||||||
for (int i = game.atloc[game.loc]; i != 0; i = game.link[i]) {
|
for (int i = game.atloc[game.loc]; i != 0; i = game.link[i]) {
|
||||||
long obj = i;
|
obj_t obj = i;
|
||||||
if (obj > NOBJECTS)
|
if (obj > NOBJECTS)
|
||||||
obj = obj - NOBJECTS;
|
obj = obj - NOBJECTS;
|
||||||
if (obj == STEPS && TOTING(NUGGET))
|
if (obj == STEPS && TOTING(NUGGET))
|
||||||
|
|
10
misc.c
10
misc.c
|
@ -121,7 +121,7 @@ void speak(const char* msg, ...)
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sspeak(const long msg, ...)
|
void sspeak(const int msg, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, msg);
|
va_start(ap, msg);
|
||||||
|
@ -402,7 +402,7 @@ static int get_special_vocab_id(const char* word)
|
||||||
return (WORD_NOT_FOUND);
|
return (WORD_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_vocab_metadata(const char* word, long* id, enum wordtype* type)
|
static void get_vocab_metadata(const char* word, vocab_t* id, enum wordtype* type)
|
||||||
{
|
{
|
||||||
/* Check for an empty string */
|
/* Check for an empty string */
|
||||||
if (strncmp(word, "", sizeof("")) == 0) {
|
if (strncmp(word, "", sizeof("")) == 0) {
|
||||||
|
@ -411,7 +411,7 @@ static void get_vocab_metadata(const char* word, long* id, enum wordtype* type)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long ref_num;
|
vocab_t ref_num;
|
||||||
|
|
||||||
ref_num = get_motion_vocab_id(word);
|
ref_num = get_motion_vocab_id(word);
|
||||||
if (ref_num != WORD_NOT_FOUND) {
|
if (ref_num != WORD_NOT_FOUND) {
|
||||||
|
@ -535,7 +535,7 @@ void move(obj_t object, loc_t where)
|
||||||
* pick up objects which are not at any loc, since carry wants to
|
* pick up objects which are not at any loc, since carry wants to
|
||||||
* remove objects from game.atloc chains. */
|
* remove objects from game.atloc chains. */
|
||||||
{
|
{
|
||||||
long from;
|
loc_t from;
|
||||||
|
|
||||||
if (object > NOBJECTS)
|
if (object > NOBJECTS)
|
||||||
from = game.fixed[object - NOBJECTS];
|
from = game.fixed[object - NOBJECTS];
|
||||||
|
@ -547,7 +547,7 @@ void move(obj_t object, loc_t where)
|
||||||
drop(object, where);
|
drop(object, where);
|
||||||
}
|
}
|
||||||
|
|
||||||
long put(obj_t object, loc_t where, long pval)
|
loc_t put(obj_t object, loc_t where, long pval)
|
||||||
/* put() is the same as move(), except it returns a value used to set up the
|
/* put() is the same as move(), except it returns a value used to set up the
|
||||||
* negated game.prop values for the repository objects. */
|
* negated game.prop values for the repository objects. */
|
||||||
{
|
{
|
||||||
|
|
8
score.c
8
score.c
|
@ -6,13 +6,13 @@
|
||||||
* scoring and wrap-up
|
* scoring and wrap-up
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static long mxscor; /* ugh..the price for having score() not exit. */
|
static int mxscor; /* ugh..the price for having score() not exit. */
|
||||||
|
|
||||||
long score(enum termination mode)
|
long score(enum termination mode)
|
||||||
/* mode is 'scoregame' if scoring, 'quitgame' if quitting, 'endgame' if died
|
/* mode is 'scoregame' if scoring, 'quitgame' if quitting, 'endgame' if died
|
||||||
* or won */
|
* or won */
|
||||||
{
|
{
|
||||||
long score = 0;
|
int score = 0;
|
||||||
|
|
||||||
/* The present scoring algorithm is as follows:
|
/* The present scoring algorithm is as follows:
|
||||||
* Objective: Points: Present total possible:
|
* Objective: Points: Present total possible:
|
||||||
|
@ -40,7 +40,7 @@ long score(enum termination mode)
|
||||||
if (!objects[i].is_treasure)
|
if (!objects[i].is_treasure)
|
||||||
continue;
|
continue;
|
||||||
if (objects[i].inventory != 0) {
|
if (objects[i].inventory != 0) {
|
||||||
long k = 12;
|
int k = 12;
|
||||||
if (i == CHEST)
|
if (i == CHEST)
|
||||||
k = 14;
|
k = 14;
|
||||||
if (i > CHEST)
|
if (i > CHEST)
|
||||||
|
@ -92,7 +92,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 < NHINTS; i++) {
|
for (int i = 0; i < NHINTS; i++) {
|
||||||
if (game.hinted[i])
|
if (game.hinted[i])
|
||||||
score = score - hints[i].penalty;
|
score = score - hints[i].penalty;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue