X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Flib%2Fbool.qh;h=c78f717d9e983be74923a5dd8fb5252b73f9b627;hp=26169cd199e61328ca0699c3946938a786e7691e;hb=83e2013a3aa40f8e5cfeac82e83c9abdd7a038b8;hpb=03f978544a8b13a18cef1c7cc3dbcaba1c3aee4c diff --git a/qcsrc/lib/bool.qh b/qcsrc/lib/bool.qh index 26169cd19..c78f717d9 100644 --- a/qcsrc/lib/bool.qh +++ b/qcsrc/lib/bool.qh @@ -1,39 +1,29 @@ -#ifndef BOOL_H -#define BOOL_H +#pragma once #ifndef QCC_SUPPORT_BOOL - #define bool float - - // Boolean Constants - const int true = 1; - const int false = 0; + // Boolean Constants + const int true = 1; + const int false = 0; #endif -// Transitional aliases -[[deprecated("use true")]] [[alias("true")]] const bool TRUE; -[[deprecated("use false")]] [[alias("false")]] const bool FALSE; +#define boolean(value) ((value) != 0) // get true/false value of a string with multiple different inputs +ERASEABLE float InterpretBoolean(string input) { - switch (strtolower(input)) - { - case "yes": - case "true": - case "on": - return true; - - case "no": - case "false": - case "off": - return false; - - default: return stof(input); - } + switch (strtolower(input)) + { + case "yes": + case "true": + case "on": + return true; + + case "no": + case "false": + case "off": + return false; + + default: return boolean(stof(input)); + } } - -float boolean(float value) { // if value is 0 return false (0), otherwise return true (1) - return (value == 0) ? false : true; -} - -#endif