Fixed crashing if attempting to send radio messages without a radio in the inventory (Undertow Games - first-rate QA since 2014)
This commit is contained in:
@@ -1613,7 +1613,7 @@ namespace Barotrauma.Networking
|
|||||||
if (senderCharacter == null) return;
|
if (senderCharacter == null) return;
|
||||||
|
|
||||||
//return if senderCharacter doesn't have a working radio
|
//return if senderCharacter doesn't have a working radio
|
||||||
var radio = senderCharacter.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
var radio = senderCharacter.Inventory.Items.FirstOrDefault(i => i != null && i.GetComponent<WifiComponent>() != null);
|
||||||
if (radio == null) return;
|
if (radio == null) return;
|
||||||
|
|
||||||
senderRadio = radio.GetComponent<WifiComponent>();
|
senderRadio = radio.GetComponent<WifiComponent>();
|
||||||
@@ -1699,11 +1699,11 @@ namespace Barotrauma.Networking
|
|||||||
case ChatMessageType.Radio:
|
case ChatMessageType.Radio:
|
||||||
if (!receiver.IsDead)
|
if (!receiver.IsDead)
|
||||||
{
|
{
|
||||||
var receiverItem = receiver.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
var receiverItem = receiver.Inventory.Items.FirstOrDefault(i => i?.GetComponent<WifiComponent>() != null);
|
||||||
//client doesn't have a radio -> don't send
|
//client doesn't have a radio -> don't send
|
||||||
if (receiverItem == null) return "";
|
if (receiverItem == null) return "";
|
||||||
|
|
||||||
var senderItem = sender.Inventory.Items.First(i => i != null && i.GetComponent<WifiComponent>() != null);
|
var senderItem = sender.Inventory.Items.FirstOrDefault(i => i?.GetComponent<WifiComponent>() != null);
|
||||||
if (senderItem == null) return "";
|
if (senderItem == null) return "";
|
||||||
|
|
||||||
var receiverRadio = receiverItem.GetComponent<WifiComponent>();
|
var receiverRadio = receiverItem.GetComponent<WifiComponent>();
|
||||||
|
|||||||
Reference in New Issue
Block a user