mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-24 13:01:48 +00:00
- Fixed: FListMenuItemPlayerDisplay could crash at various points if a class does not have a See state.
SVN r3764 (trunk)
This commit is contained in:
parent
a26cd841ae
commit
fcd4854714
1 changed files with 23 additions and 12 deletions
|
@ -385,7 +385,11 @@ void FListMenuItemPlayerDisplay::UpdateRandomClass()
|
||||||
if (++mRandomClass >= (int)PlayerClasses.Size ()) mRandomClass = 0;
|
if (++mRandomClass >= (int)PlayerClasses.Size ()) mRandomClass = 0;
|
||||||
mPlayerClass = &PlayerClasses[mRandomClass];
|
mPlayerClass = &PlayerClasses[mRandomClass];
|
||||||
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
|
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
|
||||||
mPlayerTics = mPlayerState->GetTics();
|
if (mPlayerState == NULL)
|
||||||
|
{ // No see state, so try spawn state.
|
||||||
|
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SpawnState;
|
||||||
|
}
|
||||||
|
mPlayerTics = mPlayerState != NULL ? mPlayerState->GetTics() : -1;
|
||||||
mRandomTimer = 6;
|
mRandomTimer = 6;
|
||||||
|
|
||||||
// Since the newly displayed class may used a different translation
|
// Since the newly displayed class may used a different translation
|
||||||
|
@ -436,7 +440,11 @@ void FListMenuItemPlayerDisplay::SetPlayerClass(int classnum, bool force)
|
||||||
{
|
{
|
||||||
mPlayerClass = &PlayerClasses[classnum];
|
mPlayerClass = &PlayerClasses[classnum];
|
||||||
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
|
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SeeState;
|
||||||
mPlayerTics = mPlayerState->GetTics();
|
if (mPlayerState == NULL)
|
||||||
|
{ // No see state, so try spawn state.
|
||||||
|
mPlayerState = GetDefaultByType (mPlayerClass->Type)->SpawnState;
|
||||||
|
}
|
||||||
|
mPlayerTics = mPlayerState != NULL ? mPlayerState->GetTics() : -1;
|
||||||
mClassNum = classnum;
|
mClassNum = classnum;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -558,17 +566,20 @@ void FListMenuItemPlayerDisplay::Drawer(bool selected)
|
||||||
spriteframe_t *sprframe;
|
spriteframe_t *sprframe;
|
||||||
fixed_t scaleX, scaleY;
|
fixed_t scaleX, scaleY;
|
||||||
|
|
||||||
if (mSkin == 0)
|
if (mPlayerState != NULL)
|
||||||
{
|
{
|
||||||
sprframe = &SpriteFrames[sprites[mPlayerState->sprite].spriteframes + mPlayerState->GetFrame()];
|
if (mSkin == 0)
|
||||||
scaleX = GetDefaultByType(mPlayerClass->Type)->scaleX;
|
{
|
||||||
scaleY = GetDefaultByType(mPlayerClass->Type)->scaleY;
|
sprframe = &SpriteFrames[sprites[mPlayerState->sprite].spriteframes + mPlayerState->GetFrame()];
|
||||||
}
|
scaleX = GetDefaultByType(mPlayerClass->Type)->scaleX;
|
||||||
else
|
scaleY = GetDefaultByType(mPlayerClass->Type)->scaleY;
|
||||||
{
|
}
|
||||||
sprframe = &SpriteFrames[sprites[skins[mSkin].sprite].spriteframes + mPlayerState->GetFrame()];
|
else
|
||||||
scaleX = skins[mSkin].ScaleX;
|
{
|
||||||
scaleY = skins[mSkin].ScaleY;
|
sprframe = &SpriteFrames[sprites[skins[mSkin].sprite].spriteframes + mPlayerState->GetFrame()];
|
||||||
|
scaleX = skins[mSkin].ScaleX;
|
||||||
|
scaleY = skins[mSkin].ScaleY;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sprframe != NULL)
|
if (sprframe != NULL)
|
||||||
|
|
Loading…
Reference in a new issue