Merge branch 'master' of github.com:ennorehling/eressea

This commit is contained in:
Enno Rehling 2019-12-01 17:30:07 +01:00
commit b45fe6b157
3 changed files with 39 additions and 3 deletions

2
clibs

@ -1 +1 @@
Subproject commit f8969f44de1ec413cfee82b23c9f4b3c32d49b56 Subproject commit abe774f70265de14ea7f5e530518ca130562a9c9

View File

@ -969,13 +969,13 @@ void transfer_faction(faction *fsrc, faction *fdst) {
if (u_race(u) == fdst->race) { if (u_race(u) == fdst->race) {
u->flags &= ~UFL_HERO; u->flags &= ~UFL_HERO;
if (give_unit_allowed(u) == 0) { if (give_unit_allowed(u) == 0 && !get_mage(u)) {
if (u->skills) { if (u->skills) {
int i; int i;
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;
if (skill_count[sk] + u->number > skill_limit[sk]) { if (skill_count[sk] + u->number > skill_limit[sk]) {
break; break;
} }

View File

@ -2083,6 +2083,41 @@ static void test_quit_transfer_limited(CuTest *tc) {
test_teardown(); test_teardown();
} }
/**
* Mages cannot be transfered. At all.
*/
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_GWYRRD;
set_level(u2, SK_MAGIC, 1);
create_mage(u2, M_GWYRRD);
quit_cmd(u1, u1->thisorder);
CuAssertPtrEquals(tc, f1, u1->faction);
CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT);
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.
*/ */
@ -2248,6 +2283,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