]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util.qc
Declare more ints as ints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util.qc
index 671c8d5a593e23f9c552a700172cc57b9cf7139c..e972b1d6ba1607548e265a6cf978edd5e7f653ba 100644 (file)
@@ -259,7 +259,7 @@ float fexists(string f)
 }
 
 // Databases (hash tables)
-#define DB_BUCKETS 8192
+const float DB_BUCKETS = 8192;
 void db_save(float db, string pFilename)
 {
        float fh, i, n;
@@ -346,14 +346,14 @@ void db_close(float db)
 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)));
 }
 
@@ -2261,10 +2261,10 @@ const string XENCODE_22 = "0123456789abcdefABCDEF";
 string xencode(float 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),
@@ -2373,7 +2373,7 @@ void m_shutdown()
        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: