summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/l_dgn.cc
diff options
context:
space:
mode:
authorJude Brown <bookofjude@users.sourceforge.net>2009-11-14 19:23:39 +1000
committerJude Brown <bookofjude@users.sourceforge.net>2009-11-14 19:31:11 +1000
commitdbc4e4df085f487c0bc03364ec5c62778b064fdd (patch)
treeafb000de88f20248329a4888767995573f99a3e7 /crawl-ref/source/l_dgn.cc
parent550af32eec0e42c1c8e3228221914934d20c3244 (diff)
downloadcrawl-ref-dbc4e4df085f487c0bc03364ec5c62778b064fdd.tar.gz
crawl-ref-dbc4e4df085f487c0bc03364ec5c62778b064fdd.zip
Provide sanity checking for set_border_fill_type.
On second thoughts, while an endless milieu of Trog altars sounds nice, limit it to walls, lava, water and trees.
Diffstat (limited to 'crawl-ref/source/l_dgn.cc')
-rw-r--r--crawl-ref/source/l_dgn.cc17
1 files changed, 14 insertions, 3 deletions
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc
index 39a12b9051..fa32c9da4d 100644
--- a/crawl-ref/source/l_dgn.cc
+++ b/crawl-ref/source/l_dgn.cc
@@ -896,17 +896,28 @@ static int lua_dgn_set_lt_callback(lua_State *ls)
return (0);
}
+bool _valid_border_feat (dungeon_feature_type feat)
+{
+ return ((feat <= DNGN_MAXWALL && feat >= DNGN_MINWALL)
+ || (feat == DNGN_TREES || feat == DNGN_OPEN_SEA
+ || feat == DNGN_LAVA || feat == DNGN_DEEP_WATER
+ || feat == DNGN_SHALLOW_WATER || feat == DNGN_FLOOR));
+}
+
static int lua_dgn_set_border_fill_type (lua_State *ls)
{
MAP(ls, 1, map);
if (lua_gettop(ls) != 2)
luaL_error(ls, "set_border_fill_type requires a feature.");
- dungeon_feature_type fill_type =
- dungeon_feature_by_name(luaL_checkstring(ls, 2));
+ std::string fill_string = luaL_checkstring(ls, 2);
+ dungeon_feature_type fill_type = dungeon_feature_by_name(fill_string);
- if (fill_type != DNGN_UNSEEN)
+ if (_valid_border_feat(fill_type))
map->border_fill_type = fill_type;
+ else
+ luaL_error(ls, ("set_border_fill_type cannot be the feature '" +
+ fill_string +"'.").c_str());
return (0);
}