From 7efa1c04f4a224103a6af8691b81cf1b51303d41 Mon Sep 17 00:00:00 2001 From: yamamama Date: Thu, 27 Nov 2025 03:21:31 -0500 Subject: [PATCH] Fix dubs saving for only Sonic Voice changing now does a two-pass check to make sure the given dub is both a thing and can be used by the skin Prevents the annoying edgecase of Sonic and ONLY Sonic keeping dubs through games --- src/d_netcmd.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 6 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 434a1f3e5..24e09a529 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1909,6 +1909,7 @@ static void SendNameAndColor(UINT8 n) if (!netgame) { INT32 foundskin; + kartvoicetype_e vid; CleanupPlayerName(playernum, cv_playername[n].zstring); strcpy(player_names[playernum], cv_playername[n].zstring); @@ -1936,14 +1937,50 @@ static void SendNameAndColor(UINT8 n) SetPlayerSkin(playernum, cv_skin[n].string); CV_StealthSet(&cv_skin[n], skins[cv_skin[n].value].name); - // Reset the voice to that of the skin's. + // Reset the voice. if (prevskin != player->skin && skins[player->skin].voice) { - strlcpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), sizeof(voicebuf)); + // Try getting the voice from our ID. + valuevoice = &skinvoices[player->voice_id]; + + if (valuevoice->parent != skins[player->skin].voice->parent) + { + // Parent mismatch 1; let's try the cvar. + + if (cv_voice[n].string) + { + vid = R_FindIDForVoice(cv_voice[n].string); + + if (vid == MAXSKINVOICES) + { + // No dice; use the skin. + valuevoice = skins[player->skin].voice; + } + else + { + if (skinvoices[vid].parent == skins[player->skin].voice->parent) + { + valuevoice = &skinvoices[vid]; + } + else + { + // Parent mismatch... again. + valuevoice = skins[player->skin].voice; + } + } + } + else + { + // NULL string; default to the skin. + valuevoice = skins[player->skin].voice; + } + } + + strlcpy(voicebuf, DEH_KartVoiceName(valuevoice->id), sizeof(voicebuf)); strlwr(voicebuf); CV_StealthSet(&cv_voice[n], voicebuf); - cv_voice[n].value = (UINT16)skins[player->skin].voice->id; + cv_voice[n].value = (UINT16)valuevoice->id; } } else @@ -1955,14 +1992,50 @@ static void SendNameAndColor(UINT8 n) // will always be same as current SetPlayerSkin(playernum, cv_skin[n].string); - // Reset the voice to that of the skin's. + // Reset the voice. if (prevskin != player->skin && skins[player->skin].voice) { - strlcpy(voicebuf, DEH_KartVoiceName(skins[player->skin].voice->id), sizeof(voicebuf)); + // Try getting the voice from our ID. + valuevoice = &skinvoices[player->voice_id]; + + if (valuevoice->parent != skins[player->skin].voice->parent) + { + // Parent mismatch 1; let's try the cvar. + + if (cv_voice[n].string) + { + vid = R_FindIDForVoice(cv_voice[n].string); + + if (vid == MAXSKINVOICES) + { + // No dice; use the skin. + valuevoice = skins[player->skin].voice; + } + else + { + if (skinvoices[vid].parent == skins[player->skin].voice->parent) + { + valuevoice = &skinvoices[vid]; + } + else + { + // Parent mismatch... again. + valuevoice = skins[player->skin].voice; + } + } + } + else + { + // NULL string; default to the skin. + valuevoice = skins[player->skin].voice; + } + } + + strlcpy(voicebuf, DEH_KartVoiceName(valuevoice->id), sizeof(voicebuf)); strlwr(voicebuf); CV_StealthSet(&cv_voice[n], voicebuf); - cv_voice[n].value = (UINT16)skins[player->skin].voice->id; + cv_voice[n].value = (UINT16)valuevoice->id; } }