コード例 #1
0
ファイル: Main.cs プロジェクト: Xcelled/MabiPale2
        private void OnSelected(PalePacket palePacket)
        {
            if (form == null || form.IsDisposed || palePacket.Op != Op.DungeonInfo)
                return;

            palePacket.Packet.GetLong();
            palePacket.Packet.GetLong();
            palePacket.Packet.GetByte();
            var name = palePacket.Packet.GetString();
            var itemId = palePacket.Packet.GetInt();
            var seed = palePacket.Packet.GetInt();
            var floorPlan = palePacket.Packet.GetInt();

            form.SetValuesAndGenerate(name, itemId, floorPlan);
        }
コード例 #2
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        public void OnSelected(PalePacket palePacket)
        {
            if (palePacket == null)
            {
                TxtInfo.Visible = false;
                return;
            }

            TxtInfo.WordWrap = true;

            try
            {
                switch (palePacket.Op)
                {
                    case Op.ConditionUpdate: ParseConditionUpdate(palePacket); break;
                    case Op.StatUpdatePublic:
                    case Op.StatUpdatePrivate: ParseStatUpdate(palePacket); break;

                    case Op.NpcTalk: ParseNpcTalk(palePacket); break;
                    case Op.NpcTalkSelect: ParseNpcTalkSelect(palePacket); break;
                    case Op.OpenNpcShop:
                    case Op.AddToNpcShop: ParseOpenNpcShop(palePacket); break;

                    case Op.CombatActionPack: ParseCombatActionPacket(palePacket); break;

                    case Op.ItemUpdate:
                    case Op.ItemNew: ParseItemNew(palePacket); break;

                    default: ParseUnknown(palePacket); break;
                }
            }
            catch (Exception ex)
            {
                TxtInfo.Text = "Error: " + ex.ToString();
            }

            TxtInfo.Visible = true;
        }
コード例 #3
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        private void ParseStatUpdate(PalePacket palePacket)
        {
            palePacket.Packet.GetByte();
            var count = palePacket.Packet.GetInt();

            var sb = new StringBuilder();
            for (int i = 0; i < count; ++i)
            {
                sb.AppendFormat("{0}: ", (Stat)palePacket.Packet.GetInt());

                switch (palePacket.Packet.Peek())
                {
                    case Shared.PacketElementType.Byte: sb.AppendLine(palePacket.Packet.GetByte().ToString()); break;
                    case Shared.PacketElementType.Short: sb.AppendLine(palePacket.Packet.GetShort().ToString()); break;
                    case Shared.PacketElementType.Int: sb.AppendLine(palePacket.Packet.GetInt().ToString()); break;
                    case Shared.PacketElementType.Long: sb.AppendLine(palePacket.Packet.GetLong().ToString()); break;
                    case Shared.PacketElementType.Float: sb.AppendLine(palePacket.Packet.GetFloat().ToString(CultureInfo.InvariantCulture)); break;
                    case Shared.PacketElementType.String: sb.AppendLine(palePacket.Packet.GetString().ToString()); break;
                    default: palePacket.Packet.Skip(1); sb.AppendLine("?"); break;
                }
            }

            TxtInfo.Text = sb.ToString();
        }
