diff options
author | Adam Borowski <kilobyte@angband.pl> | 2012-06-27 21:17:23 +0200 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2012-06-27 21:18:07 +0200 |
commit | 220f4c71f4fb4ae9a037a22f95340695ded24ccc (patch) | |
tree | 87c731912dde74a3612057167b36c1ba997dc5b6 /crawl-ref/source/libutil.cc | |
parent | e9b324beba2d43a455b3955561a53f20ceb69391 (diff) | |
download | crawl-ref-220f4c71f4fb4ae9a037a22f95340695ded24ccc.tar.gz crawl-ref-220f4c71f4fb4ae9a037a22f95340695ded24ccc.zip |
<webtiles> and <localtiles> tags.
Diffstat (limited to 'crawl-ref/source/libutil.cc')
-rw-r--r-- | crawl-ref/source/libutil.cc | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc index 4565594b49..9fdd396066 100644 --- a/crawl-ref/source/libutil.cc +++ b/crawl-ref/source/libutil.cc @@ -890,38 +890,39 @@ bool version_is_stable(const char *v) } } -std::string untag_tiles_console(std::string s) +static void inline _untag(std::string &s, const std::string pre, + const std::string post, bool onoff) { size_t p = 0; - while ((p = s.find("<tiles>", p)) != std::string::npos) + while ((p = s.find(pre, p)) != std::string::npos) { - size_t q = s.find("</tiles>", p); + size_t q = s.find(post, p); if (q == std::string::npos) q = s.length(); if (is_tiles()) { - s.erase(q, 8); - s.erase(p, 7); - } - else - s.erase(p, q + 8 - p); - } - - p = 0; - while ((p = s.find("<console>", p)) != std::string::npos) - { - size_t q = s.find("</console>", p); - if (q == std::string::npos) - q = s.length(); - if (!is_tiles()) - { - s.erase(q, 10); - s.erase(p, 9); + s.erase(q, post.length()); + s.erase(p, pre.length()); } else - s.erase(p, q + 10 - p); + s.erase(p, q - p + post.length()); } +} +std::string untag_tiles_console(std::string s) +{ + _untag(s, "<tiles>", "</tiles>", is_tiles()); + _untag(s, "<console>", "</console>", !is_tiles()); +#ifdef USE_TILE_WEB + _untag(s, "<webtiles>", "</webtiles>", true); +#else + _untag(s, "<webtiles>", "</webtiles>", false); +#endif +#ifdef USE_TILE_LOCAL + _untag(s, "<localtiles>", "</localtiles>", true); +#else + _untag(s, "<localtiles>", "</localtiles>", false); +#endif return s; } |