Passing NULL after the last typed argument to a variadic function leads to undefined behaviour.

This commit is contained in:
Enno Rehling 2018-02-25 17:18:30 +01:00
parent 4ce7932d14
commit 05242aaf2d
23 changed files with 100 additions and 99 deletions

View file

@ -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", NULL));
mt_register(mt_new_va("donation", "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);

View file

@ -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", NULL));
mt_register(mt_new_va("income", "unit:unit", "region:region", "amount:int", "wanted:int", "mode:int", NULL));
mt_register(mt_new_va("buy", "unit:unit", "money:int", NULL));
mt_register(mt_new_va("buyamount", "unit:unit", "amount:int", "resource:resource", NULL));
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));
}
static void test_heroes_dont_recruit(CuTest * tc) {
@ -377,11 +377,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", NULL));
mt_register(mt_new_va("maintenance", "unit:unit", "building:building", NULL));
mt_register(mt_new_va("maintenancefail", "unit:unit", "building:building", NULL));
mt_register(mt_new_va("maintenance_nowork", "building:building", NULL));
mt_register(mt_new_va("maintenance_noowner", "building:building", NULL));
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));
}
/**

View file

@ -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", NULL));
mt_register(mt_new_va("give_person", "unit:unit", "target:unit", "amount:int", NULL));
mt_register(mt_new_va("give_person_peasants", "unit:unit", "amount:int", NULL));
mt_register(mt_new_va("give_person_ocean", "unit:unit", "amount:int", NULL));
mt_register(mt_new_va("receive", "unit:unit", "target:unit", "resource:resource", "amount:int", NULL));
mt_register(mt_new_va("give", "unit:unit", "target:unit", "resource:resource", "amount:int", NULL));
mt_register(mt_new_va("give_peasants", "unit:unit", "resource:resource", "amount:int", NULL));
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));
/* error messages: */
mt_register(mt_new_va("too_many_units_in_faction", "unit:unit", "region:region", "command:order", "allowed:int", NULL));
mt_register(mt_new_va("too_many_units_in_alliance", "unit:unit", "region:region", "command:order", "allowed:int", NULL));
mt_register(mt_new_va("feedback_no_contact", "unit:unit", "region:region", "command:order", "target:unit", NULL));
mt_register(mt_new_va("feedback_give_forbidden", "unit:unit", "region:region", "command:order", NULL));
mt_register(mt_new_va("peasants_give_invalid", "unit:unit", "region:region", "command:order", NULL));
mt_register(mt_new_va("giverestriction", "unit:unit", "region:region", "command:order", "turns:int", NULL));
mt_register(mt_new_va("error_unit_size", "unit:unit", "region:region", "command:order", "maxsize:int", NULL));
mt_register(mt_new_va("nogive_reserved", "unit:unit", "region:region", "command:order", "resource:resource", "reservation:int", NULL));
mt_register(mt_new_va("race_notake", "unit:unit", "region:region", "command:order", "race:race", NULL));
mt_register(mt_new_va("race_noregroup", "unit:unit", "region:region", "command:order", "race:race", NULL));
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));
}
static void test_give_unit(CuTest * tc) {

View file

@ -256,7 +256,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", NULL));
mt_register(mt_new_va("destroy_road", "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);

View file

@ -162,7 +162,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", NULL));
mt_register(mt_new_va("missing_message", "name:string", MT_NEW_END));
}
return msg_message("missing_message", "name", name);
}

View file

@ -257,7 +257,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", NULL));
mt_register(mt_new_va("force_leave_building", "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);
@ -287,7 +287,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", NULL));
mt_register(mt_new_va("force_leave_ship", "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);
@ -875,7 +875,7 @@ static void test_luck_message(CuTest *tc) {
attrib *a;
test_setup();
mt_register(mt_new_va("peasantluck_success", "births:int", NULL));
mt_register(mt_new_va("peasantluck_success", "births:int", MT_NEW_END));
setup_terrains(tc);
r = test_create_region(0, 0, NULL);
rsetpeasants(r, 1);
@ -900,8 +900,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", NULL));
mt_register(mt_new_va("renamed_building_notseen", "region:region", "building:building", NULL));
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));
f = test_create_faction(NULL);
return test_create_unit(f, test_create_region(0, 0, NULL));
}
@ -1300,9 +1300,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", NULL));
mt_register(mt_new_va("nmr_warning_final", NULL));
mt_register(mt_new_va("warn_dropout", "faction:faction", "turn:int", NULL));
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));
config_set("nmr.timeout", "3");
f1 = test_create_faction(NULL);
f2 = test_create_faction(NULL);
@ -1324,9 +1324,9 @@ static unit * setup_mail_cmd(void) {
faction *f;
test_setup();
mt_register(mt_new_va("regionmessage", "region:region", "sender:unit", "string:string", NULL));
mt_register(mt_new_va("unitmessage", "region:region", "sender:unit", "string:string", "unit:unit", NULL));
mt_register(mt_new_va("mail_result", "message:string", "unit:unit", NULL));
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));
f = test_create_faction(NULL);
return test_create_unit(f, test_create_region(0, 0, NULL));
}
@ -1443,7 +1443,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", NULL));
mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", MT_NEW_END));
loc = get_or_create_locale("de");
locale_setstring(loc, parameters[P_ANY], "ALLE");
@ -1488,7 +1488,7 @@ static void test_show_race(CuTest *tc) {
test_setup();
mt_register(mt_new_va("msg_event", "string:string", NULL));
mt_register(mt_new_va("msg_event", "string:string", MT_NEW_END));
test_create_race("human");
rc = test_create_race("elf");
@ -1528,8 +1528,8 @@ static void test_show_both(CuTest *tc) {
message * msg;
test_setup();
mt_register(mt_new_va("msg_event", "string:string", NULL));
mt_register(mt_new_va("displayitem", "weight:int", "item:resource", "description:string", NULL));
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));
rc = test_create_race("elf");
test_create_itemtype("elvenhorse");

