Fix crash when editing profile character with existing follower

This commit is contained in:
SinnamonLat 2022-05-20 16:47:03 +02:00
parent 54b7e8e78e
commit 60449b8a26
4 changed files with 37 additions and 16 deletions

View file

@ -1399,24 +1399,27 @@ static void M_DrawProfileCard(INT32 x, INT32 y, boolean greyedout, profile_t *p)
if (M_DrawCharacterSprite(x-22, y+119, skinnum, V_FLIP, colormap))
V_DrawMappedPatch(x+14, y+66, 0, faceprefix[skinnum][FACE_RANK], colormap);
if (M_DrawFollowerSprite(x-44 +12, y+119, 0, V_FLIP, 0, sp))
if (sp->mdepth >= CSSTEP_FOLLOWER)
{
UINT16 col = (unsigned)p->followercolor;
patch_t *ico = W_CachePatchName(followers[sp->followern].icon, PU_CACHE);
UINT8 *fcolormap;
switch (col)
if (M_DrawFollowerSprite(x-44 +12, y+119, 0, V_FLIP, 0, sp))
{
case FOLLOWERCOLOR_MATCH: // "Match"
col = sp->color;
break;
case FOLLOWERCOLOR_OPPOSITE: // "Opposite"
col = skincolors[sp->color].invcolor;
break;
}
UINT16 col = (unsigned)p->followercolor;
patch_t *ico = W_CachePatchName(followers[sp->followern].icon, PU_CACHE);
UINT8 *fcolormap;
fcolormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE);
V_DrawMappedPatch(x+14+18, y+66, 0, ico, fcolormap);
switch (col)
{
case FOLLOWERCOLOR_MATCH: // "Match"
col = sp->color;
break;
case FOLLOWERCOLOR_OPPOSITE: // "Opposite"
col = skincolors[sp->color].invcolor;
break;
}
fcolormap = R_GetTranslationColormap(TC_DEFAULT, col, GTC_MENUCACHE);
V_DrawMappedPatch(x+14+18, y+66, 0, ico, fcolormap);
}
}
if (sp->mdepth == CSSTEP_ALTS || sp->mdepth == CSSTEP_COLORS || sp->mdepth == CSSTEP_FOLLOWERCOLORS)

View file

@ -2153,7 +2153,7 @@ void M_CharacterSelectInit(void)
if (optionsmenu.profile) // In menu, setting up profile character/follower
{
setup_player[j].profilen = optionsmenu.profilen;
PR_ApplyProfile(setup_player[j].profilen, 0);
PR_ApplyProfileLight(setup_player[j].profilen, 0);
}
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;

View file

@ -188,6 +188,19 @@ void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum)
CV_StealthSetValue(&cv_currprofile, profilenum);
}
void PR_ApplyProfileLight(UINT8 profilenum, UINT8 playernum)
{
profile_t *p = PR_GetProfile(profilenum);
CV_StealthSet(&cv_skin[playernum], p->skinname);
CV_StealthSetValue(&cv_playercolor[playernum], p->color);
CV_StealthSet(&cv_playername[playernum], p->playername);
// Followers
CV_StealthSet(&cv_follower[playernum], p->follower);
CV_StealthSetValue(&cv_followercolor[playernum], p->followercolor);
}
UINT8 PR_GetProfileNum(profile_t *p)
{
UINT8 i;

View file

@ -113,6 +113,11 @@ void PR_LoadProfiles(void);
// Applies the given profile's settings to the given player.
void PR_ApplyProfile(UINT8 profilenum, UINT8 playernum);
// PR_ApplyProfileLight(UINT8 profilenum, UINT8 playernum)
// Similar to PR_ApplyProfile but only applies skin and follower values.
// Controls, kickstartaccel and "current profile" data is *not* modified.
void PR_ApplyProfileLight(UINT8 profilenum, UINT8 playernum);
// PR_GetProfileNum(profile_t *p)
// Gets the profile's index # in profilesList
UINT8 PR_GetProfileNum(profile_t *p);