]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
Reverting the DP_MOVETYPEWALK_NONCLIENTS commit.
[xonotic/darkplaces.git] / host_cmd.c
index b5d43ffec2299ac62a1776f9cc75b5b727454409..7ded7c4787ef1f0bd4e1b835564f0d45f9d6e61d 100644 (file)
@@ -671,6 +671,7 @@ Host_Name_f
 cvar_t cl_name = {CVAR_SAVE, "_cl_name", "player"};
 void Host_Name_f (void)
 {
+       int i, j;
        char newName[sizeof(host_client->name)];
 
        if (Cmd_Argc () == 1)
@@ -684,16 +685,27 @@ void Host_Name_f (void)
        else
                strlcpy (newName, Cmd_Args(), sizeof (newName));
 
+       for (i = 0, j = 0;newName[i];i++)
+               if (newName[i] != '\r' && newName[i] != '\n')
+                       newName[j++] = newName[i];
+       newName[j] = 0;
+
        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);
@@ -1103,6 +1115,8 @@ void Host_Spawn_f (void)
                return;
        }
 
+       host_client->nametime = 0;
+
        // LordHavoc: moved this above the QC calls at FrikaC's request
        // send all current names, colors, and frag counts
        SZ_Clear (&host_client->message);