Ejemplo n.º 1
0
        public void CleanClientPackets()
        {
            foreach (var packet in ClientPacketsToClean)
            {
                PacketObjPool.Return(packet);
            }

            ClientPacketsToClean.Clear();
        }
Ejemplo n.º 2
0
        private void ProccessServerPacket(byte[] rawData)
        {
            var packet = MyAPIGateway.Utilities.SerializeFromBinary <Packet>(rawData);

            if (packet == null)
            {
                return;
            }

            var packetSize = rawData.Length;

            var report = Reporter.ReportPool.Get();

            report.Receiver   = NetworkReporter.Report.Received.Server;
            report.PacketSize = packetSize;
            Reporter.ReportData[packet.PType].Add(report);

            var packetObj = PacketObjPool.Get();

            packetObj.ErrorPacket.RecievedTick = Tick;
            packetObj.Packet = packet; packetObj.PacketSize = packetSize; packetObj.Report = report;

            switch (packetObj.Packet.PType)
            {
            case PacketType.ClientMouseEvent: {
                ServerClientMouseEvent(packetObj);
                break;
            }

            case PacketType.ActiveControlUpdate: {
                ServerActiveControlUpdate(packetObj);
                break;
            }

            case PacketType.FakeTargetUpdate: {
                ServerFakeTargetUpdate(packetObj);
                break;
            }

            case PacketType.AmmoCycleRequest: {
                ServerAmmoCycleRequest(packetObj);
                break;
            }

            case PacketType.ReticleUpdate: {
                ServerReticleUpdate(packetObj);
                break;
            }

            case PacketType.PlayerControlRequest:
            {
                ServerPlayerControlRequest(packetObj);
                break;
            }

            case PacketType.ClientAiAdd:
            case PacketType.ClientAiRemove: {
                ServerClientAiExists(packetObj);
                break;
            }

            case PacketType.OverRidesUpdate: {
                ServerOverRidesUpdate(packetObj);
                break;
            }

            case PacketType.RequestMouseStates: {
                ServerRequestMouseStates(packetObj);
                break;
            }

            case PacketType.RequestShootUpdate: {
                ServerRequestShootUpdate(packetObj);
                break;
            }

            case PacketType.FixedWeaponHitEvent: {
                ServerFixedWeaponHitEvent(packetObj);
                break;
            }

            case PacketType.RequestSetRof:
            case PacketType.RequestSetGuidance:
            case PacketType.RequestSetOverload:
            case PacketType.RequestSetRange:
            case PacketType.RequestSetDps:
            {
                ServerUpdateSetting(packetObj);
                break;
            }

            case PacketType.FocusUpdate:
            case PacketType.FocusLockUpdate:
            case PacketType.NextActiveUpdate:
            case PacketType.ReleaseActiveUpdate: {
                ServerFocusUpdate(packetObj);
                break;
            }

            case PacketType.ProblemReport: {
                ServerRequestReport(packetObj);
                break;
            }

            case PacketType.TerminalMonitor: {
                ServerTerminalMonitor(packetObj);
                break;
            }

            default:
                packetObj.Report.PacketValid = false;
                Reporter.ReportData[PacketType.Invalid].Add(packetObj.Report);
                break;
            }

            if (!packetObj.Report.PacketValid)
            {
                Log.LineShortDate(packetObj.ErrorPacket.Error, "net");
            }

            PacketObjPool.Return(packetObj);
        }