コード例 #4
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        private void ParseOpenNpcShop(PalePacket palePacket)
        {
            palePacket.Packet.GetString();
            palePacket.Packet.GetByte();
            palePacket.Packet.GetByte();
            palePacket.Packet.GetInt();

            var tabCount = palePacket.Packet.GetByte();
            var tabs = new Dictionary<string, List<ShopItem>>();
            for (int i = 0; i < tabCount; ++i)
            {
                var name = palePacket.Packet.GetString();

                if (!tabs.ContainsKey(name))
                    tabs.Add(name, new List<ShopItem>());

                palePacket.Packet.GetByte();

                var itemCount = palePacket.Packet.GetShort();
                for (int j = 0; j < itemCount; ++j)
                {
                    palePacket.Packet.GetLong();
                    palePacket.Packet.GetByte();
                    var itemInfo = palePacket.Packet.GetObj<ItemInfo>();
                    var itemOptionInfo = palePacket.Packet.GetObj<ItemOptionInfo>();
                    var metaData1 = palePacket.Packet.GetString();
                    var metaData2 = palePacket.Packet.GetString();
                    palePacket.Packet.GetByte();
                    palePacket.Packet.GetLong();

                    // [190100, NA200 (2015-01-15)] New/Combined
                    if (palePacket.Packet.NextIs(Shared.PacketElementType.Byte))
                    {
                        palePacket.Packet.GetByte();
                        palePacket.Packet.GetByte();
                    }

                    tabs[name].Add(new ShopItem() { Info = itemInfo, OptionInfo = itemOptionInfo, MetaData1 = metaData1 });
                }
            }

            var sb = new StringBuilder();
            var prev = "";
            foreach (var tab in tabs.OrderBy(a => a.Key))
            {
                var name = tab.Key.Substring(tab.Key.IndexOf("]") + 1);

                if (prev != name)
                {
                    if (prev != "")
                        sb.AppendLine();
                    //sb.AppendLine("// " + name);
                }

                prev = name;

                foreach (var item in tab.Value.OrderBy(a => a.Info.Id))
                {
                    var others = tab.Value.Count(a => a.Info.Id == item.Info.Id && a.Info.Amount != item.Info.Amount) != 0;

                    if (!string.IsNullOrWhiteSpace(item.MetaData1) && item.Info.Id != 70023)
                    {
                        if (item.MetaData1.Contains("FORMID:") || item.MetaData1.Contains("QSTTIP:"))
                            sb.AppendLine("Add(\"{0}\", {1}, \"{2}\", {3});", name, item.Info.Id, item.MetaData1, item.OptionInfo.Price);
                        else
                            sb.AppendLine("Add(\"{0}\", {1}, \"{2}\");", name, item.Info.Id, item.MetaData1);
                    }
                    else if (item.Info.Amount <= 1 && !others)
                    {
                        sb.AppendLine("Add(\"{0}\", {1});", name, item.Info.Id);
                    }
                    else
                    {
                        sb.AppendLine("Add(\"{0}\", {1}, {2});", name, item.Info.Id, Math.Max(1, (int)item.Info.Amount));
                    }
                }
            }

            TxtInfo.WordWrap = false;
            TxtInfo.Text = sb.ToString();
        }
コード例 #5
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        private void ParseNpcTalkSelect(PalePacket palePacket)
        {
            var xml = palePacket.Packet.GetString();

            var regex = Regex.Match(xml, @"<return type=""[^""]+"">([^<]+)</return>");
            if (!regex.Success)
                throw new Exception();

            TxtInfo.Text = "Response: " + regex.Groups[1].Value;
        }
コード例 #6
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        private void ParseNpcTalk(PalePacket palePacket)
        {
            var xmlstr = palePacket.Packet.GetString();

            var xml = XElement.Parse(xmlstr);
            if (xml.Name != "call")
                throw new ArgumentException("Expected root element to be call.");

            var function = xml.Element("function");
            if (function == null)
                throw new ArgumentException("Missing function element.");

            var prototype = function.Element("prototype");
            if (prototype == null)
                throw new ArgumentException("Missing prototype element.");

            var fIdx = prototype.Value.IndexOf("::");
            var fEnd = prototype.Value.IndexOf("(");
            var functionName = prototype.Value.Substring(fIdx + 2, fEnd - fIdx - 2);

            if (functionName == "OpenTravelerMemo")
                TxtInfo.Text = "OpenTravelerMemo" + Environment.NewLine + "Opens keyword window.";
            else if (functionName == "SelectInTalk")
                TxtInfo.Text = "SelectInTalk" + Environment.NewLine + "Sent after something selectable (buttons, keywords, etc), \"pauses\" dialog for the player to select something.";
            else if (functionName == "ShowTalkMessage")
            {
                var arguments = function.Element("arguments");
                if (prototype == null)
                    throw new ArgumentException("Missing arguments element.");

                if (arguments.Elements("argument").Count() != 2)
                    throw new ArgumentException("Mismatching argument count.");

                var last = arguments.Elements("argument").Last();
                var msgRaw = HttpUtility.HtmlDecode(last.Value);

                var msgs = msgRaw.Split(new string[] { "<p/>" }, StringSplitOptions.RemoveEmptyEntries);

                var sb = new StringBuilder();
                foreach (var msg in msgs)
                {
                    var cleanMsg = msg.Trim();
                    cleanMsg = Regex.Replace(cleanMsg, " *(<br/>) *", "$1");
                    cleanMsg = cleanMsg.Replace("\"", "\\\"");

                    // TODO: Expressions, buttons, etc. Or wait for the dialog parser?
                    sb.AppendLine("Msg(\"{0}\");", cleanMsg);
                }

                TxtInfo.WordWrap = false;
                TxtInfo.Text = sb.ToString();
            }
            else
                TxtInfo.Text = "Unknown function name '" + functionName + "'.";
        }
コード例 #7
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        private void ParseItemNew(PalePacket palePacket)
        {
            var sb = new StringBuilder();

            sb.AppendLine("Item Entity Id: {0:X16}", palePacket.Packet.GetLong());
            sb.AppendLine("Type: {0}", palePacket.Packet.GetByte());
            sb.AppendLine();

            var info = palePacket.Packet.GetObj<ItemInfo>();
            sb.AppendLine("Amount: {0}", info.Amount);
            sb.AppendLine("Color1: 0x{0:X6}", info.Color1);
            sb.AppendLine("Color2: 0x{0:X6}", info.Color2);
            sb.AppendLine("Color3: 0x{0:X6}", info.Color3);
            sb.AppendLine("Id: {0}", info.Id);
            sb.AppendLine("KnockCount: {0}", info.KnockCount);
            sb.AppendLine("Pocket: {0}", info.Pocket);
            sb.AppendLine("Region: {0}", info.Region);
            sb.AppendLine("FigureA: {0}", info.State);
            sb.AppendLine("FigureB: {0}", info.FigureB);
            sb.AppendLine("FigureC: {0}", info.FigureC);
            sb.AppendLine("FigureD: {0}", info.FigureD);
            sb.AppendLine("X: {0}", info.X);
            sb.AppendLine("Y: {0}", info.Y);
            sb.AppendLine();

            var optioninfo = palePacket.Packet.GetObj<ItemOptionInfo>();
            sb.AppendLine("__unknown15: {0}", optioninfo.__unknown15);
            sb.AppendLine("__unknown16: {0}", optioninfo.__unknown16);
            sb.AppendLine("__unknown17: {0}", optioninfo.__unknown17);
            sb.AppendLine("__unknown24: {0}", optioninfo.__unknown24);
            sb.AppendLine("__unknown25: {0}", optioninfo.__unknown25);
            sb.AppendLine("__unknown3: {0}", optioninfo.__unknown3);
            sb.AppendLine("__unknown31: {0}", optioninfo.__unknown31);
            sb.AppendLine("AttackMax: {0}", optioninfo.AttackMax);
            sb.AppendLine("AttackMin: {0}", optioninfo.AttackMin);
            sb.AppendLine("AttackSpeed: {0}", optioninfo.AttackSpeed);
            sb.AppendLine("Balance: {0}", optioninfo.Balance);
            sb.AppendLine("Critical: {0}", optioninfo.Critical);
            sb.AppendLine("Defense: {0}", optioninfo.Defense);
            sb.AppendLine("DucatPrice: {0}", optioninfo.DucatPrice);
            sb.AppendLine("Durability: {0}", optioninfo.Durability);
            sb.AppendLine("DurabilityMax: {0}", optioninfo.DurabilityMax);
            sb.AppendLine("DurabilityOriginal: {0}", optioninfo.DurabilityOriginal);
            sb.AppendLine("EffectiveRange: {0}", optioninfo.EffectiveRange);
            sb.AppendLine("Elemental: {0}", optioninfo.Elemental);
            sb.AppendLine("EP: {0}", optioninfo.EP);
            sb.AppendLine("Experience: {0}", optioninfo.Experience);
            sb.AppendLine("ExpireTime: {0}", optioninfo.ExpireTime);
            sb.AppendLine("Flags: {0}", optioninfo.Flags);
            sb.AppendLine("Grade: {0}", optioninfo.Grade);
            sb.AppendLine("JoustPointPrice: {0}", optioninfo.JoustPointPrice);
            sb.AppendLine("KnockCount: {0}", optioninfo.KnockCount);
            sb.AppendLine("LinkedPocketId: {0}", optioninfo.LinkedPocketId);
            sb.AppendLine("PonsPrice: {0}", optioninfo.PonsPrice);
            sb.AppendLine("Prefix: {0}", optioninfo.Prefix);
            sb.AppendLine("Price: {0}", optioninfo.Price);
            sb.AppendLine("Protection: {0}", optioninfo.Protection);
            sb.AppendLine("SellingPrice: {0}", optioninfo.SellingPrice);
            sb.AppendLine("StackRemainingTime: {0}", optioninfo.StackRemainingTime);
            sb.AppendLine("StarPrice: {0}", optioninfo.StarPrice);
            sb.AppendLine("Suffix: {0}", optioninfo.Suffix);
            sb.AppendLine("Upgraded: {0}", optioninfo.Upgraded);
            sb.AppendLine("UpgradeMax: {0}", optioninfo.UpgradeMax);
            sb.AppendLine("InjuryMax: {0}", optioninfo.InjuryMax);
            sb.AppendLine("InjuryMin: {0}", optioninfo.InjuryMin);
            sb.AppendLine("WeaponType: {0}", optioninfo.WeaponType);

            TxtInfo.Text = sb.ToString();
        }
