diff options
author | Jude Brown <bookofjude@users.sourceforge.net> | 2010-01-17 16:29:09 +1000 |
---|---|---|
committer | Jude Brown <bookofjude@users.sourceforge.net> | 2010-01-17 17:03:26 +1000 |
commit | 7cab36931b74bf99d3c6ee704a7ebf3b54d7a976 (patch) | |
tree | 663b3b75010fa4a3f27dce96095f4e6119d7e0ad /crawl-ref | |
parent | a660d9f8bb8aefeb80345f535d48ea26af865518 (diff) | |
download | crawl-ref-7cab36931b74bf99d3c6ee704a7ebf3b54d7a976.tar.gz crawl-ref-7cab36931b74bf99d3c6ee704a7ebf3b54d7a976.zip |
Convert fprop instances in mapdef.* to unsigned long. (greensnark)
fprop lists, and fprop_spec, now use unsigned long instead of int. This
matches env.pgrid, and means that there won't be size issues in future
when we end up with more feature properties.
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/l_dgn.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.h | 6 |
3 files changed, 16 insertions, 13 deletions
diff --git a/crawl-ref/source/l_dgn.cc b/crawl-ref/source/l_dgn.cc index ff439d5d64..739069e4e4 100644 --- a/crawl-ref/source/l_dgn.cc +++ b/crawl-ref/source/l_dgn.cc @@ -916,7 +916,7 @@ static int dgn_fprop_changed(lua_State *ls) if (lua_isnumber(ls, 3)) prop = static_cast<feature_property_type>(luaL_checkint(ls, 3)); else if (lua_isstring(ls, 3)) - prop = static_cast<feature_property_type>(str_to_fprop(lua_tostring(ls, 3))); + prop = str_to_fprop(lua_tostring(ls, 3)); coord_def pos = coord_def(luaL_checkint(ls, 1), luaL_checkint(ls, 2)); @@ -948,18 +948,14 @@ static int dgn_fprop_at (lua_State *ls) if (lua_isnumber(ls, 3)) prop = static_cast<feature_property_type>(luaL_checkint(ls, 3)); else if (lua_isstring(ls, 3)) - prop = static_cast<feature_property_type>(str_to_fprop(lua_tostring(ls, 3))); + prop = str_to_fprop(lua_tostring(ls, 3)); coord_def pos = coord_def(luaL_checkint(ls, 1), luaL_checkint(ls, 2)); if (in_bounds(pos) && prop != FPROP_NONE) - { lua_pushboolean(ls, testbits(env.pgrid(pos), prop)); - } else - { lua_pushboolean(ls, false); - } return (1); } diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 8f6f2fa02d..02b15e0eac 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -693,9 +693,16 @@ std::string map_lines::add_colour(const std::string &sub) bool map_fprop_list::parse(const std::string &fp, int weight) { - const int fprop = fp == "none" ? FPROP_NONE : str_to_fprop(fp); - if (fprop == -1) + unsigned long fprop; + + if (fp == "nothing") + fprop = FPROP_NONE; + else if (fp.empty()) + return (false); + else if (str_to_fprop(fp) == FPROP_NONE) return false; + else + fprop = str_to_fprop(fp); push_back(map_weighted_fprop(fprop, weight)); return true; @@ -4289,12 +4296,12 @@ int colour_spec::get_colour() ////////////////////////////////////////////////////////////////////////// // fprop_spec -int fprop_spec::get_property() +unsigned long fprop_spec::get_property() { if (fixed_prop != FPROP_NONE) return (fixed_prop); - int chosen = FPROP_NONE; + unsigned long chosen = FPROP_NONE; int cweight = 0; for (int i = 0, size = fprops.size(); i < size; ++i) if (x_chance_in_y(fprops[i].second, cweight += fprops[i].second)) diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index 354109e8a1..a8a237650c 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -155,7 +155,7 @@ public: map_colour_list colours; }; -typedef std::pair<int, int> map_weighted_fprop; +typedef std::pair<unsigned long, int> map_weighted_fprop; class map_fprop_list : public std::vector<map_weighted_fprop> { public: @@ -169,12 +169,12 @@ public: { } - int get_property(); + unsigned long get_property(); public: std::string key; bool fix; - int fixed_prop; + unsigned long fixed_prop; map_fprop_list fprops; }; |