From fb11e828a3a1f52e88e96cdaf1076aefac402b24 Mon Sep 17 00:00:00 2001 From: Ricardo Lopes Date: Thu, 13 Feb 2020 22:18:41 +0100 Subject: [PATCH] More slight refactoring --- QSB/NetworkPlayer.cs | 5 +---- QSB/SectorSync.cs | 10 +++++++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/QSB/NetworkPlayer.cs b/QSB/NetworkPlayer.cs index 4fcfd745..4b915270 100644 --- a/QSB/NetworkPlayer.cs +++ b/QSB/NetworkPlayer.cs @@ -27,10 +27,7 @@ namespace QSB { } public void EnterSector (Sector sector) { - var name = sector.GetName(); - if (name != Sector.Name.Unnamed && name != Sector.Name.Ship && name != Sector.Name.Sun) { - SectorSync.SetSector(netId, sector.GetName()); - } + SectorSync.SetSector(netId, sector.GetName()); } void Update () { diff --git a/QSB/SectorSync.cs b/QSB/SectorSync.cs index 953ed11e..eb65d7b3 100644 --- a/QSB/SectorSync.cs +++ b/QSB/SectorSync.cs @@ -16,7 +16,11 @@ namespace QSB { } public static void SetSector (NetworkInstanceId netId, Sector.Name sectorName, bool skipAnnounce = false) { - playerSectors[netId.Value] = GetSectorByName(sectorName); + if (sectorName == Sector.Name.Unnamed || sectorName != Sector.Name.Ship && sectorName != Sector.Name.Sun) { + return; + } + + playerSectors[netId.Value] = GetSectorTransform(sectorName); if (!skipAnnounce) { SectorMessage msg = new SectorMessage(); @@ -30,7 +34,7 @@ namespace QSB { return playerSectors[netId.Value]; } - static Transform GetSectorByName (Sector.Name sectorName) { + static Transform GetSectorTransform (Sector.Name sectorName) { foreach (var sector in _allSectors) { if (sectorName == sector.GetName()) { return sector.transform; @@ -43,7 +47,7 @@ namespace QSB { SectorMessage msg = netMsg.ReadMessage(); var sectorName = (Sector.Name) msg.sectorId; - var sectorTransform = GetSectorByName(sectorName); + var sectorTransform = GetSectorTransform(sectorName); if (sectorTransform == null) { QSB.LogToScreen("Sector", sectorName, "not found");