X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fbool.qh;h=c78f717d9e983be74923a5dd8fb5252b73f9b627;hb=3db2113eb80547da28988be0958bde321837efc1;hp=7a719af409ca1aaa49cc602518ab12529341495f;hpb=70b84d37e2cf1d5336c327cb43593024de2a2c6c;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/bool.qh b/qcsrc/lib/bool.qh index 7a719af40..c78f717d9 100644 --- a/qcsrc/lib/bool.qh +++ b/qcsrc/lib/bool.qh @@ -1,37 +1,29 @@ -#ifndef BOOL_H -#define BOOL_H +#pragma once #ifndef QCC_SUPPORT_BOOL - // 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; + switch (strtolower(input)) + { + case "yes": + case "true": + case "on": + return true; - case "no": - case "false": - case "off": - return false; + case "no": + case "false": + case "off": + return false; - default: return stof(input); - } + 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