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.cc25
1 files changed, 19 insertions, 6 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 0f8b161c2b..5e46f86774 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -1046,17 +1046,25 @@ coord_def map_lines::find_first_glyph(int gly) const
{
for (int y = 0, h = height(); y < h; ++y)
{
- for (int x = 0, w = width(); x < w; ++x)
- {
- const coord_def c(x, y);
- if ((*this)(c) == gly)
- return (c);
- }
+ std::string::size_type pos = lines[y].find(gly);
+ if (pos != std::string::npos)
+ return coord_def(pos, y);
}
return coord_def(-1, -1);
}
+coord_def map_lines::find_first_glyph(const std::string &glyphs) const
+{
+ for (int y = 0, h = height(); y < h; ++y)
+ {
+ std::string::size_type pos = lines[y].find_first_of(glyphs);
+ if (pos != std::string::npos)
+ return coord_def(pos, y);
+ }
+ return coord_def(-1, -1);
+}
+
///////////////////////////////////////////////
// dlua_set_map
@@ -1172,6 +1180,11 @@ coord_def map_def::find_first_glyph(int glyph) const
return map.find_first_glyph(glyph);
}
+coord_def map_def::find_first_glyph(const std::string &s) const
+{
+ return map.find_first_glyph(s);
+}
+
void map_def::write_index(FILE *outf) const
{
if (!cache_offset)