コード例 #8
0
ファイル: PluginManager.cs プロジェクト: Xcelled/MabiPale2
        /// <summary>
        /// Fires Send event.
        /// </summary>
        /// <param name="palePacket"></param>
        internal void OnSend(PalePacket palePacket)
        {
            var ev = Send;
            if (ev == null)
                return;

            try
            {
                var evs = ev.GetInvocationList().Cast<Action<PalePacket>>();
                foreach (var e in evs)
                {
                    e(palePacket);
                    palePacket.Packet.Rewind();
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.ToString());
            }
        }
コード例 #9
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        private void ParseCombatActionPacket(PalePacket palePacket)
        {
            var sb = new StringBuilder();

            sb.AppendLine("Id: " + palePacket.Packet.GetInt());
            sb.AppendLine("Prev Id: " + palePacket.Packet.GetInt());
            sb.AppendLine("Hit: " + palePacket.Packet.GetByte());
            sb.AppendLine("Max Hits: " + palePacket.Packet.GetByte());
            palePacket.Packet.GetByte();
            sb.AppendLine();

            var count = palePacket.Packet.GetInt();
            for (int i = 0; i < count; ++i)
            {
                var len = palePacket.Packet.GetInt();
                var buff = palePacket.Packet.GetBin();

                var actionPacket = new MabiPale2.Shared.Packet(buff, 0);
                actionPacket.GetInt();
                if (i > 0)
                    sb.AppendLine();

                var creatureEntityId = actionPacket.GetLong();
                var type = (CombatActionType)actionPacket.GetByte();

                var attackeraction = len < 80 && type != 0; // Hot fix, TODO: Proper check of type.

                sb.AppendLine(attackeraction ? "Attacker Action" : "Target Action");
                sb.AppendLine("--------------------");
                sb.AppendLine("Creature: " + creatureEntityId.ToString("X16"));
                sb.AppendLine("Type: " + type);
                sb.AppendLine("Stun: " + actionPacket.GetShort());
                sb.AppendLine("Skill Id: " + (SkillId)actionPacket.GetShort());
                actionPacket.GetShort();

                // AttackerAction
                if (attackeraction)
                {
                    sb.AppendLine("Target: " + actionPacket.GetLong().ToString("X16"));

                    var options = new List<uint>();
                    var topt = actionPacket.GetInt();
                    for (uint foo2 = 1; foo2 < 0x80000000; )
                    {
                        if ((topt & foo2) != 0)
                            options.Add(foo2);
                        foo2 <<= 1;
                    }
                    var strOptions = string.Join(", ", options.Select(a =>
                    {
                        var en = (AttackerOptions)a;
                        return "0x" + a.ToString("X2") + (en.ToString() != a.ToString() ? "(" + en + ")" : "");
                    }));

                    sb.AppendLine("Options: " + strOptions);

                    actionPacket.GetByte();
                    actionPacket.GetByte();
                    sb.AppendLine("X: " + actionPacket.GetInt());
                    sb.AppendLine("Y: " + actionPacket.GetInt());
                    if (actionPacket.NextIs(Shared.PacketElementType.Long))
                        sb.AppendLine("Prop: " + actionPacket.GetLong().ToString("X16"));
                }
                // TargetAction
                else
                {
                    // Target actions might end here, widnessed with a packet
                    // that had "97" as the previous short.
                    if (actionPacket.Peek() != Shared.PacketElementType.None)
                    {
                        // Target used Defense or Counter
                        if (type.HasFlag(CombatActionType.Defended) || type.HasFlag(CombatActionType.CounteredHit) || type.HasFlag((CombatActionType)0x73) || type.HasFlag((CombatActionType)0x13))
                        {
                            var attackerEntityId = actionPacket.GetLong();
                            actionPacket.GetInt();
                            actionPacket.GetByte();
                            actionPacket.GetByte();
                            var x = actionPacket.GetInt();
                            var y = actionPacket.GetInt();
                        }

                        var options = new List<uint>();
                        var topt = actionPacket.GetInt();
                        for (uint foo2 = 1; foo2 < 0x80000000; )
                        {
                            if ((topt & foo2) != 0)
                                options.Add(foo2);
                            foo2 <<= 1;
                        }
                        var strOptions = string.Join(", ", options.Select(a =>
                        {
                            var en = (TargetOptions)a;
                            return "0x" + a.ToString("X2") + (en.ToString() != a.ToString() ? "(" + en + ")" : "");
                        }));

                        sb.AppendLine("Options: " + strOptions);
                        sb.AppendLine("Damage: " + actionPacket.GetFloat());
                        sb.AppendLine("? Damage: " + actionPacket.GetFloat());
                        sb.AppendLine("Mana Damage?: " + actionPacket.GetInt());

                        sb.AppendLine("X-Diff: " + actionPacket.GetFloat());
                        sb.AppendLine("Y-Diff: " + actionPacket.GetFloat());
                        if (actionPacket.NextIs(Shared.PacketElementType.Float))
                        {
                            sb.AppendLine("New X: " + actionPacket.GetFloat());
                            sb.AppendLine("New Y: " + actionPacket.GetFloat());

                            // [190200, NA203 (22.04.2015)]
                            if (actionPacket.Peek() == Shared.PacketElementType.Int)
                            {
                                actionPacket.PutInt(0);
                            }
                        }

                        // MultiHit Target Option
                        if (actionPacket.NextIs(Shared.PacketElementType.Int))
                        {
                            sb.AppendLine("MultiHitDamageCount: " + actionPacket.GetInt());
                            sb.AppendLine("MultiHitdamageShowTime: " + actionPacket.GetInt());
                            sb.AppendLine("MultiHitUnk1: " + actionPacket.GetInt());
                            sb.AppendLine("MultiHitUnk2: " + actionPacket.GetInt());
                        }

                        actionPacket.GetByte();
                        sb.AppendLine("Delay: " + actionPacket.GetInt());
                        sb.AppendLine("Attacker: " + actionPacket.GetLong().ToString("X16"));
                    }
                }
            }

            TxtInfo.Text = sb.ToString();
        }
