From 1ad2775f5138ca3108404320b3e18b023e47a428 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 7 Sep 2016 15:43:04 +0200 Subject: [PATCH] simplify add_command --- src/kernel/alliance.c | 12 ++++++------ src/kernel/command.c | 2 +- src/kernel/command.h | 2 +- src/kernel/command.test.c | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/kernel/alliance.c b/src/kernel/alliance.c index c351ba5ee..121e118c7 100644 --- a/src/kernel/alliance.c +++ b/src/kernel/alliance.c @@ -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; diff --git a/src/kernel/command.c b/src/kernel/command.c index 180c9068c..fe2f2449e 100644 --- a/src/kernel/command.c +++ b/src/kernel/command.c @@ -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)); diff --git a/src/kernel/command.h b/src/kernel/command.h index e8d6bbaf2..94e38bcab 100644 --- a/src/kernel/command.h +++ b/src/kernel/command.h @@ -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 *); diff --git a/src/kernel/command.test.c b/src/kernel/command.test.c index edf521c81..76ef034c1 100644 --- a/src/kernel/command.test.c +++ b/src/kernel/command.test.c @@ -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; -} \ No newline at end of file +}