commit - cc9bbf6125fec1aaa9a7a1a06574a537fc3c3b29
commit + 7f40f3f51cc79bec922438a9fdfd147dac32d08d
blob - dd9c4e796cfe63fa782d616578cb3033971b34cd
blob + 1e0cc5bbda20cee39f9eab689a18afab750eeb4d
--- adventure.c
+++ adventure.c
+#include "adventure.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "adventure.h"
-
int
main()
{
blob - 77a11f7e7236ff90b70630acebcebb3bb20193bb
blob + ca1f2eddf1325baf4c86dc8dfc289159f74f338a
--- inventory.c
+++ inventory.c
else if (to == NULL)
printf("There is nobody here to give that to.\n");
else if (obj == to)
- printf("What's the meaning of putting a %s inside itself?\n", obj->tags[0]);
+ printf("What's the meaning of putting a %s inside itself?\n",
+ obj->tags[0]);
else if (from != obj->location) {
/* give the appropriate error message */
switch (dist) {
printf("You have no %s.\n", par->tag);
else
printf("Sorry, %s has no %s.\n",
- from->description,
- par->tag);
+ from->description, par->tag);
break;
case dist_held_contained:
blob - f66b92f00ef5d3a6a19907bf40e89aa58af648d4
blob + 462d55921e82c84339ab2341dfb69a4165df4dac
--- io.c
+++ io.c
#include "adventure.h"
/* this in only needed for readline */
+#include <readline/history.h>
+#include <readline/readline.h>
#include <stdio.h>
-#include <readline/readline.h>
-#include <readline/history.h>
-
char *line = NULL;
int
add_history(line);
return line != NULL;
}
-
blob - 0da6cc66ddcfc9ad148e6596be1aea80aef3b4d7
blob + 8f5a24bb769ef01e8cfb280592930f28dfa20851
--- match.c
+++ match.c
-#include "adventure.h"
-
#include <ctype.h>
#include <string.h>
+#include "adventure.h"
+
struct param params[MAX_PARAMS];
static const char *
{
return terminal == ' '
? match_spaces(src)
- : tolower(*src) == tolower(terminal)
- ? src + 1
- : NULL;
+ : tolower(*src) == tolower(terminal) ? src + 1 : NULL;
}
static const char *
const char *rest_of_src = loose ? src + strlen(src) : NULL;
par->tag = src;
- par->distance = *src == '\0' ? dist_no_obj_specified : dist_unknown_obj;
+ par->distance
+ = *src == '\0' ? dist_no_obj_specified : dist_unknown_obj;
- foreach_obj (obj) {
+ foreach_obj(obj)
+ {
const char **tag;
enum distance dist = distance_to(obj);
for (tag = obj->tags; *tag != NULL; ++tag) {
const char *behind_match = match_tag(src, *tag);
- if (behind_match != NULL &&
- compare_with_param(*tag, dist, par) > 0 &&
- (!loose || *skip_spaces(behind_match) == '\0')) {
+ if (behind_match != NULL
+ && compare_with_param(*tag, dist, par) > 0
+ && (!loose
+ || *skip_spaces(behind_match)
+ == '\0')) {
par->tag = *tag;
par->object = obj;
par->distance = dist;
}
/* actual parsing */
- for (src = skip_spaces(src); src != NULL && *pattern != '\0'; ++pattern) {
+ for (src = skip_spaces(src); src != NULL && *pattern != '\0';
+ ++pattern) {
src = isupper(*pattern)
? match_param(src, param_by_letter(*pattern),
- pattern[1] == '?')
- : *pattern == '?'
- ? src
- : match_terminal(src, *pattern);
+ pattern[1] == '?')
+ : *pattern == '?' ? src
+ : match_terminal(src, *pattern);
}
return src != NULL && *skip_spaces(src) == '\0';
blob - e00c37883127490644c8326a178aacfdc73c2646
blob + 91af5911f3dd08ccc9bc4ecf13e7edfd17d2569e
--- misc.c
+++ misc.c
size_t count = 0;
struct object *obj;
- foreach_obj (obj) {
+ foreach_obj(obj)
+ {
if (obj != player && obj->location == location) {
if (count++ == 0)
printf("%s:\n", location->contents);
{
struct object *obj;
- foreach_obj (obj) {
+ foreach_obj(obj)
+ {
if (distance_to(obj) == dist_here && obj->health > 0)
return obj;
}
{
struct object *obj;
- foreach_obj (obj) {
- if (obj->location == player->location &&
- obj->prospect == target)
+ foreach_obj(obj)
+ {
+ if (obj->location == player->location
+ && obj->prospect == target)
return obj;
}
enum distance
distance_to(struct object *obj)
{
- return
- !valid_obj(obj) ? dist_unknown_obj :
- obj == player ? dist_player :
- obj == player->location ? dist_location :
- obj->location == player ? dist_held :
- obj->location == player->location ? dist_here :
- get_passage_to(obj) != NULL ? dist_overthere :
- !valid_obj(obj->location) ? dist_not_here :
- obj->location->location == player ? dist_held_contained :
- obj->location->location == player->location ? dist_here_contained :
- dist_not_here;
+ return !valid_obj(obj) ? dist_unknown_obj
+ : obj == player
+ ? dist_player
+ : obj == player->location ? dist_location
+ : obj->location == player
+ ? dist_held
+ : obj->location == player->location
+ ? dist_here
+ : get_passage_to(obj) != NULL
+ ? dist_overthere
+ : !valid_obj(
+ obj->location)
+ ? dist_not_here
+ : obj->location->location
+ == player
+ ? dist_held_contained
+ : obj->location->location
+ == player->location
+ ? dist_here_contained
+ : dist_not_here;
}
void
int sum = 0;
struct object *obj;
- foreach_obj (obj) {
+ foreach_obj(obj)
+ {
if (obj->location == container)
sum += obj->weight;
}
blob - a85a81d1d2f614c61f3e32515811ffecd7c5ef12
blob + 7024675111095183a845c5f5d7dd90c267278553
--- parseexec.c
+++ parseexec.c
-#include "adventure.h"
-
#include <stdio.h>
+#include "adventure.h"
+
int
exec_quit(void)
{
else if (dist == dist_not_here)
printf("You don't see any %s here.\n", par->tag);
else if (dist == dist_overthere)
- printf("You squeeze your eyes, but %s is too far away.\n", par->tag);
+ printf("You squeeze your eyes, but %s is too far away.\n",
+ par->tag);
else if (dist == dist_here_contained)
printf("Hard to see, try to get it first.\n");
else {
int
exec_get_from(void)
{
- return move_object(param_by_letter('A'), param_by_letter('B')->object, player);
+ return move_object(
+ param_by_letter('A'), param_by_letter('B')->object, player);
}
int
int
exec_put_in(void)
{
- return move_object(param_by_letter('A'), player, param_by_letter('B')->object);
+ return move_object(
+ param_by_letter('A'), player, param_by_letter('B')->object);
}
int
parseexec(const char *input)
{
static const struct command commands[] = {
- {&exec_quit, "quit"},
- {&exec_look_around, "look"},
- {&exec_look_around, "look around"},
- {&exec_look, "look at A?"},
- {&exec_look, "look A?"},
- {&exec_go, "go to the A?"},
- {&exec_go, "go to A?"},
- {&exec_go, "go A?"},
- {&exec_get_from, "get A from B?"},
- {&exec_get, "get the A?"},
- {&exec_get, "get A?"},
- {&exec_get, "pick up the A?"},
- {&exec_get, "pick up a A?"},
- {&exec_get, "pick up A?"},
- {&exec_get, "pick the A?"},
- {&exec_get, "pick a A?"},
- {&exec_get, "pick A?"},
- {&exec_put_in, "put A in B?"},
- {&exec_put_in, "drop A in B?"},
- {&exec_drop, "drop A?"},
- {&exec_give, "give A?"},
- {&exec_ask, "ask A?"},
- {&exec_inventory, "inventory"},
- {&exec_open, "open A?"},
- {&exec_close, "close A?"},
- {&exec_lock, "lock A?"},
- {&exec_unlock, "unlock A?"},
- {&exec_no_match, "A?"},
+ { &exec_quit, "quit" },
+ { &exec_quit, "bye" },
+ { &exec_look_around, "look" },
+ { &exec_look_around, "look around" },
+ { &exec_look, "look at A?" },
+ { &exec_look, "look A?" },
+ { &exec_go, "go to the A?" },
+ { &exec_go, "go to A?" },
+ { &exec_go, "go A?" },
+ { &exec_get_from, "get A from B?" },
+ { &exec_get, "get the A?" },
+ { &exec_get, "get A?" },
+ { &exec_get, "pick up the A?" },
+ { &exec_get, "pick up a A?" },
+ { &exec_get, "pick up A?" },
+ { &exec_get, "pick the A?" },
+ { &exec_get, "pick a A?" },
+ { &exec_get, "pick A?" },
+ { &exec_put_in, "put A in B?" },
+ { &exec_put_in, "drop A in B?" },
+ { &exec_drop, "drop A?" },
+ { &exec_give, "give A?" },
+ { &exec_ask, "ask A?" },
+ { &exec_inventory, "inventory" },
+ { &exec_open, "open A?" },
+ { &exec_close, "close A?" },
+ { &exec_lock, "lock A?" },
+ { &exec_unlock, "unlock A?" },
+ { &exec_no_match, "A?" },
};
const struct command *cmd;
blob - b058a863c858125593a005c6c08423a24f67b742
blob + 3c0a6f3e79d7f5ec6fa1d49aee1028b8424fff35
--- toggle.c
+++ toggle.c
swap_locations(closed_box, locked_box);
return "OK.";
} else {
- return "You try really hard, but the closed box won't open without a key.";
+ return "You try really hard, but the closed box won't open "
+ "without a key.";
}
}