}
// Databases (hash tables)
-#define DB_BUCKETS 8192
+const float DB_BUCKETS = 8192;
void db_save(float db, string pFilename)
{
float fh, i, n;
string db_get(float db, string pKey)
{
float h;
- h = mod(crc16(FALSE, pKey), DB_BUCKETS);
+ h = crc16(FALSE, pKey) % DB_BUCKETS;
return uri_unescape(infoget(bufstr_get(db, h), pKey));
}
void db_put(float db, string pKey, string pValue)
{
float h;
- h = mod(crc16(FALSE, pKey), DB_BUCKETS);
+ h = crc16(FALSE, pKey) % DB_BUCKETS;
bufstr_set(db, h, infoadd(bufstr_get(db, h), pKey, uri_escape(pValue)));
}
fclose(fh);
}
+string format_time(float seconds)
+{
+ float days, hours, minutes;
+ seconds = floor(seconds + 0.5);
+ days = floor(seconds / 864000);
+ seconds -= days * 864000;
+ hours = floor(seconds / 36000);
+ seconds -= hours * 36000;
+ minutes = floor(seconds / 600);
+ seconds -= minutes * 600;
+ if (days > 0)
+ return sprintf(_("%d days, %02d:%02d:%02d"), days, hours, minutes, seconds);
+ else
+ return sprintf(_("%02d:%02d:%02d"), hours, minutes, seconds);
+}
+
string mmsss(float tenths)
{
float minutes;
return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, 2));
}
-string ScoreString(float pFlags, float pValue)
+string ScoreString(int pFlags, float pValue)
{
string valstr;
float l;
float invertLengthLog(float x)
{
- float l, r, m, lerr, rerr;
+ int l, r, m;
if(x >= lengthLogTable[127])
return 127;
}
// now: r is >=, l is <
- lerr = (x - lengthLogTable[l]);
- rerr = (lengthLogTable[r] - x);
+ float lerr = (x - lengthLogTable[l]);
+ float rerr = (lengthLogTable[r] - x);
if(lerr < rerr)
return l;
return r;
}
-vector decompressShortVector(float data)
+vector decompressShortVector(int data)
{
vector out;
- float p, y, len;
if(data == 0)
return '0 0 0';
- p = (data & 0xF000) / 0x1000;
- y = (data & 0x0F80) / 0x80;
- len = (data & 0x007F);
+ float p = (data & 0xF000) / 0x1000;
+ float y = (data & 0x0F80) / 0x80;
+ int len = (data & 0x007F);
//print("\ndecompress: p ", ftos(p)); print("y ", ftos(y)); print("len ", ftos(len), "\n");
void compressShortVector_init()
{
- float l, f, i;
- l = 1;
- f = pow(2, 1/8);
+ float l = 1;
+ float f = pow(2, 1/8);
+ int i;
for(i = 0; i < 128; ++i)
{
lengthLogTable[i] = l;
string find_last_color_code(string s)
{
- float start, len, i, carets;
- start = strstrofs(s, "^", 0);
+ int start = strstrofs(s, "^", 0);
if (start == -1) // no caret found
return "";
- len = strlen(s)-1;
+ int len = strlen(s)-1;
+ int i;
for(i = len; i >= start; --i)
{
if(substring(s, i, 1) != "^")
continue;
- carets = 1;
+ int carets = 1;
while (i-carets >= start && substring(s, i-carets, 1) == "^")
++carets;
return myvel + spd * mydir;
}
-void check_unacceptable_compiler_bugs()
-{
- if(cvar("_allow_unacceptable_compiler_bugs"))
- return;
- tokenize_console("foo bar");
- if(strcat(argv(0), substring("foo bar", 4, 7 - argv_start_index(1))) == "barbar")
- error("fteqcc bug introduced with revision 3178 detected. Please upgrade fteqcc to a later revision, downgrade fteqcc to revision 3177, or pester Spike until he fixes it. You can set _allow_unacceptable_compiler_bugs 1 to skip this check, but expect stuff to be horribly broken then.");
-
- string s = "";
- if (!s)
- error("The empty string counts as false. We do not want that!");
-}
-
float compressShotOrigin(vector v)
{
float x, y, z;
}
return x * 0x10000 + y * 0x100 + z;
}
-vector decompressShotOrigin(float f)
+vector decompressShotOrigin(int f)
{
vector v;
v_x = ((f & 0xFF0000) / 0x10000) / 2;
// x-encoding (encoding as zero length invisible string)
const string XENCODE_2 = "xX";
const string XENCODE_22 = "0123456789abcdefABCDEF";
-string xencode(float f)
+string xencode(int f)
{
float a, b, c, d;
- d = mod(f, 22); f = floor(f / 22);
- c = mod(f, 22); f = floor(f / 22);
- b = mod(f, 22); f = floor(f / 22);
- a = mod(f, 2); // f = floor(f / 2);
+ d = f % 22; f = floor(f / 22);
+ c = f % 22; f = floor(f / 22);
+ b = f % 22; f = floor(f / 22);
+ a = f % 2; // f = floor(f / 2);
return strcat(
"^",
substring(XENCODE_2, a, 1),
return ((a * 22 + b) * 22 + c) * 22 + d;
}
-float lowestbit(float f)
+float lowestbit(int f)
{
f &= ~(f * 2);
f &= ~(f * 4);
cvar_settemp_restore(); // this must be done LAST, but in any case
}
-#define APPROXPASTTIME_ACCURACY_REQUIREMENT 0.05
+const float APPROXPASTTIME_ACCURACY_REQUIREMENT = 0.05;
#define APPROXPASTTIME_MAX (16384 * APPROXPASTTIME_ACCURACY_REQUIREMENT)
#define APPROXPASTTIME_RANGE (64 * APPROXPASTTIME_ACCURACY_REQUIREMENT)
// this will use the value:
queue_start.FindConnectedComponent_processing = 0;
}
+#ifdef SVQC
+vector combine_to_vector(float x, float y, float z)
+{
+ vector result; result_x = x; result_y = y; result_z = z;
+ return result;
+}
+
+vector get_corner_position(entity box, float corner)
+{
+ switch(corner)
+ {
+ case 1: return combine_to_vector(box.absmin_x, box.absmin_y, box.absmin_z);
+ case 2: return combine_to_vector(box.absmax_x, box.absmin_y, box.absmin_z);
+ case 3: return combine_to_vector(box.absmin_x, box.absmax_y, box.absmin_z);
+ case 4: return combine_to_vector(box.absmin_x, box.absmin_y, box.absmax_z);
+ case 5: return combine_to_vector(box.absmax_x, box.absmax_y, box.absmin_z);
+ case 6: return combine_to_vector(box.absmin_x, box.absmax_y, box.absmax_z);
+ case 7: return combine_to_vector(box.absmax_x, box.absmin_y, box.absmax_z);
+ case 8: return combine_to_vector(box.absmax_x, box.absmax_y, box.absmax_z);
+ default: return '0 0 0';
+ }
+}
+#endif
+
// todo: this sucks, lets find a better way to do backtraces?
-#ifndef MENUQC
void backtrace(string msg)
{
float dev, war;
cvar_set("developer", ftos(dev));
cvar_set("prvm_backtraceforwarnings", ftos(war));
}
-#endif
// color code replace, place inside of sprintf and parse the string
string CCR(string input)
return 0;
}
-float Mod_Q1BSP_NativeContentsFromSuperContents(float supercontents)
+float Mod_Q1BSP_NativeContentsFromSuperContents(int supercontents)
{
if(supercontents & (DPCONTENTS_SOLID | DPCONTENTS_BODY))
return CONTENT_SOLID;