summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/stuff.cc
diff options
context:
space:
mode:
authorRobert Vollmert <rvollmert@gmx.net>2009-11-24 09:40:16 +0100
committerRobert Vollmert <rvollmert@gmx.net>2009-11-24 11:05:13 +0100
commit5648dce61108e9c5059f390a1c9b28a68ce0b439 (patch)
tree9343bf0b18644cd9e603ee23340f4744320f8979 /crawl-ref/source/stuff.cc
parentf8bbfc037a9f75e06a51fc9f1fc48c2f3d9572e1 (diff)
downloadcrawl-ref-5648dce61108e9c5059f390a1c9b28a68ce0b439.tar.gz
crawl-ref-5648dce61108e9c5059f390a1c9b28a68ce0b439.zip
Add ternary logic type maybe_bool.
Diffstat (limited to 'crawl-ref/source/stuff.cc')
-rw-r--r--crawl-ref/source/stuff.cc26
1 files changed, 26 insertions, 0 deletions
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index f7f93c67a7..f3d24c6f25 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -936,3 +936,29 @@ int random_rod_subtype()
{
return STAFF_FIRST_ROD + random2(NUM_STAVES - STAFF_FIRST_ROD);
}
+
+maybe_bool frombool(bool b)
+{
+ return (b ? B_TRUE : B_FALSE);
+}
+
+bool tobool(maybe_bool mb)
+{
+ ASSERT (mb != B_MAYBE);
+ return (mb == B_TRUE);
+}
+
+bool tobool(maybe_bool mb, bool def)
+{
+ switch (mb)
+ {
+ case B_TRUE:
+ return (true);
+ case B_FALSE:
+ return (false);
+ case B_MAYBE:
+ default:
+ return (def);
+ }
+}
+