]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_parse.c
Lots of str[n]cat, str[n]cpy, and [v]sprintf have been replaced by strlcat, strlcpy...
[xonotic/darkplaces.git] / cl_parse.c
index 38de3397371a68e4c877cb6478c2139ced42c77c..9a7ad21ac75c0d1306aba779731db1adafb42acb 100644 (file)
@@ -354,7 +354,7 @@ void CL_ParseServerInfo (void)
 
 // parse signon message
        str = MSG_ReadString ();
-       strncpy (cl.levelname, str, sizeof(cl.levelname)-1);
+       strlcpy (cl.levelname, str, sizeof(cl.levelname));
 
 // seperate the printfs so the server message can have a color
        if (cl.protocol != PROTOCOL_NEHAHRAMOVIE) // no messages when playing the Nehahra movie
@@ -807,11 +807,14 @@ void CL_ParseClientdata (int bits)
        cl.stats[STAT_CELLS] = MSG_ReadByte();
 
        i = MSG_ReadByte ();
-
        if (gamemode == GAME_HIPNOTIC || gamemode == GAME_ROGUE)
-               cl.stats[STAT_ACTIVEWEAPON] = (1<<i);
-       else
-               cl.stats[STAT_ACTIVEWEAPON] = i;
+               i = (1<<i);
+       // GAME_NEXUIZ hud needs weapon change time
+       // GAME_NEXUIZ uses a bit number as it's STAT_ACTIVEWEAPON, not a bitfield
+       // like other modes
+       if (cl.stats[STAT_ACTIVEWEAPON] != i)
+               cl.weapontime = cl.time;
+       cl.stats[STAT_ACTIVEWEAPON] = i;
 
        cl.viewzoomold = cl.viewzoomnew; // for interpolation
        if (bits & SU_VIEWZOOM)
@@ -1462,8 +1465,8 @@ void CL_ParseServerMessage(void)
                                i &= 31;
                                while(count > 0)
                                {
-                                       sprintf(temp, "%3i:%s ", cmdlog[i], cmdlogname[i]);
-                                       strcat(description, temp);
+                                       snprintf (temp, sizeof (temp), "%3i:%s ", cmdlog[i], cmdlogname[i]);
+                                       strlcat (description, temp, sizeof (description));
                                        count--;
                                        i++;
                                        i &= 31;
@@ -1547,7 +1550,7 @@ void CL_ParseServerMessage(void)
                        i = MSG_ReadByte ();
                        if (i >= MAX_LIGHTSTYLES)
                                Host_Error ("svc_lightstyle >= MAX_LIGHTSTYLES");
-                       strncpy (cl_lightstyle[i].map,  MSG_ReadString(), MAX_STYLESTRING - 1);
+                       strlcpy (cl_lightstyle[i].map,  MSG_ReadString(), sizeof (cl_lightstyle[i].map));
                        cl_lightstyle[i].map[MAX_STYLESTRING - 1] = 0;
                        cl_lightstyle[i].length = strlen(cl_lightstyle[i].map);
                        break;
@@ -1569,7 +1572,7 @@ void CL_ParseServerMessage(void)
                        i = MSG_ReadByte ();
                        if (i >= cl.maxclients)
                                Host_Error ("CL_ParseServerMessage: svc_updatename >= cl.maxclients");
-                       strcpy (cl.scores[i].name, MSG_ReadString ());
+                       strlcpy (cl.scores[i].name, MSG_ReadString (), sizeof (cl.scores[i].name));
                        break;
 
                case svc_updatefrags: