mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Extra profile menu improvements
* Don't allow creation/loading of more profiles than the game supports. * Add a few missing M_SetMenuDelay()'s * Fix PRF%c default name generation issues * There could still be an infinite loop if MAXPROFILES is ever increased >= 26... but we can handle that one later.
This commit is contained in:
parent
a6843bae78
commit
cd2bb2b300
2 changed files with 22 additions and 6 deletions
|
|
@ -4702,9 +4702,15 @@ static void M_StartEditProfile(INT32 c)
|
||||||
void M_HandleProfileSelect(INT32 ch)
|
void M_HandleProfileSelect(INT32 ch)
|
||||||
{
|
{
|
||||||
const UINT8 pid = 0;
|
const UINT8 pid = 0;
|
||||||
const INT32 maxp = PR_GetNumProfiles();
|
INT32 maxp = PR_GetNumProfiles();
|
||||||
|
boolean creatable = (maxp < MAXPROFILES);
|
||||||
(void) ch;
|
(void) ch;
|
||||||
|
|
||||||
|
if (!creatable)
|
||||||
|
{
|
||||||
|
maxp = MAXPROFILES;
|
||||||
|
}
|
||||||
|
|
||||||
if (menucmd[pid].dpad_lr > 0)
|
if (menucmd[pid].dpad_lr > 0)
|
||||||
{
|
{
|
||||||
optionsmenu.profilen++;
|
optionsmenu.profilen++;
|
||||||
|
|
@ -4749,7 +4755,7 @@ void M_HandleProfileSelect(INT32 ch)
|
||||||
M_SetMenuDelay(pid);
|
M_SetMenuDelay(pid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (optionsmenu.profilen == maxp && gamestate != GS_MENU)
|
else if (creatable && optionsmenu.profilen == maxp && gamestate != GS_MENU)
|
||||||
{
|
{
|
||||||
S_StartSound(NULL, sfx_s3k7b);
|
S_StartSound(NULL, sfx_s3k7b);
|
||||||
M_StartMessage(M_GetText("Cannot create a new profile\nmid-game. Return to the\ntitle screen first."), NULL, MM_NOTHING);
|
M_StartMessage(M_GetText("Cannot create a new profile\nmid-game. Return to the\ntitle screen first."), NULL, MM_NOTHING);
|
||||||
|
|
@ -4763,7 +4769,7 @@ void M_HandleProfileSelect(INT32 ch)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// We're on the profile selection screen.
|
// We're on the profile selection screen.
|
||||||
if (optionsmenu.profilen == maxp)
|
if (creatable && optionsmenu.profilen == maxp)
|
||||||
{
|
{
|
||||||
M_StartEditProfile(MA_YES);
|
M_StartEditProfile(MA_YES);
|
||||||
M_SetMenuDelay(pid);
|
M_SetMenuDelay(pid);
|
||||||
|
|
@ -4790,6 +4796,7 @@ void M_HandleProfileSelect(INT32 ch)
|
||||||
{
|
{
|
||||||
optionsmenu.resetprofilemenu = true;
|
optionsmenu.resetprofilemenu = true;
|
||||||
M_GoBack(0);
|
M_GoBack(0);
|
||||||
|
M_SetMenuDelay(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menutransition.tics == 0 && optionsmenu.resetprofile)
|
if (menutransition.tics == 0 && optionsmenu.resetprofile)
|
||||||
|
|
@ -4859,6 +4866,7 @@ boolean M_ProfileEditInputs(INT32 ch)
|
||||||
M_SetupNextMenu(&MAIN_ProfilesDef, false);
|
M_SetupNextMenu(&MAIN_ProfilesDef, false);
|
||||||
else
|
else
|
||||||
M_GoBack(0);
|
M_GoBack(0);
|
||||||
|
M_SetMenuDelay(pid);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -4910,6 +4918,7 @@ void M_ConfirmProfile(INT32 choice)
|
||||||
{
|
{
|
||||||
M_ProfileEditExit();
|
M_ProfileEditExit();
|
||||||
M_GoBack(0);
|
M_GoBack(0);
|
||||||
|
M_SetMenuDelay(pid);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -5186,6 +5195,7 @@ boolean M_ProfileControlsInputs(INT32 ch)
|
||||||
else if (M_MenuBackPressed(pid))
|
else if (M_MenuBackPressed(pid))
|
||||||
{
|
{
|
||||||
M_ProfileControlsConfirm(0);
|
M_ProfileControlsConfirm(0);
|
||||||
|
M_SetMenuDelay(pid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,10 +161,13 @@ void PR_InitNewProfile(void)
|
||||||
UINT8 i;
|
UINT8 i;
|
||||||
boolean nameok = false;
|
boolean nameok = false;
|
||||||
|
|
||||||
|
pname[4] = '\0';
|
||||||
|
|
||||||
// When deleting profile, it's possible to do some pretty wacko stuff that would lead a new fresh profile to share the same name as another profile we have never changed the name of.
|
// When deleting profile, it's possible to do some pretty wacko stuff that would lead a new fresh profile to share the same name as another profile we have never changed the name of.
|
||||||
|
// This could become an infinite loop if MAXPROFILES >= 26.
|
||||||
while (!nameok)
|
while (!nameok)
|
||||||
{
|
{
|
||||||
strcpy(pname, va("PRF%c", 'A'+usenum-1));
|
pname[3] = 'A'+usenum;
|
||||||
|
|
||||||
for (i = 0; i < numprofiles; i++)
|
for (i = 0; i < numprofiles; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -172,8 +175,8 @@ void PR_InitNewProfile(void)
|
||||||
if (!strcmp(pr->profilename, pname))
|
if (!strcmp(pr->profilename, pname))
|
||||||
{
|
{
|
||||||
usenum++;
|
usenum++;
|
||||||
if (usenum > 'Z' -1)
|
if (pname[3] == 'Z')
|
||||||
usenum = 'A';
|
usenum = 0;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -237,6 +240,9 @@ void PR_LoadProfiles(void)
|
||||||
|
|
||||||
fread(&numprofiles, sizeof numprofiles, 1, f);
|
fread(&numprofiles, sizeof numprofiles, 1, f);
|
||||||
|
|
||||||
|
if (numprofiles > MAXPROFILES)
|
||||||
|
numprofiles = MAXPROFILES;
|
||||||
|
|
||||||
for (i = PROFILE_GUEST+1; i < numprofiles; ++i)
|
for (i = PROFILE_GUEST+1; i < numprofiles; ++i)
|
||||||
{
|
{
|
||||||
profilesList[i] = Z_Malloc(sizeof(profile_t), PU_STATIC, NULL);
|
profilesList[i] = Z_Malloc(sizeof(profile_t), PU_STATIC, NULL);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue