Exemplo n.º 1
0
        public void ReproccessClientErrorPackets()
        {
            foreach (var packetObj in ClientSideErrorPkt)
            {
                var errorPacket = packetObj.ErrorPacket;
                var packet      = packetObj.Packet;

                if (errorPacket.MaxAttempts == 0)
                {
                    Log.LineShortDate($"        [ClientReprocessing] Entity:{packet.EntityId} - Type:{packet.PType}", "net");
                    //set packet retry variables, based on type
                    errorPacket.MaxAttempts     = 7;
                    errorPacket.RetryDelayTicks = 15;
                    errorPacket.RetryTick       = Tick + errorPacket.RetryDelayTicks;
                }

                if (errorPacket.RetryTick > Tick)
                {
                    continue;
                }
                errorPacket.RetryAttempt++;
                var success = ProccessClientPacket(packetObj, false) || packetObj.Report.PacketValid;

                if (success || errorPacket.RetryAttempt > errorPacket.MaxAttempts)
                {
                    if (!success)
                    {
                        Log.LineShortDate($"        [BadReprocess] Entity:{packet.EntityId} Cause:{errorPacket.Error ?? string.Empty} Type:{packet.PType}", "net");
                    }
                    else
                    {
                        Log.LineShortDate($"        [ReprocessSuccess] Entity:{packet.EntityId} - Type:{packet.PType} - Retries:{errorPacket.RetryAttempt}", "net");
                    }

                    ClientSideErrorPkt.Remove(packetObj);
                    ClientPacketsToClean.Add(packetObj);
                }
                else
                {
                    errorPacket.RetryTick = Tick + errorPacket.RetryDelayTicks;
                }
            }
            ClientSideErrorPkt.ApplyChanges();
        }
Exemplo n.º 2
0
        private bool ProccessClientPacket(PacketObj packetObj, bool firstRun = true)
        {
            try {
                var invalidType = false;
                switch (packetObj.Packet.PType)
                {
                case PacketType.FakeTargetUpdate:
                {
                    ClientFakeTargetUpdate(packetObj);
                    break;
                }

                case PacketType.PlayerIdUpdate:
                {
                    ClientPlayerIdUpdate(packetObj);
                    break;
                }

                case PacketType.ServerData:
                {
                    ClientServerData(packetObj);
                    break;
                }

                case PacketType.ClientMouseEvent:
                {
                    ClientClientMouseEvent(packetObj);
                    break;
                }

                case PacketType.Construct:
                {
                    ClientConstruct(packetObj);
                    break;
                }

                case PacketType.ConstructFoci:
                {
                    ClientConstructFoci(packetObj);
                    break;
                }

                case PacketType.AiData:
                {
                    ClientAiDataUpdate(packetObj);
                    break;
                }

                case PacketType.CompState:
                {
                    ClientStateUpdate(packetObj);
                    break;
                }

                case PacketType.WeaponReload:
                {
                    ClientWeaponReloadUpdate(packetObj);
                    break;
                }

                case PacketType.WeaponAmmo:
                {
                    ClientWeaponAmmoUpdate(packetObj);
                    break;
                }

                case PacketType.CompBase:
                {
                    ClientCompData(packetObj);
                    break;
                }

                case PacketType.TargetChange:
                {
                    ClientTargetUpdate(packetObj);
                    break;
                }

                case PacketType.FullMouseUpdate:
                {
                    ClientFullMouseUpdate(packetObj);
                    break;
                }

                case PacketType.QueueShot:
                {
                    ClientQueueShot(packetObj);
                    break;
                }

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

                case PacketType.ClientNotify:
                {
                    ClientNotify(packetObj);
                    break;
                }

                case PacketType.Invalid:
                {
                    Log.Line($"invalid packet: {packetObj.PacketSize} - {packetObj.Packet.PType}");
                    invalidType = true;
                    packetObj.Report.PacketValid = false;
                    break;
                }

                default:
                    Log.LineShortDate($"        [BadClientPacket] Type:{packetObj.Packet.PType} - Size:{packetObj.PacketSize}", "net");
                    Reporter.ReportData[PacketType.Invalid].Add(packetObj.Report);
                    invalidType = true;
                    packetObj.Report.PacketValid = false;
                    break;
                }
                if (firstRun && !packetObj.Report.PacketValid && !invalidType && !packetObj.ErrorPacket.Retry && !packetObj.ErrorPacket.NoReprocess)
                {
                    if (!ClientSideErrorPkt.Contains(packetObj))
                    {
                        ClientSideErrorPkt.Add(packetObj);
                    }
                    else
                    {
                        Log.Line($"ClientSideErrorPkt: this should be impossible: {packetObj.Packet.PType}");
                    }
                }

                if (firstRun)
                {
                    ClientSideErrorPkt.ApplyChanges();

                    if (!ClientSideErrorPkt.Contains(packetObj))
                    {
                        ClientPacketsToClean.Add(packetObj);
                        return(true);
                    }
                }
            }
            catch (Exception ex) { Log.Line($"Exception in ProccessClientPacket: {ex} - packetSize:{packetObj?.PacketSize} - pObjNull:{packetObj == null} - packetNull:{packetObj?.Packet == null} - error:{packetObj?.ErrorPacket == null} - report:{packetObj?.Report == null}"); }
            return(false);
        }