STIRB + PARTEI transferiert auch Magier des gleichen Gebietes.
This commit is contained in:
Enno Rehling 2020-08-16 12:44:03 +02:00
parent afa160c4c3
commit f1a0a7a55c
2 changed files with 50 additions and 4 deletions

View File

@ -938,7 +938,15 @@ void transfer_faction(faction *fsrc, faction *fdst) {
hnow += u->number; hnow += u->number;
} }
} }
if (give_unit_allowed(u) == 0 && !get_mage(u)) { if (give_unit_allowed(u) == 0) {
if (fdst->magiegebiet != M_NONE) {
struct sc_mage *m = get_mage(u);
if (m && mage_get_type(m) != fdst->magiegebiet) {
u = unext;
continue;
}
}
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) {
@ -950,7 +958,7 @@ void transfer_faction(faction *fsrc, faction *fdst) {
} }
} }
if (i != u->skill_size) { if (i != u->skill_size) {
u = u->nextF; u = unext;
continue; continue;
} }
} }
@ -3885,7 +3893,6 @@ void init_processor(void)
p += 10; /* all claims must be done before we can USE */ p += 10; /* all claims must be done before we can USE */
add_proc_region(p, enter_1, "Betreten (1. Versuch)"); /* for GIVE CONTROL */ add_proc_region(p, enter_1, "Betreten (1. Versuch)"); /* for GIVE CONTROL */
add_proc_order(p, K_USE, use_cmd, 0, "Benutzen"); add_proc_order(p, K_USE, use_cmd, 0, "Benutzen");
add_proc_order(p, K_QUIT, quit_cmd, 0, "Stirb");
p += 10; /* in case it has any effects on alliance victories */ p += 10; /* in case it has any effects on alliance victories */
add_proc_order(p, K_GIVE, give_control_cmd, 0, "GIB KOMMANDO"); add_proc_order(p, K_GIVE, give_control_cmd, 0, "GIB KOMMANDO");
@ -3916,6 +3923,7 @@ void init_processor(void)
add_proc_region(p, economics, "Geben, Vergessen"); add_proc_region(p, economics, "Geben, Vergessen");
add_proc_region(p+1, recruit, "Rekrutieren"); add_proc_region(p+1, recruit, "Rekrutieren");
add_proc_region(p+2, destroy, "Zerstoeren"); add_proc_region(p+2, destroy, "Zerstoeren");
add_proc_order(p, K_QUIT, quit_cmd, 0, "Stirb");
/* all recruitment must be finished before we can calculate /* all recruitment must be finished before we can calculate
* promotion cost of ability */ * promotion cost of ability */

View File

@ -2107,7 +2107,7 @@ static void test_quit_transfer_limited(CuTest *tc) {
} }
/** /**
* Mages cannot be transfered. At all. * Mages can be transfered within same school.
*/ */
static void test_quit_transfer_mages(CuTest *tc) { static void test_quit_transfer_mages(CuTest *tc) {
faction *f1, *f2; faction *f1, *f2;
@ -2134,8 +2134,45 @@ static void test_quit_transfer_mages(CuTest *tc) {
set_level(u2, SK_MAGIC, 1); set_level(u2, SK_MAGIC, 1);
create_mage(u2, M_GWYRRD); create_mage(u2, M_GWYRRD);
quit_cmd(u1, u1->thisorder);
CuAssertPtrEquals(tc, f2, u1->faction);
CuAssertPtrEquals(tc, f2, u2->faction);
CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT);
test_teardown();
}
/**
* Mages cannot be transfered from another school.
*/
static void test_quit_transfer_different_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_DRAIG;
set_level(u1, SK_MAGIC, 1);
create_mage(u1, M_DRAIG);
f2->magiegebiet = M_GWYRRD;
set_level(u2, SK_MAGIC, 1);
create_mage(u2, M_GWYRRD);
quit_cmd(u1, u1->thisorder); quit_cmd(u1, u1->thisorder);
CuAssertPtrEquals(tc, f1, u1->faction); CuAssertPtrEquals(tc, f1, u1->faction);
CuAssertPtrEquals(tc, f2, u2->faction);
CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT); CuAssertIntEquals(tc, FFL_QUIT, f1->flags & FFL_QUIT);
test_teardown(); test_teardown();
@ -2307,6 +2344,7 @@ CuSuite *get_laws_suite(void)
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_mages);
SUITE_ADD_TEST(suite, test_quit_transfer_different_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