コード例 #10
0
ファイル: Main.cs プロジェクト: Xcelled/MabiPale2
        private void OnRecv(PalePacket palePacket)
        {
            // EntityAppears
            if (palePacket.Op == 0x520C)
            {
                AddCreatureInfo(palePacket.Packet);
            }
            // PropAppears
            if (palePacket.Op == 0x52D0)
            {
                AddProp(palePacket.Packet);
            }
            // EntitiesAppear
            else if (palePacket.Op == 0x5334)
            {
                var entityCount = palePacket.Packet.GetShort();
                for (int i = 0; i < entityCount; ++i)
                {
                    var type = palePacket.Packet.GetShort();
                    var len = palePacket.Packet.GetInt();
                    var entityData = palePacket.Packet.GetBin();

                    // Creature
                    if (type == 16)
                    {
                        var entityPacket = new Packet(entityData, 0);
                        AddCreatureInfo(entityPacket);
                    }
                    // Prop
                    else if (type == 160)
                    {
                        var entityPacket = new Packet(entityData, 0);
                        AddProp(entityPacket);
                    }
                }
            }
        }
コード例 #11
0
ファイル: FrmMain.cs プロジェクト: Vinna/MabiPale2
        /// <summary>
        /// Loads log file and adds packets to list.
        /// </summary>
        /// <param name="path"></param>
        private void LoadFile(string path)
        {
            var newPackets = new List<PalePacket>();

            using (var sr = new StreamReader(path))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    line = line.Trim();
                    var recv = false;

                    if (string.IsNullOrWhiteSpace(line) || (!line.StartsWith("Send") && !(recv = line.StartsWith("Recv"))))
                        continue;

                    var spaceIdx = line.IndexOf(' ');

                    var date = DateTime.MinValue;
                    if (line[4] == '@')
                        date = DateTime.Parse(line.Substring(5, spaceIdx - 5));

                    var packetStr = line.Substring(spaceIdx + 1, line.Length - spaceIdx - 1);
                    var packetArr = HexTool.ToByteArray(packetStr);
                    var packet = new Packet(packetArr, 0);
                    var palePacket = new PalePacket(packet, date, recv);

                    newPackets.Insert(0, palePacket);
                }
            }

            LstPackets.BeginUpdate();

            foreach (var palePacket in newPackets)
                AddPacketToFormList(palePacket, false);

            LstPackets.EndUpdate();

            UpdateCount();

            foreach (var palePacket in newPackets)
            {
                if (palePacket.Received)
                    pluginManager.OnRecv(palePacket);
                else
                    pluginManager.OnSend(palePacket);
            }
        }
