string unescape(string in)
{
- local float i, len;
- local string str, s;
+ float i, len;
+ string str, s;
// but it doesn't seem to be necessary in my tests at least
in = strzone(in);
void wordwrap_cb(string s, float l, void(string) callback)
{
- local string c;
- local float lleft, i, j, wlen;
+ string c;
+ float lleft, i, j, wlen;
s = strzone(s);
lleft = l;
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;
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);
}
// requires that m2>m1 in all coordinates, and that m4>m3
-float boxesoverlap(vector m1, vector m2, vector m3, vector m4) {return m2_x >= m3_x && m1_x <= m4_x && m2_y >= m3_y && m1_y <= m4_y && m2_z >= m3_z && m1_z <= m4_z;};
+float boxesoverlap(vector m1, vector m2, vector m3, vector m4) {return m2_x >= m3_x && m1_x <= m4_x && m2_y >= m3_y && m1_y <= m4_y && m2_z >= m3_z && m1_z <= m4_z;}
// requires the same, but is a stronger condition
-float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) {return smins_x >= bmins_x && smaxs_x <= bmaxs_x && smins_y >= bmins_y && smaxs_y <= bmaxs_y && smins_z >= bmins_z && smaxs_z <= bmaxs_z;};
+float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) {return smins_x >= bmins_x && smaxs_x <= bmaxs_x && smins_y >= bmins_y && smaxs_y <= bmaxs_y && smins_z >= bmins_z && smaxs_z <= bmaxs_z;}
#ifndef MENUQC
#endif
float textLengthUpToWidth(string theText, float maxWidth, vector theSize, textLengthUpToWidth_widthFunction_t w)
{
- float ICanHasKallerz;
-
- // detect color codes support in the width function
- ICanHasKallerz = (w("^7", theSize) == 0);
-
// STOP.
// The following function is SLOW.
// For your safety and for the protection of those around you...
}
while(left < right - 1);
- if(ICanHasKallerz)
+ if(w("^7", theSize) == 0) // detect color codes support in the width function
{
// NOTE: when color codes are involved, this binary search is,
// mathematically, BROKEN. However, it is obviously guaranteed to
float textLengthUpToLength(string theText, float maxWidth, textLengthUpToLength_lenFunction_t w)
{
- float ICanHasKallerz;
-
- // detect color codes support in the width function
- ICanHasKallerz = (w("^7") == 0);
-
// STOP.
// The following function is SLOW.
// For your safety and for the protection of those around you...
}
while(left < right - 1);
- if(ICanHasKallerz)
+ if(w("^7") == 0) // detect color codes support in the width function
{
// NOTE: when color codes are involved, this binary search is,
// mathematically, BROKEN. However, it is obviously guaranteed to
{
float start, len, i, carets;
start = strstrofs(s, "^", 0);
- if (start == -1) // no carret found
+ if (start == -1) // no caret found
return "";
len = strlen(s)-1;
for(i = len; i >= start; --i)
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))
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))
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;
+}
+
+#ifdef CSQC
+entity ReadCSQCEntity()
+{
+ float f;
+ f = ReadShort();
+ if(f == 0)
+ return world;
+ return findfloat(world, entnum, f);
+}
+#endif