summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/l_dgn.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-10-20 10:15:35 +0200
committerRobert Vollmert <rvollmert@gmx.net>2009-10-20 10:15:35 +0200
commit29aa709171aebafc39ed2074983d0f1976583baa (patch)
treebd67f59231eb02db05daa794829e303e87012b56 /crawl-ref/source/l_dgn.cc
parent40c9bc160056918a6807b986d951dba707e33338 (diff)
downloadcrawl-ref-29aa709171aebafc39ed2074983d0f1976583baa.tar.gz
crawl-ref-29aa709171aebafc39ed2074983d0f1976583baa.zip
Split level and branch functions out of l_dgn.cc.
Diffstat (limited to 'crawl-ref/source/l_dgn.cc')
-rw-r--r--crawl-ref/source/l_dgn.cc148
1 files changed, 3 insertions, 145 deletions
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc
index 7d65aa1ec5..994d44c75a 100644
--- a/crawl-ref/source/l_dgn.cc
+++ b/crawl-ref/source/l_dgn.cc
@@ -1916,137 +1916,6 @@ LUAFN(dgn_with_map_anchors)
return (1);
}
-#define BRANCH(br, pos) \
-const char *branch_name = luaL_checkstring(ls, pos); \
-branch_type req_branch_type = str_to_branch(branch_name); \
-if (req_branch_type == NUM_BRANCHES) \
-luaL_error(ls, "Expected branch name"); \
-Branch &br = branches[req_branch_type]
-
-#define BRANCHFN(name, type, expr) \
-LUAFN(dgn_br_##name) { \
-BRANCH(br, 1); \
-PLUARET(type, expr); \
-}
-
-BRANCHFN(floorcol, number, br.floor_colour)
-BRANCHFN(rockcol, number, br.rock_colour)
-BRANCHFN(has_shops, boolean, br.has_shops)
-BRANCHFN(has_uniques, boolean, br.has_uniques)
-BRANCHFN(parent_branch, string,
- br.parent_branch == NUM_BRANCHES ? ""
- : branches[br.parent_branch].abbrevname)
-
-static void push_level_id(lua_State *ls, const level_id &lid)
-{
- // We're skipping the constructor; naughty, but level_id has no
- // virtual methods and no dynamically allocated memory.
- level_id *nlev =
- static_cast<level_id*>(lua_newuserdata(ls, sizeof(level_id)));
- *nlev = lid;
-}
-
-static level_id _lua_level_id(lua_State *ls, int ndx)
-{
- if (lua_isstring(ls, ndx))
- {
- const char *s = lua_tostring(ls, 1);
- try
- {
- return level_id::parse_level_id(s);
- }
- catch (const std::string &err)
- {
- luaL_error(ls, err.c_str());
- }
- }
- else if (lua_isuserdata(ls, ndx))
- {
- const level_id *lid = static_cast<level_id*>(lua_touserdata(ls, ndx));
- return (*lid);
- }
-
- luaL_argerror(ls, ndx, "Expected level_id");
- // Never gets here.
- return level_id();
-}
-
-LUAFN(dgn_level_id)
-{
- const int nargs = lua_gettop(ls);
- if (!nargs)
- push_level_id(ls, level_id::current());
- else if (nargs == 1)
- push_level_id(ls, _lua_level_id(ls, 1));
- return (1);
-}
-
-LUAFN(dgn_level_name)
-{
- const level_id lid(_lua_level_id(ls, 1));
- lua_pushstring(ls, lid.describe().c_str());
- return (1);
-}
-
-LUAFN(dgn_set_level_type_name)
-{
- if (you.level_type != LEVEL_PORTAL_VAULT)
- {
- luaL_error(ls, "Can only set level type name on portal vaults");
- return(0);
- }
-
- if (!lua_isstring(ls, 1))
- {
- luaL_argerror(ls, 1, "Expected string for level type name");
- return(0);
- }
-
- you.level_type_name = luaL_checkstring(ls, 1);
-
- return(0);
-}
-
-LUAFN(dgn_set_level_type_name_abbrev)
-{
- if (you.level_type != LEVEL_PORTAL_VAULT)
- {
- luaL_error(ls, "Can only set level type name abbreviation on "
- "portal vaults");
- return(0);
- }
-
- if (!lua_isstring(ls, 1))
- {
- luaL_argerror(ls, 1, "Expected string for level type name "
- "abbreviation");
- return(0);
- }
-
- you.level_type_name_abbrev = luaL_checkstring(ls, 1);
-
- return(0);
-}
-
-LUAFN(dgn_set_level_type_origin)
-{
- if (you.level_type != LEVEL_PORTAL_VAULT)
- {
- luaL_error(ls, "Can only set level type origin on portal vaults");
- return(0);
- }
-
- if (!lua_isstring(ls, 1))
- {
- luaL_argerror(ls, 1, "Expected string for level type origin");
- return(0);
- }
-
- you.level_type_origin = luaL_checkstring(ls, 1);
-
- return(0);
-}
-
static int _lua_push_map(lua_State *ls, const map_def *map)
{
if (map)
@@ -2068,17 +1937,17 @@ LUAFN(dgn_map_by_tag)
LUAFN(dgn_map_in_depth)
{
- const level_id lid = _lua_level_id(ls, 1);
+ const level_id lid = dlua_level_id(ls, 1);
const bool mini = _lua_boolean(ls, 2, true);
return _lua_push_map(ls, random_map_in_depth(lid, mini));
}
LUAFN(dgn_map_by_place)
{
- const level_id lid = _lua_level_id(ls, 1);
+ const level_id lid = dlua_level_id(ls, 1);
const bool mini = _lua_boolean(ls, 2, false);
return _lua_push_map(ls, random_map_for_place(lid, mini));
-}
+}
LUAFN(_dgn_place_map)
{
@@ -2331,17 +2200,6 @@ const struct luaL_reg dgn_lib[] =
{ "with_map_bounds_fn", dgn_with_map_bounds_fn },
{ "with_map_anchors", dgn_with_map_anchors },
-{ "br_floorcol", dgn_br_floorcol },
-{ "br_rockcol", dgn_br_rockcol },
-{ "br_has_shops", dgn_br_has_shops },
-{ "br_has_uniques", dgn_br_has_uniques },
-{ "br_parent_branch", dgn_br_parent_branch },
-
-{ "level_id", dgn_level_id },
-{ "level_name", dgn_level_name },
-{ "set_level_type_name", dgn_set_level_type_name },
-{ "set_level_type_name_abbrev", dgn_set_level_type_name_abbrev },
-{ "set_level_type_origin", dgn_set_level_type_origin },
{ "map_by_tag", dgn_map_by_tag },
{ "map_in_depth", dgn_map_in_depth },
{ "map_by_place", dgn_map_by_place },