]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
hopefully fix pos saving when the same player improves his record
authorFruitieX <rasse@rasse-laptop.(none)>
Tue, 26 Oct 2010 18:25:14 +0000 (21:25 +0300)
committerFruitieX <rasse@rasse-laptop.(none)>
Tue, 26 Oct 2010 18:25:14 +0000 (21:25 +0300)
qcsrc/server/miscfunctions.qc
qcsrc/server/race.qc

index b71eadbf38722cb17186273175c966ac4546f9fb..b2149c7aff6cd4c508b8a608bf29e15d52580040 100644 (file)
@@ -2107,7 +2107,7 @@ float race_readPos(string map, float t) {
        return 0; // pos is zero if unranked
 }
 
-void race_writeTime(string map, float t, string myuid)
+void race_writeTime(string map, float t, string myuid, float pos)
 {
        string rr;
        if(g_cts)
@@ -2115,8 +2115,8 @@ void race_writeTime(string map, float t, string myuid)
        else
                rr = RACE_RECORD;
 
-       float pos;
-       pos = race_readPos(map, t);
+       if(!pos)
+               pos = race_readPos(map, t);
 
        if(pos) { // don't even ALLOW writing unranked times into the db, less stuff to worry about in other code then :-)
                db_put(ServerProgsDB, strcat(map, rr, "time", ftos(pos)), ftos(t));
index d88694ab3fc57bde639d9a4a00d20f135a6e71ed..faeaba930073cb9cc36bcf6f764b015369de6f9f 100644 (file)
@@ -173,16 +173,16 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
        // move other rankings out of the way
        if (player_prevpos) { // player improved his existing record, only have to iterate on ranks between new and old recs
                for (i = player_prevpos; i > newpos; --i) {
-                       race_writeTime(GetMapname(), race_readTime(GetMapname(), newpos-1), race_readUID(GetMapname(), newpos-1));
+                       race_writeTime(GetMapname(), race_readTime(GetMapname(), i-1), race_readUID(GetMapname(), i-1), i);
                }
        } else { // player has no ranked record yet
                for (i = RANKINGS_CNT; i > newpos; --i) {
-                       race_writeTime(GetMapname(), race_readTime(GetMapname(), newpos-1), race_readUID(GetMapname(), newpos-1));
+                       race_writeTime(GetMapname(), race_readTime(GetMapname(), i-1), race_readUID(GetMapname(), i-1), i);
                }
        }
        
        // store new ranking
-       race_writeTime(GetMapname(), t, myuid);
+       race_writeTime(GetMapname(), t, myuid, 0); // 0 = autodetect pos
 
        if (newpos == 1) {
                write_recordmarker(e, time - TIME_DECODE(t), TIME_DECODE(t));