From 19b3b5b35a271610f142189cdc7247fc25d38774 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Fri, 18 May 2018 19:58:49 +0200 Subject: [PATCH] change how message types are created (more prep work for expat) --- src/creport.c | 2 +- src/donations.test.c | 2 +- src/economy.test.c | 18 +++---- src/give.test.c | 34 ++++++------ src/kernel/build.test.c | 2 +- src/kernel/messages.c | 6 +-- src/kernel/messages.test.c | 8 +-- src/laws.test.c | 30 +++++------ src/market.test.c | 2 +- src/monsters.test.c | 5 +- src/move.test.c | 18 ++++--- src/orderfile.test.c | 2 +- src/piracy.test.c | 18 ++++--- src/renumber.test.c | 2 +- src/report.c | 15 +++--- src/spells.test.c | 6 ++- src/spells/flyingship.test.c | 3 +- src/spells/magicresistance.test.c | 6 ++- src/spy.test.c | 39 +++++++++----- src/study.test.c | 18 ++++--- src/tests.c | 9 ++-- src/triggers/shock.test.c | 3 +- src/util/message.c | 88 +++++++++++++++---------------- src/util/message.h | 7 +-- src/util/message.test.c | 3 +- src/util/nrmessage.c | 65 +++++++++-------------- src/util/nrmessage.h | 11 ++-- src/volcano.test.c | 12 +++-- src/wormhole.test.c | 12 +++-- src/xmlreader.c | 24 ++++----- 30 files changed, 250 insertions(+), 220 deletions(-) diff --git a/src/creport.c b/src/creport.c index 325d0dec0..17cf60fdb 100644 --- a/src/creport.c +++ b/src/creport.c @@ -519,7 +519,7 @@ static void report_crtypes(FILE * F, const struct locale *lang) fputc('\"', F); fputs(str_escape(nrt_string(kmt->mtype, lang), buffer, sizeof(buffer)), F); fputs("\";text\n", F); - fprintf(F, "\"%s\";section\n", nrt_section(kmt->mtype)); + fprintf(F, "\"%s\";section\n", kmt->mtype->section); } while (mtypehash[i]) { kmt = mtypehash[i]; diff --git a/src/donations.test.c b/src/donations.test.c index a3a428a73..2cdc8f174 100644 --- a/src/donations.test.c +++ b/src/donations.test.c @@ -13,7 +13,7 @@ static void test_add_donation(CuTest *tc) { region *r; test_setup(); - mt_register(mt_new_va("donation", "from:faction", "to:faction", "amount:int", MT_NEW_END)); + mt_create_va(mt_new("donation", NULL), "from:faction", "to:faction", "amount:int", MT_NEW_END); r = test_create_region(0, 0, NULL); f1 = test_create_faction(NULL); f2 = test_create_faction(NULL); diff --git a/src/economy.test.c b/src/economy.test.c index 0ed869ef0..3b5745be4 100644 --- a/src/economy.test.c +++ b/src/economy.test.c @@ -143,10 +143,10 @@ static struct unit *create_recruiter(void) { static void setup_production(void) { init_resources(); - mt_register(mt_new_va("produce", "unit:unit", "region:region", "amount:int", "wanted:int", "resource:resource", MT_NEW_END)); - mt_register(mt_new_va("income", "unit:unit", "region:region", "amount:int", "wanted:int", "mode:int", MT_NEW_END)); - mt_register(mt_new_va("buy", "unit:unit", "money:int", MT_NEW_END)); - mt_register(mt_new_va("buyamount", "unit:unit", "amount:int", "resource:resource", MT_NEW_END)); + mt_create_va(mt_new("produce", NULL), "unit:unit", "region:region", "amount:int", "wanted:int", "resource:resource", MT_NEW_END); + mt_create_va(mt_new("income", NULL), "unit:unit", "region:region", "amount:int", "wanted:int", "mode:int", MT_NEW_END); + mt_create_va(mt_new("buy", NULL), "unit:unit", "money:int", MT_NEW_END); + mt_create_va(mt_new("buyamount", NULL), "unit:unit", "amount:int", "resource:resource", MT_NEW_END); } static void test_heroes_dont_recruit(CuTest * tc) { @@ -378,11 +378,11 @@ static void test_tax_cmd(CuTest *tc) { } static void setup_economy(void) { - mt_register(mt_new_va("recruit", "unit:unit", "region:region", "amount:int", "want:int", MT_NEW_END)); - mt_register(mt_new_va("maintenance", "unit:unit", "building:building", MT_NEW_END)); - mt_register(mt_new_va("maintenancefail", "unit:unit", "building:building", MT_NEW_END)); - mt_register(mt_new_va("maintenance_nowork", "building:building", MT_NEW_END)); - mt_register(mt_new_va("maintenance_noowner", "building:building", MT_NEW_END)); + mt_create_va(mt_new("recruit", NULL), "unit:unit", "region:region", "amount:int", "want:int", MT_NEW_END); + mt_create_va(mt_new("maintenance", NULL), "unit:unit", "building:building", MT_NEW_END); + mt_create_va(mt_new("maintenancefail", NULL), "unit:unit", "building:building", MT_NEW_END); + mt_create_va(mt_new("maintenance_nowork", NULL), "building:building", MT_NEW_END); + mt_create_va(mt_new("maintenance_noowner", NULL), "building:building", MT_NEW_END); } /** diff --git a/src/give.test.c b/src/give.test.c index 3e58216c9..d02c27e6f 100644 --- a/src/give.test.c +++ b/src/give.test.c @@ -54,24 +54,24 @@ static void setup_give(struct give *env) { } /* success messages: */ - mt_register(mt_new_va("receive_person", "unit:unit", "target:unit", "amount:int", MT_NEW_END)); - mt_register(mt_new_va("give_person", "unit:unit", "target:unit", "amount:int", MT_NEW_END)); - mt_register(mt_new_va("give_person_peasants", "unit:unit", "amount:int", MT_NEW_END)); - mt_register(mt_new_va("give_person_ocean", "unit:unit", "amount:int", MT_NEW_END)); - mt_register(mt_new_va("receive", "unit:unit", "target:unit", "resource:resource", "amount:int", MT_NEW_END)); - mt_register(mt_new_va("give", "unit:unit", "target:unit", "resource:resource", "amount:int", MT_NEW_END)); - mt_register(mt_new_va("give_peasants", "unit:unit", "resource:resource", "amount:int", MT_NEW_END)); + mt_create_va(mt_new("receive_person", NULL), "unit:unit", "target:unit", "amount:int", MT_NEW_END); + mt_create_va(mt_new("give_person", NULL), "unit:unit", "target:unit", "amount:int", MT_NEW_END); + mt_create_va(mt_new("give_person_peasants", NULL), "unit:unit", "amount:int", MT_NEW_END); + mt_create_va(mt_new("give_person_ocean", NULL), "unit:unit", "amount:int", MT_NEW_END); + mt_create_va(mt_new("receive", NULL), "unit:unit", "target:unit", "resource:resource", "amount:int", MT_NEW_END); + mt_create_va(mt_new("give", NULL), "unit:unit", "target:unit", "resource:resource", "amount:int", MT_NEW_END); + mt_create_va(mt_new("give_peasants", NULL), "unit:unit", "resource:resource", "amount:int", MT_NEW_END); /* error messages: */ - mt_register(mt_new_va("too_many_units_in_faction", "unit:unit", "region:region", "command:order", "allowed:int", MT_NEW_END)); - mt_register(mt_new_va("too_many_units_in_alliance", "unit:unit", "region:region", "command:order", "allowed:int", MT_NEW_END)); - mt_register(mt_new_va("feedback_no_contact", "unit:unit", "region:region", "command:order", "target:unit", MT_NEW_END)); - mt_register(mt_new_va("feedback_give_forbidden", "unit:unit", "region:region", "command:order", MT_NEW_END)); - mt_register(mt_new_va("peasants_give_invalid", "unit:unit", "region:region", "command:order", MT_NEW_END)); - mt_register(mt_new_va("giverestriction", "unit:unit", "region:region", "command:order", "turns:int", MT_NEW_END)); - mt_register(mt_new_va("error_unit_size", "unit:unit", "region:region", "command:order", "maxsize:int", MT_NEW_END)); - mt_register(mt_new_va("nogive_reserved", "unit:unit", "region:region", "command:order", "resource:resource", "reservation:int", MT_NEW_END)); - mt_register(mt_new_va("race_notake", "unit:unit", "region:region", "command:order", "race:race", MT_NEW_END)); - mt_register(mt_new_va("race_noregroup", "unit:unit", "region:region", "command:order", "race:race", MT_NEW_END)); + mt_create_va(mt_new("too_many_units_in_faction", NULL), "unit:unit", "region:region", "command:order", "allowed:int", MT_NEW_END); + mt_create_va(mt_new("too_many_units_in_alliance", NULL), "unit:unit", "region:region", "command:order", "allowed:int", MT_NEW_END); + mt_create_va(mt_new("feedback_no_contact", NULL), "unit:unit", "region:region", "command:order", "target:unit", MT_NEW_END); + mt_create_va(mt_new("feedback_give_forbidden", NULL), "unit:unit", "region:region", "command:order", MT_NEW_END); + mt_create_va(mt_new("peasants_give_invalid", NULL), "unit:unit", "region:region", "command:order", MT_NEW_END); + mt_create_va(mt_new("giverestriction", NULL), "unit:unit", "region:region", "command:order", "turns:int", MT_NEW_END); + mt_create_va(mt_new("error_unit_size", NULL), "unit:unit", "region:region", "command:order", "maxsize:int", MT_NEW_END); + mt_create_va(mt_new("nogive_reserved", NULL), "unit:unit", "region:region", "command:order", "resource:resource", "reservation:int", MT_NEW_END); + mt_create_va(mt_new("race_notake", NULL), "unit:unit", "region:region", "command:order", "race:race", MT_NEW_END); + mt_create_va(mt_new("race_noregroup", NULL), "unit:unit", "region:region", "command:order", "race:race", MT_NEW_END); } static void test_give_unit(CuTest * tc) { diff --git a/src/kernel/build.test.c b/src/kernel/build.test.c index 1261e5496..9bae742c2 100644 --- a/src/kernel/build.test.c +++ b/src/kernel/build.test.c @@ -253,7 +253,7 @@ static void test_build_destroy_road(CuTest *tc) message *m; test_setup(); - mt_register(mt_new_va("destroy_road", "unit:unit", "from:region", "to:region", MT_NEW_END)); + mt_create_va(mt_new("destroy_road", NULL), "unit:unit", "from:region", "to:region", MT_NEW_END); r2 = test_create_region(1, 0, 0); r = test_create_region(0, 0, NULL); rsetroad(r, D_EAST, 100); diff --git a/src/kernel/messages.c b/src/kernel/messages.c index 9875d303e..e0513b00d 100644 --- a/src/kernel/messages.c +++ b/src/kernel/messages.c @@ -82,8 +82,8 @@ struct message *msg_feedback(const struct unit *u, struct order *ord, if (!mtype) { log_warning("trying to create message of unknown type \"%s\"\n", name); if (!mt_find("missing_feedback")) { - mt_register(mt_new_va("missing_feedback", "unit:unit", - "region:region", "command:order", "name:string", MT_NEW_END)); + mt_create_va(mt_new("missing_feedback", NULL), "unit:unit", + "region:region", "command:order", "name:string", MT_NEW_END); } return msg_message("missing_feedback", "name unit region command", name, u, u->region, ord); @@ -153,7 +153,7 @@ static message *missing_message(const char *name) { log_warning("trying to create undefined message of type \"%s\"\n", name); if (strcmp(name, "missing_message") != 0) { if (!mt_find("missing_message")) { - mt_register(mt_new_va("missing_message", "name:string", MT_NEW_END)); + mt_create_va(mt_new("missing_message", NULL), "name:string", MT_NEW_END); } return msg_message("missing_message", "name", name); } diff --git a/src/kernel/messages.test.c b/src/kernel/messages.test.c index ad6a08071..961d2e63a 100644 --- a/src/kernel/messages.test.c +++ b/src/kernel/messages.test.c @@ -22,10 +22,10 @@ void test_missing_message(CuTest *tc) { void test_message(CuTest *tc) { message *msg; - message_type *mtype = mt_new("custom", NULL); + message_type *mtype; test_setup(); - mt_register(mtype); + mtype = mt_create(mt_new("custom", NULL), NULL); CuAssertPtrEquals(tc, mtype, (void *)mt_find("custom")); CuAssertIntEquals(tc, 0, mtype->nparameters); CuAssertPtrEquals(tc, NULL, (void *)mtype->pnames); @@ -47,11 +47,11 @@ void test_message(CuTest *tc) { static void test_merge_split(CuTest *tc) { message_list *mlist = 0, *append = 0; struct mlist **split; /* TODO: why is this a double asterisk? */ - message_type *mtype = mt_new("custom", NULL); + message_type *mtype; message *msg; test_setup(); - mt_register(mtype); + mtype = mt_create(mt_new("custom", NULL), NULL); add_message(&mlist, msg = msg_message(mtype->name, "")); msg_release(msg); add_message(&append, msg = msg_message(mtype->name, "")); diff --git a/src/laws.test.c b/src/laws.test.c index f9b4cfcf3..8d13b7c81 100644 --- a/src/laws.test.c +++ b/src/laws.test.c @@ -258,7 +258,7 @@ static void test_force_leave_buildings(CuTest *tc) { building * b; test_setup(); - mt_register(mt_new_va("force_leave_building", "unit:unit", "owner:unit", "building:building", MT_NEW_END)); + mt_create_va(mt_new("force_leave_building", NULL), "unit:unit", "owner:unit", "building:building", MT_NEW_END); r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION)); u1 = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(u1->faction, r); @@ -288,7 +288,7 @@ static void test_force_leave_ships(CuTest *tc) { ship *sh; test_setup(); - mt_register(mt_new_va("force_leave_ship", "unit:unit", "owner:unit", "ship:ship", MT_NEW_END)); + mt_create_va(mt_new("force_leave_ship", NULL), "unit:unit", "owner:unit", "ship:ship", MT_NEW_END); r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION)); u1 = test_create_unit(test_create_faction(NULL), r); u2 = test_create_unit(test_create_faction(NULL), r); @@ -876,7 +876,7 @@ static void test_luck_message(CuTest *tc) { attrib *a; test_setup(); - mt_register(mt_new_va("peasantluck_success", "births:int", MT_NEW_END)); + mt_create_va(mt_new("peasantluck_success", NULL), "births:int", MT_NEW_END); setup_terrains(tc); r = test_create_region(0, 0, NULL); rsetpeasants(r, 1); @@ -901,8 +901,8 @@ static unit * setup_name_cmd(void) { faction *f; test_setup(); - mt_register(mt_new_va("renamed_building_seen", "renamer:unit", "region:region", "building:building", MT_NEW_END)); - mt_register(mt_new_va("renamed_building_notseen", "region:region", "building:building", MT_NEW_END)); + mt_create_va(mt_new("renamed_building_seen", NULL), "renamer:unit", "region:region", "building:building", MT_NEW_END); + mt_create_va(mt_new("renamed_building_notseen", NULL), "region:region", "building:building", MT_NEW_END); f = test_create_faction(NULL); return test_create_unit(f, test_create_region(0, 0, NULL)); } @@ -1301,9 +1301,9 @@ static void test_ally_cmd(CuTest *tc) { static void test_nmr_warnings(CuTest *tc) { faction *f1, *f2; test_setup(); - mt_register(mt_new_va("nmr_warning", MT_NEW_END)); - mt_register(mt_new_va("nmr_warning_final", MT_NEW_END)); - mt_register(mt_new_va("warn_dropout", "faction:faction", "turn:int", MT_NEW_END)); + mt_create_va(mt_new("nmr_warning", NULL), MT_NEW_END); + mt_create_va(mt_new("nmr_warning_final", NULL), MT_NEW_END); + mt_create_va(mt_new("warn_dropout", NULL), "faction:faction", "turn:int", MT_NEW_END); config_set("nmr.timeout", "3"); f1 = test_create_faction(NULL); f2 = test_create_faction(NULL); @@ -1325,9 +1325,9 @@ static unit * setup_mail_cmd(void) { faction *f; test_setup(); - mt_register(mt_new_va("regionmessage", "region:region", "sender:unit", "string:string", MT_NEW_END)); - mt_register(mt_new_va("unitmessage", "region:region", "sender:unit", "string:string", "unit:unit", MT_NEW_END)); - mt_register(mt_new_va("mail_result", "message:string", "unit:unit", MT_NEW_END)); + mt_create_va(mt_new("regionmessage", NULL), "region:region", "sender:unit", "string:string", MT_NEW_END); + mt_create_va(mt_new("unitmessage", NULL), "region:region", "sender:unit", "string:string", "unit:unit", MT_NEW_END); + mt_create_va(mt_new("mail_result", NULL), "message:string", "unit:unit", MT_NEW_END); f = test_create_faction(NULL); return test_create_unit(f, test_create_region(0, 0, NULL)); } @@ -1444,7 +1444,7 @@ static void test_show_without_item(CuTest *tc) struct locale *loc; test_setup(); - mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", MT_NEW_END)); + mt_create_va(mt_new("displayitem", NULL), "weight:int", "item:resource", "description:string", MT_NEW_END); loc = get_or_create_locale("de"); locale_setstring(loc, parameters[P_ANY], "ALLE"); @@ -1489,7 +1489,7 @@ static void test_show_race(CuTest *tc) { test_setup(); - mt_register(mt_new_va("msg_event", "string:string", MT_NEW_END)); + mt_create_va(mt_new("msg_event", NULL), "string:string", MT_NEW_END); test_create_race("human"); rc = test_create_race("elf"); @@ -1529,8 +1529,8 @@ static void test_show_both(CuTest *tc) { message * msg; test_setup(); - mt_register(mt_new_va("msg_event", "string:string", MT_NEW_END)); - mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", MT_NEW_END)); + mt_create_va(mt_new("msg_event", NULL), "string:string", MT_NEW_END); + mt_create_va(mt_new("displayitem", NULL), "weight:int", "item:resource", "description:string", MT_NEW_END); rc = test_create_race("elf"); test_create_itemtype("elvenhorse"); diff --git a/src/market.test.c b/src/market.test.c index 452f75091..4877dbf29 100644 --- a/src/market.test.c +++ b/src/market.test.c @@ -33,7 +33,7 @@ static void test_market_curse(CuTest * tc) building_type *btype; test_setup(); - mt_register(mt_new_va("buyamount", "unit:unit", "amount:int", "resource:resource", MT_NEW_END)); + mt_create_va(mt_new("buyamount", NULL), "unit:unit", "amount:int", "resource:resource", MT_NEW_END); htype = test_create_itemtype("herb"); htype->flags |= ITF_HERB; diff --git a/src/monsters.test.c b/src/monsters.test.c index 8fe9a6b7f..54b3f7f87 100644 --- a/src/monsters.test.c +++ b/src/monsters.test.c @@ -51,7 +51,8 @@ static void create_monsters(unit **up, unit **um) { region *r; faction *fp, *fm; - mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", MT_NEW_END)); + mt_create_va(mt_new("dragon_growl", NULL), + "dragon:unit", "number:int", "target:region", "growl:string", MT_NEW_END); test_create_horse(); default_locale = test_create_locale(); fp = test_create_faction(NULL); @@ -223,8 +224,6 @@ static void test_dragon_moves(CuTest * tc) plan_monsters(m->faction); CuAssertPtrNotNull(tc, find_order("move east", m)); - mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", MT_NEW_END)); - random_growl(m, findregion(1, 0), 3); msg = test_get_last_message(r->msgs); diff --git a/src/move.test.c b/src/move.test.c index 07fde591c..a2fa4e760 100644 --- a/src/move.test.c +++ b/src/move.test.c @@ -28,8 +28,10 @@ #include static void setup_move(void) { - mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", MT_NEW_END)); - mt_register(mt_new_va("moveblocked", "unit:unit", "direction:int", MT_NEW_END)); + mt_create_va(mt_new("travel", NULL), + "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", MT_NEW_END); + mt_create_va(mt_new("moveblocked", NULL), + "unit:unit", "direction:int", MT_NEW_END); } static void test_ship_not_allowed_in_coast(CuTest * tc) @@ -285,9 +287,12 @@ void setup_drift (struct drift_fixture *fix) { u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat)); assert(fix->sh); - mt_register(mt_new_va("ship_drift", "ship:ship", "dir:int", MT_NEW_END)); - mt_register(mt_new_va("shipsink", "ship:ship", MT_NEW_END)); - mt_register(mt_new_va("massive_overload", "ship:ship", MT_NEW_END)); + mt_create_va(mt_new("ship_drift", NULL), + "ship:ship", "dir:int", MT_NEW_END); + mt_create_va(mt_new("shipsink", NULL), + "ship:ship", MT_NEW_END); + mt_create_va(mt_new("massive_overload", NULL), + "ship:ship", MT_NEW_END); } static void test_ship_no_overload(CuTest *tc) { @@ -482,7 +487,8 @@ static void test_follow_ship_msg(CuTest * tc) { td->dir = D_NORTHWEST; td->age = 2; - mt_register(mt_new_va("error18", "unit:unit", "region:region", "command:order", MT_NEW_END)); + mt_create_va(mt_new("error18", NULL), + "unit:unit", "region:region", "command:order", MT_NEW_END); init_order_depr(ord); getstrtoken(); diff --git a/src/orderfile.test.c b/src/orderfile.test.c index 11eb9ea7b..ca98fdeb0 100644 --- a/src/orderfile.test.c +++ b/src/orderfile.test.c @@ -64,7 +64,7 @@ static void test_faction_password_bad(CuTest *tc) { const char *orders[] = { "ERESSEA 1 password", NULL }; test_setup(); - mt_register(mt_new_va("wrongpasswd", "password:string", MT_NEW_END)); + mt_create_va(mt_new("wrongpasswd", NULL), "password:string", MT_NEW_END); f = test_create_faction(NULL); renumber_faction(f, 1); diff --git a/src/piracy.test.c b/src/piracy.test.c index 110dc3dcf..096e267b7 100644 --- a/src/piracy.test.c +++ b/src/piracy.test.c @@ -30,12 +30,18 @@ static void setup_piracy(void) { st_boat = test_create_shiptype("boat"); st_boat->cargo = 1000; - mt_register(mt_new_va("piratenovictim", "ship:ship", "unit:unit", "region:region", MT_NEW_END)); - mt_register(mt_new_va("piratesawvictim", "ship:ship", "unit:unit", "region:region", "dir:int", MT_NEW_END)); - mt_register(mt_new_va("shipsail", "ship:ship", "from:region", "to:region", MT_NEW_END)); - mt_register(mt_new_va("shipfly", "ship:ship", "from:region", "to:region", MT_NEW_END)); - mt_register(mt_new_va("shipnoshore", "ship:ship", "region:region", MT_NEW_END)); - mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", MT_NEW_END)); + mt_create_va(mt_new("piratenovictim", NULL), + "ship:ship", "unit:unit", "region:region", MT_NEW_END); + mt_create_va(mt_new("piratesawvictim", NULL), + "ship:ship", "unit:unit", "region:region", "dir:int", MT_NEW_END); + mt_create_va(mt_new("shipsail", NULL), + "ship:ship", "from:region", "to:region", MT_NEW_END); + mt_create_va(mt_new("shipfly", NULL), + "ship:ship", "from:region", "to:region", MT_NEW_END); + mt_create_va(mt_new("shipnoshore", NULL), + "ship:ship", "region:region", MT_NEW_END); + mt_create_va(mt_new("travel", NULL), + "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", MT_NEW_END); } static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const char *p_shiptype, diff --git a/src/renumber.test.c b/src/renumber.test.c index f176cc3d2..98ca9b48b 100644 --- a/src/renumber.test.c +++ b/src/renumber.test.c @@ -38,7 +38,7 @@ static void test_renumber_faction_duplicate(CuTest *tc) { const struct locale *lang; test_setup_ex(tc); - mt_register(mt_new_va("renumber_inuse", "id:int", MT_NEW_END)); + mt_create_va(mt_new("renumber_inuse", NULL), "id:int", MT_NEW_END); f2 = test_create_faction(NULL); u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL)); no = f->no; diff --git a/src/report.c b/src/report.c index 00089421a..4aee1eb2c 100644 --- a/src/report.c +++ b/src/report.c @@ -714,16 +714,17 @@ static void rp_messages(struct stream *out, message_list * msgs, faction * viewer, int indent, bool categorized) { - nrsection *section; - - if (!msgs) + int i; + if (!msgs) { return; - for (section = sections; section; section = section->next) { + } + for (i = 0; i != MAXSECTIONS && sections[i]; ++i) { + const char * section = sections[i]; int k = 0; struct mlist *m = msgs->begin; while (m) { /* messagetype * mt = m->type; */ - if (!categorized || strcmp(nrt_section(m->msg->type), section->name) == 0) { + if (!categorized || strcmp(m->msg->type->section, section) == 0) { char lbuf[8192]; if (!k && categorized) { @@ -731,14 +732,14 @@ rp_messages(struct stream *out, message_list * msgs, faction * viewer, int inden char cat_identifier[24]; newline(out); - sprintf(cat_identifier, "section_%s", section->name); + sprintf(cat_identifier, "section_%s", section); section_title = LOC(viewer->locale, cat_identifier); if (section_title) { centre(out, section_title, true); newline(out); } else { - log_error("no title defined for section %s in locale %s", section->name, locale_name(viewer->locale)); + log_error("no title defined for section %s in locale %s", section, locale_name(viewer->locale)); } k = 1; } diff --git a/src/spells.test.c b/src/spells.test.c index dc0644ecc..e6150cb46 100644 --- a/src/spells.test.c +++ b/src/spells.test.c @@ -130,8 +130,10 @@ static void test_view_reality(CuTest *tc) { test_setup(); setup_spells(); - mt_register(mt_new_va("spell_astral_only", "unit:unit", "region:region", "command:order", MT_NEW_END)); - mt_register(mt_new_va("viewreality_effect", "unit:unit", MT_NEW_END)); + mt_create_va(mt_new("spell_astral_only", NULL), + "unit:unit", "region:region", "command:order", MT_NEW_END); + mt_create_va(mt_new("viewreality_effect", NULL), + "unit:unit", MT_NEW_END); r = test_create_region(0, 0, NULL); ra = test_create_region(real2tp(r->x), real2tp(r->y), NULL); ra->_plane = get_astralplane(); diff --git a/src/spells/flyingship.test.c b/src/spells/flyingship.test.c index 4440c5fdf..1b1c4d7a1 100644 --- a/src/spells/flyingship.test.c +++ b/src/spells/flyingship.test.c @@ -29,7 +29,8 @@ static void test_flyingship(CuTest * tc) ship *sh1, *sh2; test_setup(); - mt_register(mt_new_va("flying_ship_result", "mage:unit", "ship:ship", MT_NEW_END)); + mt_create_va(mt_new("flying_ship_result", NULL), + "mage:unit", "ship:ship", MT_NEW_END); par.param = &par_data_ptr; par_data.typ = SPP_SHIP; diff --git a/src/spells/magicresistance.test.c b/src/spells/magicresistance.test.c index 86a66bc0e..cbfdeb4af 100644 --- a/src/spells/magicresistance.test.c +++ b/src/spells/magicresistance.test.c @@ -29,7 +29,8 @@ static void test_magicresistance_unit(CuTest *tc) { curse *c; test_setup(); - mt_register(mt_new_va("magicresistance_unit", "unit:unit", "id:int", MT_NEW_END)); + mt_create_va(mt_new("magicresistance_unit", NULL), + "unit:unit", "id:int", MT_NEW_END); r = test_create_plain(0, 0); f1 = test_create_faction(NULL); u1 = test_create_unit(f1, r); @@ -57,7 +58,8 @@ static void test_magicresistance_building(CuTest *tc) { curse *c; test_setup(); - mt_register(mt_new_va("magicresistance_building", "building:building", "id:int", MT_NEW_END)); + mt_create_va(mt_new("magicresistance_building", NULL), + "building:building", "id:int", MT_NEW_END); r = test_create_plain(0, 0); f1 = test_create_faction(NULL); u1 = test_create_unit(f1, r); diff --git a/src/spy.test.c b/src/spy.test.c index 3c4503c98..ed10c4b7e 100644 --- a/src/spy.test.c +++ b/src/spy.test.c @@ -33,19 +33,32 @@ typedef struct { } spy_fixture; static void setup_spy(spy_fixture *fix) { - mt_register(mt_new_va("spyreport", "spy:unit", "target:unit", "status:int", MT_NEW_END)); - mt_register(mt_new_va("spyreport_mage", "spy:unit", "target:unit", "type:int", MT_NEW_END)); - mt_register(mt_new_va("spyreport_faction", "spy:unit", "target:unit", "faction:faction", MT_NEW_END)); - mt_register(mt_new_va("spyreport_skills", "spy:unit", "target:unit", "skills:string", MT_NEW_END)); - mt_register(mt_new_va("spyreport_items", "spy:unit", "target:unit", "items:items", MT_NEW_END)); - mt_register(mt_new_va("destroy_ship_0", "unit:unit", "ship:ship", MT_NEW_END)); - mt_register(mt_new_va("destroy_ship_1", "unit:unit", "ship:ship", MT_NEW_END)); - mt_register(mt_new_va("destroy_ship_2", "unit:unit", "ship:ship", MT_NEW_END)); - mt_register(mt_new_va("destroy_ship_3", "ship:ship", MT_NEW_END)); - mt_register(mt_new_va("destroy_ship_4", "ship:ship", MT_NEW_END)); - mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", MT_NEW_END)); - mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", MT_NEW_END)); - mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", MT_NEW_END)); + mt_create_va(mt_new("spyreport", NULL), + "spy:unit", "target:unit", "status:int", MT_NEW_END); + mt_create_va(mt_new("spyreport_mage", NULL), + "spy:unit", "target:unit", "type:int", MT_NEW_END); + mt_create_va(mt_new("spyreport_faction", NULL), + "spy:unit", "target:unit", "faction:faction", MT_NEW_END); + mt_create_va(mt_new("spyreport_skills", NULL), + "spy:unit", "target:unit", "skills:string", MT_NEW_END); + mt_create_va(mt_new("spyreport_items", NULL), + "spy:unit", "target:unit", "items:items", MT_NEW_END); + mt_create_va(mt_new("destroy_ship_0", NULL), + "unit:unit", "ship:ship", MT_NEW_END); + mt_create_va(mt_new("destroy_ship_1", NULL), + "unit:unit", "ship:ship", MT_NEW_END); + mt_create_va(mt_new("destroy_ship_2", NULL), + "unit:unit", "ship:ship", MT_NEW_END); + mt_create_va(mt_new("destroy_ship_3", NULL), + "ship:ship", MT_NEW_END); + mt_create_va(mt_new("destroy_ship_4", NULL), + "ship:ship", MT_NEW_END); + mt_create_va(mt_new("sink_msg", NULL), + "ship:ship", "region:region", MT_NEW_END); + mt_create_va(mt_new("sink_lost_msg", NULL), + "unit:unit", "region:region", "dead:int", MT_NEW_END); + mt_create_va(mt_new("sink_saved_msg", NULL), + "unit:unit", "region:region", MT_NEW_END); if (fix) { fix->r = test_create_region(0, 0, NULL); diff --git a/src/study.test.c b/src/study.test.c index 46722c0f6..c1d0b0841 100644 --- a/src/study.test.c +++ b/src/study.test.c @@ -58,9 +58,12 @@ typedef struct { } study_fixture; static void setup_study(void) { - mt_register(mt_new_va("studycost", "unit:unit", "region:region", "cost:int", "skill:int", MT_NEW_END)); - mt_register(mt_new_va("teach_teacher", "teacher:unit", "student:unit", "skill:int", "level:int", MT_NEW_END)); - mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", MT_NEW_END)); + mt_create_va(mt_new("studycost", NULL), + "unit:unit", "region:region", "cost:int", "skill:int", MT_NEW_END); + mt_create_va(mt_new("teach_teacher", NULL), + "teacher:unit", "student:unit", "skill:int", "level:int", MT_NEW_END); + mt_create_va(mt_new("teach_student", NULL), + "teacher:unit", "student:unit", "skill:int", MT_NEW_END); } static void setup_locale(struct locale *lang) { @@ -218,7 +221,8 @@ static void test_academy_building(CuTest *tc) { message * msg; test_setup(); - mt_register(mt_new_va("teach_asgood", "unit:unit", "region:region", "command:order", "student:unit", MT_NEW_END)); + mt_create_va(mt_new("teach_asgood", NULL), + "unit:unit", "region:region", "command:order", "student:unit", MT_NEW_END); random_source_inject_constant(0.0); init_resources(); @@ -636,8 +640,10 @@ static void test_teach_message(CuTest *tc) { teaching_info *teach; test_setup(); - mt_register(mt_new_va("teach_teacher", "teacher:unit", "student:unit", "skill:int", "level:int", MT_NEW_END)); - mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", MT_NEW_END)); + mt_create_va(mt_new("teach_teacher", NULL), + "teacher:unit", "student:unit", "skill:int", "level:int", MT_NEW_END); + mt_create_va(mt_new("teach_student", NULL), + "teacher:unit", "student:unit", "skill:int", MT_NEW_END); init_resources(); u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL)); scale_number(u, 20); diff --git a/src/tests.c b/src/tests.c index 306148af2..09f533a9f 100644 --- a/src/tests.c +++ b/src/tests.c @@ -246,9 +246,12 @@ static void test_reset(void) { } random_source_reset(); - mt_register(mt_new_va("changepasswd", "value:string", MT_NEW_END)); - mt_register(mt_new_va("starvation", "unit:unit", "region:region", "dead:int", "live:int", MT_NEW_END)); - mt_register(mt_new_va("malnourish", "unit:unit", "region:region", MT_NEW_END)); + mt_create_va(mt_new("changepasswd", NULL), + "value:string", MT_NEW_END); + mt_create_va(mt_new("starvation", NULL), + "unit:unit", "region:region", "dead:int", "live:int", MT_NEW_END); + mt_create_va(mt_new("malnourish", NULL), + "unit:unit", "region:region", MT_NEW_END); if (errno) { int error = errno; diff --git a/src/triggers/shock.test.c b/src/triggers/shock.test.c index dad675e64..43b8d394b 100644 --- a/src/triggers/shock.test.c +++ b/src/triggers/shock.test.c @@ -12,7 +12,8 @@ #include static void shock_setup(void) { - mt_register(mt_new_va("shock", "mage:unit", "reason:string", MT_NEW_END)); + mt_create_va(mt_new("shock", NULL), + "mage:unit", "reason:string", MT_NEW_END); } static void test_shock(CuTest *tc) { diff --git a/src/util/message.c b/src/util/message.c index 71795cfc7..0f8b7cc36 100644 --- a/src/util/message.c +++ b/src/util/message.c @@ -60,26 +60,34 @@ arg_type *find_argtype(const char *name) return NULL; } -message_type *mt_new(const char *name, const char *args[]) +static unsigned int mt_id(const message_type * mtype) +{ + unsigned int key = 0; + size_t i = strlen(mtype->name); + + while (i > 0) { + /* TODO: why not use str_hash? */ + key = (mtype->name[--i] + key * 37); + } + return key % 0x7FFFFFFF; +} + +#define MT_MAXHASH 1021 +static selist *messagetypes[MT_MAXHASH]; + +message_type *mt_create(message_type * mtype, const char *args[]) { int nparameters = 0; - message_type *mtype; + unsigned int hash = str_hash(mtype->name) % MT_MAXHASH; + selist **qlp = messagetypes + hash; - assert(name != NULL); - if (name == NULL) { - log_error("Trying to create message_type with name=0x0\n"); - return NULL; - } if (args != NULL) { /* count the number of parameters */ while (args[nparameters]) ++nparameters; } - mtype = (message_type *)malloc(sizeof(message_type)); - mtype->key = 0; - mtype->name = str_strdup(name); - mtype->nparameters = nparameters; if (nparameters > 0) { int i; + mtype->nparameters = nparameters; mtype->pnames = (char **)malloc(sizeof(char *) * nparameters); mtype->types = (arg_type **)malloc(sizeof(arg_type *) * nparameters); for (i = 0; args[i]; ++i) { @@ -103,20 +111,38 @@ message_type *mt_new(const char *name, const char *args[]) } } } - else { - mtype->pnames = NULL; - mtype->types = NULL; + if (selist_set_insert(qlp, mtype, NULL)) { + mtype->key = mt_id(mtype); } return mtype; } -message_type *mt_new_va(const char *name, ...) +message_type *mt_new(const char *name, const char *section) +{ + message_type *mtype; + + assert(name != NULL); + if (name == NULL) { + log_error("Trying to create message_type with name=0x0\n"); + return NULL; + } + mtype = (message_type *)malloc(sizeof(message_type)); + mtype->key = 0; + mtype->name = str_strdup(name); + mtype->section = section; + mtype->nparameters = 0; + mtype->pnames = NULL; + mtype->types = NULL; + return mtype; +} + +message_type *mt_create_va(message_type *mtype, ...) { const char *args[16]; int i = 0; va_list marker; - va_start(marker, name); + va_start(marker, mtype); for (;;) { const char *c = va_arg(marker, const char *); args[i++] = c; @@ -124,8 +150,8 @@ message_type *mt_new_va(const char *name, ...) break; } va_end(marker); - args[i] = 0; - return mt_new(name, args); + args[i] = NULL; + return mt_create(mtype, args); } static variant copy_arg(const arg_type * atype, variant data) @@ -165,9 +191,6 @@ message *msg_create(const struct message_type *mtype, variant args[]) return msg; } -#define MT_MAXHASH 1021 -static selist *messagetypes[MT_MAXHASH]; - static void mt_free(void *val) { message_type *mtype = (message_type *)val; int i; @@ -205,29 +228,6 @@ const message_type *mt_find(const char *name) return 0; } -static unsigned int mt_id(const message_type * mtype) -{ - unsigned int key = 0; - size_t i = strlen(mtype->name); - - while (i > 0) { - /* TODO: why not use str_hash? */ - key = (mtype->name[--i] + key * 37); - } - return key % 0x7FFFFFFF; -} - -const message_type *mt_register(message_type * type) -{ - unsigned int hash = str_hash(type->name) % MT_MAXHASH; - selist **qlp = messagetypes + hash; - - if (selist_set_insert(qlp, type, NULL)) { - type->key = mt_id(type); - } - return type; -} - void msg_free(message * msg) { int i; diff --git a/src/util/message.h b/src/util/message.h index 7521b8e24..41d58b448 100644 --- a/src/util/message.h +++ b/src/util/message.h @@ -29,6 +29,7 @@ extern "C" { typedef struct message_type { unsigned int key; char *name; + const char *section; int nparameters; char **pnames; struct arg_type ** types; @@ -43,8 +44,6 @@ extern "C" { void message_done(void); void mt_clear(void); - struct message_type *mt_new(const char *name, const char *args[]); - struct message_type *mt_new_va(const char *name, ...); #define MT_NEW_END ((const char *)0) /* mt_new("simple_sentence", "subject:string", "predicate:string", * "object:string", "lang:locale", MT_NEW_END); */ @@ -59,8 +58,10 @@ extern "C" { const char *mt_name(const struct message_type *mtype); + struct message_type *mt_new(const char *name, const char *section); /** message_type registry (optional): **/ - const struct message_type *mt_register(struct message_type *); + struct message_type *mt_create(struct message_type *, const char *args[]); + struct message_type *mt_create_va(struct message_type *, ...); const struct message_type *mt_find(const char *); void register_argtype(const char *name, void(*free_arg) (variant), diff --git a/src/util/message.test.c b/src/util/message.test.c index 4b00b4006..df8c75126 100644 --- a/src/util/message.test.c +++ b/src/util/message.test.c @@ -8,8 +8,7 @@ static void test_mt_new(CuTest *tc) { message_type *mt; test_setup(); - mt = mt_new_va("test", "name:string", "number:int", MT_NEW_END); - mt_register(mt); + mt = mt_create_va(mt_new("test", NULL), "name:string", "number:int", MT_NEW_END); CuAssertPtrNotNull(tc, mt); CuAssertStrEquals(tc, "test", mt->name); CuAssertIntEquals(tc, 2, mt->nparameters); diff --git a/src/util/nrmessage.c b/src/util/nrmessage.c index 9461e11c5..047d3565b 100644 --- a/src/util/nrmessage.c +++ b/src/util/nrmessage.c @@ -30,7 +30,6 @@ typedef struct nrmessage_type { const struct message_type *mtype; char *vars; struct nrmessage_type *next; - const char *section; } nrmessage_type; #define NRT_MAXHASH 1021 @@ -66,41 +65,44 @@ static nrmessage_type *nrt_find(const struct message_type * mtype) return found; } -nrsection *sections; +char *sections[MAXSECTIONS]; -const nrsection *section_find(const char *name) +const char *section_find(const char *name) { - nrsection **mcp = §ions; - if (name == NULL) + int i; + + if (name == NULL) { return NULL; - for (; *mcp; mcp = &(*mcp)->next) { - nrsection *mc = *mcp; - if (!strcmp(mc->name, name)) - break; } - return *mcp; + + for (i = 0; i != MAXSECTIONS && sections[i]; ++i) { + if (strcmp(sections[i], name) == 0) { + return sections[i]; + } + } + return NULL; } -const nrsection *section_add(const char *name) -{ - nrsection **mcp = §ions; - if (name == NULL) +const char *section_add(const char *name) { + int i; + if (name == NULL) { return NULL; - for (; *mcp; mcp = &(*mcp)->next) { - nrsection *mc = *mcp; - if (!strcmp(mc->name, name)) - break; } - if (!*mcp) { - nrsection *mc = calloc(sizeof(nrsection), 1); - mc->name = str_strdup(name); - *mcp = mc; + for (i = 0; i != MAXSECTIONS && sections[i]; ++i) { + if (strcmp(sections[i], name) == 0) { + return sections[i]; + } } - return *mcp; + assert(i < MAXSECTIONS); + assert(sections[i] == NULL); + if (i + 1 < MAXSECTIONS) { + sections[i + 1] = NULL; + } + return sections[i] = str_strdup(name); } void -nrt_register(const struct message_type *mtype, const char *section) +nrt_register(const struct message_type *mtype) { unsigned int hash = mtype->key % NRT_MAXHASH; nrmessage_type *nrt = nrtypes[hash]; @@ -118,15 +120,6 @@ nrt_register(const struct message_type *mtype, const char *section) nrt = malloc(sizeof(nrmessage_type)); nrt->mtype = mtype; nrt->next = nrtypes[hash]; - if (section) { - const nrsection *s = section_find(section); - if (s == NULL) { - s = section_add(section); - } - nrt->section = s->name; - } - else - nrt->section = NULL; nrtypes[hash] = nrt; *c = '\0'; for (i = 0; i != mtype->nparameters; ++i) { @@ -159,12 +152,6 @@ size_t size, const void *userdata) return 0; } -const char *nrt_section(const struct message_type * mtype) -{ - nrmessage_type *nrt = nrt_find(mtype); - return nrt ? nrt->section : NULL; -} - void free_nrmesssages(void) { int i; for (i = 0; i != NRT_MAXHASH; ++i) { diff --git a/src/util/nrmessage.h b/src/util/nrmessage.h index 357e5d5c5..c0d9257aa 100644 --- a/src/util/nrmessage.h +++ b/src/util/nrmessage.h @@ -25,19 +25,14 @@ extern "C" { struct message_type; struct nrmessage_type; - typedef struct nrsection { - char *name; - struct nrsection *next; - } nrsection; - - extern nrsection *sections; +#define MAXSECTIONS 8 + extern char *sections[MAXSECTIONS]; void free_nrmesssages(void); - void nrt_register(const struct message_type *mtype, const char *section); + void nrt_register(const struct message_type *mtype); const char *nrt_string(const struct message_type *mtype, const struct locale *lang); - const char *nrt_section(const struct message_type *mtype); size_t nr_render(const struct message *msg, const struct locale *lang, char *buffer, size_t size, const void *userdata); diff --git a/src/volcano.test.c b/src/volcano.test.c index 8a8358c1c..c62febc0d 100644 --- a/src/volcano.test.c +++ b/src/volcano.test.c @@ -20,7 +20,8 @@ static void test_volcano_update(CuTest *tc) { const struct terrain_type *t_volcano, *t_active; test_setup(); - mt_register(mt_new_va("volcanostopsmoke", "region:region", MT_NEW_END)); + mt_create_va(mt_new("volcanostopsmoke", NULL), + "region:region", MT_NEW_END); t_volcano = test_create_terrain("volcano", LAND_REGION); t_active = test_create_terrain("activevolcano", LAND_REGION); r = test_create_region(0, 0, t_active); @@ -42,9 +43,12 @@ static void test_volcano_outbreak(CuTest *tc) { const struct terrain_type *t_volcano, *t_active; test_setup(); - mt_register(mt_new_va("volcanooutbreak", "regionv:region", "regionn:region", MT_NEW_END)); - mt_register(mt_new_va("volcanooutbreaknn", "region:region", MT_NEW_END)); - mt_register(mt_new_va("volcano_dead", "unit:unit", "region:region", "dead:int", MT_NEW_END)); + mt_create_va(mt_new("volcanooutbreak", NULL), + "regionv:region", "regionn:region", MT_NEW_END); + mt_create_va(mt_new("volcanooutbreaknn", NULL), + "region:region", MT_NEW_END); + mt_create_va(mt_new("volcano_dead", NULL), + "unit:unit", "region:region", "dead:int", MT_NEW_END); t_volcano = test_create_terrain("volcano", LAND_REGION); t_active = test_create_terrain("activevolcano", LAND_REGION); r = test_create_region(0, 0, t_active); diff --git a/src/wormhole.test.c b/src/wormhole.test.c index e275d4d67..b8baaa79a 100644 --- a/src/wormhole.test.c +++ b/src/wormhole.test.c @@ -19,10 +19,14 @@ void sort_wormhole_regions(selist *rlist, region **match, int count); void make_wormholes(region **match, int count, const building_type *bt_wormhole); static void setup_wormholes(void) { - mt_register(mt_new_va("wormhole_appear", "region:region", MT_NEW_END)); - mt_register(mt_new_va("wormhole_dissolve", "region:region", MT_NEW_END)); - mt_register(mt_new_va("wormhole_exit", "unit:unit", "region:region", MT_NEW_END)); - mt_register(mt_new_va("wormhole_requirements", "unit:unit", "region:region", MT_NEW_END)); + mt_create_va(mt_new("wormhole_appear", NULL), + "region:region", MT_NEW_END); + mt_create_va(mt_new("wormhole_dissolve", NULL), + "region:region", MT_NEW_END); + mt_create_va(mt_new("wormhole_exit", NULL), + "unit:unit", "region:region", MT_NEW_END); + mt_create_va(mt_new("wormhole_requirements", NULL), + "unit:unit", "region:region", MT_NEW_END); } static void test_make_wormholes(CuTest *tc) { diff --git a/src/xmlreader.c b/src/xmlreader.c index 88ab51237..8ba33db84 100644 --- a/src/xmlreader.c +++ b/src/xmlreader.c @@ -1304,18 +1304,28 @@ static int parse_messages(xmlDocPtr doc) xmlXPathFreeObject(result); /* add the messagetype */ + propSection = xmlGetProp(node, BAD_CAST "section"); + if (propSection == NULL) { + propSection = BAD_CAST default_section; + } + propValue = xmlGetProp(node, BAD_CAST "name"); mtype = mt_find((const char *)propValue); if (mtype == NULL) { - mtype = mt_register(mt_new((const char *)propValue, (const char **)argv)); + mtype = mt_create(mt_new((const char *)propValue, (const char *)propSection), (const char **)argv); } else { assert(argv != NULL || !"cannot redefine arguments of message now"); } xmlFree(propValue); - /* register the type for the CR */ + if (propSection != BAD_CAST default_section) { + xmlFree(propSection); + } + + /* register the type for CR and NR */ crt_register(mtype); + nrt_register(mtype); /* let's clean up the mess */ if (argv != NULL) { @@ -1323,16 +1333,6 @@ static int parse_messages(xmlDocPtr doc) free(argv[k]); free(argv); } - - propSection = xmlGetProp(node, BAD_CAST "section"); - if (propSection == NULL) { - propSection = BAD_CAST default_section; - } - nrt_register(mtype, (const char *)propSection); - - if (propSection != BAD_CAST default_section) { - xmlFree(propSection); - } } xmlXPathFreeObject(messages);