forked from github/server
fetch_astral braucht astralregions eigentlich nicht.
This commit is contained in:
parent
237ec44ea0
commit
24552613c8
|
@ -15,16 +15,20 @@ end
|
|||
|
||||
function test_fetch_astral()
|
||||
local r = region.create(0, 0, "plain")
|
||||
local ra = r:get_astral('fog')
|
||||
local rb = region.create(ra.x + 1, ra.y, 'fog')
|
||||
local f = faction.create("human")
|
||||
local u1 = unit.create(f, r, 1)
|
||||
local u2 = unit.create(f, r, 1)
|
||||
local u3 = unit.create(f, rb, 1)
|
||||
rb.plane = ra.plane
|
||||
u1.magic = "gray"
|
||||
u1:set_skill("magic", 6)
|
||||
u1.aura = 0
|
||||
u1:add_spell("fetch_astral")
|
||||
|
||||
u1:clear_orders()
|
||||
u1:add_order("ZAUBERE Ruf~der~Realitaet " .. itoa36(u2.id))
|
||||
u1:add_order("ZAUBERE Ruf~der~Realitaet " .. itoa36(u2.id) .. " " .. itoa36(u3.id))
|
||||
process_orders()
|
||||
assert_equal(1, f:count_msg_type('missing_components_list'), 'no components')
|
||||
|
||||
|
@ -33,10 +37,11 @@ function test_fetch_astral()
|
|||
assert_equal(12, u1.aura)
|
||||
assert_equal(1, f:count_msg_type('spellfail_astralonly'), 'astral space')
|
||||
|
||||
u2.region = u2.region:get_astral('fog')
|
||||
u2.region = ra
|
||||
process_orders()
|
||||
assert_equal(0, u1.aura)
|
||||
assert_equal(u1.region, u2.region)
|
||||
assert_equal(r, u2.region)
|
||||
assert_equal(rb, u3.region)
|
||||
end
|
||||
|
||||
function test_pull_astral()
|
||||
|
|
|
@ -114,6 +114,14 @@ static int tolua_region_get_plane(lua_State * L)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int tolua_region_set_plane(lua_State * L)
|
||||
{
|
||||
region *r = (region *)tolua_tousertype(L, 1, NULL);
|
||||
plane *pl = (plane *)tolua_tousertype(L, 2, NULL);
|
||||
r->_plane = pl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tolua_region_get_terrain(lua_State * L)
|
||||
{
|
||||
region *self = (region *)tolua_tousertype(L, 1, NULL);
|
||||
|
@ -768,7 +776,8 @@ void tolua_region_open(lua_State * L)
|
|||
tolua_variable(L, TOLUA_CAST "id", tolua_region_get_id, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "x", tolua_region_get_x, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "y", tolua_region_get_y, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "plane", tolua_region_get_plane, NULL);
|
||||
tolua_variable(L, TOLUA_CAST "plane", tolua_region_get_plane,
|
||||
tolua_region_set_plane);
|
||||
tolua_variable(L, TOLUA_CAST "name", tolua_region_get_name,
|
||||
tolua_region_set_name);
|
||||
tolua_variable(L, TOLUA_CAST "morale", tolua_region_get_morale,
|
||||
|
|
13
src/spells.c
13
src/spells.c
|
@ -5283,7 +5283,6 @@ int sp_fetchastral(castorder * co)
|
|||
spellparameter *pa = co->par;
|
||||
double power = co->force;
|
||||
int remaining_cap = (int)((power - 3) * 1500);
|
||||
region_list *rtl = NULL;
|
||||
region *rt = co_get_region(co); /* region to which we are fetching */
|
||||
region *ro = NULL; /* region in which the target is */
|
||||
|
||||
|
@ -5305,21 +5304,13 @@ int sp_fetchastral(castorder * co)
|
|||
if (u->region != ro) {
|
||||
/* this can happen several times if the units are from different astral
|
||||
* regions. Only possible on the intersections of schemes */
|
||||
region_list *rfind;
|
||||
if (!is_astral(u->region)) {
|
||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||
"spellfail_astralonly", ""));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (rtl != NULL)
|
||||
free_regionlist(rtl);
|
||||
rtl = astralregions(u->region, NULL);
|
||||
for (rfind = rtl; rfind != NULL; rfind = rfind->next) {
|
||||
if (rfind->data == mage->region)
|
||||
break;
|
||||
}
|
||||
if (rfind == NULL) {
|
||||
if (r_standard_to_astral(mage->region) != u->region) {
|
||||
/* the region r is not in the schemes of rt */
|
||||
ADDMSG(&mage->faction->msgs, msg_feedback(mage, co->order,
|
||||
"spellfail_distance", "target", u));
|
||||
|
@ -5401,8 +5392,6 @@ int sp_fetchastral(castorder * co)
|
|||
if (m)
|
||||
msg_release(m);
|
||||
}
|
||||
if (rtl != NULL)
|
||||
free_regionlist(rtl);
|
||||
return cast_level;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue