]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/race.qc
Merge remote-tracking branch 'origin/Mario/lsmaps_count'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / race.qc
index 2b61afd7e9636c0288177bfbec7ed4f50ec698ba..e6d7a43accca9535df7edb251036e6669c9e2da3 100644 (file)
@@ -149,17 +149,17 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
        }
 
        float oldrec;
-       string recorddifference, oldrec_holder;
+       string oldrec_holder;
        if (player_prevpos && (player_prevpos < newpos || !newpos))
        {
                oldrec = race_readTime(GetMapname(), player_prevpos);
                race_SendStatus(0, e); // "fail"
-               Send_Notification(NOTIF_ANY, world, MSG_INFO, INFO_RACE_FAIL_RANKED, mynetname, player_prevpos, t, oldrec);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_FAIL_RANKED, mynetname, player_prevpos, t, oldrec);
                return;
        } else if (!newpos) { // no ranking, time worse than the worst ranked
                oldrec = race_readTime(GetMapname(), RANKINGS_CNT);
                race_SendStatus(0, e); // "fail"
-               Send_Notification(NOTIF_ANY, world, MSG_INFO, INFO_RACE_FAIL_UNRANKED, mynetname, RANKINGS_CNT, t, oldrec);
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_FAIL_UNRANKED, mynetname, RANKINGS_CNT, t, oldrec);
                return;
        }
 
@@ -168,13 +168,13 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
        // if the player does not have a UID we can unfortunately not store the record, as the rankings system relies on UIDs
        if(myuid == "")
        {
-               bprint(mynetname, "^1 scored a new record with ^7", TIME_ENCODED_TOSTRING(t), "^1, but lacks a UID, so the record will unfortunately be lost.\n");
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_MISSING_UID, mynetname, t);
                return;
        }
 
        oldrec = race_readTime(GetMapname(), newpos);
        oldrec_holder = race_readName(GetMapname(), newpos);
-       
+
        // store new ranking
        race_writeTime(GetMapname(), t, myuid);
 
@@ -187,34 +187,24 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
        if(rankings_reply)
                strunzone(rankings_reply);
        rankings_reply = strzone(getrankings());
-       if(newpos == 1) {
-               if(newpos == player_prevpos) {
-                       recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]");
-                       bprint(mynetname, "^1 improved their 1st place record with ", TIME_ENCODED_TOSTRING(t), recorddifference, "\n");
-               } else if (oldrec == 0) {
-                       bprint(mynetname, "^1 set the 1st place record with ", TIME_ENCODED_TOSTRING(t), "\n");
-               } else {
-                       recorddifference = strcat(" ^2[-", TIME_ENCODED_TOSTRING(oldrec - t), "]");
-                       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_Notification(NOTIF_ANY, world, MSG_INFO, INFO_RACE_NEW_RECORD, e.netname, TIME_ENCODED_TOSTRING(t));
-       } 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_Notification(NOTIF_ANY, world, MSG_INFO, INFO_RACE_NEW_TIME, e.netname, TIME_ENCODED_TOSTRING(t));
-               } 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_Notification(NOTIF_ANY, world, MSG_INFO, INFO_RACE_NEW_RANK, e.netname, TIME_ENCODED_TOSTRING(t));
-               } 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_Notification(NOTIF_ANY, world, MSG_INFO, INFO_RACE_NEW_RANK, e.netname, TIME_ENCODED_TOSTRING(t));
-               }
+
+       if(newpos == player_prevpos)
+       {
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_IMPROVED, mynetname, newpos, t, oldrec);
+               if(newpos == 1) { race_SendStatus(3, e); } // "new server record"
+               else { race_SendStatus(1, e); } // "new time"
+       }
+       else if(oldrec == 0)
+       {
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_SET, mynetname, newpos, t);
+               if(newpos == 1) { race_SendStatus(3, e); } // "new server record"
+               else { race_SendStatus(2, e); } // "new rank"
+       }
+       else
+       {
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_NEW_BROKEN, mynetname, oldrec_holder, newpos, t, oldrec);
+               if(newpos == 1) { race_SendStatus(3, e); } // "new server record"
+               else { race_SendStatus(2, e); } // "new rank"
        }
 }
 
@@ -259,7 +249,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid)
 
        if(tvalid)
        if(cp == race_timed_checkpoint) // finish line
-       if not(e.race_completed)
+       if (!e.race_completed)
        {
                float s;
                if(g_race_qualifying)
@@ -287,7 +277,7 @@ void race_SendTime(entity e, float cp, float t, float tvalid)
                        {
                                e.race_completed = 1;
                                MAKE_INDEPENDENT_PLAYER(e);
-                               bprint(e.netname, "^7 has finished the race.\n");
+                               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_FINISHED, e.netname);
                                ClientData_Touch(e);
                        }
                }
@@ -467,7 +457,7 @@ void checkpoint_passed()
        /*
         * Trigger targets
         */
-       if not((self.spawnflags & 2) && (other.classname == "player"))
+       if (!((self.spawnflags & 2) && (IS_PLAYER(other))))
        {
                activator = other;
                oldmsg = self.message;
@@ -476,7 +466,7 @@ void checkpoint_passed()
                self.message = oldmsg;
        }
 
-       if(other.classname != "player")
+       if (!IS_PLAYER(other))
                return;
 
        /*
@@ -487,7 +477,7 @@ void checkpoint_passed()
        other.porto_forbidden = 2; // decreased by 1 each StartFrame
 
        if(defrag_ents) {
-               if(self.race_checkpoint == -2) 
+               if(self.race_checkpoint == -2)
                {
                        self.race_checkpoint = other.race_checkpoint;
                }
@@ -507,7 +497,7 @@ void checkpoint_passed()
                                for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
                                        if(cp.race_checkpoint == -2) // set defragcpexists to -1 so that the cp id file will be rewritten when someone finishes
                                                defragcpexists = -1;
-                               }       
+                               }
                        }
                }
                if(cp_amount == 0) {
@@ -621,7 +611,7 @@ void trigger_race_checkpoint_verify()
        if(have_verified)
                return;
        have_verified = 1;
-       
+
        qual = g_race_qualifying;
 
        oldself = self;
@@ -647,7 +637,7 @@ void trigger_race_checkpoint_verify()
                                self.race_place = race_lowest_place_spawn;
                                if(!Spawn_FilterOutBadSpots(findchain(classname, "info_player_deathmatch"), 0, FALSE))
                                        error(strcat("Checkpoint ", ftos(i), " misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
-                               
+
                                // race only (initial spawn)
                                g_race_qualifying = 0;
                                for(p = 1; p <= race_highest_place_spawn; ++p)
@@ -673,7 +663,7 @@ void trigger_race_checkpoint_verify()
                self.race_checkpoint = race_NextCheckpoint(0);
                g_race_qualifying = 1;
                self.race_place = 0; // there's only one spawn on defrag maps
+
                // check if a defragcp file already exists, then read it and apply the checkpoint order
                float fh;
                float len;
@@ -749,8 +739,8 @@ void trigger_race_checkpoint_verify()
                                        targ.wait = 0;
                                        targ.delay = 0;
 
-                    // These just make the game crash on some maps with oddly shaped triggers. 
-                    // (on the other hand they used to fix the case when two players ran through a checkpoint at once, 
+                    // These just make the game crash on some maps with oddly shaped triggers.
+                    // (on the other hand they used to fix the case when two players ran through a checkpoint at once,
                     // and often one of them just passed through without being registered. Hope it's fixed  in a better way now.
                     // (happened on item triggers too)
                     //
@@ -810,7 +800,7 @@ void spawnfunc_trigger_race_checkpoint()
        EXACTTRIGGER_INIT;
 
        self.use = checkpoint_use;
-       if not(self.spawnflags & 1)
+       if (!(self.spawnflags & 1))
                self.touch = checkpoint_touch;
 
        o = (self.absmin + self.absmax) * 0.5;
@@ -824,7 +814,7 @@ void spawnfunc_trigger_race_checkpoint()
                self.message2 = "was pushed backwards by";
        if (self.race_penalty_reason == "")
                self.race_penalty_reason = "missing a checkpoint";
-       
+
        self.race_checkpoint = self.cnt;
 
        if(self.race_checkpoint > race_highest_checkpoint)
@@ -863,7 +853,7 @@ void spawnfunc_target_checkpoint() // defrag entity
        EXACTTRIGGER_INIT;
 
        self.use = checkpoint_use;
-       if not(self.spawnflags & 1)
+       if (!(self.spawnflags & 1))
                self.touch = checkpoint_touch;
 
        o = (self.absmin + self.absmax) * 0.5;
@@ -904,7 +894,7 @@ void race_AbandonRaceCheck(entity p)
        {
                p.race_completed = 1;
                MAKE_INDEPENDENT_PLAYER(p);
-               bprint(p.netname, "^7 has abandoned the race.\n");
+               Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_RACE_ABANDONED, p.netname);
                ClientData_Touch(p);
        }
 }
@@ -1100,7 +1090,7 @@ void spawnfunc_trigger_race_penalty()
        EXACTTRIGGER_INIT;
 
        self.use = penalty_use;
-       if not(self.spawnflags & 1)
+       if (!(self.spawnflags & 1))
                self.touch = penalty_touch;
 
        if (self.race_penalty_reason == "")
@@ -1125,7 +1115,7 @@ float race_GetFractionalLapCount(entity e)
        l = PlayerScore_Add(e, SP_RACE_LAPS, 0);
        if(e.race_completed)
                return l; // not fractional
-       
+
        vector o0, o1;
        float bestfraction, fraction;
        entity lastcp, cp0, cp1;
@@ -1137,7 +1127,7 @@ float race_GetFractionalLapCount(entity e)
 
        if(nextcpindex == lastcpindex)
                return l; // finish
-       
+
        bestfraction = 1;
        for(cp0 = world; (cp0 = find(cp0, classname, "trigger_race_checkpoint")); )
        {