Replace strncpy usage with Q_strncpyz
This commit is contained in:
1 parent
c8553223ec
commit
1132abe3dc
10 files changed
+16
-34
No files matched your search
+1
-2
@@ -237,8 +237,7 @@ char *BotMapTitle(void) {
|
||||
|
||||
trap_GetServerinfo(info, sizeof(info));
|
||||
|
||||
strncpy(mapname, Info_ValueForKey( info, "mapname" ), sizeof(mapname)-1);
|
||||
mapname[sizeof(mapname)-1] = '\0';
|
||||
Q_strncpyz(mapname, Info_ValueForKey( info, "mapname" ), sizeof(mapname));
|
||||
|
||||
return mapname;
|
||||
}
|
||||
|
||||
+2
-4
@@ -1105,8 +1105,7 @@ void BotMatch_JoinSubteam(bot_state_t *bs, bot_match_t *match) {
|
||||
//get the sub team name
|
||||
trap_BotMatchVariable(match, TEAMNAME, teammate, sizeof(teammate));
|
||||
//set the sub team name
|
||||
strncpy(bs->subteam, teammate, 32);
|
||||
bs->subteam[31] = '\0';
|
||||
Q_strncpyz(bs->subteam, teammate, sizeof(bs->subteam));
|
||||
//
|
||||
trap_BotMatchVariable(match, NETNAME, netname, sizeof(netname));
|
||||
BotAI_BotInitialChat(bs, "joinedteam", teammate, NULL);
|
||||
@@ -1297,8 +1296,7 @@ void BotMatch_StartTeamLeaderShip(bot_state_t *bs, bot_match_t *match) {
|
||||
if (match->subtype & ST_I) {
|
||||
//get the team mate that will be the team leader
|
||||
trap_BotMatchVariable(match, NETNAME, teammate, sizeof(teammate));
|
||||
strncpy(bs->teamleader, teammate, sizeof(bs->teamleader));
|
||||
bs->teamleader[sizeof(bs->teamleader)-1] = '\0';
|
||||
Q_strncpyz(bs->teamleader, teammate, sizeof(bs->teamleader));
|
||||
}
|
||||
//chats for someone else
|
||||
else {
|
||||
|
||||
+4
-8
@@ -1397,8 +1397,7 @@ char *ClientName(int client, char *name, int size) {
|
||||
return "[client out of range]";
|
||||
}
|
||||
trap_GetConfigstring(CS_PLAYERS+client, buf, sizeof(buf));
|
||||
strncpy(name, Info_ValueForKey(buf, "n"), size-1);
|
||||
name[size-1] = '\0';
|
||||
Q_strncpyz(name, Info_ValueForKey(buf, "n"), size);
|
||||
Q_CleanStr( name );
|
||||
return name;
|
||||
}
|
||||
@@ -1416,8 +1415,7 @@ char *ClientSkin(int client, char *skin, int size) {
|
||||
return "[client out of range]";
|
||||
}
|
||||
trap_GetConfigstring(CS_PLAYERS+client, buf, sizeof(buf));
|
||||
strncpy(skin, Info_ValueForKey(buf, "model"), size-1);
|
||||
skin[size-1] = '\0';
|
||||
Q_strncpyz(skin, Info_ValueForKey(buf, "model"), size);
|
||||
return skin;
|
||||
}
|
||||
|
||||
@@ -1520,8 +1518,7 @@ char *EasyClientName(int client, char *buf, int size) {
|
||||
memmove(ptr, ptr+1, strlen(ptr + 1)+1);
|
||||
}
|
||||
}
|
||||
strncpy(buf, name, size-1);
|
||||
buf[size-1] = '\0';
|
||||
Q_strncpyz(buf, name, size);
|
||||
return buf;
|
||||
}
|
||||
|
||||
@@ -3692,8 +3689,7 @@ void BotMapScripts(bot_state_t *bs) {
|
||||
|
||||
trap_GetServerinfo(info, sizeof(info));
|
||||
|
||||
strncpy(mapname, Info_ValueForKey( info, "mapname" ), sizeof(mapname)-1);
|
||||
mapname[sizeof(mapname)-1] = '\0';
|
||||
Q_strncpyz(mapname, Info_ValueForKey( info, "mapname" ), sizeof(mapname));
|
||||
|
||||
if (!Q_stricmp(mapname, "q3tourney6") || !Q_stricmp(mapname, "q3tourney6_ctf") || !Q_stricmp(mapname, "mpq3tourney6")) {
|
||||
vec3_t mins = {694, 200, 480}, maxs = {968, 472, 680};
|
||||
|
||||
+1
-2
@@ -1956,8 +1956,7 @@ void BotTeamAI(bot_state_t *bs) {
|
||||
trap_BotEnterChat(bs->cs, 0, CHAT_TEAM);
|
||||
BotSayVoiceTeamOrder(bs, -1, VOICECHAT_STARTLEADER);
|
||||
ClientName(bs->client, netname, sizeof(netname));
|
||||
strncpy(bs->teamleader, netname, sizeof(bs->teamleader));
|
||||
bs->teamleader[sizeof(bs->teamleader)-1] = '\0';
|
||||
Q_strncpyz(bs->teamleader, netname, sizeof(bs->teamleader));
|
||||
bs->becometeamleader_time = 0;
|
||||
}
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user