]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util.qc
Merge remote-tracking branch 'origin' into terencehill/m_toggle_fix
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util.qc
index c3407757a469c8d3e3dbb56d03bac34d2dd85816..10e4e345b28298ead91a5420e4c0c11da92dc36b 100644 (file)
@@ -1074,8 +1074,8 @@ vector rgb_to_hsv(vector rgb)
        float mi, ma;
        vector hsv;
 
-       mi = min3(rgb_x, rgb_y, rgb_z);
-       ma = max3(rgb_x, rgb_y, rgb_z);
+       mi = min(rgb_x, rgb_y, rgb_z);
+       ma = max(rgb_x, rgb_y, rgb_z);
 
        hsv_x = rgb_mi_ma_to_hue(rgb, mi, ma);
        hsv_z = ma;
@@ -1098,8 +1098,8 @@ vector rgb_to_hsl(vector rgb)
        float mi, ma;
        vector hsl;
 
-       mi = min3(rgb_x, rgb_y, rgb_z);
-       ma = max3(rgb_x, rgb_y, rgb_z);
+       mi = min(rgb_x, rgb_y, rgb_z);
+       ma = max(rgb_x, rgb_y, rgb_z);
 
        hsl_x = rgb_mi_ma_to_hue(rgb, mi, ma);
        
@@ -1322,6 +1322,12 @@ string getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunc
        string s;
 
        s = getWrappedLine_remaining;
+       
+       if(w <= 0)
+       {
+               getWrappedLine_remaining = string_null;
+               return s; // the line has no size ANYWAY, nothing would be displayed.
+       }
 
        cantake = textLengthUpToWidth(s, w, theFontSize, tw);
        if(cantake > 0 && cantake < strlen(s))
@@ -1362,6 +1368,12 @@ string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw)
        string s;
 
        s = getWrappedLine_remaining;
+       
+       if(w <= 0)
+       {
+               getWrappedLine_remaining = string_null;
+               return s; // the line has no size ANYWAY, nothing would be displayed.
+       }
 
        cantake = textLengthUpToLength(s, w, tw);
        if(cantake > 0 && cantake < strlen(s))
@@ -2085,3 +2097,13 @@ float xdecode(string s)
                return -1;
        return ((a * 22 + b) * 22 + c) * 22 + d;
 }
+
+float lowestbit(float f)
+{
+       f &~= f * 2;
+       f &~= f * 4;
+       f &~= f * 16;
+       f &~= f * 256;
+       f &~= f * 65536;
+       return f;
+}