]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix CENTER_JOIN_PREVENT message spam while you keep pressed the join key
authorterencehill <piuntn@gmail.com>
Thu, 25 Aug 2016 09:15:17 +0000 (11:15 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 25 Aug 2016 09:15:17 +0000 (11:15 +0200)
qcsrc/server/client.qc

index d30c10feb91bd34ec7f4e1e81df7ceb062d6944f..b2fee6690928925ca3f173494a012c3161d3ee68 100644 (file)
@@ -1920,13 +1920,20 @@ int nJoinAllowed(entity this, entity ignore)
                        ++currentlyPlaying;
        ));
 
+       float free_slots = 0;
        if (!autocvar_g_maxplayers)
-               return maxclients - totalClients;
+               free_slots = maxclients - totalClients;
+       else if(currentlyPlaying < autocvar_g_maxplayers)
+               free_slots = min(maxclients - totalClients, autocvar_g_maxplayers - currentlyPlaying);
 
-       if(currentlyPlaying < autocvar_g_maxplayers)
-               return min(maxclients - totalClients, autocvar_g_maxplayers - currentlyPlaying);
+       static float join_prevent_msg_time = 0;
+       if(ignore && !free_slots && time > join_prevent_msg_time)
+       {
+               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_PREVENT);
+               join_prevent_msg_time = time + 3;
+       }
 
-       return 0;
+       return free_slots;
 }
 
 /**
@@ -1998,12 +2005,7 @@ bool spawnAllowed(entity this)
        if (this.version_mismatch) return false;
        if (teamplay && lockteams) return false;
        if (MUTATOR_CALLHOOK(ForbidSpawn, this)) return false;
-       if (!nJoinAllowed(this, this))
-       {
-               // Player may not join because g_maxplayers is set
-               Send_Notification(NOTIF_ONE_ONLY, this, MSG_CENTER, CENTER_JOIN_PREVENT);
-               return false;
-       }
+       if (!nJoinAllowed(this, this)) return false;
        return true;
 }