simplify add_command

This commit is contained in:
Enno Rehling 2016-09-07 15:43:04 +02:00
parent eed6e1d88d
commit 1ad2775f51
4 changed files with 11 additions and 11 deletions

View file

@ -289,12 +289,12 @@ static syntaxtree * build_syntax(void) {
syntaxtree *slang, *stree = stree_create();
for (slang = stree; slang; slang = slang->next) {
struct tnode *leaf = 0;
add_command(&leaf, NULL, LOC(slang->lang, alliance_kwd[ALLIANCE_KICK]), &cmd_kick);
add_command(&leaf, NULL, LOC(slang->lang, alliance_kwd[ALLIANCE_LEAVE]), &cmd_leave);
add_command(&leaf, NULL, LOC(slang->lang, alliance_kwd[ALLIANCE_TRANSFER]), &cmd_transfer);
add_command(&leaf, NULL, LOC(slang->lang, alliance_kwd[ALLIANCE_NEW]), &cmd_new);
add_command(&leaf, NULL, LOC(slang->lang, alliance_kwd[ALLIANCE_INVITE]), &cmd_invite);
add_command(&leaf, NULL, LOC(slang->lang, alliance_kwd[ALLIANCE_JOIN]), &cmd_join);
add_command(&leaf, LOC(slang->lang, alliance_kwd[ALLIANCE_KICK]), &cmd_kick);
add_command(&leaf, LOC(slang->lang, alliance_kwd[ALLIANCE_LEAVE]), &cmd_leave);
add_command(&leaf, LOC(slang->lang, alliance_kwd[ALLIANCE_TRANSFER]), &cmd_transfer);
add_command(&leaf, LOC(slang->lang, alliance_kwd[ALLIANCE_NEW]), &cmd_new);
add_command(&leaf, LOC(slang->lang, alliance_kwd[ALLIANCE_INVITE]), &cmd_invite);
add_command(&leaf, LOC(slang->lang, alliance_kwd[ALLIANCE_JOIN]), &cmd_join);
slang->root = leaf;
}
return stree;

View file

@ -67,7 +67,7 @@ syntaxtree *stree_create(void)
}
void
add_command(struct tnode **keys, void *tnext,
add_command(struct tnode **keys,
const char *str, parser fun)
{
command *cmd = (command *)malloc(sizeof(command));

View file

@ -28,7 +28,7 @@ extern "C" {
} syntaxtree;
typedef void(*parser) (const void *nodes, struct unit * u, struct order *);
void add_command(struct tnode **troot, void *tnext,
void add_command(struct tnode **troot,
const char *str, parser fun);
void do_command(const struct tnode *troot, struct unit *u, struct order *);

View file

@ -37,8 +37,8 @@ static void test_command(CuTest * tc) {
CuAssertPtrEquals(tc, loc, (struct locale *)st->lang);
CuAssertPtrEquals(tc, 0, st->root);
CuAssertPtrEquals(tc, 0, st->next);
add_command(&st->root, 0, "two", parser_two);
add_command(&st->root, 0, "six", parser_six);
add_command(&st->root, "two", parser_two);
add_command(&st->root, "six", parser_six);
CuAssertPtrNotNull(tc, st->root);
CuAssertPtrEquals(tc, st->root, stree_find(st, loc));
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
@ -54,4 +54,4 @@ CuSuite *get_command_suite(void)
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_command);
return suite;
}
}