fixed bug #1879: CAST should not prevent FOLLOW UNIT

This commit is contained in:
Steffen Mecke 2012-07-25 22:35:30 +02:00
parent 72579b0272
commit b02f275582
4 changed files with 30 additions and 9 deletions

View File

@ -1171,3 +1171,21 @@ function test_bug_1875_use_own_first()
assert_equal(99, u:get_potion("peasantblood")) -- unit uses one peasantblood effect
assert_equal(99, u2:get_potion("peasantblood")) -- u2 uses its own effect before u's
end
function test_bug_1879_follow_unit()
local r = region.create(0, 0, "plain")
local r1 = region.create(1, 0, "plain")
local f = faction.create("noreply@eressea.de", "human", "de")
local u1, u2 = two_units(r, f, f)
u1:clear_orders()
u1:set_skill("magic", 10)
u1:add_order("ZAUBERE STUFE 1 Kleine Flüche")
u1:add_order("FOLGEN EINHEIT " .. itoa36(u2.id))
u2:clear_orders()
u2:add_order("NACH o")
process_orders()
assert_equal(u1.region.id, r1.id)
assert_equal(u2.region.id, r1.id)
end

View File

@ -3711,7 +3711,7 @@ void update_long_order(unit * u)
case K_CAST:
/* dient dazu, das neben Zaubern kein weiterer Befehl
* ausgeführt werden kann, Zaubern ist ein kurzer Befehl */
set_order(&u->thisorder, NULL);
set_order(&u->thisorder, copy_order(ord));
break;
default:

View File

@ -2743,6 +2743,7 @@ void magic(void)
continue;
}
if (u->thisorder != NULL) {
for (ord = u->orders; ord; ord = ord->next) {
if (get_keyword(ord) == K_CAST) {
castorder *co = cast_cmd(u, ord);
@ -2755,6 +2756,7 @@ void magic(void)
}
}
}
}
/* Da sich die Aura und Komponenten in der Zwischenzeit verändert
* haben können und sich durch vorherige Sprüche das Zaubern

View File

@ -2697,12 +2697,13 @@ void follow_unit(unit * u)
attrib *a2 = a_find(u2->attribs, &at_follow);
if (a2 != NULL) {
unit *u3 = a2->data.v;
follow = (u3 && u2->region == u2->region);
follow = (u3 && u2->region == u3->region);
}
}
if (follow) {
fset(u, UFL_FOLLOWING);
fset(u2, UFL_FOLLOWED);
/* FOLLOW unit on a (potentially) moving unit prevents long orders */
set_order(&u->thisorder, NULL);
}
}