}
// 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)));
}
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:
return 0;
}
-float Mod_Q1BSP_NativeContentsFromSuperContents(float supercontents)
+float Mod_Q1BSP_NativeContentsFromSuperContents(int supercontents)
{
if(supercontents & (DPCONTENTS_SOLID | DPCONTENTS_BODY))
return CONTENT_SOLID;