static int lua_destroy_aoi_obj(lua_State *L){ aoi_object* o = lua_touserdata(L,1); if(o->map) aoi_leave(o); del_bitset(o->view_objs); release_luaRef((luaRef_t*)o->ud); free(o->ud); free(o); return 0; }
static int lua_aoi_leave(lua_State *L){ aoi_object* o = lua_touserdata(L,1); if(0 == aoi_leave(o)) lua_pushboolean(L,1); else lua_pushboolean(L,0); return 1; }
int luaAoiLeaveMap(lua_State *L){ struct battlemap *battlemap = (struct battlemap*)lua_touserdata(L,-1); struct aoi_object *aoi_obj = lua_touserdata(L,-2); if(0 == aoi_leave(battlemap->aoi,aoi_obj)){ release_luaObj((luaObject_t)aoi_obj->ud); free(aoi_obj); PUSH_BOOL(L,1); }else PUSH_BOOL(L,0); return 1; }