]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
damn, I can't convert hex/dec...
[xonotic/darkplaces.git] / host_cmd.c
index bac0d1424776a3556a672d62739b1eb3cb7ce006..95647886cc0d0a433bf11514e080302e4c0ed096 100644 (file)
@@ -38,7 +38,7 @@ Host_Quit_f
 
 void Host_Quit_f (void)
 {
-       Sys_Quit ();
+       Sys_Quit (0);
 }
 
 
@@ -92,7 +92,7 @@ void Host_Status_f (void)
                }
                else
                        hours = 0;
-               print ("#%-3u %-16.16s  %3i  %2i:%02i:%02i\n", j+1, client->name, client->frags, hours, minutes, seconds);
+               print ("#%-3u %-16.16s^%i  %3i  %2i:%02i:%02i\n", j+1, client->name, STRING_COLOR_DEFAULT, client->frags, hours, minutes, seconds);
                print ("   %s\n", client->netconnection ? client->netconnection->address : "botclient");
        }
 }
@@ -737,6 +737,7 @@ cvar_t cl_name = {CVAR_SAVE | CVAR_NQUSERINFOHACK, "_cl_name", "player", "intern
 void Host_Name_f (void)
 {
        int i, j;
+       qboolean valid_colors;
        char newName[sizeof(host_client->name)];
 
        if (Cmd_Argc () == 1)
@@ -771,11 +772,32 @@ void Host_Name_f (void)
 
        // point the string back at updateclient->name to keep it safe
        strlcpy (host_client->name, newName, sizeof (host_client->name));
+
+       COM_StringLengthNoColors(host_client->name, 0, &valid_colors);
+       if(!valid_colors) // NOTE: this also proves the string is not empty, as "" is a valid colored string
+       {
+               size_t l;
+               l = strlen(host_client->name);
+               if(l < sizeof(host_client->name) - 1)
+               {
+                       // duplicate the color tag to escape it
+                       host_client->name[i] = STRING_COLOR_TAG;
+                       host_client->name[i+1] = 0;
+                       //Con_DPrintf("abuse detected, adding another trailing color tag\n");
+               }
+               else
+               {
+                       // remove the last character to fix the color code
+                       host_client->name[l-1] = 0;
+                       //Con_DPrintf("abuse detected, removing a trailing color tag\n");
+               }
+       }
+
        host_client->edict->fields.server->netname = PRVM_SetEngineString(host_client->name);
        if (strcmp(host_client->old_name, host_client->name))
        {
                if (host_client->spawned)
-                       SV_BroadcastPrintf("%s changed name to %s\n", host_client->old_name, host_client->name);
+                       SV_BroadcastPrintf("%s^%i changed name to %s\n", host_client->old_name, STRING_COLOR_DEFAULT, 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);
@@ -1401,7 +1423,7 @@ void Host_Spawn_f (void)
                PRVM_ExecuteProgram (prog->globals.server->ClientConnect, "QC function ClientConnect is missing");
 
                if (svs.maxclients > 1 || cls.state == ca_dedicated)
-                       Con_Printf("%s entered the game\n", host_client->name);
+                       Con_Printf("%s^%i entered the game\n", host_client->name, STRING_COLOR_DEFAULT);
 
                PRVM_ExecuteProgram (prog->globals.server->PutClientInServer, "QC function PutClientInServer is missing");
        }
@@ -2324,8 +2346,10 @@ void Host_Pings_f (void)
        {
                packetloss = 0;
                if (svs.clients[i].netconnection)
-                       for (j = 0;j < 100;j++)
-                               packetloss += svs.clients[i].netconnection->packetlost[j];
+                       for (j = 0;j < NETGRAPH_PACKETS;j++)
+                               if (svs.clients[i].netconnection->incoming_unreliablesize[j] == NETGRAPH_LOSTPACKET)
+                                       packetloss++;
+               packetloss = packetloss * 100 / NETGRAPH_PACKETS;
                ping = (int)floor(svs.clients[i].ping*1000+0.5);
                ping = bound(0, ping, 9999);
                if (sv.protocol == PROTOCOL_QUAKEWORLD)
@@ -2369,7 +2393,7 @@ Host_InitCommands
 */
 void Host_InitCommands (void)
 {
-       dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\%s", engineversion);
+       dpsnprintf(cls.userinfo, sizeof(cls.userinfo), "\\name\\player\\team\\none\\topcolor\\0\\bottomcolor\\0\\rate\\10000\\msg\\1\\noaim\\1\\*ver\\dp");
 
        Cmd_AddCommand_WithClientCommand ("status", Host_Status_f, Host_Status_f, "print server status information");
        Cmd_AddCommand ("quit", Host_Quit_f, "quit the game");