summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-19 22:53:57 +0200
committerRobert Vollmert <rvollmert@gmx.net>2009-10-19 22:53:57 +0200
commit5bb58a2e08721ad69df30f5b10af6fef46a4b0d3 (patch)
tree121bb9b21c66aa56f95866b98a88fe80fa3ed315
parent49eb883334f3e7ab343251cdcd161b77cb3ba784 (diff)
downloadcrawl-ref-5bb58a2e08721ad69df30f5b10af6fef46a4b0d3.tar.gz
crawl-ref-5bb58a2e08721ad69df30f5b10af6fef46a4b0d3.zip
Split out crawl_lib from dlua.cc.
Also fix error in previous commit.
-rw-r--r--crawl-ref/source/dlua.cc49
-rw-r--r--crawl-ref/source/dlua.h3
-rw-r--r--crawl-ref/source/l_crawl.cc51
-rw-r--r--crawl-ref/source/makefile.obj1
4 files changed, 56 insertions, 48 deletions
diff --git a/crawl-ref/source/dlua.cc b/crawl-ref/source/dlua.cc
index 7d26c87d24..769a5b1752 100644
--- a/crawl-ref/source/dlua.cc
+++ b/crawl-ref/source/dlua.cc
@@ -1,5 +1,5 @@
/*
- * File: luadgn.cc
+ * File: dlua.cc
* Summary: Dungeon-builder Lua interface.
* Created by: dshaligram on Sat Jun 23 20:02:09 2007 UTC
*/
@@ -23,7 +23,6 @@
#include "hiscores.h"
#include "initfile.h"
#include "items.h"
-#include "l_los.h"
#include "los.h"
#include "mapdef.h"
#include "mapmark.h"
@@ -320,52 +319,6 @@ std::string dlua_chunk::get_chunk_prefix(const std::string &sorig) const
return rewrite_chunk_prefix(sorig, true);
}
-LUAFN(_crawl_args)
-{
- return dlua_stringtable(ls, SysEnv.cmd_args);
-}
-
-LUAFN(_crawl_milestone)
-{
-#ifdef DGL_MILESTONES
- mark_milestone(luaL_checkstring(ls, 1),
- luaL_checkstring(ls, 2));
-#endif
- return (0);
-}
-
-LUAFN(_crawl_redraw_view)
-{
- viewwindow(true, false);
- return (0);
-}
-
-#ifdef UNIX
-LUAFN(_crawl_millis)
-{
- struct timeval tv;
- struct timezone tz;
- const int error = gettimeofday(&tv, &tz);
- if (error)
- luaL_error(ls, make_stringf("Failed to get time: %s",
- strerror(error)).c_str());
-
- lua_pushnumber(ls, tv.tv_sec * 1000 + tv.tv_usec / 1000);
- return (1);
-}
-#endif
-
-static const struct luaL_reg crawl_lib[] =
-{
- { "args", _crawl_args },
- { "mark_milestone", _crawl_milestone },
- { "redraw_view", _crawl_redraw_view },
-#ifdef UNIX
- { "millis", _crawl_millis },
-#endif
- { NULL, NULL }
-};
-
static int file_marshall(lua_State *ls)
{
if (lua_gettop(ls) != 2)
diff --git a/crawl-ref/source/dlua.h b/crawl-ref/source/dlua.h
index f0acccb384..4d3aa4c842 100644
--- a/crawl-ref/source/dlua.h
+++ b/crawl-ref/source/dlua.h
@@ -119,9 +119,12 @@ dgn_event *var = *(dgn_event **) luaL_checkudata(ls, n, DEVENT_METATABLE)
#define MAPMARKER(ls, n, var) \
map_marker *var = *(map_marker **) luaL_checkudata(ls, n, MAPMARK_METATABLE)
+extern const struct luaL_reg crawl_lib[];
extern const struct luaL_reg dgn_lib[];
extern const struct luaL_reg los_lib[];
+void luaopen_ray(lua_State *ls);
+
void register_mapdef_tables(lua_State *ls);
//////////////////////////////////////////////////////////////////////////
diff --git a/crawl-ref/source/l_crawl.cc b/crawl-ref/source/l_crawl.cc
new file mode 100644
index 0000000000..769ce0c768
--- /dev/null
+++ b/crawl-ref/source/l_crawl.cc
@@ -0,0 +1,51 @@
+#include "AppHdr.h"
+#include "dlua.h"
+#include "initfile.h"
+#include "view.h"
+
+LUAFN(_crawl_args)
+{
+ return dlua_stringtable(ls, SysEnv.cmd_args);
+}
+
+LUAFN(_crawl_milestone)
+{
+#ifdef DGL_MILESTONES
+ mark_milestone(luaL_checkstring(ls, 1),
+ luaL_checkstring(ls, 2));
+#endif
+ return (0);
+}
+
+LUAFN(_crawl_redraw_view)
+{
+ viewwindow(true, false);
+ return (0);
+}
+
+#ifdef UNIX
+LUAFN(_crawl_millis)
+{
+ struct timeval tv;
+ struct timezone tz;
+ const int error = gettimeofday(&tv, &tz);
+ if (error)
+ luaL_error(ls, make_stringf("Failed to get time: %s",
+ strerror(error)).c_str());
+
+ lua_pushnumber(ls, tv.tv_sec * 1000 + tv.tv_usec / 1000);
+ return (1);
+}
+#endif
+
+const struct luaL_reg crawl_lib[] =
+{
+{ "args", _crawl_args },
+{ "mark_milestone", _crawl_milestone },
+{ "redraw_view", _crawl_redraw_view },
+#ifdef UNIX
+{ "millis", _crawl_millis },
+#endif
+{ NULL, NULL }
+};
+
diff --git a/crawl-ref/source/makefile.obj b/crawl-ref/source/makefile.obj
index 08e7497bf2..19c7d81b7f 100644
--- a/crawl-ref/source/makefile.obj
+++ b/crawl-ref/source/makefile.obj
@@ -38,6 +38,7 @@ itemprop.o \
items.o \
lev-pand.o \
libutil.o \
+l_crawl.o \
l_dgn.o \
l_los.o \
los.o \