]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/race.qc
Merge remote-tracking branch 'origin/master' into samual/notification_rewrite
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / race.qc
index 911106a30560358e6ae03054ab21526dc0e6ad8a..2c3f003a237f49103d01a0a04af4503e96d4a56e 100644 (file)
@@ -141,6 +141,7 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
        newpos = race_readPos(map, t);
 
        float i;
+       player_prevpos = 0;
        for(i = 1; i <= RANKINGS_CNT; ++i)
        {
                if(race_readUID(map, i) == myuid)
@@ -155,13 +156,13 @@ void race_setTime(string map, float t, string myuid, string mynetname, entity e)
                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);
+               Send_Notification(world, MSG_BROADCAST, MSG_INFO, INFO_RACE_FAIL, e.netname, TIME_ENCODED_TOSTRING(t), NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
                return;
        } else if (!newpos) { // no ranking, time worse than the worst ranked
                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);
+               Send_Notification(world, MSG_BROADCAST, MSG_INFO, INFO_RACE_FAIL, e.netname, TIME_ENCODED_TOSTRING(t), NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
                return;
        }
 
@@ -200,22 +201,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);
+               Send_Notification(world, MSG_BROADCAST, MSG_INFO, INFO_RACE_NEW_RECORD, e.netname, TIME_ENCODED_TOSTRING(t), NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
        } 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);
+                       Send_Notification(world, MSG_BROADCAST, MSG_INFO, INFO_RACE_NEW_TIME, e.netname, TIME_ENCODED_TOSTRING(t), NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
                } 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);
+                       Send_Notification(world, MSG_BROADCAST, MSG_INFO, INFO_RACE_NEW_RANK, e.netname, TIME_ENCODED_TOSTRING(t), NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
                } 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);
+                       Send_Notification(world, MSG_BROADCAST, MSG_INFO, INFO_RACE_NEW_RANK, e.netname, TIME_ENCODED_TOSTRING(t), NO_FL_ARG, NO_FL_ARG, NO_FL_ARG);
                }
        }
 }
@@ -490,8 +491,8 @@ void checkpoint_passed()
                        self.race_checkpoint = other.race_checkpoint;
                }
 
-               float largest_cp_id;
-               float cp_amount;
+               float largest_cp_id = 0;
+               float cp_amount = 0;
                for(cp = world; (cp = find(cp, classname, "target_checkpoint"));) {
                        cp_amount += 1;
                        if(cp.race_checkpoint > largest_cp_id) // update the finish id if someone hit a new checkpoint
@@ -664,7 +665,7 @@ void trigger_race_checkpoint_verify()
                g_race_qualifying = 1;
                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"));
+                       error(strcat("Checkpoint 0 misses a spawnpoint with race_place==", ftos(self.race_place), " (used for qualifying) - bailing out"));
        }
        else
        {
@@ -710,7 +711,7 @@ void trigger_race_checkpoint_verify()
                        }
 
                        if(defragcpexists != -1){
-                               float largest_cp_id;
+                               float largest_cp_id = 0;
                                for(cp = world; (cp = find(cp, classname, "target_checkpoint"));)
                                        if(cp.race_checkpoint > largest_cp_id)
                                                largest_cp_id = cp.race_checkpoint;
@@ -816,11 +817,11 @@ void spawnfunc_trigger_race_checkpoint()
        waypoint_spawnforitem_force(self, trace_endpos);
        self.nearestwaypointtimeout = time + 1000000000;
 
-       if(!self.message)
+       if(self.message == "")
                self.message = "went backwards";
-       if (!self.message2)
+       if (self.message2 == "")
                self.message2 = "was pushed backwards by";
-       if (!self.race_penalty_reason)
+       if (self.race_penalty_reason == "")
                self.race_penalty_reason = "missing a checkpoint";
        
        self.race_checkpoint = self.cnt;
@@ -869,11 +870,11 @@ void spawnfunc_target_checkpoint() // defrag entity
        waypoint_spawnforitem_force(self, trace_endpos);
        self.nearestwaypointtimeout = time + 1000000000;
 
-       if(!self.message)
+       if(self.message == "")
                self.message = "went backwards";
-       if (!self.message2)
+       if (self.message2 == "")
                self.message2 = "was pushed backwards by";
-       if (!self.race_penalty_reason)
+       if (self.race_penalty_reason == "")
                self.race_penalty_reason = "missing a checkpoint";
 
        if(self.classname == "target_startTimer")
@@ -1101,7 +1102,7 @@ void spawnfunc_trigger_race_penalty()
        if not(self.spawnflags & 1)
                self.touch = penalty_touch;
 
-       if (!self.race_penalty_reason)
+       if (self.race_penalty_reason == "")
                self.race_penalty_reason = "missing a checkpoint";
        if (!self.race_penalty)
                self.race_penalty = 5;