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, u:get_potion("peasantblood")) -- unit uses one peasantblood effect
assert_equal(99, u2:get_potion("peasantblood")) -- u2 uses its own effect before u's assert_equal(99, u2:get_potion("peasantblood")) -- u2 uses its own effect before u's
end 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: case K_CAST:
/* dient dazu, das neben Zaubern kein weiterer Befehl /* dient dazu, das neben Zaubern kein weiterer Befehl
* ausgeführt werden kann, Zaubern ist ein kurzer Befehl */ * ausgeführt werden kann, Zaubern ist ein kurzer Befehl */
set_order(&u->thisorder, NULL); set_order(&u->thisorder, copy_order(ord));
break; break;
default: default:

View File

@ -2743,13 +2743,15 @@ void magic(void)
continue; continue;
} }
for (ord = u->orders; ord; ord = ord->next) { if (u->thisorder != NULL) {
if (get_keyword(ord) == K_CAST) { for (ord = u->orders; ord; ord = ord->next) {
castorder *co = cast_cmd(u, ord); if (get_keyword(ord) == K_CAST) {
fset(u, UFL_LONGACTION | UFL_NOTMOVING); castorder *co = cast_cmd(u, ord);
if (co) { fset(u, UFL_LONGACTION | UFL_NOTMOVING);
const spell *sp = co->sp; if (co) {
add_castorder(&spellranks[sp->rank], co); const spell *sp = co->sp;
add_castorder(&spellranks[sp->rank], co);
}
} }
} }
} }

View File

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