Improve profile deletion further

- Fix the check for deleting the current profile
- Handle cv_ttlprofilen like cv_lastprofile[]
This commit is contained in:
toaster 2022-09-01 17:40:26 +01:00
parent 0424f0f07c
commit a6843bae78
2 changed files with 9 additions and 6 deletions

View file

@ -5507,19 +5507,21 @@ static void M_EraseProfileResponse(INT32 choice)
{
if (choice == MA_YES)
{
const boolean current = (optionsmenu.eraseprofilen == cv_currprofile.value); // has to be grabbed before deletion
S_StartSound(NULL, sfx_itrole); // bweh heh heh
PR_DeleteProfile(optionsmenu.eraseprofilen);
if (optionsmenu.eraseprofilen == cv_currprofile.value)
if (current)
{
CV_StealthSetValue(&cv_currprofile, -1);
CV_StealthSetValue(&cv_ttlprofilen, 0);
F_StartIntro();
M_ClearMenus(true);
}
else if (optionsmenu.eraseprofilen > PR_GetNumProfiles()-1)
{
optionsmenu.eraseprofilen--;
}
}
}

View file

@ -114,10 +114,11 @@ boolean PR_DeleteProfile(INT32 num)
profilesList[i] = profilesList[i+1];
}
// Make sure to move cv_lastprofile values as well!
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
// Make sure to move cv_lastprofile (and title profile) values as well!
for (i = 0; i < MAXSPLITSCREENPLAYERS+1; i++)
{
INT32 profileset = cv_lastprofile[i].value;
consvar_t *cv = (i == MAXSPLITSCREENPLAYERS) ? &cv_ttlprofilen : &cv_lastprofile[i];
INT32 profileset = cv->value;
if (profileset < num)
{
@ -136,7 +137,7 @@ boolean PR_DeleteProfile(INT32 num)
profileset = PROFILE_GUEST;
}
CV_StealthSetValue(&cv_lastprofile[i], profileset);
CV_StealthSetValue(cv, profileset);
}
}