Esempio n. 1
0
        public override void OnWorldPlayerEvent(string EventName, Player Plr, object Data)
        {
            if (EventName == "SEND_PACKAGES")
            {
                List <PacketInfo> P;
                if (Packets.TryGetValue(Plr.Info.Career, out P))
                {
                    foreach (PacketInfo Packet in P)
                    {
                        PacketOut Out = new PacketOut(Packet.Opcode);
                        Out.Write(Packet.Data, 3, Packet.Data.Length - 3);
                        Plr.SendPacket(Out);
                    }
                }

                if (Plr.Info.FirstConnect && Plr.GmLevel == 1)
                {
                    Plr.Info.FirstConnect = false;
                    if (!Plr.IsBanned)
                    {
                        if (Intros.Count == 0)
                        {
                            return;
                        }
                        PacketInfo Packet = Intros[Plr.Info.Career];
                        PacketOut  Out    = new PacketOut(Packet.Opcode);
                        Out.Write(Packet.Data, 3, Packet.Data.Length - 3);
                        Plr.SendPacket(Out);
                    }
                }
            }
        }
Esempio n. 2
0
        // 0 = White
        // 1 = Grey
        // 2 = Green
        // 3 = Red

        public void AddPacket(PacketInfo Packet)
        {
            Packets.Add(Packet);
            PacketsContainer TempPackets = null;

            if (!PacketsAnalyze.TryGetValue(Packet.Opcode, out TempPackets))
            {
                TempPackets      = new PacketsContainer();
                TempPackets.File = this;
                PacketsAnalyze.Add(Packet.Opcode, TempPackets);
                TempPackets.Opcode     = Packet.Opcode;
                TempPackets.OpcodeName = Packet.OpcodeName;
            }

            TempPackets.Packets.Add(Packet);
        }
Esempio n. 3
0
        public void Analyze(CanAnalyseDelegate CanAnalyze)
        {
            using (StreamReader SReader = File.OpenText(FilePath))
            {
                string     Line         = "";
                int        TempIndex    = 0;
                int        TempPosition = 0;
                byte       TempOpcode   = 0;
                string     TempOpcodeName;
                PacketInfo Packet      = null;
                int        LineId      = 0;
                int        MaxPosition = 0;

                while (!SReader.EndOfStream)
                {
                    Line = SReader.ReadLine();
                    if (Line.Length == 0)
                    {
                        continue;
                    }

                    if (Line[0] == '[')
                    {
                        ++TotalPackets;
                        TempIndex      = Line.IndexOf('(');
                        TempOpcodeName = Line.Substring(TempIndex + 7, Line.IndexOf("  ") - (TempIndex + 7));

                        if (!CanAnalyze(TempOpcodeName))
                        {
                            if (!SReader.EndOfStream)
                            {
                                Line = SReader.ReadLine();
                            }
                            if (!SReader.EndOfStream)
                            {
                                Line = SReader.ReadLine();
                            }
                            if (!SReader.EndOfStream)
                            {
                                Line = SReader.ReadLine();
                            }
                            while (!SReader.EndOfStream)
                            {
                                Line = SReader.ReadLine();

                                if (Line[0] == '-')
                                {
                                    break;
                                }
                            }
                            continue;
                        }

                        TempOpcode = byte.Parse(Line.Substring(TempIndex + 3, 2), System.Globalization.NumberStyles.HexNumber);

                        Packet = new PacketInfo(this);

                        TempIndex         = Line.LastIndexOf('=') + 1;
                        Packet.Size       = int.Parse(Line.Substring(TempIndex, Line.Length - TempIndex));
                        Packet.Opcode     = TempOpcode;
                        Packet.OpcodeName = TempOpcodeName;
                        Packet.Data       = new byte[Packet.Size];
                        if (!SReader.EndOfStream)
                        {
                            Line = SReader.ReadLine(); // |------------------------------------------------|----------------|
                        }
                        if (!SReader.EndOfStream)
                        {
                            Line = SReader.ReadLine(); // |00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF|
                        }
                        if (!SReader.EndOfStream)
                        {
                            Line = SReader.ReadLine(); // |------------------------------------------------|----------------|
                        }
                        Packet.Line  = LineId;
                        TempPosition = 0;

                        while (!SReader.EndOfStream)
                        {
                            Line = SReader.ReadLine();

                            if (Line[0] == '-')
                            {
                                break;
                            }

                            Line = Line.Replace(" ", string.Empty);

                            MaxPosition = Math.Min(33, (Packet.Size - TempPosition) * 2);
                            for (TempIndex = 1; TempIndex < MaxPosition; TempIndex += 2)
                            {
                                Packet.Data[TempPosition] = byte.Parse(Line.Substring(TempIndex, 2), System.Globalization.NumberStyles.HexNumber);
                                ++TempPosition;
                            }
                        }

                        ++LineId;

                        AddPacket(Packet);
                    }
                }
            }
        }