mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
M_CharacterSelectInit: Fix a heaping of bugs
- Fix a softlock caused by commit 8d9b42e4 (!!)
- If your profile's skin was locked, fix a softlock where control was never restored
- If your profile's skin didn't exist, fix an invalid skin id set
- Just straight up flatten out the nested complexity of this function
This commit is contained in:
parent
50a6896cce
commit
2aa36b5d32
1 changed files with 32 additions and 58 deletions
|
|
@ -317,6 +317,9 @@ static void M_SetupProfileGridPos(setup_player_t *p)
|
|||
INT32 i = R_SkinAvailable(pr->skinname);
|
||||
INT32 alt = 0; // Hey it's my character's name!
|
||||
|
||||
if (i == -1)
|
||||
i = 0;
|
||||
|
||||
// While we're here, read follower values.
|
||||
p->followern = K_FollowerAvailable(pr->follower);
|
||||
|
||||
|
|
@ -349,6 +352,9 @@ static void M_SetupMidGameGridPos(setup_player_t *p, UINT8 num)
|
|||
INT32 i = R_SkinAvailable(cv_skin[num].zstring);
|
||||
INT32 alt = 0; // Hey it's my character's name!
|
||||
|
||||
if (i == -1)
|
||||
i = 0;
|
||||
|
||||
// While we're here, read follower values.
|
||||
p->followern = cv_follower[num].value;
|
||||
p->followercolor = cv_followercolor[num].value;
|
||||
|
|
@ -377,20 +383,6 @@ void M_CharacterSelectInit(void)
|
|||
UINT8 i, j;
|
||||
setup_maxpage = 0;
|
||||
|
||||
// While we're editing profiles, don't unset the devices for p1
|
||||
if (gamestate == GS_MENU)
|
||||
{
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
// Un-set devices for all players if not editing profile
|
||||
if (!optionsmenu.profile)
|
||||
{
|
||||
G_SetDeviceForPlayer(i, -1);
|
||||
CONS_Printf("M_CharacterSelectInit: Device for %d set to %d\n", i, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memset(setup_chargrid, -1, sizeof(setup_chargrid));
|
||||
for (i = 0; i < 9; i++)
|
||||
{
|
||||
|
|
@ -404,8 +396,6 @@ void M_CharacterSelectInit(void)
|
|||
memset(setup_explosions, 0, sizeof(setup_explosions));
|
||||
setup_animcounter = 0;
|
||||
|
||||
UINT32 localskinhash[MAXSPLITSCREENPLAYERS];
|
||||
|
||||
for (i = 0; i < MAXSPLITSCREENPLAYERS; i++)
|
||||
{
|
||||
// Default to no follower / match colour.
|
||||
|
|
@ -413,12 +403,33 @@ void M_CharacterSelectInit(void)
|
|||
setup_player[i].followercategory = -1;
|
||||
setup_player[i].followercolor = FOLLOWERCOLOR_MATCH;
|
||||
|
||||
// Set default selected profile to the last used profile for each player:
|
||||
// (Make sure we don't overshoot it somehow if we deleted profiles or whatnot)
|
||||
setup_player[i].profilen = min(cv_lastprofile[i].value, PR_GetNumProfiles());
|
||||
// If we're on prpfile select, skip straight to CSSTEP_CHARS
|
||||
// do the same if we're midgame, but make sure to consider splitscreen properly.
|
||||
if (optionsmenu.profile && i == 0)
|
||||
{
|
||||
setup_player[i].profilen = optionsmenu.profilen;
|
||||
//PR_ApplyProfileLight(setup_player[i].profilen, 0);
|
||||
M_SetupProfileGridPos(&setup_player[i]);
|
||||
setup_player[i].mdepth = CSSTEP_CHARS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set default selected profile to the last used profile for each player:
|
||||
// (Make sure we don't overshoot it somehow if we deleted profiles or whatnot)
|
||||
setup_player[i].profilen = min(cv_lastprofile[i].value, PR_GetNumProfiles());
|
||||
|
||||
// Assistant for comparisons.
|
||||
localskinhash[i] = quickncasehash(cv_skin[i].string, SKINNAMESIZE);
|
||||
if (gamestate != GS_MENU && i <= splitscreen)
|
||||
{
|
||||
M_SetupMidGameGridPos(&setup_player[i], i);
|
||||
setup_player[i].mdepth = CSSTEP_CHARS;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Un-set devices
|
||||
G_SetDeviceForPlayer(i, -1);
|
||||
CONS_Printf("M_CharacterSelectInit: Device for %d set to %d\n", i, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < numskins; i++)
|
||||
|
|
@ -438,43 +449,6 @@ void M_CharacterSelectInit(void)
|
|||
|
||||
setup_maxpage = max(setup_maxpage, setup_chargrid[x][y].numskins-1);
|
||||
}
|
||||
|
||||
for (j = 0; j < MAXSPLITSCREENPLAYERS; j++)
|
||||
{
|
||||
// See also R_SkinAvailable
|
||||
|
||||
if (localskinhash[j] != skins[i].namehash)
|
||||
continue;
|
||||
|
||||
if (!stricmp(cv_skin[j].string, skins[i].name))
|
||||
continue;
|
||||
|
||||
{
|
||||
setup_player[j].gridx = x;
|
||||
setup_player[j].gridy = y;
|
||||
setup_player[j].color = skins[i].prefcolor;
|
||||
|
||||
// If we're on prpfile select, skip straight to CSSTEP_CHARS
|
||||
// do the same if we're midgame, but make sure to consider splitscreen properly.
|
||||
if ((optionsmenu.profile && j == 0) || (gamestate != GS_MENU && j <= splitscreen))
|
||||
{
|
||||
if (optionsmenu.profile) // In menu, setting up profile character/follower
|
||||
{
|
||||
setup_player[j].profilen = optionsmenu.profilen;
|
||||
PR_ApplyProfileLight(setup_player[j].profilen, 0);
|
||||
M_SetupProfileGridPos(&setup_player[j]);
|
||||
}
|
||||
else // gamestate != GS_MENU, in that case, assume this is whatever profile we chose to play with.
|
||||
{
|
||||
setup_player[j].profilen = cv_lastprofile[j].value;
|
||||
M_SetupMidGameGridPos(&setup_player[j], j);
|
||||
}
|
||||
|
||||
// Don't reapply the profile here, it was already applied.
|
||||
setup_player[j].mdepth = CSSTEP_CHARS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setup_numfollowercategories = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue