summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 08:55:18 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-09-19 08:55:18 +0000
commitae6c83ec9f0273d13ad57f1382528d7715189a2b (patch)
tree2a09386686dc53e703cf1a6ce4b25acd069b3017 /crawl-ref/source/mapdef.cc
parent4958b84b497fe729eaf14bc90b8d01874722c33d (diff)
downloadcrawl-ref-ae6c83ec9f0273d13ad57f1382528d7715189a2b.tar.gz
crawl-ref-ae6c83ec9f0273d13ad57f1382528d7715189a2b.zip
This change moves the logic for when a level or branch prohibits
teleport control from the C++ code into the vault .des files. This is done with the additions of two things: * Changeable, persistent per-level and per-branch flags which affect game play. * Dungeon events for the killing of monsters, picking up of objects and changing of features. The current level and branch flags are for teleport control prevention, making a level unmappable (like the Abyss or a Labyrinth), and preventing magic mapping from working (like the Abyss or a Labyrinth). Some related changes: * The new .des header KMASK allows for dungeon grid masks like no_monster_gen to be applied to specific symbols rather than the entire vault. * If the wizard mapping command (&{) is used in a place which is unmappable, it will ask if you wish to force the area to be mappable (so you can see what an entire Labyrinth or Abyss level looks like without having to hack the source). * A new wizard-mode level-map command, 'T', will teleport the player to wherever the cursor is pointing. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2146 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc82
1 files changed, 82 insertions, 0 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index f661c6f18a..28fc83fd57 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -1606,6 +1606,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);
@@ -1643,6 +1649,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();
@@ -2351,6 +2362,50 @@ map_transformer *map_marker_spec::clone() const
}
//////////////////////////////////////////////////////////////////////////
+// map_flags
+map_flags::map_flags()
+ : flags_set(0), 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()
@@ -2477,6 +2532,28 @@ 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);
@@ -2492,6 +2569,11 @@ item_list &keyed_mapspec::get_items()
return (item);
}
+map_flags &keyed_mapspec::get_mask()
+{
+ return (map_mask);
+}
+
//////////////////////////////////////////////////////////////////////////
// feature_slot