View file

@ -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", NULL));
mt_register(mt_new_va("buyamount", "unit:unit", "amount:int", "resource:resource", MT_NEW_END));
htype = test_create_itemtype("herb");
htype->flags |= ITF_HERB;

View file

@ -48,7 +48,7 @@ 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", NULL));
mt_register(mt_new_va("dragon_growl", "dragon:unit", "number:int", "target:region", "growl:string", MT_NEW_END));
test_create_horse();
default_locale = test_create_locale();
fp = test_create_faction(NULL);
@ -216,7 +216,7 @@ 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", NULL));
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);

View file

@ -28,8 +28,8 @@
#include <assert.h>
static void setup_move(void) {
mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", NULL));
mt_register(mt_new_va("moveblocked", "unit:unit", "direction:int", NULL));
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));
}
static void test_ship_not_allowed_in_coast(CuTest * tc)
@ -285,9 +285,9 @@ 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", NULL));
mt_register(mt_new_va("shipsink", "ship:ship", NULL));
mt_register(mt_new_va("massive_overload", "ship:ship", NULL));
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));
}
static void test_ship_no_overload(CuTest *tc) {
@ -482,7 +482,7 @@ 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", NULL));
mt_register(mt_new_va("error18", "unit:unit", "region:region", "command:order", MT_NEW_END));
init_order_depr(ord);
getstrtoken();

View file

@ -63,7 +63,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", NULL));
mt_register(mt_new_va("wrongpasswd", "password:string", MT_NEW_END));
f = test_create_faction(NULL);
renumber_faction(f, 1);

View file

@ -30,12 +30,12 @@ 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", NULL));
mt_register(mt_new_va("piratesawvictim", "ship:ship", "unit:unit", "region:region", "dir:int", NULL));
mt_register(mt_new_va("shipsail", "ship:ship", "from:region", "to:region", NULL));
mt_register(mt_new_va("shipfly", "ship:ship", "from:region", "to:region", NULL));
mt_register(mt_new_va("shipnoshore", "ship:ship", "region:region", NULL));
mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", NULL));
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));
}
static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const char *p_shiptype,

View file

@ -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", NULL));
mt_register(mt_new_va("renumber_inuse", "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;

View file

@ -130,8 +130,8 @@ 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", NULL));
mt_register(mt_new_va("viewreality_effect", "unit:unit", NULL));
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));
r = test_create_region(0, 0, NULL);
ra = test_create_region(real2tp(r->x), real2tp(r->y), NULL);
ra->_plane = get_astralplane();

View file

@ -29,7 +29,7 @@ static void test_flyingship(CuTest * tc)
ship *sh1, *sh2;
test_setup();
mt_register(mt_new_va("flying_ship_result", "mage:unit", "ship:ship", NULL));
mt_register(mt_new_va("flying_ship_result", "mage:unit", "ship:ship", MT_NEW_END));
par.param = &par_data_ptr;
par_data.typ = SPP_SHIP;

View file