コード例 #12
0
ファイル: FrmMain.cs プロジェクト: Vinna/MabiPale2
        /// <summary>
        /// Adds packet to list, scrolls down if scroll is true.
        /// </summary>
        /// <param name="palePacket"></param>
        /// <param name="scroll"></param>
        private void AddPacketToFormList(PalePacket palePacket, bool scroll)
        {
            var name = "?";
            lock (opNames)
            {
                if (opNames.ContainsKey(palePacket.Op))
                    name = opNames[palePacket.Op];
            }

            var lvi = new ListViewItem((palePacket.Received ? "<" : ">") + palePacket.Op.ToString("X8"));
            lvi.UseItemStyleForSubItems = false;
            lvi.BackColor = palePacket.Received ? Color.FromArgb(0x0033bbff) : Color.FromArgb(0x00ff5522);
            lvi.ForeColor = Color.White;
            lvi.Tag = palePacket;

            lvi.SubItems.Add(palePacket.Id.ToString("X16"));
            lvi.SubItems.Add(name);
            lvi.SubItems.Add(palePacket.Time > DateTime.MinValue ? palePacket.Time.ToString("hh:mm:ss.fff") : "");

            LstPackets.InvokeIfRequired((MethodInvoker)delegate
            {
                LstPackets.Items.Add(lvi);

                if (scroll)
                    LstPackets.Items[LstPackets.Items.Count - 1].EnsureVisible();
            });
        }
コード例 #13
0
ファイル: FrmMain.cs プロジェクト: Vinna/MabiPale2
        /// <summary>
        /// Window message handler, handles incoming data from Alissa.
        /// </summary>
        /// <param name="m"></param>
        protected override void WndProc(ref Message m)
        {
            if (m.Msg == WinApi.WM_COPYDATA)
            {
                var cds = (WinApi.COPYDATASTRUCT)Marshal.PtrToStructure(m.LParam, typeof(WinApi.COPYDATASTRUCT));

                if (cds.cbData < 12)
                    return;

                var recv = (int)cds.dwData == Sign.Recv;

                var data = new byte[cds.cbData];
                Marshal.Copy(cds.lpData, data, 0, cds.cbData);

                var packet = new Packet(data, 0);
                var palePacket = new PalePacket(packet, DateTime.Now, recv);

                lock (packetQueue)
                    packetQueue.Enqueue(palePacket);
            }
            base.WndProc(ref m);
        }
