]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
cleaned up Host_Say to not process the message (MUCH simpler and I didn't trust that...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 8 Oct 2004 04:31:06 +0000 (04:31 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 8 Oct 2004 04:31:06 +0000 (04:31 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4607 d7cf8633-e32d-0410-b094-e92efae38249

host_cmd.c

index 6d64f5911046106f5c85fd3298884260a2f2b6b3..e62c96b5fac07e2836e5b7fee5423b6ef79c2510 100644 (file)
@@ -792,7 +792,7 @@ void Host_Say(qboolean teamonly)
 {
        client_t *save;
        int j;
-       const char *p1, *p2;
+       const char *p1;
        // LordHavoc: 256 char say messages
        unsigned char text[256];
        qboolean fromServer = false;
@@ -814,39 +814,20 @@ void Host_Say(qboolean teamonly)
        if (Cmd_Argc () < 2)
                return;
 
-       save = host_client;
+       if (!teamplay.integer)
+               teamonly = false;
 
 // turn on color set 1
+       p1 = Cmd_Args();
        if (!fromServer)
-               sprintf (text, "%c%s: ", 1, host_client->name);
+               snprintf (text, sizeof(text), "%c%s: %s\n", 1, host_client->name, p1);
        else
-               sprintf (text, "%c<%s> ", 1, hostname.string);
-
-       p1 = Cmd_Args();
-       p2 = p1 + strlen(p1);
-       // remove trailing newlines
-       while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
-               p2--;
-       // remove quotes if present
-       if (*p1 == '"')
-       {
-               p1++;
-               if (p2[-1] == '"')
-                       p2--;
-               else if (fromServer)
-                       Con_Print("Host_Say: missing end quote\n");
-               else
-                       SV_ClientPrint("Host_Say: missing end quote\n");
-       }
-       while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
-               p2--;
-       for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
-               text[j++] = *p1++;
-       text[j++] = '\n';
-       text[j++] = 0;
+               snprintf (text, sizeof(text), "%c<%s> %s\n", 1, hostname.string, p1);
 
+       // note: save is not a valid edict if fromServer is true
+       save = host_client;
        for (j = 0, host_client = svs.clients;j < svs.maxclients;j++, host_client++)
-               if (host_client->spawned && (!teamplay.integer || host_client->edict->v->team == save->edict->v->team))
+               if (host_client->spawned && (!teamonly || host_client->edict->v->team == save->edict->v->team))
                        SV_ClientPrint(text);
        host_client = save;