X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fbits.qh;h=de11eef412154af108c93b92d6dd5c1768b84ea3;hb=258ffccc8aef1fc3664c15e6876cf89239e96a72;hp=ec9246c99b4ddd09da26475d93471a5f28d862de;hpb=1a463f974e1c026a16a76dd042ebccb1085ad985;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/bits.qh b/qcsrc/lib/bits.qh index ec9246c99..de11eef41 100644 --- a/qcsrc/lib/bits.qh +++ b/qcsrc/lib/bits.qh @@ -2,6 +2,9 @@ #include "log.qh" +/// Only ever assign into the first 24 bits in QC (so max is BIT(23)). +/// QC converts the float to int, performs the bit operation, then converts it back. +/// Assigning to the highest bits means some of the low ones might get lost due to float precision. #define BIT(n) (1 << (n)) #define BITS(n) (BIT(n) - 1) #ifndef BRANCHLESS_BITSET @@ -10,7 +13,7 @@ #define BITSET(var, mask, flag) ((var) ^ (-(flag) ^ (var)) & (mask)) #endif -[[eraseable]] +ERASEABLE int lowestbit(int f) { f &= ~(f << 1); @@ -21,7 +24,7 @@ int lowestbit(int f) return f; } -[[eraseable]] +ERASEABLE int randombit(int bits) { if (!(bits & (bits - 1))) // this ONLY holds for powers of two! @@ -44,7 +47,7 @@ int randombit(int bits) return b; } -[[eraseable]] +ERASEABLE int randombits(int bits, int k, bool error_return) { int r = 0; @@ -78,7 +81,7 @@ enum { OP_MINUS }; -[[eraseable]] +ERASEABLE bool GiveBit(entity e, .int fld, int bit, int op, int val) { int v0 = (e.(fld) & bit); @@ -103,7 +106,7 @@ bool GiveBit(entity e, .int fld, int bit, int op, int val) return v0 != v1; } -[[eraseable]] +ERASEABLE bool GiveValue(entity e, .int fld, int op, int val) { int v0 = e.(fld);