コード例 #14
0
ファイル: FrmInfo.cs プロジェクト: Xcelled/MabiPale2
        private void ParseOpenNpcShop(PalePacket palePacket)
        {
            palePacket.Packet.GetString();
            palePacket.Packet.GetByte();
            palePacket.Packet.GetByte();
            palePacket.Packet.GetInt();

            var tabCount = palePacket.Packet.GetByte();
            var tabs = new Dictionary<string, List<ItemInfo>>();
            for (int i = 0; i < tabCount; ++i)
            {
                var name = palePacket.Packet.GetString();

                if (!tabs.ContainsKey(name))
                    tabs.Add(name, new List<ItemInfo>());

                palePacket.Packet.GetByte();

                var itemCount = palePacket.Packet.GetShort();
                for (int j = 0; j < itemCount; ++j)
                {
                    palePacket.Packet.GetLong();
                    palePacket.Packet.GetByte();
                    var itemInfo = palePacket.Packet.GetObj<ItemInfo>();
                    palePacket.Packet.GetBin();
                    palePacket.Packet.GetString();
                    palePacket.Packet.GetString();
                    palePacket.Packet.GetByte();
                    palePacket.Packet.GetLong();

                    // [190100, NA200 (2015-01-15)] New/Combined
                    if (palePacket.Packet.NextIs(Shared.PacketElementType.Byte))
                    {
                        palePacket.Packet.GetByte();
                        palePacket.Packet.GetByte();
                    }

                    tabs[name].Add(itemInfo);
                }
            }

            var sb = new StringBuilder();
            var prev = "";
            foreach (var tab in tabs.OrderBy(a => a.Key))
            {
                var name = tab.Key.Substring(tab.Key.IndexOf("]") + 1);

                if (prev != name)
                {
                    if (prev != "")
                        sb.AppendLine();
                    sb.AppendLine("// " + name);
                }

                prev = name;

                foreach (var item in tab.Value.OrderBy(a => a.Id))
                {
                    var others = tab.Value.Count(a => a.Id == item.Id && a.Amount != item.Amount) != 0;

                    if (item.Amount <= 1 && !others)
                        sb.AppendLine("Add(\"{0}\", {1});", name, item.Id);
                    else
                        sb.AppendLine("Add(\"{0}\", {1}, {2});", name, item.Id, Math.Max(1, (int)item.Amount));
                }
            }

            TxtInfo.WordWrap = false;
            TxtInfo.Text = sb.ToString();
        }
コード例 #15
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
 private void ParseUnknown(PalePacket palePacket)
 {
     TxtInfo.Text = "No information.";
 }
コード例 #16
0
ファイル: Main.cs プロジェクト: Xcelled/MabiPale2
 private void OnSelected(PalePacket palePacket)
 {
     if (form != null && !form.IsDisposed)
         form.OnSelected(palePacket);
 }
コード例 #17
0
ファイル: FrmInfo.cs プロジェクト: xeroplz/MabiPale2
        private void ParseConditionUpdate(PalePacket palePacket)
        {
            var conditionsA = palePacket.Packet.GetLong();
            var conditionsB = palePacket.Packet.GetLong();
            var conditionsC = palePacket.Packet.GetLong();
            var conditionsD = palePacket.Packet.Peek() == Shared.PacketElementType.Long ? palePacket.Packet.GetLong() : 0;
            var conditionsE = palePacket.Packet.Peek() == Shared.PacketElementType.Long ? palePacket.Packet.GetLong() : 0;
            var conditionsF = palePacket.Packet.Peek() == Shared.PacketElementType.Long ? palePacket.Packet.GetLong() : 0;

            var sb = new StringBuilder();
            sb.AppendLine("A: {0}", (ConditionsA)conditionsA);
            sb.AppendLine("B: {0}", (ConditionsB)conditionsB);
            sb.AppendLine("C: {0}", (ConditionsC)conditionsC);
            sb.AppendLine("D: {0}", (ConditionsD)conditionsD);
            sb.AppendLine("E: {0}", (ConditionsE)conditionsE);
            sb.AppendLine("F: {0}", (ConditionsF)conditionsF);

            var extraCount = palePacket.Packet.GetInt();
            if (extraCount != 0)
                sb.AppendLine();

            for (int i = 0; i < extraCount; ++i)
            {
                var id = palePacket.Packet.GetInt();
                var str = palePacket.Packet.GetString();
                var div = id / 64;
                var mod = id % 64;

                switch (div)
                {
                    case 0: sb.AppendLine("{0} - {1}", (ConditionsA)((ulong)1 << mod), str); break;
                    case 1: sb.AppendLine("{0} - {1}", (ConditionsB)((ulong)1 << mod), str); break;
                    case 2: sb.AppendLine("{0} - {1}", (ConditionsC)((ulong)1 << mod), str); break;
                    case 3: sb.AppendLine("{0} - {1}", (ConditionsD)((ulong)1 << mod), str); break;
                    case 4: sb.AppendLine("{0} - {1}", (ConditionsE)((ulong)1 << mod), str); break;
                    case 5: sb.AppendLine("{0} - {1}", (ConditionsF)((ulong)1 << mod), str); break;
                    default:
                        var ident = (char)('A' + div) + ":0x" + ((ulong)1 << mod).ToString("X16");
                        sb.AppendLine("{0} - {1}", ident, str);
                        break;
                }
            }

            TxtInfo.Text = sb.ToString();
        }