forked from github/server
Merge branch 'master' into develop
This commit is contained in:
commit
dccde58221
|
@ -958,9 +958,17 @@ void transfer_faction(faction *fsrc, faction *fdst) {
|
||||||
for (i = 0; i != u->skill_size; ++i) {
|
for (i = 0; i != u->skill_size; ++i) {
|
||||||
const skill *sv = u->skills + i;
|
const skill *sv = u->skills + i;
|
||||||
skill_t sk = (skill_t)sv->id;
|
skill_t sk = (skill_t)sv->id;
|
||||||
|
struct sc_mage *mage;
|
||||||
|
|
||||||
if (skill_count[sk] + u->number > skill_limit[sk]) {
|
if (skill_count[sk] + u->number > skill_limit[sk]) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
mage = get_mage(u);
|
||||||
|
if (mage) {
|
||||||
|
if (fdst->magiegebiet != mage_get_type(mage)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (i != u->skill_size) {
|
if (i != u->skill_size) {
|
||||||
u = u->nextF;
|
u = u->nextF;
|
||||||
|
|
|
@ -2106,6 +2106,56 @@ static void test_quit_transfer_limited(CuTest *tc) {
|
||||||
test_teardown();
|
test_teardown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gifting units with same magic schools.
|
||||||
|
*/
|
||||||
|
static void test_quit_transfer_mages(CuTest *tc) {
|
||||||
|
faction *f1, *f2;
|
||||||
|
unit *u1, *u2;
|
||||||
|
region *r;
|
||||||
|
|
||||||
|
test_setup();
|
||||||
|
config_set_int("rules.maxskills.magic", 2);
|
||||||
|
r = test_create_plain(0, 0);
|
||||||
|
f1 = test_create_faction(NULL);
|
||||||
|
faction_setpassword(f1, "password");
|
||||||
|
u1 = test_create_unit(f1, r);
|
||||||
|
f2 = test_create_faction(NULL);
|
||||||
|
u2 = test_create_unit(f2, r);
|
||||||
|
contact_unit(u2, u1);
|
||||||
|
u1->thisorder = create_order(K_QUIT, f1->locale, "password %s %s",
|
||||||
|
LOC(f1->locale, parameters[P_FACTION]), itoa36(f2->no));
|
||||||
|
|
||||||
|
f1->magiegebiet = M_GWYRRD;
|
||||||
|
set_level(u1, SK_MAGIC, 1);
|
||||||
|
create_mage(u1, M_GWYRRD);
|
||||||
|
|
||||||
|
f2->magiegebiet = M_CERDDOR;
|
||||||
|
set_level(u2, SK_MAGIC, 1);
|
||||||
|
create_mage(u2, M_CERDDOR);
|
||||||
|
|
||||||
|
quit_cmd(u1, u1->thisorder);
|
||||||
|
CuAssertPtrEquals(tc, f1, u1->faction);
|
||||||
|
CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT);
|
||||||
|
f1->flags -= FFL_QUIT;
|
||||||
|
|
||||||
|
unit_set_magic(u1, M_CERDDOR);
|
||||||
|
scale_number(u1, 2);
|
||||||
|
f1->magiegebiet = M_CERDDOR;
|
||||||
|
quit_cmd(u1, u1->thisorder);
|
||||||
|
CuAssertPtrEquals(tc, f1, u1->faction);
|
||||||
|
CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT);
|
||||||
|
f1->flags -= FFL_QUIT;
|
||||||
|
|
||||||
|
unit_set_magic(u1, M_CERDDOR);
|
||||||
|
scale_number(u1, 1);
|
||||||
|
f1->magiegebiet = M_CERDDOR;
|
||||||
|
quit_cmd(u1, u1->thisorder);
|
||||||
|
CuAssertPtrEquals(tc, f2, u1->faction);
|
||||||
|
|
||||||
|
test_teardown();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only units of the same race can be gifted to another faction.
|
* Only units of the same race can be gifted to another faction.
|
||||||
*/
|
*/
|
||||||
|
@ -2271,6 +2321,7 @@ CuSuite *get_laws_suite(void)
|
||||||
SUITE_ADD_TEST(suite, test_quit_transfer);
|
SUITE_ADD_TEST(suite, test_quit_transfer);
|
||||||
SUITE_ADD_TEST(suite, test_quit_transfer_limited);
|
SUITE_ADD_TEST(suite, test_quit_transfer_limited);
|
||||||
SUITE_ADD_TEST(suite, test_quit_transfer_migrants);
|
SUITE_ADD_TEST(suite, test_quit_transfer_migrants);
|
||||||
|
SUITE_ADD_TEST(suite, test_quit_transfer_mages);
|
||||||
SUITE_ADD_TEST(suite, test_quit_transfer_hero);
|
SUITE_ADD_TEST(suite, test_quit_transfer_hero);
|
||||||
SUITE_ADD_TEST(suite, test_transfer_faction);
|
SUITE_ADD_TEST(suite, test_transfer_faction);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue