]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Don't attempt to network more than the maximum number of shown spectators, fixes...
authorMario <mario.mario@y7mail.com>
Sun, 2 Aug 2020 12:03:31 +0000 (22:03 +1000)
committerMario <mario.mario@y7mail.com>
Sun, 2 Aug 2020 12:03:31 +0000 (22:03 +1000)
qcsrc/client/main.qc
qcsrc/server/client.qc
qcsrc/server/client.qh

index 25403017b352b30a3239f946312280e52e1e3bc7..c2c9ee8a2f4e6c717a1dd38b653f1a5d035a2d23 100644 (file)
@@ -474,12 +474,19 @@ NET_HANDLE(ENT_CLIENT_CLIENTDATA, bool isnew)
                for(i = 0; i < MAX_SPECTATORS; ++i)
                        spectatorlist[i] = 0; // reset list first
 
-               for(i = 0; i < num_spectators; ++i)
+               int limit = min(num_spectators, MAX_SPECTATORS);
+               for(i = 0; i < limit; ++i)
                {
                        slot = ReadByte();
                        spectatorlist[i] = slot - 1;
                }
        }
+       else
+       {
+               for(int j = 0; j < MAX_SPECTATORS; ++j)
+                       spectatorlist[j] = 0; // reset list if showspectators has been turned off
+               num_spectators = 0;
+       }
 
        return = true;
 
index 3707c9e484717d184b67c433c4ba117e610ec9ab..99aa86d24f82d7d233fc12f6fff56e2661252376 100644 (file)
@@ -121,9 +121,13 @@ void WriteSpectators(entity player, entity to)
 {
        if(!player) { return; } // not sure how, but best to be safe
 
+       int spec_count = 0;
        FOREACH_CLIENT(IS_REAL_CLIENT(it) && IS_SPEC(it) && it != to && it.enemy == player,
        {
+               if(spec_count >= MAX_SPECTATORS)
+                       break;
                WriteByte(MSG_ENTITY, num_for_edict(it));
+               ++spec_count;
        });
 }
 
index e7c9036c73edd2a850b9db655b1f621389fb8da9..8e5ee757f649da5414aeff81e7245fc291894548 100644 (file)
@@ -388,3 +388,5 @@ void Join(entity this);
 #define SPECTATE_COPYFIELD(fld) SPECTATE_COPY() { this.(fld) = spectatee.(fld); }
 
 int Say(entity source, int teamsay, entity privatesay, string msgin, bool floodcontrol);
+
+const int MAX_SPECTATORS = 7;