summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapmark.cc
diff options
context:
space:
mode:
authorDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-30 15:46:55 +0530
committerDarshan Shaligram <dshaligram@users.sourceforge.net>2009-10-31 22:16:46 +0530
commitad11744e5d49d226fc9c77ed48c3dd8b97921350 (patch)
treec4334fd1e6b4b052ac93593f9021f12c9f10baac /crawl-ref/source/mapmark.cc
parent23f8631266eac1a7b4b4727b26a5fc088a6f0184 (diff)
downloadcrawl-ref-ad11744e5d49d226fc9c77ed48c3dd8b97921350.tar.gz
crawl-ref-ad11744e5d49d226fc9c77ed48c3dd8b97921350.zip
lmark.synchronized_markers(): apply one marker's effects to multiple points simultaneously.
synchronized_markers() takes a marker, and a list of method names to override, and returns a set of markers that fire simultaneously, to allow, say, fog machines that fire at random intervals, but always fire in unison. lm_mslav.lua has details. volcano.des has an example volcano entry vault that uses this. Allow fetching a list of Lua markers/marker positions by property value. Renamed dgn.find_marker_prop -> dgn.find_marker_position_by_prop. s/helper/listener/ for fog machine listeners.
Diffstat (limited to 'crawl-ref/source/mapmark.cc')
-rw-r--r--crawl-ref/source/mapmark.cc53
1 files changed, 48 insertions, 5 deletions
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index 253855eb23..e7d3abf65a 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -824,16 +824,59 @@ bool feature_marker_at(const coord_def &pos, dungeon_feature_type feat)
return (false);
}
-const coord_def find_marker_prop(const std::string &prop,
- const std::string &expected)
+coord_def find_marker_position_by_prop(const std::string &prop,
+ const std::string &expected)
{
+ const std::vector<coord_def> markers =
+ find_marker_positions_by_prop(prop, expected, 1);
+ if (markers.empty())
+ {
+ const coord_def nowhere(-1, -1);
+ return (nowhere);
+ }
+ return markers[0];
+}
+
+std::vector<coord_def> find_marker_positions_by_prop(
+ const std::string &prop,
+ const std::string &expected,
+ unsigned maxresults)
+{
+ std::vector<coord_def> marker_positions;
for (rectangle_iterator i(0, 0); i; ++i)
{
const std::string value =
env.markers.property_at(*i, MAT_ANY, prop);
if (!value.empty() && (expected.empty() || value == expected))
- return (*i);
+ {
+ marker_positions.push_back(*i);
+ if (maxresults && marker_positions.size() >= maxresults)
+ return (marker_positions);
+ }
+ }
+ return (marker_positions);
+}
+
+std::vector<map_marker*> find_markers_by_prop(
+ const std::string &prop,
+ const std::string &expected,
+ unsigned maxresults)
+{
+ std::vector<map_marker*> markers;
+ for (rectangle_iterator pos(0, 0); pos; ++pos)
+ {
+ const std::vector<map_marker*> markers_here =
+ env.markers.get_markers_at(*pos);
+ for (unsigned i = 0, size = markers_here.size(); i < size; ++i)
+ {
+ const std::string value(markers_here[i]->property(prop));
+ if (!value.empty() && (expected.empty() || value == expected))
+ {
+ markers.push_back(markers_here[i]);
+ if (maxresults && markers.size() >= maxresults)
+ return (markers);
+ }
+ }
}
- const coord_def nowhere(-1, -1);
- return (nowhere);
+ return (markers);
}