@ -29,7 +29,7 @@ static void test_magicresistance_unit(CuTest *tc) {
curse *c;
test_setup();
mt_register(mt_new_va("magicresistance_unit", "unit:unit", "id:int", NULL));
mt_register(mt_new_va("magicresistance_unit", "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 +57,7 @@ static void test_magicresistance_building(CuTest *tc) {
curse *c;
test_setup();
mt_register(mt_new_va("magicresistance_building", "building:building", "id:int", NULL));
mt_register(mt_new_va("magicresistance_building", "building:building", "id:int", MT_NEW_END));
r = test_create_plain(0, 0);
f1 = test_create_faction(NULL);
u1 = test_create_unit(f1, r);

View file

@ -33,19 +33,19 @@ typedef struct {
} spy_fixture;
static void setup_spy(spy_fixture *fix) {
mt_register(mt_new_va("spyreport", "spy:unit", "target:unit", "status:int", NULL));
mt_register(mt_new_va("spyreport_mage", "spy:unit", "target:unit", "type:int", NULL));
mt_register(mt_new_va("spyreport_faction", "spy:unit", "target:unit", "faction:faction", NULL));
mt_register(mt_new_va("spyreport_skills", "spy:unit", "target:unit", "skills:string", NULL));
mt_register(mt_new_va("spyreport_items", "spy:unit", "target:unit", "items:items", NULL));
mt_register(mt_new_va("destroy_ship_0", "unit:unit", "ship:ship", NULL));
mt_register(mt_new_va("destroy_ship_1", "unit:unit", "ship:ship", NULL));
mt_register(mt_new_va("destroy_ship_2", "unit:unit", "ship:ship", NULL));
mt_register(mt_new_va("destroy_ship_3", "ship:ship", NULL));
mt_register(mt_new_va("destroy_ship_4", "ship:ship", NULL));
mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", NULL));
mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", NULL));
mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", NULL));
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));
if (fix) {
fix->r = test_create_region(0, 0, NULL);

View file

@ -58,9 +58,9 @@ typedef struct {
} study_fixture;
static void setup_study(void) {
mt_register(mt_new_va("studycost", "unit:unit", "region:region", "cost:int", "skill:int", NULL));
mt_register(mt_new_va("teach_teacher", "teacher:unit", "student:unit", "skill:int", "level:int", NULL));
mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", NULL));
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));
}
static void setup_locale(struct locale *lang) {
@ -218,7 +218,7 @@ 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", NULL));
mt_register(mt_new_va("teach_asgood", "unit:unit", "region:region", "command:order", "student:unit", MT_NEW_END));
random_source_inject_constant(0.0);
init_resources();
@ -636,8 +636,8 @@ 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", NULL));
mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", NULL));
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));
init_resources();
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
scale_number(u, 20);

View file

@ -231,9 +231,9 @@ static void test_reset(void) {
}
random_source_reset();
mt_register(mt_new_va("changepasswd", "value:string", NULL));
mt_register(mt_new_va("starvation", "unit:unit", "region:region", "dead:int", "live:int", NULL));
mt_register(mt_new_va("malnourish", "unit:unit", "region:region", NULL));
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));
if (errno) {
int error = errno;

View file

@ -12,7 +12,7 @@
#include <CuTest.h>
static void shock_setup(void) {
mt_register(mt_new_va("shock", "mage:unit", "reason:string", NULL));
mt_register(mt_new_va("shock", "mage:unit", "reason:string", MT_NEW_END));
}
static void test_shock(CuTest *tc) {

View file

@ -45,8 +45,9 @@ extern "C" {
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", NULL); */
* "object:string", "lang:locale", MT_NEW_END); */
struct message *msg_create(const struct message_type *type,
variant args[]);

View file

@ -8,7 +8,7 @@ static void test_mt_new(CuTest *tc)
{
message_type *mt;
test_setup();
mt = mt_new_va("test", "name:string", "number:int", NULL);
mt = mt_new_va("test", "name:string", "number:int", MT_NEW_END);
mt_register(mt);
CuAssertPtrNotNull(tc, mt);
CuAssertStrEquals(tc, "test", mt->name);

View file

@ -20,7 +20,7 @@ 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", NULL));
mt_register(mt_new_va("volcanostopsmoke", "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 +42,9 @@ 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", NULL));
mt_register(mt_new_va("volcanooutbreaknn", "region:region", NULL));
mt_register(mt_new_va("volcano_dead", "unit:unit", "region:region", "dead:int", NULL));
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));
t_volcano = test_create_terrain("volcano", LAND_REGION);
t_active = test_create_terrain("activevolcano", LAND_REGION);
r = test_create_region(0, 0, t_active);

View file

@ -19,10 +19,10 @@ 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", NULL));
mt_register(mt_new_va("wormhole_dissolve", "region:region", NULL));
mt_register(mt_new_va("wormhole_exit", "unit:unit", "region:region", NULL));
mt_register(mt_new_va("wormhole_requirements", "unit:unit", "region:region", NULL));
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));
}
static void test_make_wormholes(CuTest *tc) {