forked from github/server
fix more missing_message errors.
This commit is contained in:
parent
98678d9fb2
commit
b83a1ee136
|
@ -52,6 +52,26 @@ static void setup_give(struct give *env) {
|
|||
init_locale(env->lang);
|
||||
env->f1->locale = env->lang;
|
||||
}
|
||||
|
||||
/* success messages: */
|
||||
mt_register(mt_new_va("receive_person", "unit:unit", "target:unit", "amount:int", 0));
|
||||
mt_register(mt_new_va("give_person", "unit:unit", "target:unit", "amount:int", 0));
|
||||
mt_register(mt_new_va("give_person_peasants", "unit:unit", "amount:int", 0));
|
||||
mt_register(mt_new_va("give_person_ocean", "unit:unit", "amount:int", 0));
|
||||
mt_register(mt_new_va("receive", "unit:unit", "target:unit", "resource:resource", "amount:int", 0));
|
||||
mt_register(mt_new_va("give", "unit:unit", "target:unit", "resource:resource", "amount:int", 0));
|
||||
mt_register(mt_new_va("give_peasants", "unit:unit", "resource:resource", "amount:int", 0));
|
||||
/* error messages: */
|
||||
mt_register(mt_new_va("too_many_units_in_faction", "unit:unit", "region:region", "command:order", "allowed:int", 0));
|
||||
mt_register(mt_new_va("too_many_units_in_alliance", "unit:unit", "region:region", "command:order", "allowed:int", 0));
|
||||
mt_register(mt_new_va("feedback_no_contact", "unit:unit", "region:region", "command:order", "target:unit", 0));
|
||||
mt_register(mt_new_va("feedback_give_forbidden", "unit:unit", "region:region", "command:order", 0));
|
||||
mt_register(mt_new_va("peasants_give_invalid", "unit:unit", "region:region", "command:order", 0));
|
||||
mt_register(mt_new_va("giverestriction", "unit:unit", "region:region", "command:order", "turns:int", 0));
|
||||
mt_register(mt_new_va("error_unit_size", "unit:unit", "region:region", "command:order", "maxsize:int", 0));
|
||||
mt_register(mt_new_va("nogive_reserved", "unit:unit", "region:region", "command:order", "resource:resource", "reservation:int", 0));
|
||||
mt_register(mt_new_va("race_notake", "unit:unit", "region:region", "command:order", "race:race", 0));
|
||||
mt_register(mt_new_va("race_noregroup", "unit:unit", "region:region", "command:order", "race:race", 0));
|
||||
}
|
||||
|
||||
static void test_give_unit(CuTest * tc) {
|
||||
|
|
|
@ -160,7 +160,7 @@ message *msg_message(const char *name, const char *sig, ...)
|
|||
memset(args, 0, sizeof(args));
|
||||
|
||||
if (!mtype) {
|
||||
log_warning("trying to create message of unknown type \"%s\"\n", name);
|
||||
log_error("trying to create undefined message of type \"%s\"\n", name);
|
||||
#if 0
|
||||
if (strcmp(name, "missing_message") != 0) {
|
||||
if (!mt_find("missing_message")) {
|
||||
|
|
|
@ -1297,6 +1297,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", 0));
|
||||
mt_register(mt_new_va("nmr_warning_final", 0));
|
||||
mt_register(mt_new_va("warn_dropout", "faction:faction", "turn:int", 0));
|
||||
config_set("nmr.timeout", "3");
|
||||
f1 = test_create_faction(0);
|
||||
f2 = test_create_faction(0);
|
||||
|
@ -1318,6 +1321,9 @@ static unit * setup_mail_cmd(void) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("regionmessage", "region:region", "sender:unit", "string:string", 0));
|
||||
mt_register(mt_new_va("unitmessage", "region:region", "sender:unit", "string:string", "unit:unit", 0));
|
||||
mt_register(mt_new_va("mail_result", "message:string", "unit:unit", 0));
|
||||
f = test_create_faction(0);
|
||||
return test_create_unit(f, test_create_region(0, 0, 0));
|
||||
}
|
||||
|
@ -1590,7 +1596,6 @@ static void test_demon_hunger(CuTest * tc)
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("malnourish", "unit:unit", "region:region", NULL));
|
||||
init_resources();
|
||||
r = test_create_region(0, 0, 0);
|
||||
rc = test_create_race("demon");
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <kernel/unit.h>
|
||||
|
||||
#include <util/language.h>
|
||||
#include <util/message.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
@ -32,6 +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", 0));
|
||||
|
||||
htype = test_create_itemtype("herb");
|
||||
htype->flags |= ITF_HERB;
|
||||
|
|
|
@ -48,6 +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", 0));
|
||||
test_create_horse();
|
||||
default_locale = test_create_locale();
|
||||
fp = test_create_faction(NULL);
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
#include <tests.h>
|
||||
#include <assert.h>
|
||||
|
||||
static void setup_move(void) {
|
||||
mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", 0));
|
||||
mt_register(mt_new_va("moveblocked", "unit:unit", "direction:int", 0));
|
||||
}
|
||||
|
||||
static void test_ship_not_allowed_in_coast(CuTest * tc)
|
||||
{
|
||||
region *r1, *r2;
|
||||
|
@ -570,6 +575,7 @@ static void test_route_cycle(CuTest *tc) {
|
|||
char buffer[32];
|
||||
|
||||
test_setup();
|
||||
setup_move();
|
||||
test_create_region(1, 0, NULL);
|
||||
r = test_create_region(2, 0, NULL);
|
||||
lang = test_create_locale();
|
||||
|
@ -581,6 +587,7 @@ static void test_route_cycle(CuTest *tc) {
|
|||
CuAssertStrEquals(tc, "route WEST EAST NW", get_command(u->orders, lang, buffer, sizeof(buffer)));
|
||||
init_order(u->orders, u->faction->locale);
|
||||
move_cmd(u, u->orders);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "moveblocked"));
|
||||
CuAssertIntEquals(tc, 1, u->region->x);
|
||||
CuAssertStrEquals(tc, "route east nw west", get_command(u->orders, lang, buffer, sizeof(buffer)));
|
||||
test_teardown();
|
||||
|
@ -593,6 +600,7 @@ static void test_route_pause(CuTest *tc) {
|
|||
char buffer[32];
|
||||
|
||||
test_setup();
|
||||
setup_move();
|
||||
test_create_region(1, 0, NULL);
|
||||
r = test_create_region(2, 0, NULL);
|
||||
lang = test_create_locale();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "orderfile.h"
|
||||
|
||||
#include <kernel/faction.h>
|
||||
#include <util/message.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
@ -62,6 +63,8 @@ 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", 0));
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
renumber_faction(f, 1);
|
||||
CuAssertIntEquals(tc, 1, f->no);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <util/base36.h>
|
||||
#include <util/language.h>
|
||||
#include <util/message.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
#include <tests.h>
|
||||
|
@ -28,6 +29,13 @@ static void setup_piracy(void) {
|
|||
test_create_terrain("ocean", SEA_REGION);
|
||||
st_boat = test_create_shiptype("boat");
|
||||
st_boat->cargo = 1000;
|
||||
|
||||
mt_register(mt_new_va("piratenovictim", "ship:ship", "unit:unit", "region:region", 0));
|
||||
mt_register(mt_new_va("piratesawvictim", "ship:ship", "unit:unit", "region:region", "dir:int", 0));
|
||||
mt_register(mt_new_va("shipsail", "ship:ship", "from:region", "to:region", 0));
|
||||
mt_register(mt_new_va("shipfly", "ship:ship", "from:region", "to:region", 0));
|
||||
mt_register(mt_new_va("shipnoshore", "ship:ship", "region:region", 0));
|
||||
mt_register(mt_new_va("travel", "unit:unit", "start:region", "end:region", "mode:int", "regions:regions", 0));
|
||||
}
|
||||
|
||||
static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const char *p_shiptype,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <kernel/order.h>
|
||||
#include <util/base36.h>
|
||||
#include <util/language.h>
|
||||
#include <util/message.h>
|
||||
|
||||
#include <stddef.h>
|
||||
#include <CuTest.h>
|
||||
|
@ -37,6 +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", 0));
|
||||
f2 = test_create_faction(0);
|
||||
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||
no = f->no;
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include <kernel/unit.h>
|
||||
#include <kernel/ship.h>
|
||||
|
||||
#include <util/message.h>
|
||||
|
||||
#include <magic.h>
|
||||
|
||||
#include <CuTest.h>
|
||||
|
@ -27,6 +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", 0));
|
||||
|
||||
par.param = &par_data_ptr;
|
||||
par_data.typ = SPP_SHIP;
|
||||
|
|
|
@ -33,15 +33,31 @@ typedef struct {
|
|||
} spy_fixture;
|
||||
|
||||
static void setup_spy(spy_fixture *fix) {
|
||||
test_setup();
|
||||
mt_register(mt_new_va("spyreport", "spy:unit", "target:unit", "status:int", 0));
|
||||
mt_register(mt_new_va("spyreport_mage", "spy:unit", "target:unit", "type:int", 0));
|
||||
mt_register(mt_new_va("spyreport_faction", "spy:unit", "target:unit", "faction:faction", 0));
|
||||
mt_register(mt_new_va("spyreport_skills", "spy:unit", "target:unit", "skills:string", 0));
|
||||
mt_register(mt_new_va("spyreport_items", "spy:unit", "target:unit", "items:items", 0));
|
||||
mt_register(mt_new_va("destroy_ship_0", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_1", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_2", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_3", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_4", "ship:ship", 0));
|
||||
mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", 0));
|
||||
mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", 0));
|
||||
mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", 0));
|
||||
|
||||
if (fix) {
|
||||
fix->r = test_create_region(0, 0, NULL);
|
||||
fix->spy = test_create_unit(test_create_faction(NULL), fix->r);
|
||||
fix->victim = test_create_unit(test_create_faction(NULL), fix->r);
|
||||
}
|
||||
}
|
||||
|
||||
static void test_simple_spy_message(CuTest *tc) {
|
||||
spy_fixture fix;
|
||||
|
||||
test_setup();
|
||||
setup_spy(&fix);
|
||||
|
||||
spy_message(0, fix.spy, fix.victim);
|
||||
|
@ -55,6 +71,7 @@ static void test_all_spy_message(CuTest *tc) {
|
|||
spy_fixture fix;
|
||||
item_type *itype;
|
||||
|
||||
test_setup();
|
||||
setup_spy(&fix);
|
||||
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -84,9 +101,7 @@ static void test_sabotage_self(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", 0));
|
||||
mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", 0));
|
||||
mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", 0));
|
||||
setup_spy(NULL);
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -110,11 +125,8 @@ static void test_sabotage_other_fail(CuTest *tc) {
|
|||
message *msg;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("destroy_ship_0", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_1", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_2", "unit:unit", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_3", "ship:ship", 0));
|
||||
mt_register(mt_new_va("destroy_ship_4", "ship:ship", 0));
|
||||
setup_spy(NULL);
|
||||
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
@ -198,9 +210,7 @@ static void test_sabotage_other_success(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
mt_register(mt_new_va("sink_msg", "ship:ship", "region:region", 0));
|
||||
mt_register(mt_new_va("sink_lost_msg", "unit:unit", "region:region", "dead:int", 0));
|
||||
mt_register(mt_new_va("sink_saved_msg", "unit:unit", "region:region", 0));
|
||||
setup_spy(NULL);
|
||||
r = test_create_region(0, 0, 0);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
|
|
|
@ -57,6 +57,12 @@ typedef struct {
|
|||
unit *teachers[2];
|
||||
} study_fixture;
|
||||
|
||||
static void setup_study(void) {
|
||||
mt_register(mt_new_va("studycost", "unit:unit", "region:region", "cost:int", "skill:int", 0));
|
||||
mt_register(mt_new_va("teach_teacher", "teacher:unit", "student:unit", "skill:int", "level:int", 0));
|
||||
mt_register(mt_new_va("teach_student", "teacher:unit", "student:unit", "skill:int", 0));
|
||||
}
|
||||
|
||||
static void setup_locale(struct locale *lang) {
|
||||
int i;
|
||||
for (i = 0; i < MAXSKILLS; ++i) {
|
||||
|
@ -66,7 +72,7 @@ static void setup_locale(struct locale *lang) {
|
|||
init_skills(lang);
|
||||
}
|
||||
|
||||
static void setup_study(study_fixture *fix, skill_t sk) {
|
||||
static void setup_teacher(study_fixture *fix, skill_t sk) {
|
||||
struct region * r;
|
||||
struct faction *f;
|
||||
struct locale *lang;
|
||||
|
@ -96,7 +102,7 @@ static void test_study_no_teacher(CuTest *tc) {
|
|||
study_fixture fix;
|
||||
skill *sv;
|
||||
|
||||
setup_study(&fix, SK_CROSSBOW);
|
||||
setup_teacher(&fix, SK_CROSSBOW);
|
||||
study_cmd(fix.u, fix.u->thisorder);
|
||||
CuAssertPtrNotNull(tc, sv = unit_skill(fix.u, SK_CROSSBOW));
|
||||
CuAssertIntEquals(tc, 1, sv->level);
|
||||
|
@ -109,7 +115,7 @@ static void test_study_with_teacher(CuTest *tc) {
|
|||
study_fixture fix;
|
||||
skill *sv;
|
||||
|
||||
setup_study(&fix, SK_CROSSBOW);
|
||||
setup_teacher(&fix, SK_CROSSBOW);
|
||||
set_level(fix.teachers[0], SK_CROSSBOW, TEACHDIFFERENCE);
|
||||
teach_cmd(fix.teachers[0], fix.teachers[0]->thisorder);
|
||||
CuAssertPtrEquals(tc, 0, test_get_last_message(fix.u->faction->msgs));
|
||||
|
@ -124,7 +130,7 @@ static void test_study_with_bad_teacher(CuTest *tc) {
|
|||
study_fixture fix;
|
||||
skill *sv;
|
||||
|
||||
setup_study(&fix, SK_CROSSBOW);
|
||||
setup_teacher(&fix, SK_CROSSBOW);
|
||||
teach_cmd(fix.teachers[0], fix.teachers[0]->thisorder);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(fix.u->faction->msgs, "teach_asgood"));
|
||||
study_cmd(fix.u, fix.u->thisorder);
|
||||
|
@ -262,6 +268,7 @@ static void test_academy_bonus(CuTest *tc) {
|
|||
building * b;
|
||||
|
||||
test_setup();
|
||||
setup_study();
|
||||
|
||||
random_source_inject_constant(0.0);
|
||||
init_resources();
|
||||
|
@ -389,6 +396,7 @@ static void test_study_magic(CuTest *tc) {
|
|||
const struct item_type *itype;
|
||||
|
||||
test_setup();
|
||||
setup_study();
|
||||
init_resources();
|
||||
f = test_create_faction(0);
|
||||
lang = f->locale;
|
||||
|
@ -421,6 +429,7 @@ static void test_study_cost_magic(CuTest *tc) {
|
|||
unit * u;
|
||||
|
||||
test_setup();
|
||||
setup_study();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
|
||||
CuAssertIntEquals(tc, 100, study_cost(u, SK_MAGIC));
|
||||
|
@ -444,6 +453,7 @@ static void test_study_cost(CuTest *tc) {
|
|||
const struct item_type *itype;
|
||||
|
||||
test_setup();
|
||||
setup_study();
|
||||
|
||||
itype = test_create_silver();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
|
@ -471,6 +481,7 @@ static void test_teach_magic(CuTest *tc) {
|
|||
const struct item_type *itype;
|
||||
|
||||
test_setup();
|
||||
setup_study();
|
||||
init_resources();
|
||||
itype = get_resourcetype(R_SILVER)->itype;
|
||||
f = test_create_faction(0);
|
||||
|
|
|
@ -231,6 +231,10 @@ static void test_reset(void) {
|
|||
}
|
||||
random_source_reset();
|
||||
|
||||
mt_register(mt_new_va("changepasswd", "value:string", 0));
|
||||
mt_register(mt_new_va("starvation", "unit:unit", "region:region", "dead:int", "live:int", 0));
|
||||
mt_register(mt_new_va("malnourish", "unit:unit", "region:region", 0));
|
||||
|
||||
if (errno) {
|
||||
int error = errno;
|
||||
errno = 0;
|
||||
|
|
|
@ -4,16 +4,23 @@
|
|||
#include <magic.h>
|
||||
#include <kernel/unit.h>
|
||||
#include <kernel/faction.h>
|
||||
|
||||
#include <util/event.h>
|
||||
#include <util/message.h>
|
||||
|
||||
#include <tests.h>
|
||||
#include <CuTest.h>
|
||||
|
||||
static void shock_setup(void) {
|
||||
mt_register(mt_new_va("shock", "mage:unit", "reason:string", 0));
|
||||
}
|
||||
|
||||
static void test_shock(CuTest *tc) {
|
||||
unit *u;
|
||||
trigger *tt;
|
||||
|
||||
test_setup();
|
||||
shock_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
create_mage(u, M_GRAY);
|
||||
set_level(u, SK_MAGIC, 5);
|
||||
|
@ -34,6 +41,7 @@ static void test_shock_low(CuTest *tc) {
|
|||
trigger *tt;
|
||||
|
||||
test_setup();
|
||||
shock_setup();
|
||||
u = test_create_unit(test_create_faction(0), test_create_region(0, 0, 0));
|
||||
create_mage(u, M_GRAY);
|
||||
set_level(u, SK_MAGIC, 5);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <kernel/terrain.h>
|
||||
|
||||
#include <util/attrib.h>
|
||||
#include <util/message.h>
|
||||
|
||||
#include <selist.h>
|
||||
|
||||
|
@ -17,12 +18,20 @@
|
|||
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", 0));
|
||||
mt_register(mt_new_va("wormhole_dissolve", "region:region", 0));
|
||||
mt_register(mt_new_va("wormhole_exit", "unit:unit", "region:region", 0));
|
||||
mt_register(mt_new_va("wormhole_requirements", "unit:unit", "region:region", 0));
|
||||
}
|
||||
|
||||
static void test_make_wormholes(CuTest *tc) {
|
||||
region *r1, *r2, *match[2];
|
||||
terrain_type *t_plain;
|
||||
building_type *btype;
|
||||
|
||||
test_setup();
|
||||
setup_wormholes();
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
btype = test_create_buildingtype("wormhole");
|
||||
match[0] = r1 = test_create_region(0, 0, t_plain);
|
||||
|
@ -45,6 +54,7 @@ static void test_sort_wormhole_regions(CuTest *tc) {
|
|||
selist *rlist = 0;
|
||||
|
||||
test_setup();
|
||||
setup_wormholes();
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
r1 = test_create_region(0, 0, t_plain);
|
||||
r2 = test_create_region(1, 0, t_plain);
|
||||
|
|
Loading…
Reference in New Issue