forked from github/server
Build in Visual Studio 2019
simplify test_create_faction rewrite lots of tests
This commit is contained in:
parent
9e4e9c2d3e
commit
69c4595282
78 changed files with 604 additions and 648 deletions
CMakeLists.txt
res/translations
src
CMakeLists.txtalchemy.test.c
vs2017-build.batattributes
automate.test.cbattle.test.cbind_region.cbind_ship.cchecker.ccontact.test.ccreport.test.cdonations.test.ceconomy.test.cexparse.cgive.test.cguard.test.citems
kernel
CMakeLists.txtalliance.test.cally.test.cbuild.test.cbuilding.test.ccommand.test.cconfig.test.ccurse.test.cdatabase.test.c
laws.test.clighthouse.test.cmagic.test.cmarket.test.cmonsters.test.cmove.test.cnames.test.corderfile.corderfile.test.cpiracy.test.crenumber.test.creport.test.creports.test.cspells.test.cdb
equipment.test.cfaction.test.cgroup.test.citem.test.cmessages.test.corder.test.cplane.test.cpool.test.crace.test.cregion.test.csave.test.cship.test.cskills.test.cunit.test.cspells
spy.test.cstudy.test.csummary.test.ctests.ctests.htravelthru.test.ctriggers
upkeep.test.cutil
volcano.test.cvortex.test.cwormhole.test.c
|
@ -1,5 +1,4 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
|
||||
cmake_minimum_required(VERSION 2.9)
|
||||
if (WIN32)
|
||||
FILE(TO_CMAKE_PATH "${CMAKE_MODULE_PATH}" CMAKE_MODULE_PATH )
|
||||
FILE(TO_CMAKE_PATH "${CMAKE_PREFIX_PATH}" CMAKE_PREFIX_PATH )
|
||||
|
|
|
@ -1741,10 +1741,6 @@ msgstr "caravel"
|
|||
msgid "stone_p"
|
||||
msgstr "stones"
|
||||
|
||||
msgctxt "keyword"
|
||||
msgid "locale"
|
||||
msgstr "LOCALE"
|
||||
|
||||
msgctxt "spellinfo"
|
||||
msgid "song_suscept_magic"
|
||||
msgstr "This song, which is woven into the magical essence of the region, weakens the natural resistance against a singular enchantment by 15%. Only the allies of the bard (HELP GUARD) are immune to the effect of the chant."
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
project (server C)
|
||||
|
||||
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
|
|
@ -29,10 +29,10 @@ static void test_herbsearch(CuTest * tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
rc = rc_get_or_create("dragon");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
u2 = test_create_unit(test_create_faction(rc), r);
|
||||
u2 = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
setguard(u2, true);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
itype = test_create_itemtype("rosemary");
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ static void test_otherfaction(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction_ex(u->faction->race, u->faction->locale);
|
||||
config_set("stealth.faction.other", "1");
|
||||
CuAssertIntEquals(tc, true, rule_stealth_other());
|
||||
CuAssertPtrEquals(tc, u->faction, visible_faction(f, u));
|
||||
|
|
|
@ -15,7 +15,7 @@ static void test_stealth(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_STEALTH, 2);
|
||||
CuAssertIntEquals(tc, -1, u_geteffstealth(u));
|
||||
CuAssertIntEquals(tc, 2, eff_stealth(u, u->region));
|
||||
|
|
|
@ -29,7 +29,7 @@ static void test_autostudy_init(CuTest *tc) {
|
|||
mt_create_error(771);
|
||||
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
test_create_unit(f, r);
|
||||
|
@ -40,7 +40,7 @@ static void test_autostudy_init(CuTest *tc) {
|
|||
u4->thisorder = create_order(K_AUTOSTUDY, f->locale, "Dudelidu");
|
||||
u3 = test_create_unit(f, r);
|
||||
u3->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
u5 = test_create_unit(test_create_faction(NULL), r);
|
||||
u5 = test_create_unit(test_create_faction(), r);
|
||||
u5->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
scholars[2].u = NULL;
|
||||
|
||||
|
@ -82,7 +82,7 @@ static void test_autostudy_run_twoteachers(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_level(u1, SK_ENTERTAINMENT, 2);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
|
@ -123,7 +123,7 @@ static void test_autostudy_run_bigunit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_number(u1, 20);
|
||||
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||
|
@ -154,7 +154,7 @@ static void test_autostudy_run_few_teachers(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_number(u1, 20);
|
||||
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||
|
@ -190,7 +190,7 @@ static void test_autostudy_run_few_teachers_reverse(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
set_number(u1, 20);
|
||||
set_level(u1, SK_ENTERTAINMENT, 16);
|
||||
|
@ -224,7 +224,7 @@ static void test_autostudy_run(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
set_number(u1, 2);
|
||||
|
@ -268,7 +268,7 @@ static void test_autostudy_run_noteachers(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
set_number(u1, 5);
|
||||
|
@ -303,7 +303,7 @@ static void test_autostudy_run_teachers_learn(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
set_number(u1, 2);
|
||||
|
@ -332,7 +332,7 @@ static void test_autostudy_run_skilldiff(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
set_number(u1, 1);
|
||||
|
@ -364,7 +364,7 @@ static void test_autostudy_batches(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
set_number(u1, 1);
|
||||
|
@ -396,7 +396,7 @@ static void test_do_autostudy(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_PERCEPTION]);
|
||||
set_number(u1, 1);
|
||||
|
@ -406,7 +406,7 @@ static void test_do_autostudy(CuTest *tc) {
|
|||
set_number(u2, 10);
|
||||
u3 = test_create_unit(f, r);
|
||||
u3->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
u4 = test_create_unit(test_create_faction(NULL), r);
|
||||
u4 = test_create_unit(test_create_faction(), r);
|
||||
u4->thisorder = create_order(K_AUTOSTUDY, f->locale, skillnames[SK_ENTERTAINMENT]);
|
||||
do_autostudy(r);
|
||||
CuAssertIntEquals(tc, 2, get_level(u1, SK_PERCEPTION));
|
||||
|
|
|
@ -63,7 +63,7 @@ static void test_make_fighter(CuTest * tc)
|
|||
test_setup();
|
||||
test_create_horse();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
au = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
enable_skill(SK_RIDING, true);
|
||||
|
@ -103,7 +103,7 @@ static void test_select_weapon_restricted(CuTest *tc) {
|
|||
race * rc;
|
||||
|
||||
test_setup();
|
||||
au = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
au = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("halberd");
|
||||
wtype = new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
i_change(&au->items, itype, 1);
|
||||
|
@ -160,7 +160,7 @@ static void test_select_armor(CuTest *tc) {
|
|||
battle *b;
|
||||
|
||||
test_setup();
|
||||
au = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
au = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("plate");
|
||||
new_armortype(itype, 0.0, frac_zero, 1, 0);
|
||||
i_change(&au->items, itype, 2);
|
||||
|
@ -215,8 +215,8 @@ static void test_defenders_get_building_bonus(CuTest * tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
bld = test_create_building(r, btype);
|
||||
|
||||
du = test_create_unit(test_create_faction(NULL), r);
|
||||
au = test_create_unit(test_create_faction(NULL), r);
|
||||
du = test_create_unit(test_create_faction(), r);
|
||||
au = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(du, bld);
|
||||
|
||||
b = make_battle(r);
|
||||
|
@ -264,7 +264,7 @@ static void test_attackers_get_no_building_bonus(CuTest * tc)
|
|||
bld = test_create_building(r, btype);
|
||||
bld->size = 10;
|
||||
|
||||
au = test_create_unit(test_create_faction(NULL), r);
|
||||
au = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(au, bld);
|
||||
|
||||
b = make_battle(r);
|
||||
|
@ -294,7 +294,7 @@ static void test_building_bonus_respects_size(CuTest * tc)
|
|||
bld = test_create_building(r, btype);
|
||||
bld->size = 10;
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
au = test_create_unit(f, r);
|
||||
scale_number(au, 9);
|
||||
u_set_building(au, bld);
|
||||
|
@ -355,7 +355,7 @@ static void test_natural_armor(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_STAMINA, 2);
|
||||
CuAssertIntEquals(tc, 0, rc_armor_bonus(rc));
|
||||
CuAssertIntEquals(tc, 0, natural_armor(u));
|
||||
|
@ -399,7 +399,7 @@ static void test_calculate_armor(CuTest * tc)
|
|||
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
||||
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE);
|
||||
rc = test_create_race("human");
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
|
||||
dt.fighter = setup_fighter(&b, du);
|
||||
|
@ -472,7 +472,7 @@ static void test_magic_resistance(CuTest *tc)
|
|||
ichain = it_get_or_create(rt_get_or_create("chainmail"));
|
||||
achain = new_armortype(ichain, 0.0, v50p, 3, ATF_NONE);
|
||||
rc = test_create_race("human");
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
|
||||
i_change(&du->items, ishield, 1);
|
||||
|
@ -543,7 +543,7 @@ static void test_projectile_armor(CuTest * tc)
|
|||
wtype = new_weapontype(it_get_or_create(rt_get_or_create("sword")), 0, v50p, 0, 0, 0, 0, SK_MELEE);
|
||||
rc = test_create_race("human");
|
||||
rc->battle_flags |= BF_EQUIPMENT;
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
|
||||
i_change(&du->items, ishield, 1);
|
||||
|
@ -571,8 +571,8 @@ static void test_battle_skilldiff(CuTest *tc)
|
|||
test_setup();
|
||||
|
||||
r = test_create_region(0, 0, NULL);
|
||||
ud = test_create_unit(test_create_faction(NULL), r);
|
||||
ua = test_create_unit(test_create_faction(NULL), r);
|
||||
ud = test_create_unit(test_create_faction(), r);
|
||||
ua = test_create_unit(test_create_faction(), r);
|
||||
td.fighter = setup_fighter(&b, ud);
|
||||
td.index = 0;
|
||||
ta.fighter = setup_fighter(&b, ua);
|
||||
|
@ -606,8 +606,8 @@ static void test_terminate(CuTest * tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
|
||||
rc = test_create_race("human");
|
||||
au = test_create_unit(test_create_faction(rc), r);
|
||||
du = test_create_unit(test_create_faction(rc), r);
|
||||
au = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
du = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
dt.index = 0;
|
||||
at.index = 0;
|
||||
|
||||
|
@ -638,8 +638,8 @@ static void test_battle_report_one(CuTest *tc)
|
|||
test_setup();
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
b = make_battle(r);
|
||||
join_battle(b, u1, true, &fig);
|
||||
join_battle(b, u2, false, &fig);
|
||||
|
@ -669,9 +669,8 @@ static void test_battle_report_two(CuTest *tc)
|
|||
locale_setstring(lang, "and", "and");
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1->faction->locale = lang;
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction_ex(NULL, lang), r);
|
||||
u2 = test_create_unit(test_create_faction_ex(NULL, lang), r);
|
||||
u2->faction->locale = lang;
|
||||
|
||||
str_slprintf(expect, sizeof(expect), "%s and %s", factionname(u1->faction), factionname(u2->faction));
|
||||
|
@ -702,11 +701,11 @@ static void test_battle_report_three(CuTest *tc)
|
|||
locale_setstring(lang, "and", "and");
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u1->faction->locale = lang;
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u2->faction->locale = lang;
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
u3->faction->locale = lang;
|
||||
|
||||
str_slprintf(expect, sizeof(expect), "%s, %s and %s", factionname(u1->faction), factionname(u2->faction), factionname(u3->faction));
|
||||
|
@ -735,9 +734,9 @@ static void test_battle_skilldiff_building(CuTest *tc)
|
|||
btype = setup_castle();
|
||||
|
||||
r = test_create_region(0, 0, NULL);
|
||||
ud = test_create_unit(test_create_faction(NULL), r);
|
||||
ud = test_create_unit(test_create_faction(), r);
|
||||
ud->building = test_create_building(ud->region, btype);
|
||||
ua = test_create_unit(test_create_faction(NULL), r);
|
||||
ua = test_create_unit(test_create_faction(), r);
|
||||
td.fighter = setup_fighter(&b, ud);
|
||||
td.index = 0;
|
||||
ta.fighter = setup_fighter(&b, ua);
|
||||
|
@ -784,7 +783,7 @@ static void test_drain_exp(CuTest *tc)
|
|||
|
||||
test_setup();
|
||||
config_set("study.random_progress", "0");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_STAMINA, 3);
|
||||
|
||||
CuAssertIntEquals(tc, 3, unit_skill(u, SK_STAMINA)->level);
|
||||
|
@ -842,7 +841,7 @@ static void test_tactics_chance(CuTest *tc) {
|
|||
ship_type *stype;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_ocean(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_ocean(0, 0));
|
||||
CuAssertDblEquals(tc, 0.1, tactics_chance(u, 1), 0.01);
|
||||
CuAssertDblEquals(tc, 0.3, tactics_chance(u, 3), 0.01);
|
||||
stype = test_create_shiptype("brot");
|
||||
|
@ -859,8 +858,8 @@ static void test_battle_fleeing(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_messages();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u1->status = ST_FLEE;
|
||||
u2->status = ST_AGGRO;
|
||||
#if 0
|
||||
|
|
|
@ -556,7 +556,7 @@ static int tolua_region_set_peasants(lua_State * L)
|
|||
region *self = (region *)tolua_tousertype(L, 1, NULL);
|
||||
|
||||
if (self && self->land) {
|
||||
rsetpeasants(self, lua_tointeger(L, 2));
|
||||
rsetpeasants(self, (int)lua_tointeger(L, 2));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -111,7 +111,7 @@ static int tolua_ship_set_name(lua_State * L)
|
|||
static int tolua_ship_set_size(lua_State * L)
|
||||
{
|
||||
ship *sh = (ship *)tolua_tousertype(L, 1, NULL);
|
||||
sh->size = lua_tointeger(L, 2);
|
||||
sh->size = (int)lua_tointeger(L, 2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ int parsefile(FILE *F) {
|
|||
OP_SetUserData(parser, &state);
|
||||
|
||||
while (!done) {
|
||||
size_t len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
if (ferror(F)) {
|
||||
/* TODO: error message */
|
||||
err = errno;
|
||||
|
|
|
@ -19,10 +19,10 @@ static void test_contact(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u2 = test_create_unit(f, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
CuAssertTrue(tc, ucontact(u1, u1));
|
||||
CuAssertTrue(tc, ucontact(u1, u2));
|
||||
CuAssertTrue(tc, !ucontact(u1, u3));
|
||||
|
@ -40,30 +40,30 @@ static void test_contact_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
lang = u->faction->locale;
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %i",
|
||||
LOC(lang, parameters[P_UNIT]), u2->no);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertTrue(tc, ucontact(u, u2));
|
||||
free_order(ord);
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %i",
|
||||
LOC(lang, parameters[P_FACTION]), u2->faction->no);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertTrue(tc, ucontact(u, u2));
|
||||
free_order(ord);
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%i", u2->no);
|
||||
contact_cmd(u, ord);
|
||||
CuAssertTrue(tc, ucontact(u, u2));
|
||||
free_order(ord);
|
||||
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
usetalias(u2, 42);
|
||||
ord = create_order(K_CONTACT, u->faction->locale, "%s %i",
|
||||
LOC(lang, parameters[P_TEMP]), ualias(u2));
|
||||
|
@ -82,7 +82,7 @@ static void test_contact_cmd_invalid(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
lang = u->faction->locale;
|
||||
|
||||
/* KONTAKTIERE EINHEIT <not-found> */
|
||||
|
|
|
@ -39,7 +39,7 @@ static void test_cr_unit(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f, r);
|
||||
renumber_unit(u, 1234);
|
||||
|
@ -93,7 +93,7 @@ static void test_cr_resources(CuTest *tc) {
|
|||
|
||||
setup_resources();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f, r);
|
||||
set_level(u, SK_QUARRYING, 1);
|
||||
|
@ -171,7 +171,7 @@ static void test_cr_mallorn(CuTest *tc) {
|
|||
|
||||
setup_resources();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
r->land->horses = 1;
|
||||
r->land->peasants = 200;
|
||||
|
@ -253,7 +253,7 @@ static void test_cr_hiderace(CuTest *tc) {
|
|||
struct locale * lang;
|
||||
|
||||
test_setup();
|
||||
default_locale = test_create_locale();
|
||||
default_locale = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(default_locale, "race::elf_p", "Elfen");
|
||||
locale_setstring(default_locale, "race::elf", "elf");
|
||||
locale_setstring(default_locale, "race::human_p", "Menschen");
|
||||
|
@ -263,8 +263,8 @@ static void test_cr_hiderace(CuTest *tc) {
|
|||
locale_setstring(lang, "race::human", "human");
|
||||
locale_setstring(lang, "race::elf_p", "elves");
|
||||
locale_setstring(lang, "race::elf", "elf");
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction_ex(NULL, default_locale);
|
||||
f2 = test_create_faction_ex(NULL, default_locale);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f1, r);
|
||||
|
||||
|
@ -333,8 +333,8 @@ static void test_cr_factionstealth(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f1, r);
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ static void test_add_donation(CuTest *tc) {
|
|||
test_setup();
|
||||
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);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
add_donation(f1, f2, 100, r);
|
||||
report_donations();
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(r->individual_messages->msgs, "donation"));
|
||||
|
|
|
@ -37,7 +37,7 @@ static void test_give_control_building(CuTest * tc)
|
|||
region *r;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
b = test_create_building(r, NULL);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -58,7 +58,7 @@ static void test_give_control_ship(CuTest * tc)
|
|||
region *r;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -79,7 +79,7 @@ struct steal {
|
|||
|
||||
static void setup_steal(struct steal *env, struct terrain_type *ter, struct race *rc) {
|
||||
env->r = test_create_region(0, 0, ter);
|
||||
env->f = test_create_faction(rc);
|
||||
env->f = test_create_faction_ex(rc, NULL);
|
||||
env->u = test_create_unit(env->f, env->r);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,7 @@ static struct unit *create_recruiter(void) {
|
|||
|
||||
r=test_create_region(0, 0, NULL);
|
||||
rsetpeasants(r, 999);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
change_resource(u, rtype, 1000);
|
||||
|
@ -228,7 +228,7 @@ static unit *setup_trade_unit(CuTest *tc, region *r, const struct race *rc) {
|
|||
unit *u;
|
||||
|
||||
UNUSED_ARG(tc);
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
set_level(u, SK_TRADE, 2);
|
||||
return u;
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ static void test_trade_limits(CuTest *tc) {
|
|||
b->size = 2;
|
||||
rsetpeasants(r, TRADE_FRACTION * 20);
|
||||
it_jewel = it_find("jewel");
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
set_level(u, SK_TRADE, 1);
|
||||
i_change(&u->items, it_find("money"), 500);
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "5 %s",
|
||||
|
@ -288,7 +288,7 @@ static void test_trade_needs_castle(CuTest *tc) {
|
|||
CuAssertTrue(tc, trade_needs_castle(t_desert, rc));
|
||||
CuAssertTrue(tc, trade_needs_castle(t_plain, rc));
|
||||
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s",
|
||||
LOC(u->faction->locale, resourcename(it_luxury->rtype, 0))));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, "1 %s",
|
||||
|
@ -366,7 +366,7 @@ static void test_buy_cmd(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, rt_silver);
|
||||
CuAssertPtrNotNull(tc, rt_silver->itype);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, "1 %s", LOC(u->faction->locale, resourcename(it_luxury->rtype, 0))));
|
||||
test_set_item(u, rt_silver->itype, 1000);
|
||||
|
||||
|
@ -418,7 +418,7 @@ static void test_tax_cmd(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_production();
|
||||
config_set("taxing.perlevel", "20");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -487,7 +487,7 @@ static void test_maintain_buildings(CuTest *tc) {
|
|||
btype = test_create_buildingtype("Hort");
|
||||
btype->maxsize = 10;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
b = test_create_building(r, btype);
|
||||
itype = test_create_itemtype("money");
|
||||
|
@ -544,7 +544,7 @@ static void test_recruit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
setup_economy();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 1, u->number);
|
||||
CuAssertIntEquals(tc, 1, f->num_people);
|
||||
|
@ -571,7 +571,7 @@ static void test_recruit_insect(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_calendar();
|
||||
test_create_terrain("desert", -1);
|
||||
f = test_create_faction(test_create_race("insect"));
|
||||
f = test_create_faction_ex(test_create_race("insect"), NULL);
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_RECRUIT, f->locale, "%d", 1);
|
||||
|
||||
|
@ -600,7 +600,7 @@ static void test_income(CuTest *tc)
|
|||
unit *u;
|
||||
test_setup();
|
||||
rc = test_create_race("nerd");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 20, income(u));
|
||||
u->number = 5;
|
||||
CuAssertIntEquals(tc, 100, income(u));
|
||||
|
@ -616,7 +616,7 @@ static void test_modify_material(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_production();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_WEAPONSMITH, 1);
|
||||
|
||||
/* the unit's race gets 2x savings on iron used to produce goods */
|
||||
|
@ -665,7 +665,7 @@ static void test_modify_skill(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_production();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_WEAPONSMITH, 1);
|
||||
|
||||
itype = test_create_itemtype("iron");
|
||||
|
@ -728,7 +728,7 @@ static void test_modify_production(CuTest *tc) {
|
|||
rt_silver = get_resourcetype(R_SILVER);
|
||||
itype = test_create_itemtype("stone");
|
||||
rtype = itype->rtype;
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
make_item(u, itype, 1);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(u->faction->msgs, "error_cannotmake"));
|
||||
CuAssertIntEquals(tc, 0, get_item(u, itype));
|
||||
|
@ -825,7 +825,7 @@ static void test_loot(CuTest *tc) {
|
|||
mt_create_error(48); /* unit is unarmed */
|
||||
it_silver = test_create_silver();
|
||||
config_set("rules.enable_loot", "1");
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_LOOT, f->locale, NULL);
|
||||
produce(u->region);
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error48")); /* unit is unarmed */
|
||||
|
@ -847,7 +847,7 @@ static void test_expand_production(CuTest *tc) {
|
|||
test_setup();
|
||||
orders = calloc(1, sizeof(econ_request));
|
||||
orders->qty = 2;
|
||||
orders->unit = u = test_create_unit(test_create_faction(NULL), r = test_create_region(0, 0, NULL));
|
||||
orders->unit = u = test_create_unit(test_create_faction(), r = test_create_region(0, 0, NULL));
|
||||
orders->next = NULL;
|
||||
|
||||
u->n = 1; /* will be overwritten */
|
||||
|
|
|
@ -1577,7 +1577,7 @@ int exparse_readfile(const char * filename) {
|
|||
XML_SetUserData(xp, &pi);
|
||||
memset(&pi, 0, sizeof(pi));
|
||||
for (;;) {
|
||||
size_t len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int done;
|
||||
|
||||
if (ferror(F)) {
|
||||
|
|
|
@ -54,7 +54,6 @@ static void setup_give(struct give *env) {
|
|||
env->dst = NULL;
|
||||
}
|
||||
if (env->lang) {
|
||||
locale_setstring(env->lang, env->itype->rtype->_name, "SILBER");
|
||||
init_locale(env->lang);
|
||||
env->f1->locale = env->lang;
|
||||
}
|
||||
|
@ -90,8 +89,8 @@ static void test_give_unit(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
CuAssertIntEquals(tc, 1, env.f1->num_units);
|
||||
|
@ -120,8 +119,8 @@ static void test_give_unit_humans(CuTest * tc) {
|
|||
race *rc;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(test_create_race("elf"));
|
||||
env.f2 = test_create_faction(rc = test_create_race("human"));
|
||||
env.f1 = test_create_faction_ex(test_create_race("elf"), NULL);
|
||||
env.f2 = test_create_faction_ex(rc = test_create_race("human"), env.f1->locale);
|
||||
rc->flags |= RCF_MIGRANTS;
|
||||
setup_give(&env);
|
||||
|
||||
|
@ -139,8 +138,8 @@ static void test_give_unit_humans(CuTest * tc) {
|
|||
static void test_give_unit_other_race(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(test_create_race("elf"));
|
||||
env.f2 = test_create_faction(test_create_race("orc"));
|
||||
env.f1 = test_create_faction_ex(test_create_race("elf"), NULL);
|
||||
env.f2 = test_create_faction_ex(test_create_race("orc"), env.f1->locale);
|
||||
setup_give(&env);
|
||||
scale_number(env.dst, 57);
|
||||
CuAssertIntEquals(tc, 0, count_maxmigrants(env.f2));
|
||||
|
@ -153,8 +152,8 @@ static void test_give_unit_other_race(CuTest * tc) {
|
|||
static void test_give_unit_limits(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
config_set("rules.limit.faction", "1");
|
||||
|
||||
|
@ -170,7 +169,7 @@ static void test_give_unit_limits(CuTest * tc) {
|
|||
static void test_give_unit_to_peasants(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
rsetpeasants(env.r, 0);
|
||||
|
@ -183,7 +182,7 @@ static void test_give_unit_to_peasants(CuTest * tc) {
|
|||
static void test_give_unit_to_ocean(CuTest * tc) {
|
||||
struct give env = { 0 };
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
|
||||
|
@ -196,7 +195,7 @@ static void test_give_men(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
message * msg;
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
CuAssertPtrEquals(tc, NULL, msg = give_men(1, env.src, env.dst, NULL));
|
||||
assert(!msg);
|
||||
|
@ -212,7 +211,7 @@ static void test_give_men_magicians(CuTest * tc) {
|
|||
|
||||
test_setup_ex(tc);
|
||||
mt_create_error(158);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
set_level(env.src, SK_MAGIC, 1);
|
||||
CuAssertPtrNotNull(tc, msg = give_men(1, env.src, env.dst, NULL));
|
||||
|
@ -236,8 +235,8 @@ static void test_give_men_limit(CuTest * tc) {
|
|||
message *msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction();
|
||||
env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
config_set("rules.give.max_men", "1");
|
||||
|
||||
|
@ -267,7 +266,7 @@ static void test_give_men_in_ocean(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
|
||||
|
@ -283,7 +282,7 @@ static void test_give_men_too_many(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
CuAssertPtrEquals(tc, NULL, msg = give_men(2, env.src, env.dst, NULL));
|
||||
assert(!msg);
|
||||
|
@ -296,7 +295,7 @@ static void test_give_cmd_limit(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
unit *u;
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
u = env.src;
|
||||
scale_number(u, 2);
|
||||
|
@ -312,7 +311,7 @@ static void test_give_men_none(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
msg = give_men(0, env.src, env.dst, NULL);
|
||||
CuAssertStrEquals(tc, "error96", test_get_messagetype(msg));
|
||||
|
@ -327,8 +326,8 @@ static void test_give_men_other_faction(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
contact_unit(env.dst, env.src);
|
||||
msg = give_men(1, env.src, env.dst, NULL);
|
||||
|
@ -345,8 +344,8 @@ static void test_give_men_requires_contact(CuTest * tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
msg = give_men(1, env.src, env.dst, NULL);
|
||||
CuAssertStrEquals(tc, "feedback_no_contact", test_get_messagetype(msg));
|
||||
|
@ -368,7 +367,7 @@ static void test_give_men_not_to_self(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
message * msg;
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
msg = give_men(1, env.src, env.src, NULL);
|
||||
CuAssertStrEquals(tc, "error10", test_get_messagetype(msg));
|
||||
|
@ -382,7 +381,7 @@ static void test_give_peasants(CuTest * tc) {
|
|||
message * msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
rsetpeasants(env.r, 0);
|
||||
|
@ -398,7 +397,7 @@ static void test_give(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
i_change(&env.src->items, env.itype, 10);
|
||||
|
@ -418,7 +417,7 @@ static void test_give_cmd(CuTest * tc) {
|
|||
|
||||
test_setup_ex(tc);
|
||||
env.lang = test_create_locale();
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
i_change(&env.src->items, env.itype, 10);
|
||||
|
@ -438,7 +437,7 @@ static void test_give_herbs(CuTest * tc) {
|
|||
struct order *ord;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
i_change(&env.src->items, env.itype, 10);
|
||||
|
||||
|
@ -456,7 +455,7 @@ static void test_give_okay(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f2 = env.f1 = test_create_faction(NULL);
|
||||
env.f2 = env.f1 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
config_set("rules.give.flags", "0");
|
||||
|
@ -469,8 +468,8 @@ static void test_give_denied_by_rules(CuTest * tc) {
|
|||
struct message *msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
|
||||
config_set("rules.give.flags", "0");
|
||||
|
@ -484,8 +483,8 @@ static void test_give_dead_unit(CuTest * tc) {
|
|||
struct message *msg;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
env.dst->number = 0;
|
||||
freset(env.dst, UFL_ISNEW);
|
||||
|
@ -498,8 +497,8 @@ static void test_give_new_unit(CuTest * tc) {
|
|||
struct give env = { 0 };
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f2 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = test_create_faction();
|
||||
setup_give(&env);
|
||||
env.dst->number = 0;
|
||||
fset(env.dst, UFL_ISNEW);
|
||||
|
@ -513,7 +512,7 @@ static void test_give_invalid_target(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup_ex(tc);
|
||||
env.f1 = test_create_faction(NULL);
|
||||
env.f1 = test_create_faction();
|
||||
env.f2 = 0;
|
||||
setup_give(&env);
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ static void test_is_guarded(CuTest *tc) {
|
|||
rc = rc_get_or_create("dragon");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(rc), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
CuAssertPtrEquals(tc, NULL, is_guarded(r, u1));
|
||||
setguard(u2, true);
|
||||
CuAssertPtrEquals(tc, u2, is_guarded(r, u1));
|
||||
|
@ -46,8 +46,8 @@ static void test_guard_unskilled(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
|
||||
setguard(ug, true);
|
||||
|
@ -70,8 +70,8 @@ static void test_guard_armed(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
set_level(ug, SK_MELEE, 2);
|
||||
setguard(ug, true);
|
||||
|
@ -89,7 +89,7 @@ static void test_is_guard(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
setguard(ug, true);
|
||||
CuAssertIntEquals(tc, 0, armedmen(ug, false));
|
||||
|
@ -110,8 +110,8 @@ static void test_guard_unarmed(CuTest * tc)
|
|||
rc = test_create_race("mountainguard");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
test_teardown();
|
||||
|
@ -124,7 +124,7 @@ static void test_guard_monsters(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
ug = test_create_unit(get_monsters(), r);
|
||||
setguard(ug, true);
|
||||
CuAssertPtrEquals(tc, ug, is_guarded(r, u));
|
||||
|
@ -145,7 +145,7 @@ static void test_update_guard(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, t_plain);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
set_level(ug, SK_MELEE, 1);
|
||||
setguard(ug, true);
|
||||
|
@ -172,7 +172,7 @@ static void test_guard_on(CuTest * tc)
|
|||
itype = it_get_or_create(rt_get_or_create("sword"));
|
||||
new_weapontype(itype, 0, frac_zero, NULL, 0, 0, 0, SK_MELEE);
|
||||
r = test_create_region(0, 0, t_plain);
|
||||
ug = test_create_unit(test_create_faction(NULL), r);
|
||||
ug = test_create_unit(test_create_faction(), r);
|
||||
i_change(&ug->items, itype, 1);
|
||||
set_level(ug, SK_MELEE, 1);
|
||||
ug->thisorder = create_order(K_GUARD, ug->faction->locale, NULL);
|
||||
|
|
|
@ -19,7 +19,7 @@ static void test_manacrystal(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("manacrystal");
|
||||
change_resource(u, itype->rtype, 1);
|
||||
CuAssertIntEquals(tc, -1, use_manacrystal(u, itype, 1, NULL));
|
||||
|
@ -48,7 +48,7 @@ static void test_skillpotion(CuTest *tc) {
|
|||
int initialWeeks_Magic = 0;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
itype = test_create_itemtype("skillpotion");
|
||||
change_resource(u, itype->rtype, 2);
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
project(kernel C)
|
||||
|
||||
SET(_DBFILES db/memory.c)
|
||||
|
|
|
@ -12,16 +12,14 @@
|
|||
#include <assert.h>
|
||||
|
||||
typedef struct alliance_fixture {
|
||||
struct race * rc;
|
||||
struct faction *f1, *f2;
|
||||
} alliance_fixture;
|
||||
|
||||
static void setup_alliance(alliance_fixture *fix) {
|
||||
test_setup();
|
||||
fix->rc = test_create_race("human");
|
||||
fix->f1 = test_create_faction(fix->rc);
|
||||
fix->f2 = test_create_faction(fix->rc);
|
||||
assert(fix->rc && fix->f1 && fix->f2);
|
||||
fix->f1 = test_create_faction();
|
||||
fix->f2 = test_create_faction();
|
||||
assert(fix->f1 && fix->f2);
|
||||
}
|
||||
|
||||
static void test_alliance_make(CuTest *tc) {
|
||||
|
@ -69,8 +67,8 @@ static void test_alliance_dead_faction(CuTest *tc) {
|
|||
alliance *al;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
al = makealliance(42, "Hodor");
|
||||
setalliance(f, al);
|
||||
setalliance(f2, al);
|
||||
|
@ -92,8 +90,8 @@ static void test_alliance_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_INVITE], itoa36(u2->faction->no)));
|
||||
unit_addorder(u2, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)));
|
||||
|
@ -118,8 +116,8 @@ static void test_alliance_limits(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
|
||||
config_set("rules.limit.alliance", "1");
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
|
||||
|
@ -143,8 +141,8 @@ static void test_alliance_cmd_kick(CuTest *tc) {
|
|||
test_setup();
|
||||
al = makealliance(42, "Hodor");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
setalliance(u1->faction, al);
|
||||
setalliance(u2->faction, al);
|
||||
|
||||
|
@ -162,8 +160,8 @@ static void test_alliance_cmd_no_invite(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
unit_addorder(u1, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_NEW], itoa36(42)));
|
||||
unit_addorder(u2, create_order(K_ALLIANCE, u1->faction->locale, "%s %s", alliance_kwd[ALLIANCE_JOIN], itoa36(42)));
|
||||
CuAssertTrue(tc, is_allied(u1->faction, u1->faction));
|
||||
|
@ -184,8 +182,8 @@ static void test_alliance_cmd_leave(CuTest *tc) {
|
|||
test_setup();
|
||||
al = makealliance(42, "Hodor");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
setalliance(u1->faction, al);
|
||||
setalliance(u2->faction, al);
|
||||
|
||||
|
@ -205,8 +203,8 @@ static void test_alliance_cmd_transfer(CuTest *tc) {
|
|||
test_setup();
|
||||
al = makealliance(42, "Hodor");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
setalliance(u1->faction, al);
|
||||
setalliance(u2->faction, al);
|
||||
CuAssertPtrEquals(tc, u1->faction, alliance_get_leader(al));
|
||||
|
|
|
@ -12,7 +12,7 @@ static void test_allies_clone(CuTest * tc)
|
|||
struct faction * f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertPtrEquals(tc, NULL, allies_clone(NULL));
|
||||
|
||||
ally_set(&al, f, HELP_GUARD);
|
||||
|
@ -31,7 +31,7 @@ static void test_allies(CuTest *tc) {
|
|||
struct faction * f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
|
||||
CuAssertIntEquals(tc, 0, ally_get(al, f));
|
||||
ally_set(&al, f, 42);
|
||||
|
@ -47,8 +47,8 @@ static void test_allies_set(CuTest *tc) {
|
|||
struct allies * al = NULL;
|
||||
|
||||
test_setup();
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
|
||||
CuAssertPtrEquals(tc, NULL, al);
|
||||
ally_set(&al, f1, HELP_ALL);
|
||||
|
|
|
@ -43,7 +43,7 @@ static unit * setup_build(build_fixture *bf) {
|
|||
bf->btype = test_create_buildingtype("castle");
|
||||
bf->rc = test_create_race("human");
|
||||
bf->r = test_create_region(0, 0, NULL);
|
||||
bf->f = test_create_faction(bf->rc);
|
||||
bf->f = test_create_faction_ex(bf->rc, NULL);
|
||||
assert(bf->rc && bf->f && bf->r);
|
||||
bf->u = test_create_unit(bf->f, bf->r);
|
||||
assert(bf->u);
|
||||
|
@ -100,7 +100,7 @@ static void test_build_building_stages(CuTest *tc) {
|
|||
init_resources();
|
||||
it_stone = test_create_itemtype("stone");
|
||||
btype = setup_castle(it_stone);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->building = test_create_building(u->region, btype);
|
||||
u->building->size = 1;
|
||||
set_level(u, SK_BUILDING, 2);
|
||||
|
@ -122,7 +122,7 @@ static void test_build_building_stage_continue(CuTest *tc) {
|
|||
init_resources();
|
||||
it_stone = test_create_itemtype("stone");
|
||||
btype = setup_castle(it_stone);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
set_level(u, SK_BUILDING, 2);
|
||||
i_change(&u->items, it_stone, 4);
|
||||
build_building(u, btype, -1, INT_MAX, NULL);
|
||||
|
@ -337,7 +337,7 @@ static void test_build_destroy_road(CuTest *tc)
|
|||
r2 = test_create_region(1, 0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
u = test_create_unit(f = test_create_faction(NULL), r);
|
||||
u = test_create_unit(f = test_create_faction(), r);
|
||||
u->orders = ord = create_order(K_DESTROY, f->locale, "%s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
|
||||
|
||||
CuAssertIntEquals(tc, 0, destroy_cmd(u, ord));
|
||||
|
@ -371,7 +371,7 @@ unit *test_create_guard(region *r, faction *f, race *rc) {
|
|||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
}
|
||||
if (!f) {
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
}
|
||||
ug = test_create_unit(f, r);
|
||||
setguard(ug, true);
|
||||
|
@ -391,7 +391,7 @@ static void test_build_destroy_road_guard(CuTest *tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
ug = test_create_guard(r, 0, 0);
|
||||
u = test_create_unit(f = test_create_faction(NULL), r);
|
||||
u = test_create_unit(f = test_create_faction(), r);
|
||||
u->orders = ord = create_order(K_DESTROY, f->locale, "%s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
|
||||
|
||||
set_level(u, SK_ROAD_BUILDING, 1);
|
||||
|
@ -422,7 +422,7 @@ static void test_build_destroy_road_limit(CuTest *tc)
|
|||
test_create_region(1, 0, 0);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rsetroad(r, D_EAST, 100);
|
||||
u = test_create_unit(f = test_create_faction(NULL), r);
|
||||
u = test_create_unit(f = test_create_faction(), r);
|
||||
u->orders = ord = create_order(K_DESTROY, f->locale, "1 %s %s", LOC(f->locale, parameters[P_ROAD]), LOC(f->locale, directions[D_EAST]));
|
||||
|
||||
set_level(u, SK_ROAD_BUILDING, 1);
|
||||
|
@ -444,7 +444,7 @@ static void test_build_destroy_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
mt_create_error(138);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_DESTROY, f->locale, NULL);
|
||||
CuAssertIntEquals(tc, 138, destroy_cmd(u, u->thisorder));
|
||||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "error138"));
|
||||
|
|
|
@ -44,7 +44,7 @@ static void test_building_set_owner(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -69,7 +69,7 @@ static void test_buildingowner_goes_to_next_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -95,7 +95,7 @@ static void test_buildingowner_goes_to_other_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -122,8 +122,8 @@ static void test_buildingowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -152,7 +152,7 @@ static void test_buildingowner_goes_to_next_after_leave(CuTest * tc)
|
|||
struct faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -178,7 +178,7 @@ static void test_buildingowner_goes_to_other_after_leave(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -204,8 +204,8 @@ static void test_buildingowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -237,7 +237,7 @@ static void test_buildingowner_resets_when_empty(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -263,7 +263,7 @@ void test_buildingowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
|
||||
bld = test_create_building(r, NULL);
|
||||
|
@ -358,7 +358,7 @@ static void test_active_building(CuTest *tc) {
|
|||
btype = test_create_buildingtype("castle");
|
||||
assert(btype && btype->maxsize == -1);
|
||||
b = test_create_building(r = test_create_region(0, 0, NULL), btype);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
CuAssertIntEquals(tc, false, building_is_active(b));
|
||||
CuAssertPtrEquals(tc, NULL, active_building(u, btype));
|
||||
|
||||
|
@ -388,8 +388,8 @@ static void test_safe_building(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
btype = test_create_buildingtype("castle");
|
||||
u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u1 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
|
||||
u1->building = test_create_building(u1->region, btype);
|
||||
CuAssertIntEquals(tc, false, in_safe_building(u1, u2));
|
||||
|
@ -422,9 +422,9 @@ static void test_cmp_castle_size(CuTest *tc) {
|
|||
r = test_create_region(0, 0, NULL);
|
||||
b1 = test_create_building(r, NULL);
|
||||
b2 = test_create_building(r, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
b1->size = 5;
|
||||
b2->size = 10;
|
||||
|
@ -542,9 +542,9 @@ static void test_cmp_taxes(CuTest *tc) {
|
|||
b2 = test_create_building(r, btype);
|
||||
b1->size = 5;
|
||||
b2->size = 10;
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
CuAssertPtrEquals(tc, b2, largestbuilding(r, cmp_taxes, false));
|
||||
CuAssertTrue(tc, cmp_taxes(b1, b2) < 0);
|
||||
|
@ -574,9 +574,9 @@ static void test_cmp_current_owner(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, 1, buildingeffsize(b1, false));
|
||||
b2->size = 1;
|
||||
CuAssertIntEquals(tc, 1, buildingeffsize(b2, false));
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
region_set_owner(r, u1->faction, turn);
|
||||
CuAssertPtrEquals(tc, b1, largestbuilding(r, cmp_current_owner, false));
|
||||
|
|
|
@ -31,7 +31,7 @@ static void test_command(CuTest * tc) {
|
|||
stree_add(st, "six", parser_six);
|
||||
CuAssertPtrNotNull(tc, st->root);
|
||||
CuAssertPtrEquals(tc, st->root, stree_find(st, loc));
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_ALLIANCE, loc, "two");
|
||||
do_command(st->root, u, u->thisorder);
|
||||
CuAssertIntEquals(tc, u->number, 2);
|
||||
|
|
|
@ -29,7 +29,7 @@ static void test_read_unitid(CuTest *tc) {
|
|||
lang = test_create_locale();
|
||||
/* note that the english order is FIGHT, not COMBAT, so this is a poor example */
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, t_plain));
|
||||
usetalias(u, atoi36("42"));
|
||||
|
||||
ord = create_order(K_GIVE, lang, "TEMP 42");
|
||||
|
@ -72,7 +72,7 @@ static void test_getunit(CuTest *tc) {
|
|||
lang = test_create_locale();
|
||||
/* note that the english order is FIGHT, not COMBAT, so this is a poor example */
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, t_plain));
|
||||
/* This unit is also TEMP 42: */
|
||||
usetalias(u, atoi36("42"));
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef struct {
|
|||
static void setup_curse(curse_fixture *fix, const char *name) {
|
||||
test_setup();
|
||||
fix->r = test_create_region(0, 0, NULL);
|
||||
fix->u = test_create_unit(test_create_faction(NULL), fix->r);
|
||||
fix->u = test_create_unit(test_create_faction(), fix->r);
|
||||
fix->c = create_curse(fix->u, &fix->r->attribs, ct_find(name), 1.0, 1, 1.0, 0);
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ static void test_curse_flags(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
c1 = create_curse(u, &u->attribs, &ct_dummy, 1, 1, 1, 0);
|
||||
CuAssertPtrEquals(tc, u, c1->magician);
|
||||
CuAssertIntEquals(tc, 1, (int)c1->effect);
|
||||
|
|
|
@ -52,7 +52,7 @@ static void test_update_faction(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
db_driver_open(DB_GAME, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, 0, f->uid);
|
||||
id = 0;
|
||||
err = db_driver_faction_save(&id, f->no,
|
||||
|
|
|
@ -101,7 +101,7 @@ int db_driver_faction_save(dbrow_id * p_id, int no, const char *email, const cha
|
|||
dbrow_id id = *p_id;
|
||||
int err;
|
||||
char dbno[4];
|
||||
size_t len;
|
||||
int len;
|
||||
const char *str;
|
||||
sqlite3_stmt *stmt = (id > 0) ? g_stmt_update_faction : g_stmt_insert_faction;
|
||||
|
||||
|
@ -110,8 +110,8 @@ int db_driver_faction_save(dbrow_id * p_id, int no, const char *email, const cha
|
|||
err = sqlite3_reset(stmt);
|
||||
if (err != SQLITE_OK) return err;
|
||||
str = itoa36(no);
|
||||
len = strlen(str);
|
||||
assert(len <= 4);
|
||||
len = (int)strlen(str);
|
||||
assert(len > 0 && len <= 4);
|
||||
memcpy(dbno, str, len);
|
||||
err = sqlite3_bind_text(stmt, 1, dbno, len, SQLITE_STATIC);
|
||||
if (err != SQLITE_OK) return err;
|
||||
|
|
|
@ -29,7 +29,7 @@ static void test_equipment(CuTest * tc)
|
|||
test_setup();
|
||||
callbacks.equip_unit = equip_callback;
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, true, equip_unit_mask(u, "hodor", EQUIP_ALL));
|
||||
CuAssertIntEquals(tc, EQUIP_ALL, eq_mask);
|
||||
CuAssertPtrEquals(tc, u, eq_unit);
|
||||
|
|
|
@ -33,9 +33,9 @@ static void test_destroyfaction_allies(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
ally_set(&f1->allies, f2, HELP_FIGHT);
|
||||
CuAssertIntEquals(tc, HELP_FIGHT, alliedfaction(f1, f2, HELP_ALL));
|
||||
CuAssertPtrEquals(tc, f2, f1->next);
|
||||
|
@ -50,7 +50,7 @@ static void test_remove_empty_factions_alliance(CuTest *tc) {
|
|||
struct alliance *al;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
al = makealliance(0, "Hodor");
|
||||
setalliance(f, al);
|
||||
CuAssertPtrEquals(tc, f, alliance_get_leader(al));
|
||||
|
@ -68,7 +68,7 @@ static void test_remove_empty_factions(CuTest *tc) {
|
|||
test_setup();
|
||||
fm = get_or_create_monsters();
|
||||
assert(fm);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
remove_empty_factions();
|
||||
CuAssertIntEquals(tc, false, f->_alive);
|
||||
|
@ -87,7 +87,7 @@ static void test_remove_dead_factions(CuTest *tc) {
|
|||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
fm = get_or_create_monsters();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(fm && r && f);
|
||||
test_create_unit(f, r);
|
||||
test_create_unit(fm, r);
|
||||
|
@ -136,7 +136,7 @@ static void test_check_passwd(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setpassword(f, password_hash("password", PASSWORD_DEFAULT));
|
||||
CuAssertTrue(tc, checkpasswd(f, "password"));
|
||||
CuAssertTrue(tc, !checkpasswd(f, "assword"));
|
||||
|
@ -151,7 +151,7 @@ static void test_change_locale(CuTest *tc) {
|
|||
struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
lang = get_or_create_locale("en");
|
||||
u = test_create_unit(f, test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_ENTERTAIN, f->locale, NULL);
|
||||
|
@ -208,7 +208,7 @@ static void test_set_origin(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertPtrEquals(tc, NULL, f->origin);
|
||||
faction_setorigin(f, 0, 1, 1);
|
||||
CuAssertIntEquals(tc, 0, f->origin->id);
|
||||
|
@ -233,7 +233,7 @@ static void test_set_origin_bug(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
pl = create_new_plane(0, "", 0, 19, 0, 19, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setorigin(f, 0, -10, 3);
|
||||
faction_setorigin(f, 0, -13, -4);
|
||||
adjust_coordinates(f, &x, &y, pl);
|
||||
|
@ -250,7 +250,7 @@ static void test_max_migrants(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 0, count_maxmigrants(f));
|
||||
rc->flags |= RCF_MIGRANTS;
|
||||
|
@ -264,7 +264,7 @@ static void test_skill_limit(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, INT_MAX, faction_skill_limit(f, SK_ENTERTAINMENT));
|
||||
CuAssertIntEquals(tc, 3, faction_skill_limit(f, SK_ALCHEMY));
|
||||
config_set_int("rules.maxskills.alchemy", 4);
|
||||
|
@ -287,7 +287,7 @@ static void test_valid_race(CuTest *tc) {
|
|||
test_setup();
|
||||
rc1 = test_create_race("human");
|
||||
rc2 = test_create_race("elf");
|
||||
f = test_create_faction(rc1);
|
||||
f = test_create_faction_ex(rc1, NULL);
|
||||
CuAssertTrue(tc, valid_race(f, rc1));
|
||||
CuAssertTrue(tc, !valid_race(f, rc2));
|
||||
rc_set_param(rc1, "other_race", "elf");
|
||||
|
@ -300,7 +300,7 @@ static void test_dbstrings(CuTest *tc) {
|
|||
const char *lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
|
||||
faction *f;
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setbanner(f, lipsum);
|
||||
faction_setpassword(f, lipsum + 12);
|
||||
CuAssertStrEquals(tc, lipsum, faction_getbanner(f));
|
||||
|
@ -319,7 +319,7 @@ static void test_set_email(CuTest *tc) {
|
|||
CuAssertIntEquals(tc, -1, check_email("eressea@"));
|
||||
CuAssertIntEquals(tc, -1, check_email(""));
|
||||
CuAssertIntEquals(tc, -1, check_email(NULL));
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
|
||||
sprintf(email, "enno");
|
||||
faction_setemail(f, email);
|
||||
|
@ -345,7 +345,7 @@ static void test_save_special_items(CuTest *tc) {
|
|||
itype = test_create_itemtype("banana");
|
||||
itype->flags |= ITF_NOTLOST;
|
||||
rc = test_create_race("template");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
i_change(&u->items, itype, 1);
|
||||
|
||||
/* when there is no monster in the region, a ghost of the dead unit is created: */
|
||||
|
@ -387,7 +387,7 @@ static void test_addplayer(CuTest *tc) {
|
|||
callbacks.equip_unit = NULL;
|
||||
itype = test_create_silver();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = addplayer(r, f);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
CuAssertPtrEquals(tc, r, u->region);
|
||||
|
|
|
@ -31,11 +31,11 @@ static void test_group_readwrite_dead_faction(CuTest *tc) {
|
|||
int fno;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
CuAssertPtrEquals(tc, f, factions);
|
||||
CuAssertPtrEquals(tc, NULL, f->next);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
CuAssertPtrEquals(tc, f2, factions->next);
|
||||
u = test_create_unit(f2, test_create_region(0, 0, NULL));
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
@ -79,7 +79,7 @@ static void test_group_readwrite(CuTest * tc)
|
|||
test_setup();
|
||||
mstream_init(&data.strm);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
create_group(f, "NW", 42);
|
||||
g = create_group(f, "Egoisten", 43);
|
||||
CuAssertPtrEquals(tc, f, g->f);
|
||||
|
@ -122,7 +122,7 @@ static void test_group(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
assert(u);
|
||||
|
|
|
@ -74,7 +74,7 @@ void test_change_item(CuTest * tc)
|
|||
test_create_itemtype("iron");
|
||||
init_resources();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
test_uchange(tc, u, get_resourcetype(R_IRON));
|
||||
test_log_stderr(1);
|
||||
test_teardown();
|
||||
|
|
|
@ -29,7 +29,7 @@ void test_missing_feedback(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_ENTERTAIN, u->faction->locale, NULL);
|
||||
message_handle_missing(MESSAGE_MISSING_REPLACE);
|
||||
msg = msg_error(u, NULL, 77);
|
||||
|
@ -103,7 +103,7 @@ static void test_noerror(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
lang = test_create_locale();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = parse_order("!@move", lang);
|
||||
CuAssertIntEquals(tc, K_MOVE | CMD_QUIET | CMD_PERSIST, u->thisorder->command);
|
||||
CuAssertTrue(tc, !is_persistent(u->thisorder));
|
||||
|
|
|
@ -390,7 +390,7 @@ static void test_study_order(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "ALCH");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, skillname(SK_ALCHEMY, lang), gettoken(token, sizeof(token)));
|
||||
|
@ -419,7 +419,7 @@ static void test_study_order_unknown(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "Schiffsbau");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, "Schiffsbau", gettoken(token, sizeof(token)));
|
||||
|
@ -449,7 +449,7 @@ static void test_study_order_quoted(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "Waffenloser~Kampf");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, skillname(SK_WEAPONLESS, lang), gettoken(token, sizeof(token)));
|
||||
|
@ -478,7 +478,7 @@ static void test_study_order_unknown_tilde(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "Waffenloser~Mampf");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, "Waffenloser Mampf", gettoken(token, sizeof(token)));
|
||||
|
@ -507,7 +507,7 @@ static void test_study_order_unknown_quoted(CuTest *tc) {
|
|||
locale_setstring(lang, "keyword::study", "LERNE");
|
||||
init_keywords(lang);
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, lang, "'Waffenloser Dampf'");
|
||||
CuAssertIntEquals(tc, K_STUDY, init_order(u->thisorder, lang));
|
||||
CuAssertStrEquals(tc, "Waffenloser Dampf", gettoken(token, sizeof(token)));
|
||||
|
@ -552,7 +552,7 @@ static void test_create_order_long(CuTest *tc) {
|
|||
stream_order(&out, ord, lang, true);
|
||||
out.api->rewind(out.handle);
|
||||
out.api->readln(out.handle, buffer, sizeof(buffer));
|
||||
CuAssertIntEquals(tc, 1026, strlen(buffer));
|
||||
CuAssertIntEquals(tc, 1026, (int)strlen(buffer));
|
||||
mstream_done(&out);
|
||||
free_order(ord);
|
||||
test_teardown();
|
||||
|
|
|
@ -46,7 +46,7 @@ static void test_origin(CuTest *tc) {
|
|||
int x, y;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
x = 0;
|
||||
y = 0;
|
||||
adjust_coordinates(f, &x, &y, 0);
|
||||
|
|
|
@ -24,7 +24,7 @@ void test_reservation(CuTest *tc) {
|
|||
test_create_world();
|
||||
rtype = rt_get_or_create("money");
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f && rtype && rtype->itype);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -54,7 +54,7 @@ void test_pool_get_item(CuTest *tc) {
|
|||
rtype = rt_get_or_create("money");
|
||||
rtype->flags |= RTF_POOLED;
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
u1 = test_create_unit(f, r);
|
||||
u_setrace(u1, rc = test_create_race("undead"));
|
||||
|
@ -77,12 +77,12 @@ void test_pool(CuTest *tc) {
|
|||
rtype = rt_get_or_create("money");
|
||||
rtype->flags |= RTF_POOLED;
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
assert(r && f && rtype && rtype->itype);
|
||||
u1 = test_create_unit(f, r);
|
||||
u2 = test_create_unit(f, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
assert(u1 && u2);
|
||||
i_change(&u1->items, rtype->itype, 100);
|
||||
set_resvalue(u1, rtype->itype, 50);
|
||||
|
@ -122,7 +122,7 @@ void test_pool_bug_2042(CuTest *tc) {
|
|||
test_create_world();
|
||||
rtype = rt_get_or_create("money");
|
||||
it_get_or_create(rtype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f && rtype && rtype->itype);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -144,12 +144,12 @@ void test_pool_use(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
itype = it_get_or_create(rt_get_or_create("money"));
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f && itype);
|
||||
u1 = test_create_unit(f, r);
|
||||
u2 = test_create_unit(f, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
assert(u1 && u2);
|
||||
i_change(&u1->items, itype, 100);
|
||||
set_resvalue(u1, itype, 50);
|
||||
|
@ -193,7 +193,7 @@ void test_change_resource(CuTest * tc)
|
|||
enable_skill(SK_MAGIC, true);
|
||||
|
||||
r = findregion(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
set_level(u, SK_MAGIC, 5);
|
||||
|
|
|
@ -173,8 +173,8 @@ static void test_racename(CuTest *tc) {
|
|||
unit *u;
|
||||
struct locale * lang;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = lang = test_create_locale();
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = lang = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(lang, "race::human_p", "Menschen");
|
||||
locale_setstring(lang, "race::human", "Mensch");
|
||||
locale_setstring(lang, "prefix::dark", "Dunkel");
|
||||
|
|
|
@ -47,9 +47,9 @@ static void test_region_get_owner(CuTest *tc) {
|
|||
b2 = test_create_building(r, NULL);
|
||||
b1->size = 5;
|
||||
b2->size = 10;
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u1, b1);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u_set_building(u2, b2);
|
||||
CuAssertPtrEquals(tc, u2->faction, region_get_owner(r));
|
||||
test_teardown();
|
||||
|
|
|
@ -60,7 +60,7 @@ static void test_readwrite_unit(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
u = test_create_unit(f, r);
|
||||
unit_setname(u, " Hodor ");
|
||||
|
@ -77,7 +77,7 @@ static void test_readwrite_unit(CuTest * tc)
|
|||
|
||||
data.strm.api->rewind(data.strm.handle);
|
||||
free_gamedata();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
renumber_faction(f, fno);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
@ -101,7 +101,7 @@ static void test_readwrite_faction(CuTest * tc)
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
free(f->name);
|
||||
f->name = str_strdup(" Hodor ");
|
||||
CuAssertStrEquals(tc, " Hodor ", f->name);
|
||||
|
@ -258,11 +258,11 @@ static void test_readwrite_dead_faction_group(CuTest *tc) {
|
|||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
fno = f->no;
|
||||
CuAssertPtrEquals(tc, f, factions);
|
||||
CuAssertPtrEquals(tc, NULL, f->next);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
CuAssertPtrEquals(tc, f2, factions->next);
|
||||
u = test_create_unit(f2, test_create_region(0, 0, NULL));
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
@ -303,7 +303,7 @@ static void test_readwrite_dead_faction_regionowner(CuTest *tc) {
|
|||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
||||
config_set("rules.region_owners", "1");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
test_create_unit(f, r = test_create_region(0, 0, NULL));
|
||||
region_set_owner(r, f, 0);
|
||||
destroyfaction(&factions);
|
||||
|
@ -331,8 +331,8 @@ static void test_readwrite_dead_faction_changefaction(CuTest *tc) {
|
|||
unit * u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u = test_create_unit(f2, r = test_create_region(0, 0, NULL));
|
||||
tr = trigger_changefaction(u, f);
|
||||
add_trigger(&u->attribs, "timer", trigger_timeout(10, tr));
|
||||
|
@ -368,8 +368,8 @@ static void test_readwrite_dead_faction_createunit(CuTest *tc) {
|
|||
unit * u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u = test_create_unit(f2, r = test_create_region(0, 0, NULL));
|
||||
tr = trigger_createunit(r, f, f->race, 1);
|
||||
add_trigger(&u->attribs, "timer", trigger_timeout(10, tr));
|
||||
|
@ -402,7 +402,7 @@ static void test_read_password(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setpassword(f, password_hash("secret", PASSWORD_DEFAULT));
|
||||
mstream_init(&data.strm);
|
||||
gamedata_init(&data, &store, RELEASE_VERSION);
|
||||
|
@ -426,7 +426,7 @@ static void test_read_password_external(CuTest *tc) {
|
|||
if (remove(pwfile) != 0) {
|
||||
errno = 0;
|
||||
}
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
faction_setpassword(f, password_hash("secret", PASSWORD_DEFAULT));
|
||||
CuAssertPtrNotNull(tc, faction_getpassword(f));
|
||||
mstream_init(&data.strm);
|
||||
|
|
|
@ -39,7 +39,7 @@ static void test_ship_crewed(CuTest * tc)
|
|||
struct ship_type *stype;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_ocean(0, 0);
|
||||
stype = test_create_shiptype("longboat");
|
||||
stype->cptskill = 2;
|
||||
|
@ -89,14 +89,12 @@ static void test_ship_set_owner(CuTest * tc)
|
|||
struct unit *u1, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
stype = st_find("boat");
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -119,18 +117,14 @@ static void test_shipowner_goes_to_next_when_empty(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -154,18 +148,14 @@ static void test_shipowner_goes_to_other_when_empty(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -189,19 +179,15 @@ static void test_shipowner_goes_to_same_faction_when_empty(CuTest * tc)
|
|||
struct unit *u, *u2, *u3;
|
||||
struct faction *f1, *f2;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f2 = test_create_faction(human);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -229,18 +215,14 @@ static void test_shipowner_goes_to_next_after_leave(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -264,18 +246,14 @@ static void test_shipowner_goes_to_other_after_leave(CuTest * tc)
|
|||
struct unit *u, *u2;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -299,19 +277,15 @@ static void test_shipowner_goes_to_same_faction_after_leave(CuTest * tc)
|
|||
struct unit *u, *u2, *u3;
|
||||
struct faction *f1, *f2;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f2 = test_create_faction(human);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -341,18 +315,14 @@ static void test_shipowner_resets_when_empty(CuTest * tc)
|
|||
struct unit *u;
|
||||
struct faction *f;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f = test_create_faction(human);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -374,18 +344,14 @@ void test_shipowner_goes_to_empty_unit_after_leave(CuTest * tc)
|
|||
struct unit *u1, *u2, *u3;
|
||||
struct faction *f1;
|
||||
const struct ship_type *stype;
|
||||
const struct race *human;
|
||||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
human = rc_find("human");
|
||||
CuAssertPtrNotNull(tc, human);
|
||||
|
||||
stype = st_find("boat");
|
||||
CuAssertPtrNotNull(tc, stype);
|
||||
|
||||
f1 = test_create_faction(human);
|
||||
f1 = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
|
||||
sh = test_create_ship(r, stype);
|
||||
|
@ -450,7 +416,7 @@ static ship *setup_ship(void) {
|
|||
}
|
||||
|
||||
static void setup_crew(ship *sh, struct faction *f, unit **cap, unit **crew) {
|
||||
if (!f) f = test_create_faction(NULL);
|
||||
if (!f) f = test_create_faction();
|
||||
assert(cap);
|
||||
assert(crew);
|
||||
*cap = test_create_unit(f, sh->region);
|
||||
|
@ -470,7 +436,7 @@ static void test_shipspeed_speedy(CuTest *tc) {
|
|||
stype->range = 5;
|
||||
stype->range_max = -1;
|
||||
stype->flags |= SFL_SPEEDY;
|
||||
cap = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
cap = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
crw = test_create_unit(cap->faction, cap->region);
|
||||
sh = test_create_ship(cap->region, stype);
|
||||
cap->ship = sh;
|
||||
|
@ -603,7 +569,7 @@ static void test_maximum_shipspeed(CuTest *tc) {
|
|||
sh = setup_ship();
|
||||
rc = test_create_race("aquarian");
|
||||
rc->flags |= RCF_SHIPSPEED;
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
setup_crew(sh, f, &cap, &crew);
|
||||
CuAssertIntEquals(tc, sh->type->range + 1, shipspeed(sh, cap));
|
||||
create_curse(0, &sh->attribs, &ct_stormwind, 1, 1, 1, 0);
|
||||
|
@ -661,7 +627,7 @@ static void test_shipspeed_max_range(CuTest *tc) {
|
|||
setup_crew(sh, NULL, &cap, &crew);
|
||||
config_set("movement.shipspeed.skillbonus", "5");
|
||||
r = sh->region;
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(r && f);
|
||||
stype = st_get_or_create(sh->type->_name);
|
||||
|
||||
|
@ -692,7 +658,7 @@ static void test_crew_skill(CuTest *tc) {
|
|||
r = test_create_ocean(0, 0);
|
||||
sh = test_create_ship(r, stype);
|
||||
CuAssertIntEquals(tc, 0, crew_skill(sh));
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
set_level(u, SK_SAILING, 1);
|
||||
CuAssertIntEquals(tc, 0, crew_skill(sh));
|
||||
u_set_ship(u, sh);
|
||||
|
|
|
@ -15,7 +15,7 @@ static void test_skills(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
config_set_int("study.random_progress", 0);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, u->skills);
|
||||
CuAssertIntEquals(tc, 0, u->skill_size);
|
||||
CuAssertIntEquals(tc, 0, get_level(u, SK_CROSSBOW));
|
||||
|
|
|
@ -36,7 +36,7 @@ static void test_remove_empty_units(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
uid = u->no;
|
||||
remove_empty_units();
|
||||
CuAssertPtrNotNull(tc, findunit(uid));
|
||||
|
@ -53,7 +53,7 @@ static void test_remove_empty_units_in_region(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
u = test_create_unit(u->faction, u->region);
|
||||
CuAssertPtrNotNull(tc, u->nextF);
|
||||
uid = u->no;
|
||||
|
@ -74,7 +74,7 @@ static void test_remove_units_without_faction(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
uid = u->no;
|
||||
u_setfaction(u, 0);
|
||||
remove_empty_units_in_region(u->region);
|
||||
|
@ -90,7 +90,7 @@ static void test_remove_units_with_dead_faction(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
uid = u->no;
|
||||
u->faction->_alive = false;
|
||||
remove_empty_units_in_region(u->region);
|
||||
|
@ -106,7 +106,7 @@ static void test_scale_number(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
ptype = it_get_or_create(rt_get_or_create("hodor"));
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
change_effect(u, ptype, 1);
|
||||
u->hp = 35;
|
||||
CuAssertIntEquals(tc, 1, u->number);
|
||||
|
@ -135,7 +135,7 @@ static void test_unit_name(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
renumber_unit(u, 666);
|
||||
unit_setname(u, "Hodor");
|
||||
CuAssertStrEquals(tc, "Hodor (ii)", unitname(u));
|
||||
|
@ -146,7 +146,7 @@ static void test_unit_name_from_race(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
renumber_unit(u, 666);
|
||||
unit_setname(u, NULL);
|
||||
|
||||
|
@ -166,7 +166,7 @@ static void test_update_monster_name(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
unit_setname(u, "Hodor");
|
||||
CuAssertTrue(tc, !unit_name_equals_race(u));
|
||||
|
@ -191,7 +191,7 @@ static void test_names(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), findregion(0, 0));
|
||||
u = test_create_unit(test_create_faction(), findregion(0, 0));
|
||||
|
||||
unit_setname(u, "Hodor");
|
||||
unit_setid(u, 5);
|
||||
|
@ -207,10 +207,10 @@ static void test_default_name(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
lang = test_create_locale();
|
||||
lang = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(lang, "unitdefault", "Zweiheit");
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(NULL, lang), test_create_plain(0, 0));
|
||||
|
||||
default_name(u, buf, sizeof(buf));
|
||||
|
||||
|
@ -232,7 +232,7 @@ static void test_skillmod(CuTest *tc) {
|
|||
attrib *a;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_ARMORER, 5);
|
||||
CuAssertIntEquals(tc, 5, effskill(u, SK_ARMORER, NULL));
|
||||
|
||||
|
@ -259,7 +259,7 @@ static void test_skill_hunger(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_ARMORER, 6);
|
||||
set_level(u, SK_SAILING, 6);
|
||||
fset(u, UFL_HUNGER);
|
||||
|
@ -277,7 +277,7 @@ static void test_skill_familiar(CuTest *tc) {
|
|||
test_setup();
|
||||
|
||||
/* setup two units */
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
mag = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fam = test_create_unit(mag->faction, test_create_region(0, 0, NULL));
|
||||
set_level(fam, SK_PERCEPTION, 6);
|
||||
CuAssertIntEquals(tc, 6, effskill(fam, SK_PERCEPTION, NULL));
|
||||
|
@ -303,7 +303,7 @@ static void test_inside_building(CuTest *tc) {
|
|||
building *b;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
b = test_create_building(u->region, NULL);
|
||||
|
||||
b->size = 1;
|
||||
|
@ -327,7 +327,7 @@ static void test_skills(CuTest *tc) {
|
|||
unit *u;
|
||||
skill *sv;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
sv = add_skill(u, SK_ALCHEMY);
|
||||
CuAssertPtrNotNull(tc, sv);
|
||||
CuAssertPtrEquals(tc, sv, u->skills);
|
||||
|
@ -368,7 +368,7 @@ static void test_limited_skills(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, false, has_limited_skills(u));
|
||||
set_level(u, SK_ENTERTAINMENT, 1);
|
||||
CuAssertIntEquals(tc, false, has_limited_skills(u));
|
||||
|
@ -395,7 +395,7 @@ static void test_unit_description(CuTest *tc) {
|
|||
test_setup();
|
||||
lang = test_create_locale();
|
||||
rc = test_create_race("hodor");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
CuAssertStrEquals(tc, NULL, unit_getinfo(u));
|
||||
CuAssertStrEquals(tc, NULL, u_description(u, lang));
|
||||
|
@ -421,7 +421,7 @@ static void test_remove_unit(CuTest *tc) {
|
|||
init_resources();
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u2 = test_create_unit(f, r);
|
||||
u1 = test_create_unit(f, r);
|
||||
CuAssertPtrEquals(tc, u1, f->units);
|
||||
|
@ -465,7 +465,7 @@ static void test_renumber_unit(CuTest *tc) {
|
|||
unit *u1, *u2;
|
||||
|
||||
test_setup();
|
||||
u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u1 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(u1->faction, u1->region);
|
||||
rng_init(0);
|
||||
renumber_unit(u1, 0);
|
||||
|
@ -486,7 +486,7 @@ static void test_name_unit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("skeleton");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
rc->name_unit = gen_name;
|
||||
name_unit(u);
|
||||
CuAssertStrEquals(tc, "Hodor", unit_getname(u));
|
||||
|
@ -502,7 +502,7 @@ static void test_heal_factor(CuTest *tc) {
|
|||
test_setup();
|
||||
t_plain = test_create_terrain("plain", LAND_REGION|FOREST_REGION);
|
||||
rc = rc_get_or_create("human");
|
||||
u = test_create_unit(test_create_faction(rc), r = test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r = test_create_region(0, 0, t_plain));
|
||||
rsettrees(r, 1, r->terrain->size / TREESIZE);
|
||||
rsettrees(r, 2, 0);
|
||||
CuAssertTrue(tc, r_isforest(r));
|
||||
|
@ -524,7 +524,7 @@ static void test_unlimited_units(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, 0, f->num_units);
|
||||
CuAssertIntEquals(tc, 0, f->num_people);
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
|
@ -553,7 +553,7 @@ static void test_clone_men_bug_2386(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
scale_number(u1, 8237);
|
||||
u1->hp = 39 * u1->number;
|
||||
|
@ -572,7 +572,7 @@ static void test_clone_men(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
scale_number(u1, 10);
|
||||
u2 = test_create_unit(f, r);
|
||||
|
@ -596,7 +596,7 @@ static void test_transfermen(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
scale_number(u1, 3500);
|
||||
u2 = test_create_unit(f, r);
|
||||
|
@ -624,7 +624,7 @@ static void test_get_modifier(CuTest *tc) {
|
|||
rc->bonus[SK_ARMORER] = 1;
|
||||
rc->bonus[SK_TAXING] = 0;
|
||||
rc->bonus[SK_TRADE] = -1;
|
||||
u = test_create_unit(test_create_faction(rc), r = test_create_region(0, 0, t_plain));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r = test_create_region(0, 0, t_plain));
|
||||
|
||||
/* no effects for insects in plains: */
|
||||
CuAssertIntEquals(tc, 0, get_modifier(u, SK_TAXING, 0, r, true));
|
||||
|
@ -649,7 +649,7 @@ static void test_gift_items(CuTest *tc) {
|
|||
test_setup();
|
||||
init_resources();
|
||||
r = test_create_plain(0, 0);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
region_setresource(r, rtype, 0);
|
||||
i_change(&u->items, rtype->itype, 10);
|
||||
|
@ -661,7 +661,7 @@ static void test_gift_items(CuTest *tc) {
|
|||
region_setresource(r, rtype, 0);
|
||||
i_change(&u->items, rtype->itype, 10);
|
||||
i_change(&u->items, get_resourcetype(R_HORSE)->itype, 20);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
gift_items(u, GIFT_FRIENDS | GIFT_PEASANTS | GIFT_SELF);
|
||||
CuAssertIntEquals(tc, 20, region_getresource(r, get_resourcetype(R_HORSE)));
|
||||
|
@ -682,7 +682,7 @@ static void test_gift_items(CuTest *tc) {
|
|||
i_change(&u1->items, rtype->itype, -10);
|
||||
|
||||
set_number(u1, 2);
|
||||
u_setfaction(u2, test_create_faction(NULL));
|
||||
u_setfaction(u2, test_create_faction());
|
||||
ally_set(&u->faction->allies, u2->faction, HELP_MONEY);
|
||||
ally_set(&u2->faction->allies, u->faction, HELP_GIVE);
|
||||
region_setresource(r, rtype, 0);
|
||||
|
|
156
src/laws.test.c
156
src/laws.test.c
|
@ -62,7 +62,7 @@ static void test_rename_building(CuTest * tc)
|
|||
btype = test_create_buildingtype("castle");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
b = new_building(btype, r, default_locale, 1);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u_set_building(u, b);
|
||||
|
||||
|
@ -85,7 +85,7 @@ static void test_rename_building_twice(CuTest * tc)
|
|||
btype = test_create_buildingtype("castle");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
b = new_building(btype, r, default_locale, 1);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u_set_building(u, b);
|
||||
|
||||
|
@ -108,7 +108,7 @@ static void test_enter_building(CuTest * tc)
|
|||
test_create_locale();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
b = test_create_building(r, test_create_buildingtype("castle"));
|
||||
|
||||
rc->flags = RCF_WALK;
|
||||
|
@ -143,7 +143,7 @@ static void test_enter_ship(CuTest * tc)
|
|||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rc = test_create_race("smurf");
|
||||
u = test_create_unit(test_create_faction(rc), r);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
|
||||
rc->flags = RCF_WALK;
|
||||
|
@ -181,7 +181,7 @@ static void test_display_cmd(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, test_create_terrain("plain", LAND_REGION));
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
assert(u);
|
||||
|
@ -244,9 +244,9 @@ static void test_force_leave_buildings(CuTest *tc) {
|
|||
test_setup();
|
||||
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);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
b = test_create_building(r, NULL);
|
||||
u_set_building(u1, b);
|
||||
building_set_owner(u1);
|
||||
|
@ -273,8 +273,8 @@ static void test_force_leave_ships(CuTest *tc) {
|
|||
test_setup();
|
||||
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);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u1, sh);
|
||||
u_set_ship(u2, sh);
|
||||
|
@ -292,8 +292,8 @@ static void test_force_leave_ships_on_ocean(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_ocean(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u1, sh);
|
||||
u_set_ship(u2, sh);
|
||||
|
@ -313,7 +313,7 @@ static void test_fishing_feeds_2_people(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_ocean(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u, sh);
|
||||
|
@ -349,7 +349,7 @@ static void test_fishing_does_not_give_goblins_money(CuTest * tc)
|
|||
itype = test_create_silver();
|
||||
|
||||
r = test_create_ocean(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u, sh);
|
||||
|
@ -374,7 +374,7 @@ static void test_fishing_gets_reset(CuTest * tc)
|
|||
itype = test_create_silver();
|
||||
|
||||
r = test_create_ocean(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
sh = test_create_ship(r, NULL);
|
||||
u_set_ship(u, sh);
|
||||
|
@ -432,7 +432,7 @@ static void test_maketemp(CuTest * tc)
|
|||
unit *u, *u2;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
|
||||
u->orders = create_order(K_MAKETEMP, f->locale, "1");
|
||||
|
@ -460,7 +460,7 @@ static void test_maketemp_default_order(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
config_set("orders.default", "work");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
|
||||
new_units();
|
||||
|
@ -495,7 +495,7 @@ static void test_limit_new_units(CuTest * tc)
|
|||
mt_create_va(mt_new("too_many_units_in_alliance", NULL), "unit:unit",
|
||||
"region:region", "command:order", "allowed:int", MT_NEW_END);
|
||||
al = makealliance(1, "Hodor");
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 1, f->num_units);
|
||||
CuAssertIntEquals(tc, 1, f->num_people);
|
||||
|
@ -526,7 +526,7 @@ static void test_limit_new_units(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, test_find_messagetype(f->msgs, "too_many_units_in_alliance"));
|
||||
|
||||
config_set("rules.limit.alliance", "3");
|
||||
u = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), u->region);
|
||||
setalliance(u->faction, al);
|
||||
|
||||
CuAssertPtrEquals(tc, NULL, u->orders);
|
||||
|
@ -544,7 +544,7 @@ static void test_cannot_create_unit_above_limit(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
test_create_world();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
config_set("rules.limit.faction", "4");
|
||||
|
||||
CuAssertIntEquals(tc, 0, checkunitnumber(f, 4));
|
||||
|
@ -568,7 +568,7 @@ static void test_reserve_cmd(CuTest *tc) {
|
|||
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
assert(rtype && rtype->itype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -597,7 +597,7 @@ static void setup_pay_cmd(struct pay_fixture *fix) {
|
|||
building_type *btcastle;
|
||||
|
||||
test_create_world();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = findregion(0, 0);
|
||||
assert(r && f);
|
||||
btcastle = test_create_buildingtype("castle");
|
||||
|
@ -682,7 +682,7 @@ static void test_new_units(CuTest *tc) {
|
|||
const struct locale *loc;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -711,7 +711,7 @@ void setup_guard(guard_fixture *fix, bool armed) {
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u = test_create_unit(f, r);
|
||||
|
@ -822,7 +822,7 @@ static void test_reserve_self(CuTest *tc) {
|
|||
|
||||
rtype = get_resourcetype(R_SILVER);
|
||||
assert(rtype && rtype->itype);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r && f);
|
||||
u1 = test_create_unit(f, r);
|
||||
|
@ -914,7 +914,7 @@ static unit * setup_name_cmd(void) {
|
|||
mt_create_error(12);
|
||||
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);
|
||||
f = test_create_faction();
|
||||
return test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
}
|
||||
|
||||
|
@ -981,7 +981,7 @@ static void test_name_building(CuTest *tc) {
|
|||
u = setup_name_cmd();
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
f = u->faction;
|
||||
uo = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
uo = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u_set_building(uo, u->building);
|
||||
ux = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u_set_building(ux, u->building);
|
||||
|
@ -1029,7 +1029,7 @@ static void test_name_ship(CuTest *tc) {
|
|||
u = setup_name_cmd();
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
f = u->faction;
|
||||
uo = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
uo = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u_set_ship(uo, u->ship);
|
||||
ux = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u_set_ship(ux, u->ship);
|
||||
|
@ -1067,7 +1067,7 @@ static void test_long_order_normal(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fset(u, UFL_MOVED);
|
||||
fset(u, UFL_LONGACTION);
|
||||
unit_addorder(u, ord = create_order(K_MOVE, u->faction->locale, 0));
|
||||
|
@ -1085,7 +1085,7 @@ static void test_long_order_none(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
update_long_order(u);
|
||||
CuAssertPtrEquals(tc, NULL, u->thisorder);
|
||||
CuAssertPtrEquals(tc, NULL, u->orders);
|
||||
|
@ -1097,7 +1097,7 @@ static void test_long_order_cast(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, NULL));
|
||||
update_long_order(u);
|
||||
|
@ -1111,7 +1111,7 @@ static void test_long_order_buy_sell(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, NULL));
|
||||
|
@ -1127,7 +1127,7 @@ static void test_long_order_multi_long(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
mt_create_error(52);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_MOVE, u->faction->locale, NULL));
|
||||
unit_addorder(u, create_order(K_DESTROY, u->faction->locale, NULL));
|
||||
update_long_order(u);
|
||||
|
@ -1142,7 +1142,7 @@ static void test_long_order_multi_buy(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
mt_create_error(52);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
update_long_order(u);
|
||||
|
@ -1156,7 +1156,7 @@ static void test_long_order_multi_sell(CuTest *tc) {
|
|||
/* TODO: write more tests */
|
||||
unit *u;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_SELL, u->faction->locale, 0));
|
||||
|
@ -1172,7 +1172,7 @@ static void test_long_order_buy_cast(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
mt_create_error(52);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
unit_addorder(u, create_order(K_BUY, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_CAST, u->faction->locale, 0));
|
||||
update_long_order(u);
|
||||
|
@ -1186,7 +1186,7 @@ static void test_long_order_hungry(CuTest *tc) {
|
|||
unit *u;
|
||||
test_setup();
|
||||
config_set("hunger.long", "1");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fset(u, UFL_HUNGER);
|
||||
unit_addorder(u, create_order(K_MOVE, u->faction->locale, 0));
|
||||
unit_addorder(u, create_order(K_DESTROY, u->faction->locale, 0));
|
||||
|
@ -1205,7 +1205,7 @@ static void test_ally_cmd_errors(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
mt_create_error(66);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
fid = u->faction->no + 1;
|
||||
CuAssertPtrEquals(tc, NULL, findfaction(fid));
|
||||
|
||||
|
@ -1225,7 +1225,7 @@ static void test_banner_cmd(CuTest *tc) {
|
|||
test_setup();
|
||||
mt_create_error(125);
|
||||
mt_create_va(mt_new("changebanner", NULL), "value:string", MT_NEW_END);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
|
||||
ord = create_order(K_BANNER, f->locale, "Hodor!");
|
||||
banner_cmd(u, ord);
|
||||
|
@ -1253,7 +1253,7 @@ static void test_email_cmd(CuTest *tc) {
|
|||
mt_create_error(85);
|
||||
mt_create_va(mt_new("changemail", NULL), "value:string", MT_NEW_END);
|
||||
mt_create_va(mt_new("changemail_invalid", NULL), "value:string", MT_NEW_END);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
|
||||
ord = create_order(K_EMAIL, f->locale, "hodor@example.com");
|
||||
email_cmd(u, ord);
|
||||
|
@ -1286,7 +1286,7 @@ static void test_name_cmd(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
setalliance(f, al = makealliance(42, ""));
|
||||
|
||||
ord = create_order(K_NAME, f->locale, "%s ' Ho\tdor '", LOC(f->locale, parameters[P_UNIT]));
|
||||
|
@ -1331,7 +1331,7 @@ static void test_name_foreign_cmd(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(f = test_create_faction(NULL), r = test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), r = test_create_region(0, 0, NULL));
|
||||
b = test_create_building(u->region, NULL);
|
||||
u->thisorder = create_order(K_NAME, f->locale, "%s %s %s Hodor",
|
||||
LOC(f->locale, parameters[P_FOREIGN]),
|
||||
|
@ -1349,8 +1349,8 @@ static void test_name_cmd_2274(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
u3 = test_create_unit(u2->faction, r);
|
||||
u_set_building(u1, test_create_building(r, NULL));
|
||||
u1->building->size = 10;
|
||||
|
@ -1379,8 +1379,8 @@ static void test_ally_cmd(CuTest *tc) {
|
|||
order *ord;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction(NULL);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
f = test_create_faction();
|
||||
|
||||
ord = create_order(K_ALLY, f->locale, "%s", itoa36(f->no));
|
||||
ally_cmd(u, ord);
|
||||
|
@ -1416,8 +1416,8 @@ static void test_nmr_warnings(CuTest *tc) {
|
|||
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);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
f2->age = 2;
|
||||
f2->lastorders = 1;
|
||||
turn = 3;
|
||||
|
@ -1441,7 +1441,7 @@ static unit * setup_mail_cmd(void) {
|
|||
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);
|
||||
f = test_create_faction();
|
||||
return test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
}
|
||||
|
||||
|
@ -1566,7 +1566,7 @@ static void test_show_without_item(CuTest *tc)
|
|||
init_parameters(loc);
|
||||
|
||||
r = test_create_region(0, 0, test_create_terrain("testregion", LAND_REGION));
|
||||
f = test_create_faction(test_create_race("human"));
|
||||
f = test_create_faction_ex(test_create_race("human"), NULL);
|
||||
u = test_create_unit(f, r);
|
||||
|
||||
itype = it_get_or_create(rt_get_or_create("testitem"));
|
||||
|
@ -1636,7 +1636,7 @@ static void test_show_race(CuTest *tc) {
|
|||
rc = test_create_race("elf");
|
||||
|
||||
loc = setup_locale();
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = loc;
|
||||
|
||||
ord = create_order(K_RESHOW, loc, "Mensch");
|
||||
|
@ -1676,7 +1676,7 @@ static void test_show_both(CuTest *tc) {
|
|||
CuAssertPtrNotNull(tc, finditemtype("elf", loc));
|
||||
CuAssertPtrNotNull(tc, findrace("elf", loc));
|
||||
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = loc;
|
||||
i_change(&u->items, finditemtype("elfenpferd", loc), 1);
|
||||
ord = create_order(K_RESHOW, loc, "Elf");
|
||||
|
@ -1735,7 +1735,7 @@ static void test_demon_hunger(CuTest * tc)
|
|||
init_resources();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
rc = test_create_race("demon");
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, NULL);
|
||||
u = test_create_unit(f, r);
|
||||
u->hp = 999;
|
||||
|
||||
|
@ -1767,7 +1767,7 @@ static void test_armedmen(CuTest *tc) {
|
|||
item_type *it_sword;
|
||||
weapon_type *wtype;
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
it_sword = test_create_itemtype("sword");
|
||||
wtype = new_weapontype(it_sword, 0, frac_make(1, 2), 0, 0, 0, 0, SK_MELEE);
|
||||
CuAssertIntEquals(tc, 0, armedmen(u, false));
|
||||
|
@ -1796,8 +1796,8 @@ static void test_cansee(CuTest *tc) {
|
|||
unit *u, *u2;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
|
||||
CuAssertTrue(tc, cansee(u->faction, u->region, u2, 0));
|
||||
|
||||
|
@ -1815,8 +1815,8 @@ static void test_cansee_ring(CuTest *tc) {
|
|||
item_type *itype[2];
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
scale_number(u2, 2);
|
||||
|
||||
itype[0] = test_create_itemtype("roi");
|
||||
|
@ -1848,8 +1848,8 @@ static void test_cansee_sphere(CuTest *tc) {
|
|||
item_type *itype[2];
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
|
||||
itype[0] = test_create_itemtype("sphereofinv");
|
||||
itype[1] = test_create_itemtype("aots");
|
||||
|
@ -1894,7 +1894,7 @@ static void test_long_orders(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertTrue(tc, long_order_allowed(u));
|
||||
u->flags |= UFL_LONGACTION;
|
||||
CuAssertTrue(tc, !long_order_allowed(u));
|
||||
|
@ -1907,13 +1907,13 @@ static void test_long_order_on_ocean(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("pikachu");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_ocean(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_ocean(0, 0));
|
||||
CuAssertTrue(tc, !long_order_allowed(u));
|
||||
rc->flags |= RCF_SWIM;
|
||||
CuAssertTrue(tc, long_order_allowed(u));
|
||||
|
||||
rc = test_create_race("aquarian");
|
||||
u = test_create_unit(test_create_faction(rc), u->region);
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), u->region);
|
||||
CuAssertTrue(tc, long_order_allowed(u));
|
||||
test_teardown();
|
||||
}
|
||||
|
@ -1932,7 +1932,7 @@ static void test_password_cmd(CuTest *tc) {
|
|||
mt_create_error(283);
|
||||
mt_create_error(321);
|
||||
mt_create_va(mt_new("changepasswd", NULL), "value:string", MT_NEW_END);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_PASSWORD, f->locale, "password1234", NULL);
|
||||
password_cmd(u, u->thisorder);
|
||||
CuAssertTrue(tc, checkpasswd(f, "password1234"));
|
||||
|
@ -2026,7 +2026,7 @@ static void test_quit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u->thisorder = create_order(K_QUIT, f->locale, "password");
|
||||
|
||||
|
@ -2052,10 +2052,10 @@ static void test_quit_transfer(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2079,10 +2079,10 @@ static void test_quit_transfer_limited(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2117,10 +2117,10 @@ static void test_quit_transfer_mages(CuTest *tc) {
|
|||
test_setup();
|
||||
config_set_int("rules.maxskills.magic", 2);
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2153,10 +2153,10 @@ static void test_quit_transfer_different_mages(CuTest *tc) {
|
|||
test_setup();
|
||||
config_set_int("rules.maxskills.magic", 2);
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2188,10 +2188,10 @@ static void test_quit_transfer_migrants(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2216,10 +2216,10 @@ static void test_quit_transfer_hero(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
faction_setpassword(f1, "password");
|
||||
u1 = test_create_unit(f1, r);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
contact_unit(u2, u1);
|
||||
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||
|
@ -2242,8 +2242,8 @@ static void test_transfer_faction(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
u2 = test_create_unit(f1, r);
|
||||
u_setrace(u2, test_create_race("smurf"));
|
||||
|
|
|
@ -23,8 +23,8 @@ static void test_lighthouse_range(CuTest * tc)
|
|||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
test_create_region(1, 0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
b = test_create_building(r, test_create_buildingtype("lighthouse"));
|
||||
CuAssertIntEquals(tc, 0, lighthouse_range(b));
|
||||
b->size = 9;
|
||||
|
|
|
@ -37,7 +37,7 @@ void test_updatespells(CuTest * tc)
|
|||
test_setup();
|
||||
test_create_race("human");
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
sp = create_spell("testspell");
|
||||
CuAssertPtrNotNull(tc, sp);
|
||||
|
||||
|
@ -109,7 +109,7 @@ void test_pay_spell(CuTest * tc)
|
|||
test_setup();
|
||||
init_resources();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
||||
|
@ -143,7 +143,7 @@ void test_pay_spell_failure(CuTest * tc)
|
|||
test_setup();
|
||||
init_resources();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
|
||||
|
@ -180,7 +180,7 @@ void test_getspell_unit(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
create_mage(u, M_GWYRRD);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -208,7 +208,7 @@ void test_getspell_faction(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
create_mage(u, f->magiegebiet);
|
||||
|
@ -239,7 +239,7 @@ void test_getspell_school(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
create_mage(u, f->magiegebiet);
|
||||
|
@ -269,7 +269,7 @@ void test_set_pre_combatspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -301,7 +301,7 @@ void test_set_main_combatspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -333,7 +333,7 @@ void test_set_post_combatspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -364,7 +364,7 @@ void test_hasspell(CuTest * tc)
|
|||
|
||||
test_setup();
|
||||
r = test_create_plain(0, 0);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_TYBIED;
|
||||
u = test_create_unit(f, r);
|
||||
enable_skill(SK_MAGIC, true);
|
||||
|
@ -405,7 +405,7 @@ void test_multi_cast(CuTest *tc) {
|
|||
locale_setstring(lang, mkname_spell(sp), "Feuerball");
|
||||
CuAssertStrEquals(tc, "Feuerball", spell_name(mkname_spell(sp), lang));
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
set_level(u, SK_MAGIC, 10);
|
||||
unit_add_spell(u, sp, 1);
|
||||
CuAssertPtrEquals(tc, sp, unit_getspell(u, "Feuerball", lang));
|
||||
|
@ -426,7 +426,7 @@ static void test_magic_resistance(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_plain(0, 0));
|
||||
CuAssertTrue(tc, frac_equal(rc->magres, magic_resistance(u)));
|
||||
rc->magres = frac_one;
|
||||
CuAssert(tc, "magic resistance is capped at 0.9", frac_equal(magic_resistance(u), frac_make(9, 10)));
|
||||
|
@ -446,7 +446,7 @@ static void test_max_spellpoints(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_plain(0, 0));
|
||||
CuAssertIntEquals(tc, 0, max_spellpoints(u, u->region));
|
||||
CuAssertIntEquals(tc, 0, max_spellpoints(u, NULL));
|
||||
create_mage(u, M_GWYRRD);
|
||||
|
@ -472,7 +472,7 @@ static void test_regenerate_aura(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
create_mage(u, M_GWYRRD);
|
||||
CuAssertIntEquals(tc, 0, get_spellpoints(u));
|
||||
CuAssertIntEquals(tc, 1, max_spellpoints(u, NULL));
|
||||
|
@ -503,7 +503,7 @@ static void test_regenerate_aura_migrants(CuTest *tc) {
|
|||
rc->maxaura = 100;
|
||||
rc->flags |= RCF_FAMILIAR;
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
CuAssertIntEquals(tc, 0, get_spellpoints(u));
|
||||
regenerate_aura();
|
||||
|
@ -521,7 +521,7 @@ static void test_fix_fam_migrants(CuTest *tc) {
|
|||
rc->flags |= RCF_FAMILIAR;
|
||||
|
||||
/* u is a migrant with at_mage attribute, but not a familiar */
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
create_mage(u, M_GRAY);
|
||||
CuAssertTrue(tc, !is_familiar(u));
|
||||
|
@ -531,8 +531,8 @@ static void test_fix_fam_migrants(CuTest *tc) {
|
|||
CuAssertPtrEquals(tc, NULL, get_mage(u));
|
||||
|
||||
/* u is a familiar, and stays unchanged: */
|
||||
mage = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mage = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
/* reproduce the bug, create a broken familiar: */
|
||||
create_newfamiliar(mage, u);
|
||||
|
@ -564,8 +564,8 @@ static void test_fix_fam_spells(CuTest *tc) {
|
|||
rc->flags |= RCF_FAMILIAR;
|
||||
|
||||
/* u is a familiar, and gets equipped: */
|
||||
mage = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mage = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
/* reproduce the bug, create a broken familiar: */
|
||||
callbacks.equip_unit = NULL;
|
||||
|
@ -581,7 +581,7 @@ static void test_fix_fam_spells(CuTest *tc) {
|
|||
CuAssertTrue(tc, u_hasspell(u, sp));
|
||||
|
||||
/* u is a migrant, and does not get equipped: */
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u_setrace(u, rc);
|
||||
CuAssertTrue(tc, !is_familiar(u));
|
||||
fix_fam_spells(u);
|
||||
|
@ -617,7 +617,7 @@ static void test_is_mage(CuTest *tc) {
|
|||
struct sc_mage *mage;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, get_mage(u));
|
||||
CuAssertTrue(tc, !is_mage(u));
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
|
@ -634,7 +634,7 @@ static void test_get_mage(CuTest *tc) {
|
|||
struct sc_mage *mage;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, get_mage(u));
|
||||
CuAssertPtrNotNull(tc, mage = create_mage(u, M_CERDDOR));
|
||||
CuAssertPtrEquals(tc, mage, get_mage(u));
|
||||
|
@ -646,7 +646,7 @@ static void test_familiar_set(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mag = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
fam = test_create_unit(mag->faction, test_create_plain(0, 0));
|
||||
CuAssertPtrEquals(tc, NULL, get_familiar(mag));
|
||||
CuAssertPtrEquals(tc, NULL, get_familiar_mage(fam));
|
||||
|
@ -666,7 +666,7 @@ static void test_familiar_age(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mag = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
fam = test_create_unit(mag->faction, test_create_plain(0, 0));
|
||||
set_familiar(mag, fam);
|
||||
CuAssertPtrEquals(tc, fam, get_familiar(mag));
|
||||
|
@ -697,7 +697,7 @@ static void test_familiar_equip(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
callbacks.equip_unit = equip_callback;
|
||||
mag = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
mag = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u = test_create_unit(mag->faction, test_create_plain(0, 0));
|
||||
CuAssertStrEquals(tc, "human", u->_race->_name);
|
||||
set_familiar(mag, u);
|
||||
|
|
|
@ -68,7 +68,7 @@ static void test_market_curse(CuTest * tc)
|
|||
b->flags |= BLD_MAINTAINED;
|
||||
b->size = b->type->maxsize;
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u_set_building(u, b);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ static void create_monsters(unit **up, unit **um) {
|
|||
"dragon:unit", "number:int", "target:region", "growl:string", MT_NEW_END);
|
||||
test_create_horse();
|
||||
default_locale = test_create_locale();
|
||||
fp = test_create_faction(NULL);
|
||||
fp = test_create_faction();
|
||||
|
||||
fm = get_or_create_monsters();
|
||||
fset(fm, FFL_NOIDLEOUT);
|
||||
|
@ -273,7 +273,7 @@ static void test_spawn_seaserpent(CuTest *tc) {
|
|||
rc = test_create_race("seaserpent");
|
||||
rc->flags &= ~RCF_PLAYABLE;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = spawn_seaserpent(r, f);
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
CuAssertPtrEquals(tc, NULL, u->_name);
|
||||
|
@ -287,7 +287,7 @@ static void test_monsters_hate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
tu = test_create_unit(test_create_faction(NULL), test_create_plain(1, 0));
|
||||
tu = test_create_unit(test_create_faction(), test_create_plain(1, 0));
|
||||
mu = test_create_unit(get_monsters(), test_create_plain(0, 0));
|
||||
lang = mu->faction->locale;
|
||||
a_add(&mu->attribs, make_hate(tu));
|
||||
|
|
|
@ -86,7 +86,7 @@ static void setup_harbor(move_fixture *mf) {
|
|||
b = test_create_building(r, btype);
|
||||
b->flags |= BLD_MAINTAINED;
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u->ship = sh;
|
||||
ship_set_owner(u);
|
||||
|
||||
|
@ -114,7 +114,7 @@ static void test_ship_blocked_by_harbormaster(CuTest * tc) {
|
|||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), mf.r);
|
||||
u = test_create_unit(test_create_faction(), mf.r);
|
||||
u->building = mf.b;
|
||||
building_set_owner(u);
|
||||
|
||||
|
@ -129,7 +129,7 @@ static void test_ship_has_harbormaster_contact(CuTest * tc) {
|
|||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), mf.r);
|
||||
u = test_create_unit(test_create_faction(), mf.r);
|
||||
u->building = mf.b;
|
||||
building_set_owner(u);
|
||||
contact_unit(mf.b->_owner, mf.sh->_owner);
|
||||
|
@ -160,7 +160,7 @@ static void test_ship_has_harbormaster_ally(CuTest * tc) {
|
|||
test_setup();
|
||||
setup_harbor(&mf);
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), mf.r);
|
||||
u = test_create_unit(test_create_faction(), mf.r);
|
||||
u->building = mf.b;
|
||||
building_set_owner(u);
|
||||
ally_set(&u->faction->allies, mf.u->faction, HELP_GUARD);
|
||||
|
@ -177,7 +177,7 @@ static void test_walkingcapacity(CuTest *tc) {
|
|||
test_setup();
|
||||
init_resources();
|
||||
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
cap = u->number * (u->_race->capacity + u->_race->weight);
|
||||
CuAssertIntEquals(tc, cap, walkingcapacity(u));
|
||||
scale_number(u, 2);
|
||||
|
@ -282,7 +282,7 @@ void setup_drift (struct drift_fixture *fix) {
|
|||
fix->st_boat->cabins = 20000;
|
||||
|
||||
test_create_ocean(0, 0);
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(NULL), fix->r = test_create_ocean(-1, 0));
|
||||
fix->u = test_create_unit(fix->f = test_create_faction(), fix->r = test_create_ocean(-1, 0));
|
||||
assert(fix->r && fix->u && fix->f);
|
||||
set_level(fix->u, SK_SAILING, fix->st_boat->sumskill);
|
||||
u_set_ship(fix->u, fix->sh = test_create_ship(fix->u->region, fix->st_boat));
|
||||
|
@ -455,10 +455,10 @@ static void test_follow_unit(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_plain(0, 0));
|
||||
r = test_create_plain(1, 0);
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
ord = create_order(K_MOVE, f->locale, shortdirections[D_EAST] + 4);
|
||||
unit_addorder(u2, ord);
|
||||
u2->thisorder = copy_order(ord);
|
||||
|
@ -492,7 +492,7 @@ static void test_follow_unit_self(CuTest *tc) {
|
|||
mt_create_va(mt_new("followfail", NULL),
|
||||
"unit:unit", "follower:unit", MT_NEW_END);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, test_create_plain(0, 0));
|
||||
ord = create_order(K_FOLLOW, f->locale, "EINHEIT %s", itoa36(u->no));
|
||||
unit_addorder(u, ord);
|
||||
|
@ -523,7 +523,7 @@ static void test_follow_ship_msg(CuTest * tc) {
|
|||
test_setup();
|
||||
init_resources();
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_plain(0, 0);
|
||||
test_create_ocean(-1, 1); /* D_NORTHWEST */
|
||||
|
||||
|
@ -619,7 +619,7 @@ static void test_movement_speed(CuTest *tc) {
|
|||
test_setup();
|
||||
it_horse = test_create_horse();
|
||||
rc = test_create_race(NULL);
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
rc->speed = 1.0;
|
||||
CuAssertIntEquals(tc, BP_WALKING, movement_speed(u));
|
||||
|
@ -646,7 +646,7 @@ static void test_route_cycle(CuTest *tc) {
|
|||
r = test_create_region(2, 0, NULL);
|
||||
lang = test_create_locale();
|
||||
CuAssertPtrNotNull(tc, LOC(lang, shortdirections[D_WEST]));
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u->faction->locale = lang;
|
||||
CuAssertIntEquals(tc, RCF_WALK, u->_race->flags & RCF_WALK);
|
||||
u->orders = create_order(K_ROUTE, u->faction->locale, "WEST EAST NW");
|
||||
|
@ -694,7 +694,7 @@ static void test_route_pause(CuTest *tc) {
|
|||
r = test_create_region(2, 0, NULL);
|
||||
lang = test_create_locale();
|
||||
CuAssertPtrNotNull(tc, LOC(lang, shortdirections[D_WEST]));
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u->faction->locale = lang;
|
||||
CuAssertIntEquals(tc, RCF_WALK, u->_race->flags & RCF_WALK);
|
||||
u->orders = create_order(K_ROUTE, u->faction->locale, "PAUSE EAST NW");
|
||||
|
@ -713,7 +713,7 @@ static void test_movement_speed_dragon(CuTest *tc) {
|
|||
rc = test_create_race("dragon");
|
||||
rc->flags |= RCF_DRAGON;
|
||||
rc->speed = 1.5;
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 6, movement_speed(u));
|
||||
test_teardown();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ static void test_names(CuTest * tc)
|
|||
CuAssertPtrNotNull(tc, get_function("name_dracoid"));
|
||||
default_locale = test_create_locale();
|
||||
rc = test_create_race("undead");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, default_locale), test_create_region(0, 0, NULL));
|
||||
locale_setstring(default_locale, "undead_name_0", "Graue");
|
||||
locale_setstring(default_locale, "undead_postfix_0", "Kobolde");
|
||||
CuAssertPtrNotNull(tc, rc->name_unit);
|
||||
|
@ -44,11 +44,11 @@ static void test_monster_names(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
register_names();
|
||||
default_locale = test_create_locale();
|
||||
default_locale = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(default_locale, "race::irongolem", "Eisengolem");
|
||||
locale_setstring(default_locale, "race::irongolem_p", "Eisengolems");
|
||||
rc = test_create_race("irongolem");
|
||||
f = test_create_faction(rc);
|
||||
f = test_create_faction_ex(rc, default_locale);
|
||||
f->flags |= FFL_NPC;
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
unit_setname(u, "Hodor");
|
||||
|
|
|
@ -159,7 +159,7 @@ int parseorders(FILE *F)
|
|||
OP_SetUserData(parser, &state);
|
||||
|
||||
while (!done) {
|
||||
size_t len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
int len = (int)fread(buf, 1, sizeof(buf), F);
|
||||
if (ferror(F)) {
|
||||
/* TODO: error message */
|
||||
err = errno;
|
||||
|
|
|
@ -27,7 +27,7 @@ static void test_unit_orders(CuTest *tc) {
|
|||
FILE *F = tmpfile();
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_plain(0, 0));
|
||||
f->locale = test_create_locale();
|
||||
u->orders = create_order(K_ENTERTAIN, f->locale, NULL);
|
||||
faction_setpassword(f, password_hash("password", PASSWORD_DEFAULT));
|
||||
|
@ -53,7 +53,7 @@ static void test_faction_password_okay(CuTest *tc) {
|
|||
FILE *F;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
renumber_faction(f, 1);
|
||||
CuAssertIntEquals(tc, 1, f->no);
|
||||
faction_setpassword(f, "password");
|
||||
|
@ -74,7 +74,7 @@ static void test_faction_password_bad(CuTest *tc) {
|
|||
test_setup();
|
||||
mt_create_va(mt_new("wrongpasswd", NULL), "password:string", MT_NEW_END);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
renumber_faction(f, 1);
|
||||
CuAssertIntEquals(tc, 1, f->no);
|
||||
faction_setpassword(f, "patzword");
|
||||
|
|
|
@ -56,7 +56,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
|
|||
setup_piracy();
|
||||
vterrain = get_or_create_terrain("terrain1");
|
||||
fset(vterrain, v_r_flags);
|
||||
*victim = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, vterrain));
|
||||
*victim = test_create_unit(test_create_faction(), test_create_region(1, 0, vterrain));
|
||||
assert(*victim);
|
||||
|
||||
if (v_shiptype) {
|
||||
|
@ -68,7 +68,7 @@ static void setup_pirate(unit **pirate, int p_r_flags, int p_rc_flags, const cha
|
|||
st_boat->coasts[1] = 0;
|
||||
}
|
||||
|
||||
*pirate = create_unit(test_create_region(0, 0, get_or_create_terrain("terrain2")), f = test_create_faction(NULL), 1, rc = rc_get_or_create("pirate"), 0, 0, 0);
|
||||
*pirate = create_unit(test_create_region(0, 0, get_or_create_terrain("terrain2")), f = test_create_faction(), 1, rc = rc_get_or_create("pirate"), 0, 0, 0);
|
||||
fset(rc, p_rc_flags);
|
||||
assert(f && *pirate);
|
||||
|
||||
|
@ -97,10 +97,10 @@ static void test_piracy_cmd(CuTest * tc) {
|
|||
|
||||
t_ocean = get_or_create_terrain("ocean");
|
||||
st_boat = st_get_or_create("boat");
|
||||
u2 = test_create_unit(test_create_faction(NULL), test_create_region(1, 0, t_ocean));
|
||||
u2 = test_create_unit(test_create_faction(), test_create_region(1, 0, t_ocean));
|
||||
assert(u2);
|
||||
u_set_ship(u2, test_create_ship(u2->region, st_boat));
|
||||
u = test_create_unit(f = test_create_faction(NULL), r = test_create_region(0, 0, t_ocean));
|
||||
u = test_create_unit(f = test_create_faction(), r = test_create_region(0, 0, t_ocean));
|
||||
assert(f && u);
|
||||
set_level(u, SK_SAILING, st_boat->sumskill);
|
||||
u_set_ship(u, test_create_ship(u->region, st_boat));
|
||||
|
@ -130,8 +130,7 @@ static void test_piracy_cmd_errors(CuTest * tc) {
|
|||
|
||||
st_boat = st_get_or_create("boat");
|
||||
r = test_create_race("pirates");
|
||||
u = test_create_unit(f = test_create_faction(r), test_create_region(0, 0, get_or_create_terrain("ocean")));
|
||||
f->locale = test_create_locale();
|
||||
u = test_create_unit(f = test_create_faction_ex(r, NULL), test_create_region(0, 0, get_or_create_terrain("ocean")));
|
||||
u->thisorder = create_order(K_PIRACY, f->locale, "");
|
||||
assert(u && u->thisorder);
|
||||
|
||||
|
@ -199,14 +198,14 @@ static void test_piracy_cmd_land_to_land(CuTest * tc) {
|
|||
|
||||
/* create a target: */
|
||||
r = test_create_region(0, 0, t_plain);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u->ship = test_create_ship(r, stype);
|
||||
target = f->no;
|
||||
|
||||
/* create a pirate: */
|
||||
r = test_create_region(1, 0, t_plain);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
u->ship = test_create_ship(r, stype);
|
||||
set_level(u, SK_SAILING, u->ship->type->sumskill);
|
||||
|
|
|
@ -28,7 +28,7 @@ static void test_renumber_faction(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->faction->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
lang = u->faction->locale;
|
||||
|
@ -47,8 +47,8 @@ static void test_renumber_faction_duplicate(CuTest *tc) {
|
|||
|
||||
setup_renumber(tc);
|
||||
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));
|
||||
f2 = test_create_faction();
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = f->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s %s", LOC(lang, parameters[P_FACTION]), itoa36(f2->no));
|
||||
|
@ -66,7 +66,7 @@ static void test_renumber_faction_invalid(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(0), test_create_region(0, 0, 0));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, 0));
|
||||
no = f->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s [halima]", LOC(lang, parameters[P_FACTION]));
|
||||
|
@ -96,7 +96,7 @@ static void test_renumber_building(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
no = u->building->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
|
@ -119,7 +119,7 @@ static void test_renumber_building_duplicate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
uno = u->building->no;
|
||||
u->building = test_create_building(u->region, NULL);
|
||||
|
@ -138,7 +138,7 @@ static void test_renumber_ship(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
no = u->ship->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
|
@ -155,7 +155,7 @@ static void test_renumber_ship_twice(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
no = u->ship->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
|
@ -177,7 +177,7 @@ static void test_renumber_ship_duplicate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
uno = u->ship->no;
|
||||
u->ship = test_create_ship(u->region, NULL);
|
||||
|
@ -196,7 +196,7 @@ static void test_renumber_unit(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
uno = (no > 1) ? no - 1 : no + 1;
|
||||
lang = u->faction->locale;
|
||||
|
@ -214,7 +214,7 @@ static void test_renumber_unit_duplicate(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
u2 = test_create_unit(f, u->region);
|
||||
lang = f->locale;
|
||||
|
@ -233,7 +233,7 @@ static void test_renumber_unit_limit(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s 10000", LOC(lang, parameters[P_UNIT]));
|
||||
|
@ -251,7 +251,7 @@ static void test_renumber_unit_invalid(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
setup_renumber(tc);
|
||||
u = test_create_unit(f = test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(f = test_create_faction(), test_create_region(0, 0, NULL));
|
||||
no = u->no;
|
||||
lang = f->locale;
|
||||
u->thisorder = create_order(K_NUMBER, lang, "%s TEMP", LOC(lang, parameters[P_UNIT]));
|
||||
|
|
|
@ -106,8 +106,7 @@ static void test_report_region(CuTest *tc) {
|
|||
rsettrees(r, 0, 1);
|
||||
rsettrees(r, 1, 2);
|
||||
rsettrees(r, 2, 3);
|
||||
f = test_create_faction(NULL);
|
||||
f->locale = lang;
|
||||
f = test_create_faction_ex(NULL, lang);
|
||||
u = test_create_unit(f, r);
|
||||
set_level(u, SK_QUARRYING, 1);
|
||||
|
||||
|
@ -187,11 +186,10 @@ static void test_report_allies(CuTest *tc) {
|
|||
lang = test_create_locale();
|
||||
locale_setstring(lang, "list_and", " und ");
|
||||
mstream_init(&out);
|
||||
f = test_create_faction(NULL);
|
||||
f->locale = lang;
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f3 = test_create_faction(NULL);
|
||||
f = test_create_faction_ex(NULL, lang);
|
||||
f1 = test_create_faction_ex(NULL, lang);
|
||||
f2 = test_create_faction_ex(NULL, lang);
|
||||
f3 = test_create_faction_ex(NULL, lang);
|
||||
snprintf(exp, sizeof(exp), "Wir helfen %s (%s).\n\n",
|
||||
factionname(f1),
|
||||
LOC(lang, parameters[P_GUARD]));
|
||||
|
@ -242,7 +240,7 @@ static void test_report_travelthru(CuTest *tc) {
|
|||
mstream_init(&out);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
r->flags |= RF_TRAVELUNIT;
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->locale = lang;
|
||||
u = test_create_unit(f, test_create_region(0, 1, NULL));
|
||||
unit_setname(u, "Hodor");
|
||||
|
@ -282,7 +280,7 @@ typedef struct {
|
|||
} spell_fixture;
|
||||
|
||||
static void setup_spell_fixture(spell_fixture * spf) {
|
||||
spf->lang = test_create_locale();
|
||||
spf->lang = get_or_create_locale(__FUNCTION__);
|
||||
locale_setstring(spf->lang, mkname("spell", "testspell"), "Testzauber");
|
||||
locale_setstring(spf->lang, "nr_spell_type", "Typ:");
|
||||
locale_setstring(spf->lang, "sptype_normal", "Normal");
|
||||
|
|
|
@ -57,7 +57,7 @@ static void test_reorder_units(CuTest * tc)
|
|||
r = test_create_region(0, 0, NULL);
|
||||
b = test_create_building(r, NULL);
|
||||
s = test_create_ship(r, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
|
||||
u0 = test_create_unit(f, r);
|
||||
u_set_ship(u0, s);
|
||||
|
@ -111,8 +111,8 @@ static void test_seen_faction(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
rc = test_create_race("human");
|
||||
f1 = test_create_faction(rc);
|
||||
f2 = test_create_faction(rc);
|
||||
f1 = test_create_faction_ex(rc, NULL);
|
||||
f2 = test_create_faction_ex(rc, NULL);
|
||||
add_seen_faction(f1, f2);
|
||||
CuAssertPtrEquals(tc, f2, selist_get(f1->seen_factions, 0));
|
||||
CuAssertIntEquals(tc, 1, selist_length(f1->seen_factions));
|
||||
|
@ -186,9 +186,9 @@ static void test_bufunit_fstealth(CuTest *tc) {
|
|||
lang = get_or_create_locale("de");
|
||||
locale_setstring(lang, "status_aggressive", "aggressive");
|
||||
locale_setstring(lang, "anonymous", "anonymous");
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f1->locale = lang;
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
f2->locale = lang;
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(f1, r);
|
||||
|
@ -272,7 +272,7 @@ static void test_bufunit(CuTest *tc) {
|
|||
locale_setstring(lang, "skill::alchemy", "Alchemie");
|
||||
locale_setstring(lang, "status_aggressive", "aggressiv");
|
||||
init_skills(lang);
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = lang;
|
||||
faction_setname(u->faction, "UFO");
|
||||
renumber_faction(u->faction, 1);
|
||||
|
@ -290,7 +290,7 @@ static void test_bufunit(CuTest *tc) {
|
|||
bufunit_depr(u->faction, u, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), 1 human, aggressiv, Talente: Alchemie 2, Segeln 1.", buffer);
|
||||
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->locale = get_or_create_locale("de");
|
||||
bufunit_depr(f, u, 0, buffer, sizeof(buffer));
|
||||
CuAssertStrEquals(tc, "Hodor (1), UFO (1), 1 human.", buffer);
|
||||
|
@ -335,7 +335,7 @@ static void test_newbie_password_message(CuTest *tc) {
|
|||
report_context ctx;
|
||||
faction *f;
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->age = 5;
|
||||
f->flags = 0;
|
||||
prepare_report(&ctx, f, NULL);
|
||||
|
@ -356,8 +356,8 @@ static void test_prepare_travelthru(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r1 = test_create_region(0, 0, NULL);
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
r3 = test_create_region(3, 0, 0);
|
||||
|
@ -392,9 +392,9 @@ static void test_get_addresses(CuTest *tc) {
|
|||
region *r;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
test_create_unit(f, r);
|
||||
test_create_unit(f1, r);
|
||||
|
@ -419,9 +419,9 @@ static void test_get_addresses_fstealth(CuTest *tc) {
|
|||
unit *u;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
test_create_unit(f, r);
|
||||
u = test_create_unit(f1, r);
|
||||
|
@ -448,25 +448,25 @@ static void test_get_addresses_travelthru(CuTest *tc) {
|
|||
race *rc;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r1 = test_create_region(0, 0, NULL);
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
u = test_create_unit(f, r2);
|
||||
travelthru_add(r1, u);
|
||||
|
||||
f1 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
u = test_create_unit(f1, r1);
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
set_factionstealth(u, f2);
|
||||
u->building = test_create_building(u->region, test_create_buildingtype("tower"));
|
||||
|
||||
rc = rc_get_or_create("dragon");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
f3 = test_create_faction(rc);
|
||||
f3 = test_create_faction_ex(rc, NULL);
|
||||
u = test_create_unit(f3, r1);
|
||||
setguard(u, true);
|
||||
|
||||
f4 = test_create_faction(NULL);
|
||||
f4 = test_create_faction();
|
||||
u = test_create_unit(f4, r1);
|
||||
set_level(u, SK_STEALTH, 1);
|
||||
|
||||
|
@ -495,7 +495,7 @@ void test_prepare_lighthouse_capacity(CuTest *tc) {
|
|||
report_context ctx;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
btype = test_create_buildingtype("lighthouse");
|
||||
|
@ -506,7 +506,7 @@ void test_prepare_lighthouse_capacity(CuTest *tc) {
|
|||
b->flags |= BLD_MAINTAINED;
|
||||
b->size = 10;
|
||||
update_lighthouse(b);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r1);
|
||||
u1 = test_create_unit(test_create_faction(), r1);
|
||||
u1->number = 4;
|
||||
u1->building = b;
|
||||
set_level(u1, SK_PERCEPTION, 3);
|
||||
|
@ -554,7 +554,7 @@ static void test_prepare_lighthouse(CuTest *tc) {
|
|||
test_setup();
|
||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r1 = test_create_region(0, 0, t_plain);
|
||||
r2 = test_create_region(1, 0, t_ocean);
|
||||
r3 = test_create_region(2, 0, t_ocean);
|
||||
|
@ -598,7 +598,7 @@ static void test_prepare_lighthouse_owners(CuTest *tc)
|
|||
config_set("rules.region_owners", "1");
|
||||
t_ocean = test_create_terrain("ocean", SEA_REGION);
|
||||
t_plain = test_create_terrain("plain", LAND_REGION);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r1 = test_create_region(0, 0, t_plain);
|
||||
r2 = test_create_region(1, 0, t_ocean);
|
||||
test_create_region(2, 0, t_ocean);
|
||||
|
@ -609,7 +609,7 @@ static void test_prepare_lighthouse_owners(CuTest *tc)
|
|||
b->size = 10;
|
||||
update_lighthouse(b);
|
||||
test_create_unit(f, r1);
|
||||
u = test_create_unit(test_create_faction(NULL), r1);
|
||||
u = test_create_unit(test_create_faction(), r1);
|
||||
u->building = b;
|
||||
region_set_owner(b->region, f, 0);
|
||||
CuAssertIntEquals(tc, 2, lighthouse_view_distance(b, NULL));
|
||||
|
@ -629,7 +629,7 @@ static void test_prepare_report(CuTest *tc) {
|
|||
region *r;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
|
||||
prepare_report(&ctx, f, NULL);
|
||||
|
@ -662,7 +662,7 @@ static void test_seen_neighbours(CuTest *tc) {
|
|||
region *r1, *r2;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r1 = test_create_region(0, 0, NULL);
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
|
||||
|
@ -683,7 +683,7 @@ static void test_seen_travelthru(CuTest *tc) {
|
|||
region *r1, *r2, *r3;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r1 = test_create_region(0, 0, NULL);
|
||||
r2 = test_create_region(1, 0, 0);
|
||||
r3 = test_create_region(2, 0, 0);
|
||||
|
@ -764,7 +764,7 @@ static void test_report_far_vision(CuTest *tc) {
|
|||
faction *f;
|
||||
region *r1, *r2;
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r1 = test_create_region(0, 0, NULL);
|
||||
test_create_unit(f, r1);
|
||||
r2 = test_create_region(10, 0, 0);
|
||||
|
@ -786,7 +786,7 @@ static void test_stealth_modifier(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
CuAssertIntEquals(tc, 0, stealth_modifier(r, f, seen_unit));
|
||||
CuAssertIntEquals(tc, -1, stealth_modifier(r, f, seen_travel));
|
||||
|
@ -805,7 +805,7 @@ static void test_insect_warnings(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
test_create_calendar();
|
||||
f = test_create_faction(test_create_race("insect"));
|
||||
f = test_create_faction_ex(test_create_race("insect"), NULL);
|
||||
|
||||
CuAssertIntEquals(tc, SEASON_AUTUMN, get_gamedate(1083, &gd)->season);
|
||||
report_warnings(f, gd.turn);
|
||||
|
@ -832,7 +832,7 @@ static void test_newbie_warning(CuTest *tc) {
|
|||
faction *f;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
config_set_int("NewbieImmunity", 3);
|
||||
|
||||
f->age = 2;
|
||||
|
@ -856,10 +856,10 @@ static void test_visible_unit(CuTest *tc) {
|
|||
race *rc;
|
||||
|
||||
test_setup();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
rc = test_create_race("smurf");
|
||||
rc->flags |= RCF_UNARMEDGUARD;
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
|
||||
CuAssertTrue(tc, cansee(f, u->region, u, 0));
|
||||
CuAssertTrue(tc, visible_unit(u, f, 0, seen_unit));
|
||||
|
@ -956,7 +956,7 @@ static void test_reports_genpassword(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
mt_create_va(mt_new("changepasswd", NULL), "value:string", MT_NEW_END);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, 0, f->lastorders);
|
||||
CuAssertIntEquals(tc, 0, f->password_id);
|
||||
f->options = 0;
|
||||
|
|
|
@ -38,8 +38,8 @@ static void test_good_dreams(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
||||
|
@ -66,8 +66,8 @@ static void test_dreams(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
||||
|
@ -94,8 +94,8 @@ static void test_bad_dreams(CuTest *tc) {
|
|||
test_setup();
|
||||
test_create_world();
|
||||
r = findregion(0, 0);
|
||||
f1 = test_create_faction(NULL);
|
||||
f2 = test_create_faction(NULL);
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
||||
|
@ -130,7 +130,7 @@ static void test_view_reality(CuTest *tc) {
|
|||
mt_create_va(mt_new("viewreality_effect", NULL),
|
||||
"unit:unit", MT_NEW_END);
|
||||
rx = test_create_region(0, TP_RADIUS + 1, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, rx);
|
||||
|
||||
/* can only cast in astral space */
|
||||
|
@ -203,7 +203,7 @@ static void test_show_astral(CuTest *tc) {
|
|||
"unit:unit", MT_NEW_END);
|
||||
ra = test_create_region(real2tp(0), real2tp(0) + 1 + SHOWASTRAL_MAX_RADIUS, NULL);
|
||||
ra->_plane = get_astralplane();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, ra);
|
||||
|
||||
/* error: unit is in astral space */
|
||||
|
@ -269,7 +269,7 @@ static void test_watch_region(CuTest *tc) {
|
|||
faction *f;
|
||||
test_setup();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
CuAssertIntEquals(tc, -1, get_observer(r, f));
|
||||
set_observer(r, f, 0, 2);
|
||||
CuAssertIntEquals(tc, 0, get_observer(r, f));
|
||||
|
|
|
@ -37,7 +37,7 @@ static void test_flyingship(CuTest * tc)
|
|||
par_data.flag = 0;
|
||||
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(test_create_race("human"));
|
||||
f = test_create_faction();
|
||||
u = test_create_unit(f, r);
|
||||
|
||||
shipType1 = test_create_shiptype("boot");
|
||||
|
|
|
@ -32,10 +32,10 @@ static void test_magicresistance_unit(CuTest *tc) {
|
|||
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);
|
||||
f1 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
||||
f2 = test_create_faction(NULL);
|
||||
f2 = test_create_faction();
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
||||
c = create_curse(u1, &u2->attribs, &ct_magicresistance, 10, 20, 30, u2->number);
|
||||
|
@ -61,7 +61,7 @@ static void test_magicresistance_building(CuTest *tc) {
|
|||
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);
|
||||
f1 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
||||
b1 = test_create_building(r, NULL);
|
||||
|
|
|
@ -60,8 +60,8 @@ static void setup_spy(spy_fixture *fix) {
|
|||
|
||||
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);
|
||||
fix->spy = test_create_unit(test_create_faction(), fix->r);
|
||||
fix->victim = test_create_unit(test_create_faction(), fix->r);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ static void test_sabotage_self(CuTest *tc) {
|
|||
setup_spy(NULL);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
assert(u && u->faction && u->region == r);
|
||||
u->ship = test_create_ship(r, NULL);
|
||||
assert(u->ship);
|
||||
|
@ -139,9 +139,9 @@ static void test_sink_ship(CuTest *tc) {
|
|||
test_setup();
|
||||
setup_spy(NULL);
|
||||
r = test_create_ocean(0, 0);
|
||||
u1 = test_create_unit(test_create_faction(NULL), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
u3 = test_create_unit(test_create_faction(NULL), r);
|
||||
u3 = test_create_unit(test_create_faction(), r);
|
||||
u1->ship = u2->ship = u3->ship = sh = test_create_ship(r, NULL);
|
||||
|
||||
sink_ship(sh);
|
||||
|
@ -173,8 +173,8 @@ static void test_sabotage_other_fail(CuTest *tc) {
|
|||
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
assert(u && u2);
|
||||
u2->ship = test_create_ship(r, NULL);
|
||||
assert(u2->ship);
|
||||
|
@ -198,7 +198,7 @@ static void test_setstealth_cmd(CuTest *tc) {
|
|||
const struct locale *lang;
|
||||
|
||||
test_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
lang = u->faction->locale;
|
||||
u->flags = UFL_ANON_FACTION | UFL_DEFENDER;
|
||||
u->thisorder = create_order(K_SETSTEALTH, lang, "%s %s",
|
||||
|
@ -222,7 +222,7 @@ static void test_setstealth_demon(CuTest *tc) {
|
|||
test_setup();
|
||||
lang = test_create_locale();
|
||||
rc = test_create_race("demon");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_plain(0, 0));
|
||||
rc = test_create_race("dwarf");
|
||||
init_races(lang);
|
||||
u->thisorder = create_order(K_SETSTEALTH, lang, racename(lang, u, rc));
|
||||
|
@ -239,7 +239,7 @@ static void test_setstealth_demon_bad(CuTest *tc) {
|
|||
test_setup();
|
||||
lang = test_create_locale();
|
||||
rc = test_create_race("demon");
|
||||
u = test_create_unit(test_create_faction(rc), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_plain(0, 0));
|
||||
|
||||
rc = test_create_race("smurf");
|
||||
rc->flags &= ~RCF_PLAYABLE;
|
||||
|
@ -260,8 +260,8 @@ static void test_sabotage_other_success(CuTest *tc) {
|
|||
setup_spy(NULL);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r);
|
||||
u = test_create_unit(test_create_faction(NULL), r);
|
||||
u2 = test_create_unit(test_create_faction(NULL), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
u2 = test_create_unit(test_create_faction(), r);
|
||||
assert(u && u2);
|
||||
u2->ship = test_create_ship(r, NULL);
|
||||
assert(u2->ship);
|
||||
|
|
|
@ -91,7 +91,7 @@ static void setup_teacher(study_fixture *fix, skill_t sk) {
|
|||
setup_study();
|
||||
config_set("study.random_progress", "0");
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->locale = lang = test_create_locale();
|
||||
setup_locale(lang);
|
||||
fix->u = test_create_unit(f, r);
|
||||
|
@ -155,7 +155,7 @@ static void test_check_student(CuTest *tc) {
|
|||
race *rc;
|
||||
|
||||
setup_study();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
u->thisorder = create_order(K_STUDY, u->faction->locale, skillnames[SK_CROSSBOW]);
|
||||
CuAssertTrue(tc, check_student(u, u->thisorder, SK_CROSSBOW));
|
||||
CuAssertPtrEquals(tc, NULL, u->faction->msgs);
|
||||
|
@ -186,7 +186,7 @@ static void test_study_bug_2194(CuTest *tc) {
|
|||
init_resources();
|
||||
loc = test_create_locale();
|
||||
setup_locale(loc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_plain(0, 0));
|
||||
u = test_create_unit(test_create_faction(), test_create_plain(0, 0));
|
||||
scale_number(u, 2);
|
||||
set_level(u, SK_CROSSBOW, TEACHDIFFERENCE);
|
||||
u->faction->locale = loc;
|
||||
|
@ -239,7 +239,7 @@ static void test_produceexp(CuTest *tc) {
|
|||
|
||||
g_tc = tc;
|
||||
setup_study();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 2);
|
||||
config_set("study.produceexp", "20");
|
||||
produceexp_ex(u, SK_ALCHEMY, 1, cb_learn_one);
|
||||
|
@ -261,7 +261,7 @@ static void test_academy_building(CuTest *tc) {
|
|||
init_resources();
|
||||
loc = test_create_locale();
|
||||
setup_locale(loc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 2);
|
||||
set_level(u, SK_CROSSBOW, TEACHDIFFERENCE);
|
||||
u->faction->locale = loc;
|
||||
|
@ -310,10 +310,10 @@ static void test_academy_bonus(CuTest *tc) {
|
|||
init_resources();
|
||||
loc = test_create_locale();
|
||||
setup_locale(loc);
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->faction->locale = loc;
|
||||
|
||||
u0 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u0 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
set_level(u, SK_CROSSBOW, TEACHDIFFERENCE);
|
||||
set_level(u0, SK_CROSSBOW, TEACHDIFFERENCE);
|
||||
|
||||
|
@ -363,7 +363,7 @@ void test_learn_skill_single(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
config_set("study.random_progress", "0");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
CuAssertIntEquals(tc, 0, learn_skill(u, SK_ALCHEMY, STUDYDAYS, 0));
|
||||
CuAssertPtrNotNull(tc, sv = u->skills);
|
||||
CuAssertIntEquals(tc, SK_ALCHEMY, sv->id);
|
||||
|
@ -383,7 +383,7 @@ void test_learn_skill_multi(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
config_set("study.random_progress", "0");
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 10);
|
||||
CuAssertIntEquals(tc, 0, learn_skill(u, SK_ALCHEMY, STUDYDAYS * u->number, 0));
|
||||
CuAssertPtrNotNull(tc, sv = u->skills);
|
||||
|
@ -405,7 +405,7 @@ static void test_demon_skillchanges(CuTest *tc) {
|
|||
setup_study();
|
||||
rc = test_create_race("demon");
|
||||
CuAssertPtrEquals(tc, (void *)rc, (void *)get_race(RC_DAEMON));
|
||||
u = test_create_unit(test_create_faction(rc), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction_ex(rc, NULL), test_create_region(0, 0, NULL));
|
||||
CuAssertPtrNotNull(tc, u);
|
||||
set_level(u, SK_CROSSBOW, 1);
|
||||
demon_skillchange(u);
|
||||
|
@ -418,7 +418,7 @@ static void test_study_cmd(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
|
||||
learn_inject();
|
||||
study_cmd(u, u->thisorder);
|
||||
|
@ -437,7 +437,7 @@ static void test_study_magic(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
lang = f->locale;
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_STUDY, lang, skillnames[SK_MAGIC]);
|
||||
|
@ -468,7 +468,7 @@ static void test_study_cost_magic(CuTest *tc) {
|
|||
unit * u;
|
||||
|
||||
setup_study();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
|
||||
CuAssertIntEquals(tc, 100, study_cost(u, SK_MAGIC));
|
||||
set_level(u, SK_MAGIC, 1);
|
||||
|
@ -493,7 +493,7 @@ static void test_study_cost(CuTest *tc) {
|
|||
setup_study();
|
||||
|
||||
itype = test_create_silver();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 2);
|
||||
u->thisorder = create_order(K_STUDY, u->faction->locale, skillnames[SK_ALCHEMY]);
|
||||
|
||||
|
@ -520,7 +520,7 @@ static void test_teach_magic(CuTest *tc) {
|
|||
setup_study();
|
||||
init_resources();
|
||||
itype = get_resourcetype(R_SILVER)->itype;
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
f->magiegebiet = M_GWYRRD;
|
||||
u = test_create_unit(f, test_create_region(0, 0, NULL));
|
||||
u->thisorder = create_order(K_STUDY, f->locale, skillnames[SK_MAGIC]);
|
||||
|
@ -545,7 +545,7 @@ static void test_teach_cmd(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 10);
|
||||
u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
|
||||
ut = test_create_unit(u->faction, u->region);
|
||||
|
@ -566,7 +566,7 @@ static void test_teach_two(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
u1 = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u1 = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u1, 5);
|
||||
u1->thisorder = create_order(K_STUDY, u1->faction->locale, "CROSSBOW");
|
||||
u2 = test_create_unit(u1->faction, u1->region);
|
||||
|
@ -596,7 +596,7 @@ static void test_teach_two_skills(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u1 = test_create_unit(f, r);
|
||||
scale_number(u1, 5);
|
||||
|
@ -627,7 +627,7 @@ static void test_teach_one_to_many(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 20);
|
||||
u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
|
||||
ut = test_create_unit(u->faction, u->region);
|
||||
|
@ -648,7 +648,7 @@ static void test_teach_many_to_one(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 20);
|
||||
u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
|
||||
u1 = test_create_unit(u->faction, u->region);
|
||||
|
@ -675,13 +675,13 @@ static void test_teach_message(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
scale_number(u, 20);
|
||||
u->thisorder = create_order(K_STUDY, u->faction->locale, "CROSSBOW");
|
||||
u1 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u1 = test_create_unit(test_create_faction(), u->region);
|
||||
set_level(u1, SK_CROSSBOW, TEACHDIFFERENCE);
|
||||
u1->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no));
|
||||
u2 = test_create_unit(test_create_faction(NULL), u->region);
|
||||
u2 = test_create_unit(test_create_faction(), u->region);
|
||||
ally_set(&u->faction->allies, u2->faction, HELP_GUARD);
|
||||
set_level(u2, SK_CROSSBOW, TEACHDIFFERENCE);
|
||||
u2->thisorder = create_order(K_TEACH, u->faction->locale, itoa36(u->no));
|
||||
|
@ -714,7 +714,7 @@ static void test_teach_many_to_many(CuTest *tc) {
|
|||
|
||||
setup_study();
|
||||
init_resources();
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
r = test_create_region(0, 0, NULL);
|
||||
s1 = test_create_unit(f, r);
|
||||
scale_number(s1, 20);
|
||||
|
|
|
@ -12,8 +12,8 @@ static void test_summary(CuTest * tc)
|
|||
{
|
||||
struct summary *sum;
|
||||
test_setup();
|
||||
test_create_faction(NULL);
|
||||
test_create_faction(NULL);
|
||||
test_create_faction();
|
||||
test_create_faction();
|
||||
sum = make_summary();
|
||||
report_summary(sum, true);
|
||||
CuAssertIntEquals(tc, 0, remove("parteien.full"));
|
||||
|
|
27
src/tests.c
27
src/tests.c
|
@ -169,14 +169,21 @@ struct locale * test_create_locale(void) {
|
|||
return loc;
|
||||
}
|
||||
|
||||
struct faction *test_create_faction(const struct race *rc)
|
||||
struct faction *test_create_faction_ex(const struct race *rc, const struct locale *loc)
|
||||
{
|
||||
struct locale * loc = test_create_locale();
|
||||
faction *f = addfaction("nobody@eressea.de", NULL, rc ? rc : test_create_race("human"), loc);
|
||||
faction* f;
|
||||
if (loc == NULL) {
|
||||
loc = test_create_locale();
|
||||
}
|
||||
f = addfaction("nobody@eressea.de", NULL, rc ? rc : test_create_race("human"), loc);
|
||||
test_clear_messages(f);
|
||||
return f;
|
||||
}
|
||||
|
||||
struct faction* test_create_faction(void) {
|
||||
return test_create_faction_ex(NULL, NULL);
|
||||
}
|
||||
|
||||
struct unit *test_create_unit(struct faction *f, struct region *r)
|
||||
{
|
||||
const struct race * rc = f ? f->race : 0;
|
||||
|
@ -371,11 +378,15 @@ ship_type * test_create_shiptype(const char * name)
|
|||
}
|
||||
stype->coasts =
|
||||
(terrain_type **)malloc(sizeof(terrain_type *) * 3);
|
||||
stype->coasts[0] = test_create_terrain("plain", LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | FLY_INTO);
|
||||
stype->coasts[0] = test_create_terrain("plain",
|
||||
LAND_REGION | FOREST_REGION | WALK_INTO | CAVALRY_REGION | FLY_INTO);
|
||||
stype->coasts[1] = test_create_terrain("ocean", SEA_REGION | SWIM_INTO | FLY_INTO);
|
||||
stype->coasts[2] = NULL;
|
||||
if (default_locale) {
|
||||
locale_setstring(default_locale, name, name);
|
||||
const char* str = locale_getstring(default_locale, name);
|
||||
if (!str || strcmp(name, str) != 0) {
|
||||
locale_setstring(default_locale, name, name);
|
||||
}
|
||||
}
|
||||
return stype;
|
||||
}
|
||||
|
@ -492,12 +503,8 @@ void test_create_world(void)
|
|||
|
||||
loc = test_create_locale();
|
||||
|
||||
locale_setstring(loc, parameters[P_SHIP], "SCHIFF");
|
||||
locale_setstring(loc, parameters[P_ANY], "ALLE");
|
||||
init_parameters(loc);
|
||||
|
||||
locale_setstring(loc, "status_aggressive", "aggressiv");
|
||||
locale_setstring(loc, keyword(K_RESERVE), "RESERVIEREN");
|
||||
locale_setstring(loc, "money", "Silber");
|
||||
locale_setstring(loc, "money_p", "Silber");
|
||||
locale_setstring(loc, "cart", "Wagen");
|
||||
|
@ -542,8 +549,6 @@ void test_create_world(void)
|
|||
}
|
||||
}
|
||||
|
||||
test_create_race("human");
|
||||
|
||||
test_create_buildingtype("castle");
|
||||
test_create_shiptype("boat");
|
||||
}
|
||||
|
|
|
@ -48,7 +48,8 @@ extern "C" {
|
|||
struct region *test_create_region(int x, int y, const struct terrain_type *terrain);
|
||||
struct region *test_create_ocean(int x, int y);
|
||||
struct region *test_create_plain(int x, int y);
|
||||
struct faction *test_create_faction(const struct race *rc);
|
||||
struct faction* test_create_faction(void);
|
||||
struct faction *test_create_faction_ex(const struct race *rc, const struct locale *lang);
|
||||
struct unit *test_create_unit(struct faction *f, struct region *r);
|
||||
void test_create_world(void);
|
||||
struct item_type * test_create_horse(void);
|
||||
|
|
|
@ -33,7 +33,7 @@ static void setup_travelthru(travel_fixture *fix, int nunits) {
|
|||
while (r->attribs) {
|
||||
a_remove(&r->attribs, r->attribs);
|
||||
}
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
while (nunits--) {
|
||||
unit *u = test_create_unit(f, test_create_region(1, 0, NULL));
|
||||
travelthru_add(r, u);
|
||||
|
|
|
@ -22,7 +22,7 @@ static void test_shock(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
shock_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
create_mage(u, M_GWYRRD);
|
||||
set_level(u, SK_MAGIC, 5);
|
||||
set_spellpoints(u, 10);
|
||||
|
@ -43,7 +43,7 @@ static void test_shock_low(CuTest *tc) {
|
|||
|
||||
test_setup();
|
||||
shock_setup();
|
||||
u = test_create_unit(test_create_faction(NULL), test_create_region(0, 0, NULL));
|
||||
u = test_create_unit(test_create_faction(), test_create_region(0, 0, NULL));
|
||||
create_mage(u, M_GWYRRD);
|
||||
set_level(u, SK_MAGIC, 5);
|
||||
set_spellpoints(u, 1);
|
||||
|
|
|
@ -25,8 +25,8 @@ void test_upkeep_default(CuTest * tc)
|
|||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
f2 = test_create_faction(test_create_race("human"));
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
assert(f1 && f2);
|
||||
u1 = test_create_unit(f1, r);
|
||||
u2 = test_create_unit(f2, r);
|
||||
|
@ -56,7 +56,7 @@ void test_upkeep_hunger_damage(CuTest * tc)
|
|||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
f1 = test_create_faction();
|
||||
u1 = test_create_unit(f1, r);
|
||||
assert(r && u1);
|
||||
|
||||
|
@ -82,7 +82,7 @@ void test_upkeep_from_pool(CuTest * tc)
|
|||
assert(i_silver);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
assert(r);
|
||||
u1 = test_create_unit(test_create_faction(test_create_race("human")), r);
|
||||
u1 = test_create_unit(test_create_faction(), r);
|
||||
assert(u1);
|
||||
u2 = test_create_unit(u1->faction, r);
|
||||
assert(u2);
|
||||
|
@ -115,8 +115,8 @@ void test_upkeep_from_friend(CuTest * tc)
|
|||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
f1 = test_create_faction(test_create_race("human"));
|
||||
f2 = test_create_faction(test_create_race("human"));
|
||||
f1 = test_create_faction();
|
||||
f2 = test_create_faction();
|
||||
assert(f1 && f2);
|
||||
ally_set(&f1->allies, f2, HELP_MONEY);
|
||||
u1 = test_create_unit(f1, r);
|
||||
|
@ -149,7 +149,7 @@ void test_upkeep_free(CuTest * tc)
|
|||
i_silver = it_find("money");
|
||||
assert(i_silver);
|
||||
r = test_create_region(0, 0, NULL);
|
||||
u = test_create_unit(test_create_faction(test_create_race("human")), r);
|
||||
u = test_create_unit(test_create_faction(), r);
|
||||
assert(r && u);
|
||||
|
||||
config_set("rules.food.flags", "4"); /* FOOD_IS_FREE */
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
cmake_minimum_required(VERSION 2.6)
|
||||
project (crypto C)
|
||||
|
||||
IF (MSVC)
|
||||
|
|
|
@ -80,10 +80,10 @@ static int timing_safe_strcmp(const char *str1, const char *str2)
|
|||
const unsigned char *u1;
|
||||
const unsigned char *u2;
|
||||
int ret;
|
||||
int i;
|
||||
unsigned int i;
|
||||
|
||||
int len1 = strlen(str1);
|
||||
int len2 = strlen(str2);
|
||||
size_t len1 = strlen(str1);
|
||||
size_t len2 = strlen(str2);
|
||||
|
||||
/* In our context both strings should always have the same length
|
||||
* because they will be hashed passwords. */
|
||||
|
|
|
@ -211,9 +211,9 @@ void locale_setstring(locale * lang, const char *key, const char *value)
|
|||
else {
|
||||
if (strcmp(find->str, value) != 0) {
|
||||
log_warning("multiple translations for key %s\n", key);
|
||||
free(find->str);
|
||||
find->str = str_strdup(value);
|
||||
}
|
||||
free(find->str);
|
||||
find->str = str_strdup(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ void sbs_printf(struct sbstring *sbs, const char *format, ...)
|
|||
int bytes = vsnprintf(sbs->end, size, format, argp);
|
||||
if (bytes > 0) {
|
||||
if ((size_t)bytes >= size) {
|
||||
bytes = size - 1;
|
||||
bytes = (int)(size - 1);
|
||||
/* terminate truncated output */
|
||||
sbs->end[bytes] = '\0';
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ static void test_sbstring(CuTest * tc)
|
|||
|
||||
sbs_adopt(&sbs, buffer + 2, sizeof(buffer) - 2);
|
||||
CuAssertStrEquals(tc, "3456789012345", sbs.begin);
|
||||
CuAssertIntEquals(tc, 13, sbs_length(&sbs));
|
||||
CuAssertIntEquals(tc, 13, (int)sbs_length(&sbs));
|
||||
}
|
||||
|
||||
static void test_sbs_strcat(CuTest * tc)
|
||||
|
|
|
@ -34,7 +34,7 @@ static bool char_trimmed(wint_t wc) {
|
|||
|
||||
size_t unicode_utf8_trim(char *buf)
|
||||
{
|
||||
int result = 0, ts = 0;
|
||||
size_t result = 0, ts = 0;
|
||||
char *op = buf, *ip = buf, *lc = buf;
|
||||
assert(buf);
|
||||
while (*ip) {
|
||||
|
|
|
@ -16,23 +16,23 @@ static void test_unicode_trim(CuTest * tc)
|
|||
char buffer[32];
|
||||
|
||||
strcpy(buffer, "Hello World");
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 0, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello World", buffer);
|
||||
|
||||
strcpy(buffer, " Hello World");
|
||||
CuAssertIntEquals(tc, 2, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 2, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello World", buffer);
|
||||
|
||||
strcpy(buffer, "Hello World ");
|
||||
CuAssertIntEquals(tc, 2, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 2, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello World", buffer);
|
||||
|
||||
strcpy(buffer, " Hello World ");
|
||||
CuAssertIntEquals(tc, 2, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 2, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello World", buffer);
|
||||
|
||||
strcpy(buffer, "Hello\t\r\nWorld");
|
||||
CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 3, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "HelloWorld", buffer);
|
||||
|
||||
strcpy(buffer, "LTR");
|
||||
|
@ -40,27 +40,27 @@ static void test_unicode_trim(CuTest * tc)
|
|||
buffer[4] = -128;
|
||||
buffer[5] = -114;
|
||||
buffer[6] = 0;
|
||||
CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 3, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "LTR", buffer);
|
||||
|
||||
strcpy(buffer, " Hello Word ");
|
||||
CuAssertIntEquals(tc, 4, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 4, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello Word", buffer);
|
||||
|
||||
strcpy(buffer, "Hello Word\n");
|
||||
CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 1, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello Word", buffer);
|
||||
|
||||
strcpy(buffer, " Hello Word\t\n");
|
||||
CuAssertIntEquals(tc, 4, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 4, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello Word", buffer);
|
||||
|
||||
strcpy(buffer, " \t Hello Word");
|
||||
CuAssertIntEquals(tc, 3, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 3, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello Word", buffer);
|
||||
|
||||
buffer[9] = -61;
|
||||
CuAssertIntEquals(tc, 1, unicode_utf8_trim(buffer));
|
||||
CuAssertIntEquals(tc, 1, (int)unicode_utf8_trim(buffer));
|
||||
CuAssertStrEquals(tc, "Hello Wor?", buffer);
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ static void test_unicode_utf8_to_ucs(CuTest *tc) {
|
|||
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_decode(&wc, "a", &sz));
|
||||
CuAssertIntEquals(tc, 'a', wc);
|
||||
CuAssertIntEquals(tc, 1, sz);
|
||||
CuAssertIntEquals(tc, 1, (int)sz);
|
||||
}
|
||||
|
||||
static void test_unicode_bug2262(CuTest *tc) {
|
||||
|
@ -137,13 +137,13 @@ static void test_unicode_bug2262(CuTest *tc) {
|
|||
|
||||
strcpy(name, "utende");
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_decode(&wc, name, &sz));
|
||||
CuAssertIntEquals(tc, 1, sz);
|
||||
CuAssertIntEquals(tc, 1, (int)sz);
|
||||
CuAssertIntEquals(tc, 'u', wc);
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, 0, (int)unicode_utf8_trim(name));
|
||||
|
||||
name[0] = -4; /* latin1: ü should fail to decode */
|
||||
CuAssertIntEquals(tc, EILSEQ, unicode_utf8_decode(&wc, name, &sz));
|
||||
CuAssertIntEquals(tc, EILSEQ, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, EILSEQ, (int)unicode_utf8_trim(name));
|
||||
}
|
||||
|
||||
static void test_unicode_compare(CuTest *tc)
|
||||
|
@ -159,7 +159,7 @@ static void test_unicode_trim_zwnj(CuTest *tc) {
|
|||
char expect[64];
|
||||
snprintf(name, sizeof(name), "%sA%sB%s ", zwnj, zwnj, zwnj);
|
||||
snprintf(expect, sizeof(expect), "A%sB", zwnj);
|
||||
CuAssertIntEquals(tc, 8, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, 8, (int)unicode_utf8_trim(name));
|
||||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ static void test_unicode_trim_nbsp(CuTest *tc) {
|
|||
char expect[64];
|
||||
snprintf(name, sizeof(name), "%sA%sB%s ", code, code, code);
|
||||
snprintf(expect, sizeof(expect), "A%sB", code);
|
||||
CuAssertIntEquals(tc, 6, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, 6, (int)unicode_utf8_trim(name));
|
||||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ static void test_unicode_trim_nnbsp(CuTest *tc) {
|
|||
char expect[64];
|
||||
snprintf(name, sizeof(name), "%sA%sB%s ", code, code, code);
|
||||
snprintf(expect, sizeof(expect), "A%sB", code);
|
||||
CuAssertIntEquals(tc, 8, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, 8, (int)unicode_utf8_trim(name));
|
||||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ static void test_unicode_trim_figure_space(CuTest *tc) {
|
|||
char expect[64];
|
||||
snprintf(name, sizeof(name), "%sA%sB%s ", code, code, code);
|
||||
snprintf(expect, sizeof(expect), "A%sB", code);
|
||||
CuAssertIntEquals(tc, 8, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, 8, (int)unicode_utf8_trim(name));
|
||||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
|
@ -199,7 +199,7 @@ static void test_unicode_trim_ltrm(CuTest *tc) {
|
|||
char expect[64];
|
||||
snprintf(name, sizeof(name), "%sBrot%szeit%s ", ltrm, ltrm, ltrm);
|
||||
snprintf(expect, sizeof(expect), "Brot%szeit", ltrm);
|
||||
CuAssertIntEquals(tc, 8, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, 8, (int)unicode_utf8_trim(name));
|
||||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ static void test_unicode_trim_emoji(CuTest *tc) {
|
|||
char expect[64];
|
||||
snprintf(name, sizeof(name), "%s Alarm%sClock %s", clock, clock, clock);
|
||||
strcpy(expect, name);
|
||||
CuAssertIntEquals(tc, 0, unicode_utf8_trim(name));
|
||||
CuAssertIntEquals(tc, 0, (int)unicode_utf8_trim(name));
|
||||
CuAssertStrEquals(tc, expect, name);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ static void test_volcano_outbreak(CuTest *tc) {
|
|||
t_active = test_create_terrain("activevolcano", LAND_REGION);
|
||||
r = test_create_region(0, 0, t_active);
|
||||
rn = test_create_region(1, 0, t_volcano);
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r);
|
||||
u1->hp = u1->number;
|
||||
u2 = test_create_unit(f, rn);
|
||||
|
|
|
@ -30,8 +30,7 @@ static void test_move_to_vortex(CuTest *tc) {
|
|||
r1 = test_create_region(0, 0, t_plain);
|
||||
r2 = test_create_region(5, 0, t_plain);
|
||||
CuAssertPtrNotNull(tc, create_special_direction(r1, r2, 10, "", "vortex", true));
|
||||
u = test_create_unit(test_create_faction(rc_get_or_create("hodor")), r1);
|
||||
u->faction->locale = lang;
|
||||
u = test_create_unit(test_create_faction_ex(NULL, lang), r1);
|
||||
CuAssertIntEquals(tc, E_MOVE_NOREGION, movewhere(u, "barf", r1, &r));
|
||||
CuAssertIntEquals(tc, E_MOVE_OK, movewhere(u, "wirbel", r1, &r));
|
||||
CuAssertPtrEquals(tc, r2, r);
|
||||
|
|
|
@ -84,7 +84,7 @@ static void test_wormhole_transfer(CuTest *tc) {
|
|||
r2 = test_create_plain(1, 0);
|
||||
b = test_create_building(r1, NULL);
|
||||
b->size = 4;
|
||||
f = test_create_faction(NULL);
|
||||
f = test_create_faction();
|
||||
u1 = test_create_unit(f, r1);
|
||||
u1->number = 2;
|
||||
u_set_building(u1, b);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
IF "%WIN32_DEV%" == "" SET WIN32_DEV="C:\Libraries"
|
||||
SET CMAKE_ROOT=%ProgramFiles%\CMake
|
||||
IF "%LUA_DEV%" == "" SET LUA_DEV="%ProgramFiles(x86)%/Lua/5.1"
|
||||
SET VSVERSION=15
|
||||
SET VSVERSION=16
|
||||
SET SRCDIR=%CD%
|
||||
REM CD ..
|
||||
REM SET ERESSEA=%CD%
|
||||
|
@ -15,5 +15,5 @@ cd build-vs%VSVERSION%
|
|||
IF NOT EXIST CMakeCache.txt GOTO NOCACHE
|
||||
DEL CMakeCache.txt
|
||||
:NOCACHE
|
||||
"%CMAKE_ROOT%\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -DCMAKE_PREFIX_PATH="%LUA_DEV%;%WIN32_DEV%" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
|
||||
"%CMAKE_ROOT%\bin\cmake.exe" -G "Visual Studio %VSVERSION%" -A Win32 -DCMAKE_PREFIX_PATH="%LUA_DEV%;%WIN32_DEV%" -DCMAKE_MODULE_PATH="%SRCDIR%/cmake/Modules" -DCMAKE_SUPPRESS_REGENERATION=TRUE ..
|
||||
PAUSE
|
||||
|
|
Loading…
Add table
Reference in a new issue