Use srtlcpy for voice name conversions

This commit is contained in:
yamamama 2025-11-16 21:05:04 -05:00
parent f47e123c8b
commit 3f23e3b00d
3 changed files with 21 additions and 21 deletions

View file

@ -1426,7 +1426,7 @@ static UINT8 Skin_FindValidDub(consvar_t *cvar, UINT16 skin_id, kartvoice_t *voi
}
// Scan through our allocated skin voices for the wanted voice.
strncpy(cvarname, value, VOICENAMESIZE);
strlcpy(cvarname, value, sizeof(cvarname));
strupr(cvarname);
i = DEH_FindKartVoice(cvarname);
@ -1437,7 +1437,7 @@ static UINT8 Skin_FindValidDub(consvar_t *cvar, UINT16 skin_id, kartvoice_t *voi
if (skinvoices[i].parent == skin_id || forceme)
{
// Change the cvar to be the value of the name.
strncpy(cvarname, DEH_KartVoiceName(i), VOICENAMESIZE);
strlcpy(cvarname, DEH_KartVoiceName(i), sizeof(cvarname));
strlwr(cvarname);
CV_StealthSet(cvar, cvarname);
@ -1450,7 +1450,7 @@ static UINT8 Skin_FindValidDub(consvar_t *cvar, UINT16 skin_id, kartvoice_t *voi
CONS_Alert(CONS_NOTICE, M_GetText("Voice \"%s\" doesn't belong to this skin (%s).\n"), DEH_KartVoiceName(i), skins[skin_id].name);
// *Reassign* the voice cvar to whatever the current voice is, at least.
strncpy(cvarname, DEH_KartVoiceName(myvoice->id), VOICENAMESIZE);
strlcpy(cvarname, DEH_KartVoiceName(myvoice->id), sizeof(cvarname));
strlwr(cvarname);
CV_StealthSet(cvar, cvarname);
@ -1469,7 +1469,7 @@ static UINT8 Skin_FindValidDub(consvar_t *cvar, UINT16 skin_id, kartvoice_t *voi
CONS_Alert(CONS_NOTICE, M_GetText("Voice \"%s\" does not exist.\n"), value);
// Reassign the voice cvar to our current voice.
strncpy(cvarname, DEH_KartVoiceName(myvoice->id), VOICENAMESIZE);
strlcpy(cvarname, DEH_KartVoiceName(myvoice->id), sizeof(cvarname));
strlwr(cvarname);
CV_StealthSet(cvar, cvarname);
@ -1939,7 +1939,7 @@ static void SendNameAndColor(UINT8 n)
// Reset the voice to that of the skin's.
if (prevskin != player->skin && skins[player->skin].voice)
{
strncpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -1958,7 +1958,7 @@ static void SendNameAndColor(UINT8 n)
// Reset the voice to that of the skin's.
if (prevskin != player->skin && skins[player->skin].voice)
{
strncpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -1969,7 +1969,7 @@ static void SendNameAndColor(UINT8 n)
// Need to update voices after the fact.
if (!cv_voice[n].string)
{
strncpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -1981,7 +1981,7 @@ static void SendNameAndColor(UINT8 n)
if (valuevoice)
{
strncpy(voicebuf, DEH_KartVoiceName(valuevoice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(valuevoice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2000,7 +2000,7 @@ static void SendNameAndColor(UINT8 n)
if (valuevoice)
{
strncpy(voicebuf, DEH_KartVoiceName(valuevoice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(valuevoice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2009,7 +2009,7 @@ static void SendNameAndColor(UINT8 n)
else
{
// ...still nothing?
strncpy(voicebuf, DEH_KartVoiceName(0), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(0), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2041,7 +2041,7 @@ static void SendNameAndColor(UINT8 n)
if (Skin_FindValidDub(&cv_voice[n], cv_skin[n].value, voice, false, true))
{
// Our voice is no longer valid, set it to that of our skin's.
strncpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2064,7 +2064,7 @@ static void SendNameAndColor(UINT8 n)
// Need to update voices after the fact.
if (!cv_voice[n].string)
{
strncpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2080,7 +2080,7 @@ static void SendNameAndColor(UINT8 n)
if (valuevoice && valuevoice->parent == cv_skin[n].value)
{
strncpy(voicebuf, DEH_KartVoiceName(valuevoice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(valuevoice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2099,7 +2099,7 @@ static void SendNameAndColor(UINT8 n)
if (valuevoice)
{
strncpy(voicebuf, DEH_KartVoiceName(valuevoice->id), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(valuevoice->id), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2108,7 +2108,7 @@ static void SendNameAndColor(UINT8 n)
else
{
// ...still nothing?
strncpy(voicebuf, DEH_KartVoiceName(0), VOICENAMESIZE);
strlcpy(voicebuf, DEH_KartVoiceName(0), sizeof(voicebuf));
strlwr(voicebuf);
CV_StealthSet(&cv_voice[n], voicebuf);
@ -2246,7 +2246,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
{
CV_StealthSet(&cv_skin[localplayer], skins[forcedskin].name);
strncpy(voicename, DEH_KartVoiceName(skins[forcedskin].voice->id), VOICENAMESIZE);
strlcpy(voicename, DEH_KartVoiceName(skins[forcedskin].voice->id), sizeof(voicename));
strlwr(voicename);
CV_StealthSet(&cv_voice[localplayer], voicename);
@ -2265,7 +2265,7 @@ static void Got_NameAndColor(UINT8 **cp, INT32 playernum)
if (localplayer != -1)
{
strncpy(voicename, DEH_KartVoiceName(voice), VOICENAMESIZE);
strlcpy(voicename, DEH_KartVoiceName(voice), sizeof(voicename));
strlwr(voicename);
CV_StealthSet(&cv_voice[localplayer], voicename);
@ -7540,7 +7540,7 @@ static void __voice_cvar_func(INT32 pid, UINT8 pnum)
if (!(cht_debug || devparm) && !(multiplayer || netgame) // In single player.
&& (gamestate != GS_WAITINGPLAYERS)) // allows command line -warp x +skin y
{
strncpy(cvarname, DEH_KartVoiceName(myvoice->id), VOICENAMESIZE);
strlcpy(cvarname, DEH_KartVoiceName(myvoice->id), sizeof(cvarname));
strlwr(cvarname);
CV_StealthSet(&cv_voice[pnum], cvarname);
@ -7555,7 +7555,7 @@ static void __voice_cvar_func(INT32 pid, UINT8 pnum)
{
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your voice at the moment.\n"));
strncpy(cvarname, DEH_KartVoiceName(myvoice->id), VOICENAMESIZE);
strlcpy(cvarname, DEH_KartVoiceName(myvoice->id), sizeof(cvarname));
strlwr(cvarname);
CV_StealthSet(&cv_voice[pnum], cvarname);

View file

@ -2627,7 +2627,7 @@ static int lib_rAddKartVoice(lua_State *L)
char wordupper[VOICENAMESIZE+1];
strncpy(wordupper, word, VOICENAMESIZE);
strlcpy(wordupper, word, sizeof(wordupper));
strupr(wordupper);
INT32 i = DEH_FindKartVoice(wordupper);

View file

@ -1273,7 +1273,7 @@ INT32 R_AllocKartVoice(boolean skinalloc, const char* name, INT32 *out)
{
char voxname_upper[VOICENAMESIZE];
strncpy(voxname_upper, name, VOICENAMESIZE);
strlcpy(voxname_upper, name, sizeof(voxname_upper));
strupr(voxname_upper);
*out = DEH_FindKartVoice(voxname_upper);