Reindent and cleanup.
This commit is contained in:
parent
5341a3e2ee
commit
fd02259c7f
5 changed files with 93 additions and 99 deletions
9
common.h
9
common.h
|
@ -9,7 +9,7 @@
|
||||||
extern const char advent_to_ascii[128];
|
extern const char advent_to_ascii[128];
|
||||||
extern const char ascii_to_advent[128];
|
extern const char ascii_to_advent[128];
|
||||||
|
|
||||||
enum bug_e {
|
enum bugtype {
|
||||||
MESSAGE_LINE_GT_70_CHARACTERS, // 0
|
MESSAGE_LINE_GT_70_CHARACTERS, // 0
|
||||||
NULL_LINE_IN_MESSAGE, // 1
|
NULL_LINE_IN_MESSAGE, // 1
|
||||||
TOO_MANY_WORDS_OF_MESSAGES, // 2
|
TOO_MANY_WORDS_OF_MESSAGES, // 2
|
||||||
|
@ -30,14 +30,13 @@ enum bug_e {
|
||||||
CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION, // 25
|
CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION, // 25
|
||||||
LOCATION_HAS_NO_TRAVEL_ENTRIES, // 26
|
LOCATION_HAS_NO_TRAVEL_ENTRIES, // 26
|
||||||
HINT_NUMBER_EXCEEDS_GOTO_LIST, // 27
|
HINT_NUMBER_EXCEEDS_GOTO_LIST, // 27
|
||||||
INVALID_MOTH_RETURNED_BY_DATA_FUNCTION, // 28
|
TOO_MANY_PARAMETERS_GIVEN_TO_SETPRM, // 28
|
||||||
TOO_MANY_PARAMETERS_GIVEN_TO_SETPRM, // 29
|
|
||||||
SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN=99, // 99
|
SPEECHPART_NOT_TRANSITIVE_OR_INTRANSITIVE_OR_UNKNOWN=99, // 99
|
||||||
ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH, // 100
|
ACTION_RETURNED_PHASE_CODE_BEYOND_END_OF_SWITCH, // 100
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void bug(enum bug_e num, const char *error_string) __attribute__((__noreturn__));
|
static inline void bug(enum bugtype num, const char *error_string) __attribute__((__noreturn__));
|
||||||
static inline void bug(enum bug_e num, const char *error_string)
|
static inline void bug(enum bugtype num, const char *error_string)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Fatal error %d, %s.\n", num, error_string);
|
fprintf(stderr, "Fatal error %d, %s.\n", num, error_string);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
2
main.c
2
main.c
|
@ -636,7 +636,7 @@ static bool playermove(token_t verb, int motion)
|
||||||
/* else fall through */
|
/* else fall through */
|
||||||
} else if (game.prop[motion] != game.newloc / 100 - 3)
|
} else if (game.prop[motion] != game.newloc / 100 - 3)
|
||||||
break;
|
break;
|
||||||
L12:
|
L12:
|
||||||
do {
|
do {
|
||||||
if (TRAVEL[kk] < 0)
|
if (TRAVEL[kk] < 0)
|
||||||
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
|
BUG(CONDITIONAL_TRAVEL_ENTRY_WITH_NO_ALTERATION);
|
||||||
|
|
21
misc.c
21
misc.c
|
@ -13,12 +13,11 @@
|
||||||
void* xmalloc(size_t size)
|
void* xmalloc(size_t size)
|
||||||
{
|
{
|
||||||
void* ptr = malloc(size);
|
void* ptr = malloc(size);
|
||||||
if (ptr == NULL)
|
if (ptr == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Out of memory!\n");
|
fprintf(stderr, "Out of memory!\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
return(ptr);
|
return (ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
char* xstrdup(const char* s)
|
char* xstrdup(const char* s)
|
||||||
|
@ -218,12 +217,10 @@ char* get_input()
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
char* input;
|
char* input;
|
||||||
while (true)
|
while (true) {
|
||||||
{
|
|
||||||
if (editline)
|
if (editline)
|
||||||
input = linenoise(input_prompt);
|
input = linenoise(input_prompt);
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
input = NULL;
|
input = NULL;
|
||||||
size_t n = 0;
|
size_t n = 0;
|
||||||
if (isatty(0))
|
if (isatty(0))
|
||||||
|
@ -250,7 +247,7 @@ char* get_input()
|
||||||
if (logfp)
|
if (logfp)
|
||||||
echo_input(logfp, input_prompt, input);
|
echo_input(logfp, input_prompt, input);
|
||||||
|
|
||||||
return(input);
|
return (input);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response)
|
bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response)
|
||||||
|
@ -282,17 +279,15 @@ bool YES(vocab_t question, vocab_t yes_response, vocab_t no_response)
|
||||||
RSPEAK(yes_response);
|
RSPEAK(yes_response);
|
||||||
outcome = true;
|
outcome = true;
|
||||||
break;
|
break;
|
||||||
}
|
} else if (no == 0 || n == 0) {
|
||||||
else if (no == 0 || n == 0) {
|
|
||||||
RSPEAK(no_response);
|
RSPEAK(no_response);
|
||||||
outcome = false;
|
outcome = false;
|
||||||
break;
|
break;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
RSPEAK(PLEASE_ANSWER);
|
RSPEAK(PLEASE_ANSWER);
|
||||||
}
|
}
|
||||||
linenoiseFree(reply);
|
linenoiseFree(reply);
|
||||||
return(outcome);
|
return (outcome);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Line-parsing routines (GETTXT, MAKEWD, PUTTXT, SHFTXT) */
|
/* Line-parsing routines (GETTXT, MAKEWD, PUTTXT, SHFTXT) */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue