Removed unused code, reindented
This commit is contained in:
parent
0e2c851131
commit
03b2f1c86e
3 changed files with 51 additions and 63 deletions
1
advent.h
1
advent.h
|
@ -206,7 +206,6 @@ extern void packed_to_token(long, char token[]);
|
||||||
extern long token_to_packed(const char token[]);
|
extern long token_to_packed(const char token[]);
|
||||||
extern void tokenize(char*, struct command_t *);
|
extern void tokenize(char*, struct command_t *);
|
||||||
extern void vspeak(const char*, bool, va_list);
|
extern void vspeak(const char*, bool, va_list);
|
||||||
extern bool wordeq(token_t, token_t);
|
|
||||||
extern bool wordempty(token_t);
|
extern bool wordempty(token_t);
|
||||||
extern void wordclear(token_t *);
|
extern void wordclear(token_t *);
|
||||||
extern void speak(const char*, ...);
|
extern void speak(const char*, ...);
|
||||||
|
|
12
main.c
12
main.c
|
@ -397,7 +397,7 @@ static bool dwarfmove(void)
|
||||||
else if (j > 1 && game.newloc == tk[j - 1])
|
else if (j > 1 && game.newloc == tk[j - 1])
|
||||||
continue;
|
continue;
|
||||||
else if (j >= DIM(tk) - 1)
|
else if (j >= DIM(tk) - 1)
|
||||||
/* This can't actually happen. */
|
/* This can't actually happen. */
|
||||||
continue; // LCOV_EXCL_LINE
|
continue; // LCOV_EXCL_LINE
|
||||||
else if (game.newloc == game.dloc[i])
|
else if (game.newloc == game.dloc[i])
|
||||||
continue;
|
continue;
|
||||||
|
@ -1126,7 +1126,7 @@ Lclosecheck:
|
||||||
command.id1 = command.id2;
|
command.id1 = command.id2;
|
||||||
command.id2 = WORD_EMPTY;
|
command.id2 = WORD_EMPTY;
|
||||||
} else {
|
} else {
|
||||||
if (!((command.id1 != WATER && command.id1 != OIL) || (command.id2 != PLANT && command.id2 != DOOR))) {
|
if (!((command.id1 != WATER && command.id1 != OIL) || (command.id2 != PLANT && command.id2 != DOOR))) {
|
||||||
if (AT(command.id2))
|
if (AT(command.id2))
|
||||||
command.wd2 = token_to_packed("POUR");
|
command.wd2 = token_to_packed("POUR");
|
||||||
}
|
}
|
||||||
|
@ -1143,9 +1143,9 @@ Lookup:
|
||||||
rspeak(GO_UNNEEDED);
|
rspeak(GO_UNNEEDED);
|
||||||
}
|
}
|
||||||
packed_to_token(command.wd1, word1);
|
packed_to_token(command.wd1, word1);
|
||||||
long defn;
|
long defn;
|
||||||
enum wordtype type;
|
enum wordtype type;
|
||||||
get_vocab_metadata(word1, &defn, &type);
|
get_vocab_metadata(word1, &defn, &type);
|
||||||
if (defn == WORD_NOT_FOUND) {
|
if (defn == WORD_NOT_FOUND) {
|
||||||
if (fallback_handler(command))
|
if (fallback_handler(command))
|
||||||
continue;
|
continue;
|
||||||
|
@ -1154,7 +1154,7 @@ Lookup:
|
||||||
goto Lclearobj;
|
goto Lclearobj;
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NO_WORD_TYPE: // FIXME: treating NO_WORD_TYPE as a motion word is confusing
|
case NO_WORD_TYPE: // FIXME: treating NO_WORD_TYPE as a motion word is confusing
|
||||||
case MOTION:
|
case MOTION:
|
||||||
playermove(defn);
|
playermove(defn);
|
||||||
return true;
|
return true;
|
||||||
|
|
101
misc.c
101
misc.c
|
@ -128,11 +128,6 @@ void tokenize(char* raw, struct command_t *cmd)
|
||||||
|
|
||||||
/* Hide the fact that wods are corrently packed longs */
|
/* Hide the fact that wods are corrently packed longs */
|
||||||
|
|
||||||
bool wordeq(token_t a, token_t b)
|
|
||||||
{
|
|
||||||
return a == b;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wordempty(token_t a)
|
bool wordempty(token_t a)
|
||||||
{
|
{
|
||||||
return a == 0;
|
return a == 0;
|
||||||
|
@ -171,17 +166,17 @@ void vspeak(const char* msg, bool blank, va_list ap)
|
||||||
long previous_arg = 0;
|
long previous_arg = 0;
|
||||||
for (int i = 0; i < msglen; i++) {
|
for (int i = 0; i < msglen; i++) {
|
||||||
if (msg[i] != '%') {
|
if (msg[i] != '%') {
|
||||||
/* Ugh. Least obtrusive way to deal with artifacts "on the floor"
|
/* Ugh. Least obtrusive way to deal with artifacts "on the floor"
|
||||||
* being dropped outside of both cave and building. */
|
* being dropped outside of both cave and building. */
|
||||||
if (strncmp(msg + i, "floor", 5) == 0 && strchr(" .", msg[i+5]) && !INSIDE(game.loc)) {
|
if (strncmp(msg + i, "floor", 5) == 0 && strchr(" .", msg[i + 5]) && !INSIDE(game.loc)) {
|
||||||
strcpy(renderp, "ground");
|
strcpy(renderp, "ground");
|
||||||
renderp += 6;
|
renderp += 6;
|
||||||
i += 4;
|
i += 4;
|
||||||
size -= 5;
|
size -= 5;
|
||||||
} else {
|
} else {
|
||||||
*renderp++ = msg[i];
|
*renderp++ = msg[i];
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
long arg = va_arg(ap, long);
|
long arg = va_arg(ap, long);
|
||||||
if (arg == -1)
|
if (arg == -1)
|
||||||
|
@ -525,59 +520,53 @@ int get_special_vocab_id(const char* word)
|
||||||
|
|
||||||
void get_vocab_metadata(const char* word, long* id, enum wordtype* type)
|
void get_vocab_metadata(const char* word, long* id, enum wordtype* type)
|
||||||
{
|
{
|
||||||
/* Check for an empty string */
|
/* Check for an empty string */
|
||||||
if (strncmp(word, "", sizeof("")) == 0)
|
if (strncmp(word, "", sizeof("")) == 0) {
|
||||||
{
|
*id = WORD_EMPTY;
|
||||||
*id = WORD_EMPTY;
|
*type = NO_WORD_TYPE;
|
||||||
*type = NO_WORD_TYPE;
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long ref_num;
|
long 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) {
|
||||||
{
|
*id = ref_num;
|
||||||
*id = ref_num;
|
*type = MOTION;
|
||||||
*type = MOTION;
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ref_num = get_object_vocab_id(word);
|
ref_num = get_object_vocab_id(word);
|
||||||
if (ref_num != WORD_NOT_FOUND)
|
if (ref_num != WORD_NOT_FOUND) {
|
||||||
{
|
*id = ref_num;
|
||||||
*id = ref_num;
|
*type = OBJECT;
|
||||||
*type = OBJECT;
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ref_num = get_action_vocab_id(word);
|
ref_num = get_action_vocab_id(word);
|
||||||
if (ref_num != WORD_NOT_FOUND)
|
if (ref_num != WORD_NOT_FOUND) {
|
||||||
{
|
*id = ref_num;
|
||||||
*id = ref_num;
|
*type = ACTION;
|
||||||
*type = ACTION;
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ref_num = get_special_vocab_id(word);
|
ref_num = get_special_vocab_id(word);
|
||||||
if (ref_num != WORD_NOT_FOUND)
|
if (ref_num != WORD_NOT_FOUND) {
|
||||||
{
|
*id = ref_num;
|
||||||
*id = ref_num;
|
*type = SPECIAL;
|
||||||
*type = SPECIAL;
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for the reservoir magic word.
|
// Check for the reservoir magic word.
|
||||||
if (strcasecmp(word, game.zzword) == 0)
|
if (strcasecmp(word, game.zzword) == 0) {
|
||||||
{
|
*id = PART;
|
||||||
*id = PART;
|
*type = ACTION;
|
||||||
*type = ACTION;
|
return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*id = WORD_NOT_FOUND;
|
*id = WORD_NOT_FOUND;
|
||||||
*type = NO_WORD_TYPE;
|
*type = NO_WORD_TYPE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void juggle(obj_t object)
|
void juggle(obj_t object)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue