]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
sv_ccmds: Perform actual name change from a single function. Announce in chat.
authorcloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 9 Aug 2020 18:38:04 +0000 (18:38 +0000)
committercloudwalk <cloudwalk@d7cf8633-e32d-0410-b094-e92efae38249>
Sun, 9 Aug 2020 18:38:04 +0000 (18:38 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12887 d7cf8633-e32d-0410-b094-e92efae38249

server.h
sv_ccmds.c
sv_main.c

index d8250f658d74600d2d4d4c0fd9898dc371679491..a8769f6e24f8fdf75a983c8eeb12d3b0bcb133b1 100644 (file)
--- a/server.h
+++ b/server.h
@@ -610,7 +610,7 @@ void SV_StopThread(void);
 
 void VM_CustomStats_Clear(void);
 void VM_SV_UpdateCustomStats(client_t *client, prvm_edict_t *ent, sizebuf_t *msg, int *stats);
-
+void SV_Name(int clientnum);
 void SV_InitOperatorCommands(void);
 
 void SV_Savegame_to(prvm_prog_t *prog, const char *name);
index ea24d8593529cea83e83bf7e70a9d050cdf316bd..51f3eb27c2c265da0d3e1232fa40475b154c18e5 100644 (file)
@@ -938,6 +938,23 @@ static void SV_Status_f(cmd_state_t *cmd)
        }
 }
 
+void SV_Name(int clientnum)
+{
+       prvm_prog_t *prog = SVVM_prog;
+       PRVM_serveredictstring(host_client->edict, netname) = PRVM_SetEngineString(prog, host_client->name);
+       if (strcmp(host_client->old_name, host_client->name))
+       {
+               if (host_client->begun)
+                       SV_BroadcastPrintf("\003%s ^7changed name to ^3%s\n", host_client->old_name, host_client->name);
+               strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
+               // send notification to all clients
+               MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
+               MSG_WriteByte (&sv.reliable_datagram, clientnum);
+               MSG_WriteString (&sv.reliable_datagram, host_client->name);
+               SV_WriteNetnameIntoDemo(host_client);
+       }       
+}
+
 /*
 ======================
 SV_Name_f
@@ -945,7 +962,6 @@ SV_Name_f
 */
 static void SV_Name_f(cmd_state_t *cmd)
 {
-       prvm_prog_t *prog = SVVM_prog;
        int i, j;
        qboolean valid_colors;
        const char *newNameSource;
@@ -1040,18 +1056,7 @@ static void SV_Name_f(cmd_state_t *cmd)
        if (j >= 0 && strlen(host_client->name) < sizeof(host_client->name) - 2)
                memcpy(host_client->name + strlen(host_client->name), STRING_COLOR_DEFAULT_STR, strlen(STRING_COLOR_DEFAULT_STR) + 1);
 
-       PRVM_serveredictstring(host_client->edict, netname) = PRVM_SetEngineString(prog, host_client->name);
-       if (strcmp(host_client->old_name, host_client->name))
-       {
-               if (host_client->begun)
-                       SV_BroadcastPrintf("%s ^7changed name to %s\n", host_client->old_name, host_client->name);
-               strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
-               // send notification to all clients
-               MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
-               MSG_WriteByte (&sv.reliable_datagram, host_client - svs.clients);
-               MSG_WriteString (&sv.reliable_datagram, host_client->name);
-               SV_WriteNetnameIntoDemo(host_client);
-       }
+       SV_Name(host_client - svs.clients);
 }
 
 static void SV_Rate_f(cmd_state_t *cmd)
index c6a2c3b63705e2680122c61ed2f1dd8f4bccc90e..18a2f41cab1bc3b1dd030762c8485693aeb2df49 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -2648,18 +2648,7 @@ static void SV_UpdateToReliableMessages (void)
                //strlcpy (host_client->name, name, sizeof (host_client->name));
                if (name != host_client->name) // prevent buffer overlap SIGABRT on Mac OSX
                        strlcpy (host_client->name, name, sizeof (host_client->name));
-               PRVM_serveredictstring(host_client->edict, netname) = PRVM_SetEngineString(prog, host_client->name);
-               if (strcmp(host_client->old_name, host_client->name))
-               {
-                       if (host_client->begun)
-                               SV_BroadcastPrintf("%s ^7changed name to %s\n", host_client->old_name, host_client->name);
-                       strlcpy(host_client->old_name, host_client->name, sizeof(host_client->old_name));
-                       // send notification to all clients
-                       MSG_WriteByte (&sv.reliable_datagram, svc_updatename);
-                       MSG_WriteByte (&sv.reliable_datagram, i);
-                       MSG_WriteString (&sv.reliable_datagram, host_client->name);
-                       SV_WriteNetnameIntoDemo(host_client);
-               }
+               SV_Name(i);
 
                // DP_SV_CLIENTCOLORS
                host_client->colors = (int)PRVM_serveredictfloat(host_client->edict, clientcolors);