diff --git a/QSB/DeathSync/RespawnOnDeath.cs b/QSB/DeathSync/RespawnOnDeath.cs index 71d9d60b..23181671 100644 --- a/QSB/DeathSync/RespawnOnDeath.cs +++ b/QSB/DeathSync/RespawnOnDeath.cs @@ -125,10 +125,16 @@ namespace QSB.DeathSync } private SpawnPoint GetSpawnPoint(bool isShip = false) - => _playerSpawner - .GetValue("_spawnList") - .FirstOrDefault(spawnPoint => + { + var spawnList = _playerSpawner.GetValue("_spawnList"); + if (spawnList == null) + { + DebugLog.ToConsole($"Warning - _spawnList was null for player spawner!", MessageType.Warning); + return null; + } + return spawnList.FirstOrDefault(spawnPoint => spawnPoint.GetSpawnLocation() == SpawnLocation.TimberHearth && spawnPoint.IsShipSpawn() == isShip); + } } } \ No newline at end of file diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 93dea025..b865c534 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -146,10 +146,13 @@ namespace QSB } var offset3 = 10f; - GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current closest sector :"); + GUI.Label(new Rect(420, offset3, 200f, 20f), $"Current synced sector :"); offset3 += _debugLineSpacing; - var sector = PlayerTransformSync.LocalInstance.SectorSync.GetClosestSector(Locator.GetPlayerTransform()); - GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {sector.AttachedObject.name} : {sector.IsFakeSector}"); + var sector = PlayerTransformSync.LocalInstance.ReferenceSector; + var text = sector == null + ? "NULL SECTOR" + : $"{sector.AttachedObject.name} : {sector.IsFakeSector}"; + GUI.Label(new Rect(420, offset3, 400f, 20f), $"- {text}"); offset3 += _debugLineSpacing; var offset2 = 10f; diff --git a/QSB/SectorSync/SectorSync.cs b/QSB/SectorSync/SectorSync.cs index 43613437..6e8f2633 100644 --- a/QSB/SectorSync/SectorSync.cs +++ b/QSB/SectorSync/SectorSync.cs @@ -92,9 +92,7 @@ namespace QSB.SectorSync && sector.ShouldSyncTo()); if (activeNotNullNotBlacklisted.Count() == 0) { - DebugLog.ToConsole( - $"Error - Zero available sectors for {trans.name} to sync to! Current QSBSector count : {QSBWorldSync.GetWorldObjects().Count()}", - MessageType.Error); + return default; } var ordered = activeNotNullNotBlacklisted .OrderBy(sector => Vector3.Distance(sector.Position, trans.position)) diff --git a/QSB/SectorSync/WorldObjects/QSBSector.cs b/QSB/SectorSync/WorldObjects/QSBSector.cs index e7f8c3ef..4c15839a 100644 --- a/QSB/SectorSync/WorldObjects/QSBSector.cs +++ b/QSB/SectorSync/WorldObjects/QSBSector.cs @@ -34,16 +34,17 @@ namespace QSB.SectorSync.WorldObjects public bool ShouldSyncTo() { - if (!AttachedObject.gameObject.activeInHierarchy) - { - return false; - } - if (AttachedObject == null) { DebugLog.ToConsole($"Warning - AttachedObject for sector id:{ObjectId} is null!", MessageType.Warning); return false; } + + if (!AttachedObject.gameObject.activeInHierarchy) + { + return false; + } + if (Type == Sector.Name.Ship) { return false;