From: FruitieX Date: Tue, 26 Oct 2010 18:25:14 +0000 (+0300) Subject: hopefully fix pos saving when the same player improves his record X-Git-Tag: xonotic-v0.1.0preview~202^2~9 X-Git-Url: https://de.git.xonotic.org/?a=commitdiff_plain;h=d561f76342a7e8060a5a1aae4bab3f2bf56c17aa;p=xonotic%2Fxonotic-data.pk3dir.git hopefully fix pos saving when the same player improves his record --- diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index b71eadbf3..b2149c7af 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -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)); diff --git a/qcsrc/server/race.qc b/qcsrc/server/race.qc index d88694ab3..faeaba930 100644 --- a/qcsrc/server/race.qc +++ b/qcsrc/server/race.qc @@ -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));