Skip to content

Commit

Permalink
Fix routers packets
Browse files Browse the repository at this point in the history
  • Loading branch information
starfi5h committed Jan 22, 2024
1 parent 84f7201 commit 0ae5cbf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
4 changes: 2 additions & 2 deletions NebulaNetwork/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ public void Dispose()

public void SendPacketToLocalStar<T>(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>(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>(T packet, int planetId) where T : class, new()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#region

using NebulaAPI.GameState;
using NebulaAPI.Packets;
using NebulaModel;
using NebulaModel.Networking;
using NebulaModel.Packets;
using NebulaModel.Packets.Routers;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#region

using NebulaAPI.GameState;
using NebulaAPI.Packets;
using NebulaModel;
using NebulaModel.Networking;
using NebulaModel.Packets;
using NebulaModel.Packets.Routers;
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions NebulaNetwork/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public void SendToMatching<T>(T packet, Predicate<INebulaPlayer> condition)

public void SendPacketToLocalStar<T>(T packet) where T : class, new()
{
var starId = GameMain.data.localStar.id;
var starId = GameMain.data.localStar?.id ?? -1;
SendPacketToStar(packet, starId);
}

Expand All @@ -399,7 +399,7 @@ public void SendToMatching<T>(T packet, Predicate<INebulaPlayer> condition)

public void SendPacketToLocalPlanet<T>(T packet) where T : class, new()
{
var planetId = GameMain.data.mainPlayer.planetId;
var planetId = GameMain.data.localPlanet?.id ?? -1;
SendPacketToPlanet(packet, planetId);
}

Expand Down

0 comments on commit 0ae5cbf

Please sign in to comment.