]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/race.qc
lol i had forgotten the mutators/gamemode_freezetag.qc file itself :X
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / race.qc
index 19995d7d058cebfd82626d849b460155906777ac..3786edbe5137d25c431da79d37036f9ea7b97361 100644 (file)
@@ -104,7 +104,7 @@ void race_send_recordtime(float msg)
        WriteByte(msg, SVC_TEMPENTITY);
        WriteByte(msg, TE_CSQC_RACE);
        WriteByte(msg, RACE_NET_SERVER_RECORD);
-       WriteInt24_t(msg, race_readTime(MapInfo_Map_bspname, 1));
+       WriteInt24_t(msg, race_readTime(GetMapname(), 1));
 }
 
 void race_SendRankings(float pos, float prevpos, float del, float msg)
@@ -115,8 +115,8 @@ void race_SendRankings(float pos, float prevpos, float del, float msg)
        WriteShort(msg, pos);
        WriteShort(msg, prevpos);
        WriteShort(msg, del);
-       WriteString(msg, race_readName(MapInfo_Map_bspname, pos));
-       WriteInt24_t(msg, race_readTime(MapInfo_Map_bspname, pos));
+       WriteString(msg, race_readName(GetMapname(), pos));
+       WriteInt24_t(msg, race_readTime(GetMapname(), pos));
 }
 
 void race_SendStatus(float id, entity e)
@@ -151,33 +151,24 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
        string recorddifference, oldrec_holder;
        if (player_prevpos && (player_prevpos < newpos || !newpos))
        {
-               oldrec = race_readTime(MapInfo_Map_bspname, player_prevpos);
+               oldrec = race_readTime(GetMapname(), player_prevpos);
                recorddifference = strcat(" ^1[+", TIME_ENCODED_TOSTRING(t - oldrec), "]");
                bprint(mynetname, "^7 couldn't break their ", race_placeName(player_prevpos), " place record of ", TIME_ENCODED_TOSTRING(oldrec), recorddifference, "\n");
                race_SendStatus(0, e); // "fail"
+               Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_FAIL, MSG_RACE);
                return;
        } else if (!newpos) { // no ranking, time worse than the worst ranked
-               recorddifference = strcat(" ^1[+", TIME_ENCODED_TOSTRING(t - race_readTime(MapInfo_Map_bspname, RANKINGS_CNT)), "]");
-               bprint(mynetname, "^7 couldn't break the ", race_placeName(RANKINGS_CNT), " place record of ", TIME_ENCODED_TOSTRING(race_readTime(MapInfo_Map_bspname, RANKINGS_CNT)), recorddifference, "\n");
+               recorddifference = strcat(" ^1[+", TIME_ENCODED_TOSTRING(t - race_readTime(GetMapname(), RANKINGS_CNT)), "]");
+               bprint(mynetname, "^7 couldn't break the ", race_placeName(RANKINGS_CNT), " place record of ", TIME_ENCODED_TOSTRING(race_readTime(GetMapname(), RANKINGS_CNT)), recorddifference, "\n");
                race_SendStatus(0, e); // "fail"
+               Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_FAIL, MSG_RACE);
                return;
        }
 
        // if we didn't hit a return yet, we have a new record!
 
-       oldrec = race_readTime(MapInfo_Map_bspname, newpos);
-       oldrec_holder = race_readName(MapInfo_Map_bspname, newpos);
-
-       // 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));
-               }
-       } 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));
-               }
-       }
+       oldrec = race_readTime(GetMapname(), newpos);
+       oldrec_holder = race_readName(GetMapname(), newpos);
        
        // store new ranking
        race_writeTime(GetMapname(), t, myuid);
@@ -202,18 +193,22 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
                        bprint(mynetname, "^1 broke ", oldrec_holder, "^1's 1st place record with ", strcat(TIME_ENCODED_TOSTRING(t), recorddifference, "\n"));
                }
                race_SendStatus(3, e); // "new server record"
+               Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_SERVER_RECORD, MSG_RACE);
        } else {
                if(newpos == player_prevpos) {
                        recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]");
                        bprint(mynetname, "^5 improved their ", race_placeName(newpos), " ^5place record with ", TIME_ENCODED_TOSTRING(t), recorddifference, "\n");
                        race_SendStatus(1, e); // "new time"
+                       Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_NEW_TIME, MSG_RACE);
                } else if (oldrec == 0) {
                        bprint(mynetname, "^2 set the ", race_placeName(newpos), " ^2place record with ", TIME_ENCODED_TOSTRING(t), "\n");
                        race_SendStatus(2, e); // "new rank"
+                       Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_NEW_RANK, MSG_RACE);
                } else {
                        recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]");
                        bprint(mynetname, "^2 broke ", oldrec_holder, "^2's ", race_placeName(newpos), " ^2place record with ", strcat(TIME_ENCODED_TOSTRING(t), recorddifference, "\n"));
                        race_SendStatus(2, e); // "new rank"
+                       Send_KillNotification(e.netname, TIME_ENCODED_TOSTRING(t), "", RACE_NEW_TIME, MSG_RACE);
                }
        }
 }
@@ -303,7 +298,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid)
                        if(t != 0) {
                                if(cp == race_timed_checkpoint)
                                {
-                                       race_setTime(MapInfo_Map_bspname, t, e.crypto_idfp, e.netname, e);
+                                       race_setTime(GetMapname(), t, e.crypto_idfp, e.netname, e);
                                        if(g_cts && cvar("g_cts_finish_kill_delay"))
                                        {
                                                CTS_ClientKill(cvar("g_cts_finish_kill_delay"));