(46cd6704b) Add some extra null checks trying to blind fix #1529.

This commit is contained in:
Joonas Rikkonen
2019-06-11 21:49:07 +03:00
parent 7de768085e
commit cf7c0533fe
2 changed files with 31 additions and 24 deletions
@@ -20,8 +20,8 @@ namespace Barotrauma
/// </summary> /// </summary>
const float CharacterWaitOnSwitch = 10.0f; const float CharacterWaitOnSwitch = 10.0f;
private List<CharacterInfo> characterInfos = new List<CharacterInfo>(); private readonly List<CharacterInfo> characterInfos = new List<CharacterInfo>();
private List<Character> characters = new List<Character>(); private readonly List<Character> characters = new List<Character>();
private Point screenResolution; private Point screenResolution;
@@ -437,19 +437,24 @@ namespace Barotrauma
if (characterPreviewFrame != null) if (characterPreviewFrame != null)
{ {
characterPreviewFrame.Parent.RemoveChild(characterPreviewFrame); characterPreviewFrame.Parent?.RemoveChild(characterPreviewFrame);
characterPreviewFrame = null; characterPreviewFrame = null;
} }
if (characterList != null)
{
if (Campaign is SinglePlayerCampaign) if (Campaign is SinglePlayerCampaign)
{ {
var hireableCharacters = location.GetHireableCharacters(); var hireableCharacters = location.GetHireableCharacters();
foreach (GUIComponent child in characterList.Content.Children.ToList()) foreach (GUIComponent child in characterList.Content.Children.ToList())
{ {
if (child.UserData is CharacterInfo character) if (child.UserData is CharacterInfo character)
{
if (GameMain.GameSession.CrewManager != null)
{ {
if (GameMain.GameSession.CrewManager.GetCharacterInfos().Contains(character)) { continue; } if (GameMain.GameSession.CrewManager.GetCharacterInfos().Contains(character)) { continue; }
} }
}
else if (child.UserData as string == "mycrew" || child.UserData as string == "hire") else if (child.UserData as string == "mycrew" || child.UserData as string == "hire")
{ {
continue; continue;
@@ -473,6 +478,8 @@ namespace Barotrauma
} }
} }
characterList.UpdateScrollBarSize(); characterList.UpdateScrollBarSize();
}
characterList.UpdateScrollBarSize();
RefreshMyItems(); RefreshMyItems();