From d4065da159cb407f1680de9f03596cd397ded525 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Mon, 28 May 2007 11:28:11 +0000 Subject: Added new orc entries and vaults (Lemuel). Added support to the map designer for specifying the monster-type for zombies, skeletons, simulacra and spectral things. Also allow specifying the number of heads for hydras ("12-headed hydra"). Fixed lexer rule bug (IDENTIFIER). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1490 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/libutil.cc | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crawl-ref/source/libutil.cc') diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc index a2fa623530..6bf33921ba 100644 --- a/crawl-ref/source/libutil.cc +++ b/crawl-ref/source/libutil.cc @@ -193,6 +193,25 @@ void lowercase(std::string &s) s[i] = tolower(s[i]); } +bool ends_with(const std::string &s, const std::string &suffix) +{ + if (s.length() < suffix.length()) + return false; + return (s.substr(s.length() - suffix.length()) == suffix); +} + +int ends_with(const std::string &s, const char *suffixes[]) +{ + if (!suffixes) + return (0); + for (int i = 0; suffixes[i]; ++i) + { + if (ends_with(s, suffixes[i])) + return (1 + i); + } + return (0); +} + std::string replace_all(std::string s, const std::string &find, const std::string &repl) -- cgit v1.2.3-54-g00ecf