]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util.qc
Merge branch 'amade/small-fixes' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util.qc
index 38514e9270b7f457bbf8590d1d26f091af641272..91d68f1ba1313cb0a7eb543dd7b6406fafd26d7e 100644 (file)
 */
 vector real_origin(entity ent)
 {
 */
 vector real_origin(entity ent)
 {
-       entity e;
        vector v = ((ent.absmin + ent.absmax) * 0.5);
        vector v = ((ent.absmin + ent.absmax) * 0.5);
+       entity e = ent.tag_entity;
 
 
-       e = ent.tag_entity;
        while(e)
        {
                v = v + ((e.absmin + e.absmax) * 0.5);
        while(e)
        {
                v = v + ((e.absmin + e.absmax) * 0.5);
@@ -326,7 +325,7 @@ float compressShortVector(vector vec)
 STATIC_INIT(compressShortVector)
 {
        float l = 1;
 STATIC_INIT(compressShortVector)
 {
        float l = 1;
-       float f = pow(2, 1/8);
+       float f = (2 ** (1/8));
        int i;
        for(i = 0; i < 128; ++i)
        {
        int i;
        for(i = 0; i < 128; ++i)
        {
@@ -414,11 +413,11 @@ string fixPriorityList(string order, float from, float to, float subtract, float
 string mapPriorityList(string order, string(string) mapfunc)
 {
        string neworder;
 string mapPriorityList(string order, string(string) mapfunc)
 {
        string neworder;
-       float i, n;
+       float n;
 
        n = tokenize_console(order);
        neworder = "";
 
        n = tokenize_console(order);
        neworder = "";
-       for(i = 0; i < n; ++i)
+       for(float i = 0; i < n; ++i)
                neworder = strcat(neworder, mapfunc(argv(i)), " ");
 
        return substring(neworder, 0, strlen(neworder) - 1);
                neworder = strcat(neworder, mapfunc(argv(i)), " ");
 
        return substring(neworder, 0, strlen(neworder) - 1);
@@ -426,15 +425,12 @@ string mapPriorityList(string order, string(string) mapfunc)
 
 string swapInPriorityList(string order, float i, float j)
 {
 
 string swapInPriorityList(string order, float i, float j)
 {
-       string s;
-       float w, n;
-
-       n = tokenize_console(order);
+       float n = tokenize_console(order);
 
        if(i >= 0 && i < n && j >= 0 && j < n && i != j)
        {
 
        if(i >= 0 && i < n && j >= 0 && j < n && i != j)
        {
-               s = "";
-               for(w = 0; w < n; ++w)
+               string s = "";
+               for(float w = 0; w < n; ++w)
                {
                        if(w == i)
                                s = strcat(s, argv(j), " ");
                {
                        if(w == i)
                                s = strcat(s, argv(j), " ");
@@ -672,7 +668,6 @@ bool isCaretEscaped(string theText, float pos)
 
 int skipIncompleteTag(string theText, float pos, int len)
 {
 
 int skipIncompleteTag(string theText, float pos, int len)
 {
-       int i = 0, ch = 0;
        int tag_start = -1;
 
        if(substring(theText, pos - 1, 1) == "^")
        int tag_start = -1;
 
        if(substring(theText, pos - 1, 1) == "^")
@@ -680,7 +675,7 @@ int skipIncompleteTag(string theText, float pos, int len)
                if(isCaretEscaped(theText, pos - 1) || pos >= len)
                        return 0;
 
                if(isCaretEscaped(theText, pos - 1) || pos >= len)
                        return 0;
 
-               ch = str2chr(theText, pos);
+               int ch = str2chr(theText, pos);
                if(ch >= '0' && ch <= '9')
                        return 1; // ^[0-9] color code found
                else if (ch == 'x')
                if(ch >= '0' && ch <= '9')
                        return 1; // ^[0-9] color code found
                else if (ch == 'x')
@@ -690,7 +685,7 @@ int skipIncompleteTag(string theText, float pos, int len)
        }
        else
        {
        }
        else
        {
-               for(i = 2; pos - i >= 0 && i <= 4; ++i)
+               for(int i = 2; pos - i >= 0 && i <= 4; ++i)
                {
                        if(substring(theText, pos - i, 2) == "^x")
                        {
                {
                        if(substring(theText, pos - i, 2) == "^x")
                        {
@@ -784,8 +779,7 @@ string find_last_color_code(string s)
        if (start == -1) // no caret found
                return "";
        int len = strlen(s)-1;
        if (start == -1) // no caret found
                return "";
        int len = strlen(s)-1;
-       int i;
-       for(i = len; i >= start; --i)
+       for(int i = len; i >= start; --i)
        {
                if(substring(s, i, 1) != "^")
                        continue;
        {
                if(substring(s, i, 1) != "^")
                        continue;