diff --git a/NebulaNetwork/Client.cs b/NebulaNetwork/Client.cs index ec571abe0..c9e0b1e29 100644 --- a/NebulaNetwork/Client.cs +++ b/NebulaNetwork/Client.cs @@ -175,12 +175,12 @@ public void Dispose() public void SendPacketToLocalStar(T packet) where T : class, new() { - serverConnection?.SendPacket(new StarBroadcastPacket(PacketProcessor.Write(packet), GameMain.mainPlayer.planetId)); + serverConnection?.SendPacket(new StarBroadcastPacket(PacketProcessor.Write(packet), GameMain.data.localStar?.id ?? -1)); } public void SendPacketToLocalPlanet(T packet) where T : class, new() { - serverConnection?.SendPacket(new PlanetBroadcastPacket(PacketProcessor.Write(packet), GameMain.mainPlayer.planetId)); + serverConnection?.SendPacket(new PlanetBroadcastPacket(PacketProcessor.Write(packet), GameMain.data.localPlanet?.id ?? -1)); } public void SendPacketToPlanet(T packet, int planetId) where T : class, new() diff --git a/NebulaNetwork/PacketProcessors/Routers/PlanetBroadcastProcessor.cs b/NebulaNetwork/PacketProcessors/Routers/PlanetBroadcastProcessor.cs index d8aafde7e..44ea66410 100644 --- a/NebulaNetwork/PacketProcessors/Routers/PlanetBroadcastProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Routers/PlanetBroadcastProcessor.cs @@ -1,8 +1,6 @@ #region -using NebulaAPI.GameState; using NebulaAPI.Packets; -using NebulaModel; using NebulaModel.Networking; using NebulaModel.Packets; using NebulaModel.Packets.Routers; @@ -25,7 +23,7 @@ protected override void ProcessPacket(PlanetBroadcastPacket packet, NebulaConnec if (IsHost) Multiplayer.Session.Server.SendToMatching(packet, p => p.Data.LocalPlanetId == packet.PlanetId && - p.Connection.Equals(conn) + !p.Connection.Equals(conn) ); //Forward packet data to be processed diff --git a/NebulaNetwork/PacketProcessors/Routers/StarBroadcastProcessor.cs b/NebulaNetwork/PacketProcessors/Routers/StarBroadcastProcessor.cs index c53c5cabc..230342e95 100644 --- a/NebulaNetwork/PacketProcessors/Routers/StarBroadcastProcessor.cs +++ b/NebulaNetwork/PacketProcessors/Routers/StarBroadcastProcessor.cs @@ -1,8 +1,6 @@ #region -using NebulaAPI.GameState; using NebulaAPI.Packets; -using NebulaModel; using NebulaModel.Networking; using NebulaModel.Packets; using NebulaModel.Packets.Routers; @@ -25,7 +23,7 @@ protected override void ProcessPacket(StarBroadcastPacket packet, NebulaConnecti if (IsHost) Multiplayer.Session.Server.SendToMatching(packet, p => p.Data.LocalStarId == packet.StarId && - p.Connection.Equals(conn) + !p.Connection.Equals(conn) ); //Forward packet data to be processed diff --git a/NebulaNetwork/Server.cs b/NebulaNetwork/Server.cs index cfcd02a20..b5b4b2a01 100644 --- a/NebulaNetwork/Server.cs +++ b/NebulaNetwork/Server.cs @@ -388,7 +388,7 @@ public void SendToMatching(T packet, Predicate condition) public void SendPacketToLocalStar(T packet) where T : class, new() { - var starId = GameMain.data.localStar.id; + var starId = GameMain.data.localStar?.id ?? -1; SendPacketToStar(packet, starId); } @@ -399,7 +399,7 @@ public void SendToMatching(T packet, Predicate condition) public void SendPacketToLocalPlanet(T packet) where T : class, new() { - var planetId = GameMain.data.mainPlayer.planetId; + var planetId = GameMain.data.localPlanet?.id ?? -1; SendPacketToPlanet(packet, planetId); }