forked from github/server
create_teleport_plane hat regionen erzeugt, die nicht im Astralraum liegen.
Lua-binding kriegt eine methode region.remove um regionen zu entfernen
This commit is contained in:
parent
df26ef19be
commit
f15e8526b7
|
@ -1820,13 +1820,11 @@ sp_treewalkenter(castorder *co)
|
|||
}
|
||||
|
||||
rt = r_standard_to_astral(r);
|
||||
if(!rt || is_cursed(rt->attribs, C_ASTRALBLOCK, 0)) {
|
||||
if (rt==NULL || is_cursed(rt->attribs, C_ASTRALBLOCK, 0)) {
|
||||
cmistake(mage, co->order, 192, MSG_MAGIC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
assert(rt != NULL);
|
||||
|
||||
remaining_cap = (int)(power * 500);
|
||||
|
||||
/* fuer jede Einheit */
|
||||
|
|
|
@ -55,7 +55,9 @@ real2tp(int rk) {
|
|||
|
||||
static region *
|
||||
tpregion(const region *r) {
|
||||
return findregion(TE_CENTER_X+real2tp(r->x), TE_CENTER_Y+real2tp(r->y));
|
||||
region * rt = findregion(TE_CENTER_X+real2tp(r->x), TE_CENTER_Y+real2tp(r->y));
|
||||
if (rplane(rt) != get_astralplane()) return NULL;
|
||||
return rt;
|
||||
}
|
||||
|
||||
region_list *
|
||||
|
@ -93,7 +95,7 @@ r_standard_to_astral(const region *r)
|
|||
if (rplane(r) != get_normalplane()) return NULL;
|
||||
|
||||
r2 = tpregion(r);
|
||||
if (rplane(r2) != get_astralplane() || rterrain(r2) != T_ASTRAL) return NULL;
|
||||
if (rterrain(r2) != T_ASTRAL) return NULL;
|
||||
|
||||
return r2;
|
||||
}
|
||||
|
@ -194,7 +196,7 @@ create_teleport_plane(void)
|
|||
* Region gemacht wird.
|
||||
*/
|
||||
|
||||
for (r=regions;r;r=r->next) if(r->planep == NULL) {
|
||||
for (r=regions;r;r=r->next) if (r->planep == NULL) {
|
||||
region *ra = tpregion(r);
|
||||
if (ra==NULL) {
|
||||
ra = new_region(TE_CENTER_X+real2tp(r->x), TE_CENTER_Y+real2tp(r->y));
|
||||
|
|
|
@ -165,6 +165,35 @@ region_adddirection(region& r, region &rt, const char * name, const char * info)
|
|||
sd->active = 1;
|
||||
}
|
||||
|
||||
static void
|
||||
region_remove(region& r)
|
||||
{
|
||||
region ** rp = ®ions;
|
||||
while (*rp) {
|
||||
if (*rp==&r) {
|
||||
unit * u;
|
||||
for (u=r.units;u;u=u->next) {
|
||||
destroy_unit(u);
|
||||
}
|
||||
*rp = r.next;
|
||||
#ifdef FAST_CONNECT
|
||||
direction_t dir;
|
||||
for (dir=0;dir!=MAXDIRECTIONS;++dir) {
|
||||
region * rn = r.connect[dir];
|
||||
if (rn) {
|
||||
direction_t reldir = reldirection(rn, &r);
|
||||
r.connect[dir] = NULL;
|
||||
rn->connect[reldir] = NULL;
|
||||
}
|
||||
}
|
||||
assert (dir>=0 && dir<MAXDIRECTIONS);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
rp = &(*rp)->next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
bind_region(lua_State * L)
|
||||
{
|
||||
|
@ -185,6 +214,8 @@ bind_region(lua_State * L)
|
|||
.def("get_flag", ®ion_getflag)
|
||||
.def("set_flag", ®ion_setflag)
|
||||
|
||||
.def("remove", ®ion_remove)
|
||||
|
||||
.def("get_road", ®ion_getroad)
|
||||
.def("set_road", ®ion_setroad)
|
||||
|
||||
|
|
|
@ -52,10 +52,6 @@ function process(orders)
|
|||
-- load scripts:
|
||||
run_scripts()
|
||||
|
||||
u = get_unit(atoi36("50ki"))
|
||||
if u~=nil then
|
||||
u.region:set_flag(14, true)
|
||||
end
|
||||
--
|
||||
process_orders()
|
||||
|
||||
|
|
Loading…
Reference in New Issue