]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use the same variable names as minigame_getWrappedLine as they are a clearer
authorterencehill <piuntn@gmail.com>
Thu, 31 Dec 2020 14:09:40 +0000 (15:09 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 31 Dec 2020 14:09:40 +0000 (15:09 +0100)
qcsrc/common/minigames/cl_minigames.qc
qcsrc/common/util.qc

index e5fe71642693da115116a847b8a24af294985ed6..eaf8e0d65b7ae01c523ca23acd587fda0b311280 100644 (file)
@@ -248,12 +248,7 @@ NET_HANDLE(ENT_CLIENT_MINIGAME, bool isnew)
 
 string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
 {
-       int last_word;
-       string s;
-       int take_until;
-       int skip = 0;
-
-       s = getWrappedLine_remaining;
+       string s = getWrappedLine_remaining;
 
        if(w <= 0)
        {
@@ -261,11 +256,12 @@ string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_
                return s; // the line has no size ANYWAY, nothing would be displayed.
        }
 
-       take_until = textLengthUpToWidth(s, w, theFontSize, tw);
+       int take_until = textLengthUpToWidth(s, w, theFontSize, tw);
 
        if ( take_until > strlen(s) )
                take_until = strlen(s);
 
+       int skip = 0;
        for ( int i = 0; i < take_until; i++ )
                if ( substring(s,i,1) == "\n" )
                {
@@ -278,7 +274,7 @@ string minigame_getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_
        {
                if ( skip == 0 && take_until < strlen(s) )
                {
-                       last_word = take_until;
+                       int last_word = take_until;
                        while(last_word > 0 && substring(s, last_word, 1) != " ")
                                --last_word;
 
index 27aa5f3f2d22ae923dc485fe79744fe19fd7460d..d823eeec22ba8af7986d50eb27a0a28c5a20a61c 100644 (file)
@@ -922,11 +922,7 @@ string find_last_color_code(string s)
 
 string getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunction_t tw)
 {
-       float cantake;
-       float take;
-       string s;
-
-       s = getWrappedLine_remaining;
+       string s = getWrappedLine_remaining;
 
        if(w <= 0)
        {
@@ -934,26 +930,26 @@ string getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunc
                return s; // the line has no size ANYWAY, nothing would be displayed.
        }
 
-       cantake = textLengthUpToWidth(s, w, theFontSize, tw);
-       if(cantake > 0 && cantake < strlen(s))
+       int take_until = textLengthUpToWidth(s, w, theFontSize, tw);
+       if(take_until > 0 && take_until < strlen(s))
        {
-               take = cantake - 1;
-               while(take > 0 && substring(s, take, 1) != " ")
-                       --take;
+               int last_word = take_until - 1;
+               while(last_word > 0 && substring(s, last_word, 1) != " ")
+                       --last_word;
 
                int skip = 0;
-               if(take != 0)
+               if(last_word != 0)
                {
-                       cantake = take;
+                       take_until = last_word;
                        skip = 1;
                }
 
-               getWrappedLine_remaining = substring(s, cantake + skip, strlen(s) - cantake);
+               getWrappedLine_remaining = substring(s, take_until + skip, strlen(s) - take_until);
                if(getWrappedLine_remaining == "")
                        getWrappedLine_remaining = string_null;
                else if (tw("^7", theFontSize) == 0)
-                       getWrappedLine_remaining = strcat(find_last_color_code(substring(s, 0, cantake)), getWrappedLine_remaining);
-               return substring(s, 0, cantake);
+                       getWrappedLine_remaining = strcat(find_last_color_code(substring(s, 0, take_until)), getWrappedLine_remaining);
+               return substring(s, 0, take_until);
        }
        else
        {
@@ -964,11 +960,7 @@ string getWrappedLine(float w, vector theFontSize, textLengthUpToWidth_widthFunc
 
 string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw)
 {
-       float cantake;
-       float take;
-       string s;
-
-       s = getWrappedLine_remaining;
+       string s = getWrappedLine_remaining;
 
        if(w <= 0)
        {
@@ -976,26 +968,26 @@ string getWrappedLineLen(float w, textLengthUpToLength_lenFunction_t tw)
                return s; // the line has no size ANYWAY, nothing would be displayed.
        }
 
-       cantake = textLengthUpToLength(s, w, tw);
-       if(cantake > 0 && cantake < strlen(s))
+       int take_until = textLengthUpToLength(s, w, tw);
+       if(take_until > 0 && take_until < strlen(s))
        {
-               take = cantake - 1;
-               while(take > 0 && substring(s, take, 1) != " ")
-                       --take;
+               int last_word = take_until - 1;
+               while(last_word > 0 && substring(s, last_word, 1) != " ")
+                       --last_word;
 
                int skip = 0;
-               if(take != 0)
+               if(last_word != 0)
                {
-                       cantake = take;
+                       take_until = last_word;
                        skip = 1;
                }
 
-               getWrappedLine_remaining = substring(s, cantake + skip, strlen(s) - cantake);
+               getWrappedLine_remaining = substring(s, take_until + skip, strlen(s) - take_until);
                if(getWrappedLine_remaining == "")
                        getWrappedLine_remaining = string_null;
                else if (tw("^7") == 0)
-                       getWrappedLine_remaining = strcat(find_last_color_code(substring(s, 0, cantake)), getWrappedLine_remaining);
-               return substring(s, 0, cantake);
+                       getWrappedLine_remaining = strcat(find_last_color_code(substring(s, 0, take_until)), getWrappedLine_remaining);
+               return substring(s, 0, take_until);
        }
        else
        {