]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Store 99 time records in the server database. Send g_cts_send_rankings_cnt records...
authorNick Savchenko <nsavch@gmail.com>
Mon, 4 Jun 2018 20:51:42 +0000 (23:51 +0300)
committerNick Savchenko <nsavch@gmail.com>
Mon, 4 Jun 2018 20:51:42 +0000 (23:51 +0300)
gamemodes-server.cfg
qcsrc/client/main.qc
qcsrc/common/constants.qh
qcsrc/common/net_linked.qh
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_race.qc
qcsrc/server/race.qc
qcsrc/server/race.qh

index 6790a3b4fb9575ab91e070c57bc984ac97609ba2..7319cba4e8d1d1d286261036a5da4b215e26364c 100644 (file)
@@ -308,6 +308,7 @@ exec ctfscoring-samual.cfg
 set g_cts 0 "CTS: complete the stage"
 set g_cts_selfdamage 1 "0 = disable all selfdamage and falldamage in cts"
 set g_cts_finish_kill_delay 10 "prevent cheating by running back to the start line, and starting out with more speed than otherwise possible"
+set g_cts_send_rankings_cnt 15 "send this number of map records to clients"
 
 
 // ==========================
index 37027d25cd35570419c819179b207311580f157e..9f1061dc9dd6bafaa43016b9a612108febd05a29 100644 (file)
@@ -1144,6 +1144,9 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
                        strcpy(race_speedaward_alltimebest_holder, ReadString());
                        strcpy(race_speedaward_alltimebest_unit, GetSpeedUnit(autocvar_hud_panel_physics_speed_unit));
                        break;
+               case RACE_NET_RANKINGS_CNT:
+                       RANKINGS_RECEIVED_CNT = ReadByte();
+                       break;
                case RACE_NET_SERVER_RANKINGS:
                        float prevpos, del;
             int pos = ReadShort();
@@ -1153,13 +1156,14 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
                        // move other rankings out of the way
             int i;
                        if (prevpos) {
-                               for (i=prevpos-1;i>pos-1;--i) {
+                               int m = min(prevpos, RANKINGS_RECEIVED_CNT);
+                               for (i=m-1; i>pos-1; --i) {
                                        grecordtime[i] = grecordtime[i-1];
                                        strcpy(grecordholder[i], grecordholder[i-1]);
                                }
                        } else if (del) { // a record has been deleted by the admin
-                               for (i=pos-1; i<= RANKINGS_CNT-1; ++i) {
-                                       if (i == RANKINGS_CNT-1) { // clear out last record
+                               for (i=pos-1; i<= RANKINGS_RECEIVED_CNT-1; ++i) {
+                                       if (i == RANKINGS_RECEIVED_CNT-1) { // clear out last record
                                                grecordtime[i] = 0;
                                                strfree(grecordholder[i]);
                                        }
@@ -1169,12 +1173,18 @@ NET_HANDLE(TE_CSQC_RACE, bool isNew)
                                        }
                                }
                        } else { // player has no ranked record yet
-                               for (i=RANKINGS_CNT-1;i>pos-1;--i) {
+                               for (i=RANKINGS_RECEIVED_CNT-1;i>pos-1;--i) {
                                        grecordtime[i] = grecordtime[i-1];
                                        strcpy(grecordholder[i], grecordholder[i-1]);
                                }
                        }
 
+                       if (grecordtime[RANKINGS_RECEIVED_CNT]) {
+                               // kick off the player who fell from the last displayed position
+                               grecordtime[RANKINGS_RECEIVED_CNT] = 0;
+                               strfree(grecordholder[RANKINGS_RECEIVED_CNT]);
+                       }
+
                        // store new ranking
                        strcpy(grecordholder[pos-1], ReadString());
                        grecordtime[pos-1] = ReadInt24_t();
index 8afe47bdeed09a1ac19c242b2706a91d8422a72e..675b75c0a4a0fc4ae21e39bc4fbbe67415e8bb3c 100644 (file)
@@ -1,6 +1,6 @@
 #pragma once
 
-const int RANKINGS_CNT = 100;
+const int RANKINGS_CNT = 99;
 
 ///////////////////////////
 // keys pressed
index 657e761712250cc7aed93ec4f3d93747979588f6..6651c6cb9b75fae79d13d8a38681883c557873a1 100644 (file)
@@ -22,6 +22,7 @@ const int RACE_NET_SERVER_RANKINGS = 11;
 const int RACE_NET_SERVER_STATUS = 12;
 const int RACE_NET_CHECKPOINT_HIT_SELF_QUALIFYING = 13; // byte checkpoint, short time, short recordtime
 const int RACE_NET_CHECKPOINT_NEXT_SELF_QUALIFYING = 14; // byte nextcheckpoint, short recordtime
+const int RACE_NET_RANKINGS_CNT = 15;
 
 REGISTER_NET_LINKED(_ENT_CLIENT_INIT)
 #ifdef CSQC
index e0d25e9e8f494c829c8fbf3156f15c92f168cddf..1847473cf9f57eb51fd768d94ac072fe242e8c56 100644 (file)
@@ -2228,7 +2228,9 @@ MUTATOR_HOOKFUNCTION(ctf, ClientConnect)
 
        if(IS_REAL_CLIENT(player))
        {
-               for(int i = 1; i <= RANKINGS_CNT; ++i)
+               int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt);
+               race_send_rankings_cnt(MSG_ONE);
+               for (int i = 1; i <= m; ++i)
                {
                        race_SendRankings(i, 0, 0, MSG_ONE);
                }
index 1363411aa9e75c7f388aad0439b6e7ef1abc2371..87830db48609f8af700064d24839d2a169e872a8 100644 (file)
@@ -199,7 +199,9 @@ MUTATOR_HOOKFUNCTION(cts, ClientConnect)
                race_send_speedaward_alltimebest(MSG_ONE);
 
                float i;
-               for (i = 1; i <= RANKINGS_CNT; ++i)
+               int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt);
+               race_send_rankings_cnt(MSG_ONE);
+               for (i = 1; i <= m; ++i)
                {
                        race_SendRankings(i, 0, 0, MSG_ONE);
                }
index e4109b72a8523e84bd913951409a50339866ed50..65541fc0868f03e80fd10d4ece5ea56cd3a27c81 100644 (file)
@@ -245,7 +245,9 @@ MUTATOR_HOOKFUNCTION(rc, ClientConnect)
                race_send_speedaward_alltimebest(MSG_ONE);
 
                float i;
-               for (i = 1; i <= RANKINGS_CNT; ++i)
+               int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt);
+               race_send_rankings_cnt(MSG_ONE);
+               for (i = 1; i <= m; ++i)
                {
                        race_SendRankings(i, 0, 0, MSG_ONE);
                }
index 743d02d03c0acc1af8d95a94c460131e6a398f94..da86f76f0bf4dbcd1deceb6027bfd96c58eda2dd 100644 (file)
@@ -224,6 +224,14 @@ void race_send_speedaward_alltimebest(float msg)
        WriteString(msg, speedaward_alltimebest_holder);
 }
 
+void race_send_rankings_cnt(float msg)
+{
+       WriteHeader(msg, TE_CSQC_RACE);
+       WriteByte(msg, RACE_NET_RANKINGS_CNT);
+       int m = min(RANKINGS_CNT, autocvar_g_cts_send_rankings_cnt);
+       WriteByte(msg, m);
+}
+
 void race_SendRankings(float pos, float prevpos, float del, float msg)
 {
        WriteHeader(msg, TE_CSQC_RACE);
index 472827efa4a81d13a014ae84d998f1b88d62628f..32edca781768165a32e3309433c9e8774e9c238f 100644 (file)
@@ -5,6 +5,8 @@ float race_teams;
 // scores
 const float ST_RACE_LAPS = 1;
 
+int autocvar_g_cts_send_rankings_cnt = 15;
+
 bool g_race_qualifying;
 
 float speedaward_lastsent;
@@ -61,6 +63,8 @@ void race_send_speedaward(float msg);
 
 void race_send_speedaward_alltimebest(float msg);
 
+void race_send_rankings_cnt(float msg);
+
 void race_SendRankings(float pos, float prevpos, float del, float msg);
 
 void race_RetractPlayer(entity this);