add null checks to all uses of OrbTransformSyncs

This commit is contained in:
Mister_Nebula 2021-10-26 14:08:23 +01:00
parent d59b0b2ea5
commit 18dc5bfbde
2 changed files with 4 additions and 4 deletions

View File

@ -69,7 +69,7 @@ namespace QSB.OrbSync.Events
DebugLog.ToConsole("Error - FromPlayer is null!", MessageType.Error);
}
var orbSync = NomaiOrbTransformSync.OrbTransformSyncs
var orbSync = NomaiOrbTransformSync.OrbTransformSyncs.Where(x => x != null)
.FirstOrDefault(x => x.AttachedObject == QSBWorldSync.OldOrbList[message.ObjectId].transform);
if (orbSync == null)
{
@ -115,13 +115,13 @@ namespace QSB.OrbSync.Events
return;
}
if (!NomaiOrbTransformSync.OrbTransformSyncs.Any(x => x.AttachedObject == QSBWorldSync.OldOrbList[message.ObjectId].transform))
if (!NomaiOrbTransformSync.OrbTransformSyncs.Where(x => x != null).Any(x => x.AttachedObject == QSBWorldSync.OldOrbList[message.ObjectId].transform))
{
DebugLog.ToConsole($"Error - No NomaiOrbTransformSync has AttachedOrb with objectId {message.ObjectId}!");
return;
}
var orb = NomaiOrbTransformSync.OrbTransformSyncs
var orb = NomaiOrbTransformSync.OrbTransformSyncs.Where(x => x != null)
.First(x => x.AttachedObject == QSBWorldSync.OldOrbList[message.ObjectId].transform);
orb.enabled = true;
}

View File

@ -165,7 +165,7 @@ namespace QSB.WorldSync
return;
}
var orbSync = NomaiOrbTransformSync.OrbTransformSyncs.FirstOrDefault(x => x.AttachedObject == affectingOrb.transform);
var orbSync = NomaiOrbTransformSync.OrbTransformSyncs.Where(x => x != null).FirstOrDefault(x => x.AttachedObject == affectingOrb.transform);
if (orbSync == null)
{
DebugLog.ToConsole($"Error - No NomaiOrbTransformSync found for {affectingOrb.name} (For slot {slot.name})!", MessageType.Error);