summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/l_los.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-30 14:41:08 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-01 21:45:24 +0100
commita062c664e4802851fba4cc5a001e49a61698f4a3 (patch)
treef5e18d1200bcc501c8444bef3c4c2b1062df3e63 /crawl-ref/source/l_los.cc
parentb456d4c4fa57ab3eebfce79af43efaf457303f7e (diff)
downloadcrawl-ref-a062c664e4802851fba4cc5a001e49a61698f4a3.tar.gz
crawl-ref-a062c664e4802851fba4cc5a001e49a61698f4a3.zip
Adapt l_los.cc to new ray_def and reenable.
Diffstat (limited to 'crawl-ref/source/l_los.cc')
-rw-r--r--crawl-ref/source/l_los.cc55
1 files changed, 27 insertions, 28 deletions
diff --git a/crawl-ref/source/l_los.cc b/crawl-ref/source/l_los.cc
index 5e5d73b168..b8ee71a573 100644
--- a/crawl-ref/source/l_los.cc
+++ b/crawl-ref/source/l_los.cc
@@ -14,8 +14,6 @@
#include "ray.h"
#include "stuff.h"
-#if 0
-
#define RAY_METATABLE "dgn.ray"
void lua_push_ray(lua_State *ls, ray_def *ray)
@@ -38,6 +36,20 @@ LUAFN(los_find_ray)
return (0);
}
+#define VECT(v, p1, p2) \
+ geom::vector v; \
+ v.x = luaL_checknumber(ls, p1); \
+ v.y = luaL_checknumber(ls, p2);
+
+LUAFN(los_make_ray)
+{
+ VECT(s, 1, 2);
+ VECT(d, 3, 4);
+ ray_def *ray = new ray_def(geom::ray(s.x, s.y, d.x, d.y));
+ lua_push_ray(ls, ray);
+ return (1);
+}
+
LUAFN(los_cell_see_cell)
{
COORDS(p, 1, 2);
@@ -45,47 +57,38 @@ LUAFN(los_cell_see_cell)
PLUARET(number, cell_see_cell(p, q));
}
-#endif
-
const struct luaL_reg los_dlib[] =
{
-#if 0
{ "findray", los_find_ray },
+ { "make_ray", los_make_ray },
{ "cell_see_cell", los_cell_see_cell },
-#endif
{ NULL, NULL }
};
-#if 0
#define RAY(ls, n, var) \
ray_def *var = *(ray_def **) luaL_checkudata(ls, n, RAY_METATABLE)
-LUAFN(ray_accx)
-{
- RAY(ls, 1, ray);
- lua_pushnumber(ls, ray->accx);
- return (1);
-}
-
-LUAFN(ray_accy)
+LUAFN(ray_start)
{
RAY(ls, 1, ray);
- lua_pushnumber(ls, ray->accy);
- return (1);
+ lua_pushnumber(ls, ray->r.start.x);
+ lua_pushnumber(ls, ray->r.start.y);
+ return (2);
}
-LUAFN(ray_slope)
+LUAFN(ray_dir)
{
RAY(ls, 1, ray);
- lua_pushnumber(ls, ray->slope);
- return (1);
+ lua_pushnumber(ls, ray->r.dir.x);
+ lua_pushnumber(ls, ray->r.dir.y);
+ return (2);
}
LUAFN(ray_advance)
{
RAY(ls, 1, ray);
- lua_pushnumber(ls, ray->advance());
- return (1);
+ ray->advance();
+ return (0);
}
LUAFN(ray_pos)
@@ -99,18 +102,14 @@ LUAFN(ray_pos)
static const struct luaL_reg ray_dlib[] =
{
- { "accx", ray_accx },
- { "accy", ray_accy },
- { "slope", ray_slope },
+ { "start", ray_start },
+ { "dir", ray_dir },
{ "advance", ray_advance },
{ "pos", ray_pos },
{ NULL, NULL }
};
-#endif
void luaopen_ray(lua_State *ls)
{
-#if 0
clua_register_metatable(ls, RAY_METATABLE, ray_dlib, lua_object_gc<ray_def>);
-#endif
}