public void ProcessPacket(DysonSphereRemoveNodePacket packet, NebulaConnection conn) { Log.Info($"Processing DysonSphere Remove Node notification for system {GameMain.data.galaxy.stars[packet.StarIndex].name} (Index: {GameMain.data.galaxy.stars[packet.StarIndex].index})"); using (DysonSphere_Manager.IncomingDysonSpherePacket.On()) { DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); if (dsl != null) { int num = 0; DysonNode dysonNode = dsl.nodePool[packet.NodeId]; //Remove all frames that are part of the node while (dysonNode.frames.Count > 0) { dsl.RemoveDysonFrame(dysonNode.frames[0].id); if (num++ > 4096) { Assert.CannotBeReached(); break; } } //Remove all shells that are part of the node while (dysonNode.shells.Count > 0) { dsl.RemoveDysonShell(dysonNode.shells[0].id); if (num++ > 4096) { Assert.CannotBeReached(); break; } } dsl.RemoveDysonNode(packet.NodeId); } } }
public override void ProcessPacket(DysonSphereRemoveNodePacket packet, NebulaConnection conn) { DysonSphereLayer layer = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); if (layer == null) { return; } using (Multiplayer.Session.DysonSpheres.IsIncomingRequest.On()) { if (!Check(layer, packet)) { Log.Warn($"Cannnot remove node[{packet.NodeId}] on layer[{layer.id}], starIndex[{packet.StarIndex}]"); Multiplayer.Session.DysonSpheres.HandleDesync(packet.StarIndex, conn); return; } //No need to remove if the node is already null if (layer.nodePool[packet.NodeId] != null) { layer.RemoveDysonNode(packet.NodeId); NebulaWorld.Universe.DysonSphereManager.ClearSelection(packet.StarIndex, layer.id); } } if (IsHost) { Multiplayer.Session.DysonSpheres.SendPacketToDysonSphereExcept(packet, packet.StarIndex, conn); } }
public override void ProcessPacket(DysonSphereRemoveNodePacket packet, NebulaConnection conn) { bool valid = true; if (IsHost) { Player player = playerManager.GetPlayer(conn); if (player != null) { playerManager.SendPacketToOtherPlayers(packet, player); } else { valid = false; } } if (valid) { using (DysonSphereManager.IsIncomingRequest.On()) { DysonSphereLayer dsl = GameMain.data.dysonSpheres[packet.StarIndex]?.GetLayer(packet.LayerId); if (dsl != null) { int num = 0; DysonNode dysonNode = dsl.nodePool[packet.NodeId]; //Remove all frames that are part of the node while (dysonNode.frames.Count > 0) { dsl.RemoveDysonFrame(dysonNode.frames[0].id); if (num++ > 4096) { Assert.CannotBeReached(); break; } } //Remove all shells that are part of the node while (dysonNode.shells.Count > 0) { dsl.RemoveDysonShell(dysonNode.shells[0].id); if (num++ > 4096) { Assert.CannotBeReached(); break; } } dsl.RemoveDysonNode(packet.NodeId); } } } }