]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/scores.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / scores.qc
index 1b7808db199945ced560261aceebd217a8223ede..83c5d5ee5339e96aaef7405e4206837655767d6f 100644 (file)
@@ -223,7 +223,7 @@ bool ScoreInfo_SendEntity(entity this, entity to, int sf)
        WriteByte(MSG_ENTITY, welcome_msg_too);
        // welcome message is sent here because it needs to know the gametype
        if (welcome_msg_too)
-               SendWelcomemessage_msg_type(to, false, MSG_ENTITY);
+               SendWelcomeMessage(to, MSG_ENTITY);
        return true;
 }
 
@@ -292,8 +292,8 @@ float PlayerScore_Clear(entity player)
        sk = CS(player).scorekeeper;
        FOREACH(Scores, true, {
                if(sk.(scores(it)) != 0)
-                       if(scores_label(it) != "")
-                               sk.SendFlags |= BIT(i % 16);
+                       //if(scores_label(it) != "")
+                       sk.SendFlags |= (2 ** (i % 16));
                if(i != SP_ELO.m_id)
                        sk.(scores(it)) = 0;
        });
@@ -310,8 +310,8 @@ void Score_ClearAll()
                if (!sk) continue;
                FOREACH(Scores, true, {
                        if(sk.(scores(it)) != 0)
-                               if(scores_label(it) != "")
-                                       sk.SendFlags |= BIT(i % 16);
+                               //if(scores_label(it) != "")
+                               sk.SendFlags |= (2 ** (i % 16));
                        if(i != SP_ELO.m_id)
                                sk.(scores(it)) = 0;
                });
@@ -324,8 +324,8 @@ void Score_ClearAll()
                for(int j = 0; j < MAX_TEAMSCORE; ++j)
                {
                        if(sk.(teamscores(j)) != 0)
-                               if(teamscores_label(j) != "")
-                                       sk.SendFlags |= BIT(j);
+                               //if(teamscores_label(j) != "")
+                               sk.SendFlags |= (2 ** j);
                        sk.(teamscores(j)) = 0;
                }
        }
@@ -372,8 +372,8 @@ float PlayerScore_Add(entity player, PlayerScoreField scorefield, float score)
        {
                return s.(scores(scorefield));
        }
-       if(scores_label(scorefield) != "")
-               s.SendFlags |= BIT(scorefield.m_id % 16);
+       //if(scores_label(scorefield) != "")
+       s.SendFlags |= (2 ** (scorefield.m_id % 16));
        if(!warmup_stage)
                PlayerStats_GameReport_Event_Player(s.owner, strcat(PLAYERSTATS_TOTAL, scores_label(scorefield)), score);
        s.(scores(scorefield)) += score;
@@ -441,6 +441,24 @@ float PlayerScore_Compare(entity t1, entity t2, bool strict)
        return result;
 }
 
+bool Score_NewLeader()
+{
+       if(teamplay) {
+               if (WinningConditionHelper_winnerteam != WinningConditionHelper_winnerteam_last && (WinningConditionHelper_secondteam || WinningConditionHelper_equality))
+               {
+                       WinningConditionHelper_winnerteam_last = WinningConditionHelper_winnerteam;
+                       return true;
+               }
+       } else {
+               if (WinningConditionHelper_winner != WinningConditionHelper_winner_last && (WinningConditionHelper_second || WinningConditionHelper_equality))
+               {
+                       WinningConditionHelper_winner_last = WinningConditionHelper_winner;
+                       return true;
+               }
+       }
+       return false;
+}
+
 void WinningConditionHelper(entity this)
 {
        float c;
@@ -543,7 +561,15 @@ void WinningConditionHelper(entity this)
 
                WinningConditionHelper_equality = (PlayerScore_Compare(winnerscorekeeper, secondscorekeeper, false) == 0);
                if(WinningConditionHelper_equality)
+               {
+                       WinningConditionHelper_equality_one = WinningConditionHelper_winner;
+                       WinningConditionHelper_equality_two = WinningConditionHelper_second;
                        WinningConditionHelper_winner = WinningConditionHelper_second = NULL;
+               }
+               else
+               {
+                       WinningConditionHelper_equality_one = WinningConditionHelper_equality_two = NULL;
+               }
 
                WinningConditionHelper_topscore = winnerscorekeeper.scores_primary;
                WinningConditionHelper_secondscore = secondscorekeeper.scores_primary;
@@ -864,7 +890,7 @@ void Score_NicePrint_Team(entity to, float t, float w)
                        {
                                fl = teamscores_flags(i);
                                sc = sk.(teamscores(i));
-                               s = strcat(s, " ", Score_NicePrint_ItemColor(fl), ScoreString(fl, sc));
+                               s = strcat(s, " ", Score_NicePrint_ItemColor(fl), ScoreString(fl, sc, 0));
                        }
        }
        else
@@ -912,7 +938,7 @@ void Score_NicePrint_Player(entity to, entity p, float w)
                {
                        fl = scores_flags(it);
                        sc = sk.(scores(it));
-                       s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, ScoreString(fl, sc)));
+                       s = strcat(s, " ", Score_NicePrint_ItemColor(fl), strpad(-w, ScoreString(fl, sc, 0)));
                }
     });