]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Cleanup of count_ordinal stuffz
authorSamual Lenks <samual@xonotic.org>
Sun, 3 Mar 2013 06:04:06 +0000 (01:04 -0500)
committerSamual Lenks <samual@xonotic.org>
Sun, 3 Mar 2013 06:04:06 +0000 (01:04 -0500)
qcsrc/common/util.qc
qcsrc/server/command/getreplies.qc
qcsrc/server/miscfunctions.qc

index a7a7d59822be2d3bc2aaf2fd83e52051b7efa89c..4cb51f0af614b51a808c96204c4fca88ed31ffce 100644 (file)
@@ -2615,27 +2615,19 @@ string count_ordinal(float interval)
        // Basically, it just allows you to represent a number or count in different ways
        // depending on the number... like, with count_ordinal you can provide integers
        // and retrieve 1st, 2nd, 3rd, nth ordinal numbers in a clean and simple way.
        // Basically, it just allows you to represent a number or count in different ways
        // depending on the number... like, with count_ordinal you can provide integers
        // and retrieve 1st, 2nd, 3rd, nth ordinal numbers in a clean and simple way.
-
-       switch(mod(floor(interval), 100))
+       if(floor((mod(interval, 100))/10) * 10 != 10) // examples: 12th, 111th, 213th will not execute this block
        {
        {
-               // if the first two numbers are 11,12,13, use nth for output
-               case 11:
-               case 12:
-               case 13:
-                       { return sprintf(_("%dth"), interval); }
-               
-               default:
+               // otherwise, check normally for 1st,2nd,3rd insertions
+               switch(mod(interval, 10))
                {
                {
-                       // otherwise, check normally for 1st,2nd,3rd insertions
-                       switch(mod(interval, 10))
-                       {
-                               case 1: return sprintf(_("%dst"), interval);
-                               case 2: return sprintf(_("%dnd"), interval);
-                               case 3: return sprintf(_("%drd"), interval);
-                       }
-                       return sprintf(_("%dth"), interval);
+                       case 1: return sprintf(_("%dst"), interval);
+                       case 2: return sprintf(_("%dnd"), interval);
+                       case 3: return sprintf(_("%drd"), interval);
+                       default: return sprintf(_("%dth"), interval);
                }
        }
                }
        }
+       else { return sprintf(_("%dth"), interval); }
+       
        return "";
 }
 
        return "";
 }
 
index 0bedd6d5e21f3ce44f0b2d479eed092a59029b65..39206966cfee11bf0c8326ca76a6b138c0eebe4f 100644 (file)
@@ -96,7 +96,7 @@ string getrankings()
                        continue;
                        
                n = race_readName(map, i);
                        continue;
                        
                n = race_readName(map, i);
-               p = race_placeName(i);
+               p = count_ordinal(i);
                s = strcat(s, strpad(8, p), " ", strpad(-8, TIME_ENCODED_TOSTRING(t)), " ", n, "\n");
        }
 
                s = strcat(s, strpad(8, p), " ", strpad(-8, TIME_ENCODED_TOSTRING(t)), " ", n, "\n");
        }
 
@@ -240,7 +240,7 @@ string getladder()
        s = strcat(s, " ^7Total  ^3|");
        
        for(i = 1; i <= LADDER_CNT; ++i)
        s = strcat(s, " ^7Total  ^3|");
        
        for(i = 1; i <= LADDER_CNT; ++i)
-               { s = strcat(s, " ^7", race_placeName(i), " ^3|"); }
+               { s = strcat(s, " ^7", count_ordinal(i), " ^3|"); }
        
        s = strcat(s, " ^7Speed awards ^3| ^7Name");
        s = strcat(s, "\n^3----+--------");
        
        s = strcat(s, " ^7Speed awards ^3| ^7Name");
        s = strcat(s, "\n^3----+--------");
@@ -263,7 +263,7 @@ string getladder()
                if(argv(LADDER_CNT+1) == "") // total is 0, skip
                        continue;
                        
                if(argv(LADDER_CNT+1) == "") // total is 0, skip
                        continue;
                        
-               s = strcat(s, strpad(4, race_placeName(i+1)), "^3| ^7"); // pos
+               s = strcat(s, strpad(4, count_ordinal(i+1)), "^3| ^7"); // pos
                s = strcat(s, strpad(7, argv(LADDER_CNT+1)), "^3| ^7"); // total
                
                for(j = 1; j <= min(9, LADDER_CNT); ++j)
                s = strcat(s, strpad(7, argv(LADDER_CNT+1)), "^3| ^7"); // total
                
                for(j = 1; j <= min(9, LADDER_CNT); ++j)
index fd7020f44377fc355d8dc5a77e04b33c862cbda8..2b73841808bed3223c1eef10bef5c06dd384138c 100644 (file)
@@ -2016,22 +2016,6 @@ string race_readName(string map, float pos)
        return uid2name(db_get(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(pos))));
 }
 
        return uid2name(db_get(ServerProgsDB, strcat(map, rr, "crypto_idfp", ftos(pos))));
 }
 
-string race_placeName(float pos) {
-       if(floor((mod(pos, 100))/10) * 10 != 10) // examples: 12th, 111th, 213th will not execute this block
-       {
-               if(mod(pos, 10) == 1)
-                       return strcat(ftos(pos), "st");
-               else if(mod(pos, 10) == 2)
-                       return strcat(ftos(pos), "nd");
-               else if(mod(pos, 10) == 3)
-                       return strcat(ftos(pos), "rd");
-               else
-                       return strcat(ftos(pos), "th");
-       }
-       else
-               return strcat(ftos(pos), "th");
-}
-
 float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
 {
     float m, i;
 float MoveToRandomMapLocation(entity e, float goodcontents, float badcontents, float badsurfaceflags, float attempts, float maxaboveground, float minviewdistance)
 {
     float m, i;