Fix the MP character select being completely busted and sending infinite changenameandcolor packets

Still has weird inappropriate conditions for changing skin, but gets the feature at least WORKING for now.
This commit is contained in:
toaster 2022-11-07 20:16:53 +00:00
parent 2e75012645
commit e086b52055
2 changed files with 13 additions and 16 deletions

View file

@ -1499,14 +1499,11 @@ static void SendNameAndColor(UINT8 n)
if (!cv_followercolor[n].value) if (!cv_followercolor[n].value)
CV_StealthSet(&cv_followercolor[n], "Match"); // set it to "Match". I don't care about your stupidity! CV_StealthSet(&cv_followercolor[n], "Match"); // set it to "Match". I don't care about your stupidity!
// so like, this is sent before we even use anything like cvars or w/e so it's possible that follower is set to a pretty yikes value, so let's fix that before we send garbage that could crash the game:
if (cv_follower[n].value >= numfollowers || cv_follower[n].value < -1)
CV_StealthSet(&cv_follower[n], "None");
if (!strcmp(cv_playername[n].string, player_names[playernum]) if (!strcmp(cv_playername[n].string, player_names[playernum])
&& cv_playercolor[n].value == player->skincolor && cv_playercolor[n].value == player->skincolor
&& !strcmp(cv_skin[n].string, skins[player->skin].name) && !stricmp(cv_skin[n].string, skins[player->skin].name)
&& cv_follower[n].value == player->followerskin && !stricmp(cv_follower[n].string,
(player->followerskin < 0 ? "None" : followers[player->followerskin].name))
&& cv_followercolor[n].value == player->followercolor) && cv_followercolor[n].value == player->followercolor)
return; return;
@ -6060,6 +6057,7 @@ static void Name_OnChange(void)
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You may not change your name when chat is muted.\n"));
CV_StealthSet(&cv_playername[0], player_names[consoleplayer]); CV_StealthSet(&cv_playername[0], player_names[consoleplayer]);
return;
} }
else else
SendNameAndColor(0); SendNameAndColor(0);
@ -6169,7 +6167,9 @@ static void Skin_OnChange(void)
} }
if (CanChangeSkinWhilePlaying(consoleplayer)) if (CanChangeSkinWhilePlaying(consoleplayer))
{
SendNameAndColor(0); SendNameAndColor(0);
}
else else
{ {
CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n")); CONS_Alert(CONS_NOTICE, M_GetText("You can't change your skin at the moment.\n"));

View file

@ -1583,6 +1583,9 @@ void M_Ticker(void)
{ {
INT32 i; INT32 i;
if (!menuactive)
return;
if (menutransition.tics != 0 || menutransition.dest != 0) if (menutransition.tics != 0 || menutransition.dest != 0)
{ {
noFurtherInput = true; noFurtherInput = true;
@ -3095,8 +3098,6 @@ static void M_MPConfirmCharacterSelection(void)
for (i = 0; i < splitscreen +1; i++) for (i = 0; i < splitscreen +1; i++)
{ {
char cmd[MAXSTRINGLENGTH];
// colour // colour
// (convert the number that's saved to a string we can use) // (convert the number that's saved to a string we can use)
col = setup_player[i].color; col = setup_player[i].color;
@ -3108,18 +3109,14 @@ static void M_MPConfirmCharacterSelection(void)
else else
CV_StealthSet(&cv_follower[i], followers[setup_player[i].followern].name); CV_StealthSet(&cv_follower[i], followers[setup_player[i].followern].name);
// follower color
CV_StealthSetValue(&cv_followercolor[i], setup_player[i].followercolor);
// finally, call the skin[x] console command. // finally, call the skin[x] console command.
// This will call SendNameAndColor which will synch everything we sent here and apply the changes! // This will call SendNameAndColor which will synch everything we sent here and apply the changes!
// This is a hack to make sure we call Skin[x]_OnChange afterwards CV_StealthSet(&cv_skin[i], skins[setup_player[i].skin].name);
CV_StealthSetValue(&cv_skin[i], -1);
strcpy(cmd, cv_skin[i].name); // ...actually, let's do this last - Skin_OnChange has some return-early occasions
strcat(cmd, va(" %s", skins[setup_player[i].skin].name)); // follower color
COM_ImmedExecute(cmd); CV_SetValue(&cv_followercolor[i], setup_player[i].followercolor);
} }
M_ClearMenus(true); M_ClearMenus(true);