summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc105
1 files changed, 99 insertions, 6 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index bc62c32151..91243e8c2e 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -2,7 +2,7 @@
* File: mapdef.cc
* Summary: Support code for Crawl des files.
*
- * Modified for Crawl Reference by $Author: dshaligram $ on $Date: 2007-06-30T15:49:18.688054Z $
+ * Modified for Crawl Reference by $Author$ on $Date$
*/
#include <iostream>
@@ -1158,7 +1158,8 @@ map_def::map_def()
: name(), tags(), place(), depths(), orient(), chance(),
welcome_messages(), map(), mons(), items(), keyspecs(),
prelude("dlprelude"), main("dlmain"), validate("dlvalidate"),
- veto("dlveto"), index_only(false), cache_offset(0L)
+ veto("dlveto"), rock_colour(BLACK), floor_colour(BLACK),
+ index_only(false), cache_offset(0L)
{
init();
}
@@ -1182,8 +1183,13 @@ void map_def::reinit()
{
items.clear();
keyspecs.clear();
+ level_flags.clear();
+ branch_flags.clear();
+
welcome_messages.clear();
+ rock_colour = floor_colour = BLACK;
+
// Base chance; this is not a percentage.
chance = 10;
@@ -1446,19 +1452,19 @@ std::string map_def::validate_map_def()
switch (orient)
{
case MAP_NORTH: case MAP_SOUTH:
- if (map.height() >= GYM * 2 / 3)
+ if (map.height() > GYM * 2 / 3)
return make_stringf("Map too large - height %d (max %d)",
map.height(), GYM * 2 / 3);
break;
case MAP_EAST: case MAP_WEST:
- if (map.width() >= GXM * 2 / 3)
+ if (map.width() > GXM * 2 / 3)
return make_stringf("Map too large - width %d (max %d)",
map.width(), GXM * 2 / 3);
break;
case MAP_NORTHEAST: case MAP_SOUTHEAST:
case MAP_NORTHWEST: case MAP_SOUTHWEST:
case MAP_FLOAT:
- if (map.width() >= GXM * 2 / 3 || map.height() > GYM * 2 / 3)
+ if (map.width() > GXM * 2 / 3 || map.height() > GYM * 2 / 3)
return make_stringf("Map too large - %dx%d (max %dx%d)",
map.width(), map.height(),
GXM * 2 / 3, GYM * 2 / 3);
@@ -1739,6 +1745,12 @@ bool map_def::has_tag_suffix(const std::string &suffix) const
&& tags.find(suffix + " ") != std::string::npos;
}
+const keyed_mapspec *map_def::mapspec_for_key(int key) const
+{
+ keyed_specs::const_iterator i = keyspecs.find(key);
+ return i != keyspecs.end()? &i->second : NULL;
+}
+
keyed_mapspec *map_def::mapspec_for_key(int key)
{
keyed_specs::iterator i = keyspecs.find(key);
@@ -1776,6 +1788,11 @@ std::string map_def::add_key_mons(const std::string &s)
return add_key_field(s, &keyed_mapspec::set_mons);
}
+std::string map_def::add_key_mask(const std::string &s)
+{
+ return add_key_field(s, &keyed_mapspec::set_mask);
+}
+
std::vector<std::string> map_def::get_shuffle_strings() const
{
return map.get_shuffle_strings();
@@ -2505,6 +2522,55 @@ std::string map_marker_spec::describe() const
}
//////////////////////////////////////////////////////////////////////////
+// map_flags
+map_flags::map_flags()
+ : flags_set(0), flags_unset(0)
+{
+}
+
+void map_flags::clear()
+{
+ flags_set = flags_unset = 0;
+}
+
+typedef std::map<std::string, unsigned long> flag_map;
+
+map_flags map_flags::parse(const std::string flag_list[],
+ const std::string &s) throw(std::string)
+{
+ map_flags mf;
+
+ const std::vector<std::string> segs = split_string("/", s);
+
+ flag_map flag_vals;
+ for (int i = 0; flag_list[i] != ""; i++)
+ flag_vals[flag_list[i]] = 1 << i;
+
+ for (int i = 0, size = segs.size(); i < size; i++)
+ {
+ std::string flag = segs[i];
+ bool negate = false;
+
+ if (flag[0] == '!')
+ {
+ flag = flag.substr(1);
+ negate = true;
+ }
+
+ flag_map::const_iterator val = flag_vals.find(flag);
+ if (val == flag_vals.end())
+ throw make_stringf("Unknown flag: '%s'", flag.c_str());
+
+ if (negate)
+ mf.flags_unset |= val->second;
+ else
+ mf.flags_set |= val->second;
+ }
+
+ return mf;
+}
+
+//////////////////////////////////////////////////////////////////////////
// keyed_mapspec
keyed_mapspec::keyed_mapspec()
@@ -2631,9 +2697,31 @@ std::string keyed_mapspec::set_item(const std::string &s, bool fix)
return (err);
}
+std::string keyed_mapspec::set_mask(const std::string &s, bool garbage)
+{
+ UNUSED(garbage);
+
+ err.clear();
+
+ try
+ {
+ static std::string flag_list[] =
+ {"vault", "no_item_gen", "no_monster_gen", "no_pool_fixup",
+ "no_secret_doors", "opaque", ""};
+ map_mask = map_flags::parse(flag_list, s);
+ }
+ catch (const std::string &error)
+ {
+ err = error;
+ return (err);
+ }
+
+ return (err);
+}
+
feature_spec keyed_mapspec::get_feat()
{
- return feat.get_feat(key_glyph);
+ return feat.get_feat('.');
}
mons_list &keyed_mapspec::get_monsters()
@@ -2646,6 +2734,11 @@ item_list &keyed_mapspec::get_items()
return (item);
}
+map_flags &keyed_mapspec::get_mask()
+{
+ return (map_mask);
+}
+
//////////////////////////////////////////////////////////////////////////
// feature_slot