From 5dfc57336e7ebf6bc6ec504a269e14d01eb0da91 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Sep 2010 20:11:32 +0000 Subject: [PATCH] - fixed: The class selection menu crashed when no item in the menu was selected. SVN r2786 (trunk) --- src/menu/playerdisplay.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/menu/playerdisplay.cpp b/src/menu/playerdisplay.cpp index f9871e1ca6..a621562fd1 100644 --- a/src/menu/playerdisplay.cpp +++ b/src/menu/playerdisplay.cpp @@ -424,14 +424,18 @@ void FListMenuItemPlayerDisplay::SetPlayerClass(int classnum, bool force) bool FListMenuItemPlayerDisplay::UpdatePlayerClass() { - int classnum; - FName seltype = mOwner->mItems[mOwner->mSelectedItem]->GetAction(&classnum); + if (mOwner->mSelectedItem >= 0) + { + int classnum; + FName seltype = mOwner->mItems[mOwner->mSelectedItem]->GetAction(&classnum); - if (seltype != NAME_Episodemenu) return false; - if (PlayerClasses.Size() == 0) return false; + if (seltype != NAME_Episodemenu) return false; + if (PlayerClasses.Size() == 0) return false; - SetPlayerClass(classnum); - return true; + SetPlayerClass(classnum); + return true; + } + return false; } //=============================================================================