]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Tomaz's nametime patch (prevent frequent name changes on the server)
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 13 May 2004 18:40:01 +0000 (18:40 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 13 May 2004 18:40:01 +0000 (18:40 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4158 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c
server.h

index b5d43ffec2299ac62a1776f9cc75b5b727454409..645a6a18ecb5053f89a39d75af19ca7f16f1a6d8 100644 (file)
@@ -686,14 +686,20 @@ void Host_Name_f (void)
 
        if (cmd_source == src_command)
        {
-               if (strcmp(cl_name.string, newName) == 0)
-                       return;
                Cvar_Set ("_cl_name", newName);
                if (cls.state == ca_connected)
                        Cmd_ForwardToServer ();
                return;
        }
 
+       if (sv.time < host_client->nametime)
+       {
+               SV_ClientPrintf("You can't change name more than once every 5 seconds!\n");
+               return;
+       }
+       
+       host_client->nametime = sv.time + 5;
+
        if (strcmp(host_client->name, newName) && host_client->name[0] && strcmp(host_client->name, "unconnected"))
                SV_BroadcastPrintf("%s changed name to %s\n", host_client->name, newName);
        strcpy(host_client->name, newName);
index e520b600d8eb90775d06fe9e1df02beff50693cb..5ae03a239c6c8831b2c199cf20d0d469413511f5 100644 (file)
--- a/server.h
+++ b/server.h
@@ -149,6 +149,10 @@ typedef struct client_s
 
        // visibility state
        float visibletime[MAX_EDICTS];
+
+       // prevent animated names
+       float nametime;
+
 #ifdef QUAKEENTITIES
        // delta compression state
        float nextfullupdate[MAX_EDICTS];