]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/bool.qh
26169cd199e61328ca0699c3946938a786e7691e
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / bool.qh
1 #ifndef BOOL_H
2 #define BOOL_H
3
4 #ifndef QCC_SUPPORT_BOOL
5     #define bool float
6
7     // Boolean Constants
8     const int true      = 1;
9     const int false = 0;
10 #endif
11
12 // Transitional aliases
13 [[deprecated("use true")]] [[alias("true")]] const bool TRUE;
14 [[deprecated("use false")]] [[alias("false")]] const bool FALSE;
15
16 // get true/false value of a string with multiple different inputs
17 float InterpretBoolean(string input)
18 {
19     switch (strtolower(input))
20     {
21         case "yes":
22         case "true":
23         case "on":
24             return true;
25
26         case "no":
27         case "false":
28         case "off":
29             return false;
30
31         default: return stof(input);
32     }
33 }
34
35 float boolean(float value) { // if value is 0 return false (0), otherwise return true (1)
36     return (value == 0) ? false : true;
37 }
38
39 #endif