forked from github/server
Bugfix 2109: Einheiten lassen sich nicht mehr zwischen Parteien übergeben
https://bugs.eressea.de/view.php?id=2109 Wenn max_transfers < 0 war, wurde das nur in give_men richtig interpretiert, aber nicht in give_unit.
This commit is contained in:
parent
0dd02dbf72
commit
12946615e5
14
src/give.c
14
src/give.c
|
@ -401,7 +401,7 @@ message * disband_men(int n, unit * u, struct order *ord) {
|
||||||
void give_unit(unit * u, unit * u2, order * ord)
|
void give_unit(unit * u, unit * u2, order * ord)
|
||||||
{
|
{
|
||||||
region *r = u->region;
|
region *r = u->region;
|
||||||
int n = u->number;
|
int maxt = max_transfers();
|
||||||
|
|
||||||
if (!rule_transfermen() && u->faction != u2->faction) {
|
if (!rule_transfermen() && u->faction != u2->faction) {
|
||||||
cmistake(u, ord, 74, MSG_COMMERCE);
|
cmistake(u, ord, 74, MSG_COMMERCE);
|
||||||
|
@ -472,9 +472,11 @@ void give_unit(unit * u, unit * u2, order * ord)
|
||||||
cmistake(u, ord, 105, MSG_COMMERCE);
|
cmistake(u, ord, 105, MSG_COMMERCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (u2->faction->newbies + n > max_transfers()) {
|
if (maxt >= 0 && u->faction != u2->faction) {
|
||||||
cmistake(u, ord, 129, MSG_COMMERCE);
|
if (u2->faction->newbies + u->number > maxt) {
|
||||||
return;
|
cmistake(u, ord, 129, MSG_COMMERCE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (u_race(u) != u2->faction->race) {
|
if (u_race(u) != u2->faction->race) {
|
||||||
if (u2->faction->race != get_race(RC_HUMAN)) {
|
if (u2->faction->race != get_race(RC_HUMAN)) {
|
||||||
|
@ -510,9 +512,9 @@ void give_unit(unit * u, unit * u2, order * ord)
|
||||||
cmistake(u, ord, 156, MSG_COMMERCE);
|
cmistake(u, ord, 156, MSG_COMMERCE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
add_give(u, u2, n, n, get_resourcetype(R_PERSON), ord, 0);
|
add_give(u, u2, u->number, u->number, get_resourcetype(R_PERSON), ord, 0);
|
||||||
u_setfaction(u, u2->faction);
|
u_setfaction(u, u2->faction);
|
||||||
u2->faction->newbies += n;
|
u2->faction->newbies += u->number;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool can_give_to(unit *u, unit *u2) {
|
bool can_give_to(unit *u, unit *u2) {
|
||||||
|
|
|
@ -61,8 +61,14 @@ static void test_give_unit(CuTest * tc) {
|
||||||
env.f2 = test_create_faction(0);
|
env.f2 = test_create_faction(0);
|
||||||
setup_give(&env);
|
setup_give(&env);
|
||||||
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
|
env.r->terrain = test_create_terrain("ocean", SEA_REGION);
|
||||||
|
set_param(&global.parameters, "rules.give.max_men", "0");
|
||||||
|
give_unit(env.src, env.dst, NULL);
|
||||||
|
CuAssertPtrEquals(tc, env.f1, env.src->faction);
|
||||||
|
CuAssertIntEquals(tc, 0, env.f2->newbies);
|
||||||
|
set_param(&global.parameters, "rules.give.max_men", "-1");
|
||||||
give_unit(env.src, env.dst, NULL);
|
give_unit(env.src, env.dst, NULL);
|
||||||
CuAssertPtrEquals(tc, env.f2, env.src->faction);
|
CuAssertPtrEquals(tc, env.f2, env.src->faction);
|
||||||
|
CuAssertIntEquals(tc, 1, env.f2->newbies);
|
||||||
CuAssertPtrEquals(tc, 0, env.f1->units);
|
CuAssertPtrEquals(tc, 0, env.f1->units);
|
||||||
test_cleanup();
|
test_cleanup();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue