]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - host_cmd.c
more size_t
[xonotic/darkplaces.git] / host_cmd.c
index b88d27bcfd993d21693465b0e4a22ca5ce93ae2b..3a62b1dfb75b2b62d6cc3f959c839a7ea0b9da24 100644 (file)
@@ -369,6 +369,11 @@ This is sent just before a server changes levels
 */
 void Host_Reconnect_f (void)
 {
+       if (cmd_source == src_command)
+       {
+               Con_Print("reconnect is not valid from the console\n");
+               return;
+       }
        if (Cmd_Argc() != 1)
        {
                Con_Print("reconnect : wait for signon messages again\n");
@@ -430,12 +435,14 @@ void Host_SavegameComment (char *text)
 
        for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
                text[i] = ' ';
-       memcpy (text, cl.levelname, strlen(cl.levelname));
+       // LordHavoc: added min() to prevent overflow
+       memcpy (text, cl.levelname, min(strlen(cl.levelname), SAVEGAME_COMMENT_LENGTH));
        sprintf (kills,"kills:%3i/%3i", cl.stats[STAT_MONSTERS], cl.stats[STAT_TOTALMONSTERS]);
        memcpy (text+22, kills, strlen(kills));
-// convert space to _ to make stdio happy
+       // convert space to _ to make stdio happy
+       // LordHavoc: convert control characters to _ as well
        for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
-               if (text[i] == ' ')
+               if (text[i] <= ' ')
                        text[i] = '_';
        text[SAVEGAME_COMMENT_LENGTH] = '\0';
 }
@@ -811,8 +818,6 @@ void Host_Playermodel_f (void)
                PRVM_GETEDICTFIELDVALUE(host_client->edict, eval_playermodel)->string = PRVM_SetEngineString(host_client->playermodel);
        if (strcmp(host_client->old_model, host_client->playermodel))
        {
-               if (host_client->spawned)
-                       SV_BroadcastPrintf("%s changed model to %s\n", host_client->name, host_client->playermodel);
                strcpy(host_client->old_model, host_client->playermodel);
                /*// send notification to all clients
                MSG_WriteByte (&sv.reliable_datagram, svc_updatepmodel);
@@ -926,9 +931,9 @@ void Host_Say(qboolean teamonly)
                p1++;
        }
        if (!fromServer)
-               dpsnprintf (text, sizeof(text), "%c%s: %s", 1, host_client->name, p1);
+               dpsnprintf (text, sizeof(text), "%c%s" STRING_COLOR_DEFAULT_STR ": %s", 1, host_client->name, p1);
        else
-               dpsnprintf (text, sizeof(text), "%c<%s> %s", 1, hostname.string, p1);
+               dpsnprintf (text, sizeof(text), "%c<%s" STRING_COLOR_DEFAULT_STR "> %s", 1, hostname.string, p1);
        p2 = text + strlen(text);
        while ((const char *)p2 > (const char *)text && (p2[-1] == '\r' || p2[-1] == '\n' || (p2[-1] == '\"' && quoted)))
        {
@@ -966,7 +971,7 @@ void Host_Say_Team_f(void)
 void Host_Tell_f(void)
 {
        client_t *save;
-       int j;
+       size_t j;
        const char *p1, *p2;
        char text[1024]; // LordHavoc: FIXME: temporary buffer overflow fix (was 64)
        qboolean fromServer = false;
@@ -1013,7 +1018,7 @@ void Host_Tell_f(void)
        }
        while (p2 > p1 && (p2[-1] == '\n' || p2[-1] == '\r'))
                p2--;
-       for (j = strlen(text);j < (int)(sizeof(text) - 2) && p1 < p2;)
+       for (j = strlen(text);j < (sizeof(text) - 2) && p1 < p2;)
                text[j++] = *p1++;
        text[j++] = '\n';
        text[j++] = 0;
@@ -1674,9 +1679,9 @@ void Host_Viewmodel_f (void)
                return;
 
        m = Mod_ForName (Cmd_Argv(1), false, true, false);
-       if (!m)
+       if (!m || !m->loaded || !m->Draw)
        {
-               Con_Printf("Can't load %s\n", Cmd_Argv(1));
+               Con_Printf("viewmodel: can't load %s\n", Cmd_Argv(1));
                return;
        }