(46cd6704b) Add some extra null checks trying to blind fix #1529.
This commit is contained in:
@@ -20,8 +20,8 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
const float CharacterWaitOnSwitch = 10.0f;
|
||||
|
||||
private List<CharacterInfo> characterInfos = new List<CharacterInfo>();
|
||||
private List<Character> characters = new List<Character>();
|
||||
private readonly List<CharacterInfo> characterInfos = new List<CharacterInfo>();
|
||||
private readonly List<Character> characters = new List<Character>();
|
||||
|
||||
private Point screenResolution;
|
||||
|
||||
|
||||
@@ -437,40 +437,47 @@ namespace Barotrauma
|
||||
|
||||
if (characterPreviewFrame != null)
|
||||
{
|
||||
characterPreviewFrame.Parent.RemoveChild(characterPreviewFrame);
|
||||
characterPreviewFrame.Parent?.RemoveChild(characterPreviewFrame);
|
||||
characterPreviewFrame = null;
|
||||
}
|
||||
|
||||
if (Campaign is SinglePlayerCampaign)
|
||||
if (characterList != null)
|
||||
{
|
||||
var hireableCharacters = location.GetHireableCharacters();
|
||||
foreach (GUIComponent child in characterList.Content.Children.ToList())
|
||||
if (Campaign is SinglePlayerCampaign)
|
||||
{
|
||||
if (child.UserData is CharacterInfo character)
|
||||
var hireableCharacters = location.GetHireableCharacters();
|
||||
foreach (GUIComponent child in characterList.Content.Children.ToList())
|
||||
{
|
||||
if (GameMain.GameSession.CrewManager.GetCharacterInfos().Contains(character)) { continue; }
|
||||
if (child.UserData is CharacterInfo character)
|
||||
{
|
||||
if (GameMain.GameSession.CrewManager != null)
|
||||
{
|
||||
if (GameMain.GameSession.CrewManager.GetCharacterInfos().Contains(character)) { continue; }
|
||||
}
|
||||
}
|
||||
else if (child.UserData as string == "mycrew" || child.UserData as string == "hire")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
characterList.RemoveChild(child);
|
||||
}
|
||||
else if (child.UserData as string == "mycrew" || child.UserData as string == "hire")
|
||||
if (!hireableCharacters.Any())
|
||||
{
|
||||
continue;
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), characterList.Content.RectTransform), TextManager.Get("HireUnavailable"), textAlignment: Alignment.Center)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
characterList.RemoveChild(child);
|
||||
}
|
||||
if (!hireableCharacters.Any())
|
||||
{
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.2f), characterList.Content.RectTransform), TextManager.Get("HireUnavailable"), textAlignment: Alignment.Center)
|
||||
else
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (CharacterInfo c in hireableCharacters)
|
||||
{
|
||||
var frame = c.CreateCharacterFrame(characterList.Content, c.Name + " (" + c.Job.Name + ")", c);
|
||||
new GUITextBlock(new RectTransform(Vector2.One, frame.RectTransform, Anchor.TopRight), c.Salary.ToString(), textAlignment: Alignment.CenterRight);
|
||||
foreach (CharacterInfo c in hireableCharacters)
|
||||
{
|
||||
var frame = c.CreateCharacterFrame(characterList.Content, c.Name + " (" + c.Job.Name + ")", c);
|
||||
new GUITextBlock(new RectTransform(Vector2.One, frame.RectTransform, Anchor.TopRight), c.Salary.ToString(), textAlignment: Alignment.CenterRight);
|
||||
}
|
||||
}
|
||||
}
|
||||
characterList.UpdateScrollBarSize();
|
||||
}
|
||||
characterList.UpdateScrollBarSize();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user