summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libutil.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-12 11:32:15 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-12 11:32:15 +0000
commitfed7cd6012682b1638463bdc5a0303089c967846 (patch)
treee88217f560f168f797bb895929baf3a87a83c565 /crawl-ref/source/libutil.h
parent0dcc5cec25b63cb1649ddc501d6ea44cb0fdbc43 (diff)
downloadcrawl-ref-fed7cd6012682b1638463bdc5a0303089c967846.tar.gz
crawl-ref-fed7cd6012682b1638463bdc5a0303089c967846.zip
New Zot levels, courtesy Lemuel (David).
Added more control when specifying draconians in maps (any yellow draconian, green draconian knight, any nonbase red draconian, any base draconian, etc.). Fixed crash when dragon or draconian breathes and the player is unarmed. Replaced magic number 250 in monster creation with enum constant MONS_PROGRAM_BUG. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3253 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libutil.h')
-rw-r--r--crawl-ref/source/libutil.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/crawl-ref/source/libutil.h b/crawl-ref/source/libutil.h
index db63e6ff6c..4c64be32e6 100644
--- a/crawl-ref/source/libutil.h
+++ b/crawl-ref/source/libutil.h
@@ -94,6 +94,18 @@ typedef bool (*p_match)(void *compiled_pattern, const char *text, int length);
std::string & trim_string( std::string &str );
std::string trimmed_string( std::string s );
+inline bool starts_with(const std::string &s, const std::string &prefix)
+{
+ return (s.rfind(prefix, 0) != std::string::npos);
+}
+
+inline bool ends_with(const std::string &s, const std::string &suffix)
+{
+ if (s.length() < suffix.length())
+ return false;
+ return (s.find(suffix, s.length() - suffix.length()) != std::string::npos);
+}
+
// Splits string 's' on the separator 'sep'. If trim == true, trims each
// segment. If accept_empties == true, accepts empty segments. If nsplits >= 0,
// splits on the first nsplits occurrences of the separator, and stores the