Exemple #1
0
        private void UpdateItemsListInternal()
        {
            System.Collections.ArrayList dirty_items = new System.Collections.ArrayList();

            for (int i = 0; i < listView_items_data_items.Count; i++)
            {
                uint id = Util.GetUInt32(((ListViewItem)listView_items_data_items[i]).SubItems[2].Text);

                if (Globals.gamedata.nearby_items.ContainsKey(id))
                {
                    ItemInfo item = Util.GetItem(id);

                    item.InList = true;

                    //update it
                    //((ListViewItem)listView_items_data_items[i]).SubItems[0].Text = Util.GetItemName(item.ItemID);
                    //((ListViewItem)listView_items_data_items[i]).SubItems[1].Text = item.Count.ToString();
                    //((ListViewItem)listView_items_data_items[i]).SubItems[2].Text = item.ID.ToString();
                }
                else
                {
                    dirty_items.Add(i);
                }
            }

            //need to remove all dirty items now
            for (int i = dirty_items.Count - 1; i >= 0; i--)
            {
                listView_items_data_items.RemoveAt((int)dirty_items[i]);
            }
            dirty_items.Clear();

            foreach (ItemInfo item in Globals.gamedata.nearby_items.Values)
            {
                if (!item.InList)
                {
                    item.InList = true;

                    string mesh_info = "";
                    if (!item.HasMesh)
                    {
                        mesh_info = " [NO MESH]";
                    }

                    //add it
                    System.Windows.Forms.ListViewItem ObjListItem;
                    ObjListItem = new ListViewItem(Util.GetItemName(item.ItemID) + mesh_info); //ItmID
                    ObjListItem.SubItems.Add(item.Count.ToString());                           //Count
                    ObjListItem.SubItems.Add(item.ID.ToString());                              //ObjID
                    ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(item.ItemID);

                    listView_items_data_items.Add(ObjListItem);
                }
            }
        }
Exemple #2
0
        public static void CleanUp()
        {
            if (Globals.Script_Debugging)
            {
                Globals.l2net_home.Add_Debug("cleanup tick");
            }

            if (Globals.gamedata.running)
            {
                AddInfo.CleanUp_Char();
                AddInfo.CleanUp_NPC();
                AddInfo.CleanUp_Item();
            }
        }
Exemple #3
0
        private void BroadCastStautsUpdateNPC(NetPacket np)
        {
            //no need to update with data from ourselves or about ourselves
            if (np.SenderID == Globals.gamedata.my_char.ID || np.ID == Globals.gamedata.my_char.ID)
            {
            }
            else
            {
                Globals.NPCLock.EnterReadLock();
                try
                {
                    //no need to update people in our immediate party (we will get those updates from the server)
                    //...but
                    //any update we recieve directly from a player in our party is probably going to be more up to date than the packet we recieved from the server
                    //so for now... let's actually use the packet...

                    NPCInfo npc = Util.GetNPC(np.ID);

                    if (npc != null)
                    {
                        npc.Max_CP = np.MaxCP;
                        npc.Cur_CP = np.CurCP;
                        npc.Max_HP = np.MaxHP;
                        npc.Cur_HP = np.CurHP;
                        npc.Max_MP = np.MaxMP;
                        npc.Cur_MP = np.CurMP;
                    }
                }//unlock
                finally
                {
                    Globals.NPCLock.ExitReadLock();

                    if (np.ID == Globals.gamedata.my_char.TargetID)
                    {
                        AddInfo.Set_Target_HP();
                    }
                }
            }//end of else
        }
Exemple #4
0
        public static void Init(string[] args)
        {
            Globals.PATH = Environment.CurrentDirectory;

            try
            {
                if (Globals.LogWriting)
                {
                    Globals.text_out = new StreamWriter(Globals.PATH + "\\logs\\" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString() + ".txt");
                }
                else
                {
                    Globals.text_out = null;
                }
            }
            catch
            {
                Globals.text_out = null;
                Globals.l2net_home.Add_PopUpError("failed to create text output log file... do you have the datapack?" + Environment.NewLine + "L2.net needs write/create access to the \\logs\\ folder to log chat.");
            }

#if DEBUG
            try
            {
                Globals.gamedataout   = new StreamWriter(Globals.PATH + "\\logs\\from_gamelog.txt");
                Globals.gamedatato    = new StreamWriter(Globals.PATH + "\\logs\\to_gamelog.txt");
                Globals.clientdataout = new StreamWriter(Globals.PATH + "\\logs\\from_clientlog.txt");
                Globals.clientdatato  = new StreamWriter(Globals.PATH + "\\logs\\to_clientlog.txt");

                Globals.gamedataout.AutoFlush   = true;
                Globals.gamedatato.AutoFlush    = true;
                Globals.clientdataout.AutoFlush = true;
                Globals.clientdatato.AutoFlush  = true;
            }
            catch
            {
            }
#endif

            //set up all the arraylists for data
            Globals.gamedata.my_char = new Player_Info();
            Globals.gamedata.my_pet  = new Pet_Info();
            Globals.gamedata.my_pet1 = new Pet_Info();
            Globals.gamedata.my_pet2 = new Pet_Info();
            Globals.gamedata.my_pet3 = new Pet_Info();

            //flush and clear all the shortcuts
            for (int i = 0; i < Globals.Skills_Pages * Globals.Skills_PerPage; i++)
            {
                Globals.gamedata.ShortCuts.Add(new ShortCut());
            }

            Globals.gamedata.botoptions   = new BotOptions();
            Globals.gamedata.alertoptions = new AlertOptions();

            LoadData.LoadDataFiles();


            AddInfo.Set_PartyVisible();
            AddInfo.Set_PartyInfo();

            try
            {
                Globals.Keyboard = new DX_Keyboard();
            }
            catch (Exception e)
            {
                Globals.l2net_home.Add_Error("crash: failed to create SlimDX Keyboard : " + e.Message);
            }

            Globals.broadcastthread = new BroadcastThread();

            Util.Setup_Threads();

            //process command line crap


            foreach (string s in args)
            {
                // char type = s[1];
                string command;
                string data;
                int    indexOfColon = s.IndexOf(':');
                if (indexOfColon == -1)
                {
                    command = s;
                    data    = "";
                }
                else
                {
                    command = s.Substring(0, indexOfColon);
                    data    = s.Substring(indexOfColon + 1, s.Length - (indexOfColon + 1));
                }

                command = command.ToLower();

                switch (command)
                {
                case "-a":
                case "-accept":
                    Globals.pre_agree = true;
                    break;

                case "-b":
                case "-blowfish":
                    Globals.pre_blowfish = data;
                    break;

                case "-c":
                case "-protocol":
                    Globals.pre_chron_cmd = true;
                    Globals.pre_protocol  = data;
                    break;

                case "-d":
                case "-loginport":
                    Globals.pre_login_port = data;
                    break;

                case "-i":
                case "-loginip":
                    Globals.pre_login_ip = data;
                    break;

                case "-p":
                case "-password":
                    Globals.pre_password = data;
                    break;

                case "-u":
                case "-username":
                    Globals.pre_username = data;
                    break;

                case "-o":
                case "-options":
                    Globals.BotOptionsFile = data;
                    break;

                case "-s":
                case "-script":
                    Globals.Script_MainFile = data;
                    break;

                case "-x":
                case "-iglistenport":
                    Globals.pre_IG_listen_port = data;
                    break;

                case "-y":
                case "-iglistenip":
                    Globals.pre_IG_listen_ip = data;
                    break;

                case "-z":
                case "-chronicle":
                    Globals.pre_chron = Util.GetInt32(data);
                    break;

                case "-overidegameserver":
                    Globals.pre_useGameServerOveride  = true;
                    Globals.pre_checkAdvancedSettings = true;
                    break;

                case "-upl":
                case "-useproxylogin":
                    Globals.pre_useProxyServerForLogin = true;
                    Globals.pre_checkAdvancedSettings  = true;
                    break;

                case "-upg":
                case "-useproxygame":
                    Globals.pre_useProxyServerForGameserver = true;
                    Globals.pre_checkAdvancedSettings       = true;
                    break;

                case "-gameserverip":
                    Globals.pre_gameserver_override_ip = data;
                    break;

                case "-gameserverport":
                    Globals.pre_gameserver_override_port = data;
                    break;

                case "-s5ip":
                case "-socks5ip":
                    Globals.pre_socks5_ip = data;
                    break;

                case "-s5po":
                case "-socks5port":
                    Globals.pre_socks5_port = data;
                    break;

                case "-s5us":
                case "-socks5username":
                    Globals.pre_socks5_username = data;
                    break;

                case "-s5pa":
                case "-socks5password":
                    Globals.pre_socks5_password = data;
                    break;

                case "-ew":
                case "-enterworld":
                    Globals.pre_EnterWorldCheckbox = true;
                    break;

                case "-ig":
                    Globals.pre_IG = true;
                    break;

                case "-oog":
                    Globals.pre_OOG = true;
                    break;

                case "-ewip":
                    Globals.pre_enterworld_ip = true;
                    break;

                case "-ip01":
                    Globals.pre_enterworld_ip_tab[0] = data;
                    break;

                case "-ip02":
                    Globals.pre_enterworld_ip_tab[1] = data;
                    break;

                case "-ip03":
                    Globals.pre_enterworld_ip_tab[2] = data;
                    break;

                case "-ip04":
                    Globals.pre_enterworld_ip_tab[3] = data;
                    break;

                case "-ip11":
                    Globals.pre_enterworld_ip_tab[4] = data;
                    break;

                case "-ip12":
                    Globals.pre_enterworld_ip_tab[5] = data;
                    break;

                case "-ip13":
                    Globals.pre_enterworld_ip_tab[6] = data;
                    break;

                case "-ip14":
                    Globals.pre_enterworld_ip_tab[7] = data;
                    break;

                case "-ip21":
                    Globals.pre_enterworld_ip_tab[8] = data;
                    break;

                case "-ip22":
                    Globals.pre_enterworld_ip_tab[9] = data;
                    break;

                case "-ip23":
                    Globals.pre_enterworld_ip_tab[10] = data;
                    break;

                case "-ip24":
                    Globals.pre_enterworld_ip_tab[11] = data;
                    break;

                case "-ip31":
                    Globals.pre_enterworld_ip_tab[12] = data;
                    break;

                case "-ip32":
                    Globals.pre_enterworld_ip_tab[13] = data;
                    break;

                case "-ip33":
                    Globals.pre_enterworld_ip_tab[14] = data;
                    break;

                case "-ip34":
                    Globals.pre_enterworld_ip_tab[15] = data;
                    break;

                case "-ip41":
                    Globals.pre_enterworld_ip_tab[16] = data;
                    break;

                case "-ip42":
                    Globals.pre_enterworld_ip_tab[17] = data;
                    break;

                case "-ip43":
                    Globals.pre_enterworld_ip_tab[18] = data;
                    break;

                case "-ip44":
                    Globals.pre_enterworld_ip_tab[19] = data;
                    break;

                case "-ubs":
                    Globals.pre_unknow_blowfish = true;
                    break;

                case "-wasp":
                    Globals.pre_proxy_serv = true;
                    break;

                case "-gslp":
                    Globals.pre_game_srv_listen_prt = data;
                    break;

                case "-ggip":
                    Globals.gamedata.GG_IP = data;
                    break;

                case "-ggport":
                    Globals.gamedata.GG_Port = Util.GetInt32(data);
                    break;

                case "-ggsrv":
                    Globals.pre_GGSrv = true;
                    break;

                case "-ggcl":
                    Globals.pre_GGClient = true;
                    break;

                case "-secpin":
                    Globals.SecurityPin = data;
                    break;

                case "-oldclient":
                    Globals.gamedata.SecurityPinOldClient = true;
                    break;

                case "-al":
                case "-auto-login":
                case "-auto_login":
                case "-autologin":
                    Globals.auto_login = true;
                    break;
                }
            }
        }
Exemple #5
0
        private void UpdateMyBuffsListInternal()
        {
            System.Collections.ArrayList dirty_items = new System.Collections.ArrayList();

            for (int i = 0; i < listView_mybuffs_data.Items.Count; i++)
            {
                uint id = Util.GetUInt32(((ListViewItem)listView_mybuffs_data_items[i]).SubItems[3].Text);

                if (Globals.gamedata.mybuffs.ContainsKey(id))
                {
                    CharBuff cb = Util.GetBuff(id);

                    cb.InList = true;

                    if (cb.ExpiresTime == -1)
                    {
                        ((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = "ON";
                    }
                    else
                    {
                        System.TimeSpan remain = new System.TimeSpan(cb.ExpiresTime - System.DateTime.Now.Ticks);

                        //update it
                        //((ListViewItem)listView_npc_data_items[i]).SubItems[0].Text = Util.GetNPCName(npc.NPCID);
                        //((ListViewItem)listView_npc_data_items[i]).SubItems[1].Text = npc.Title;
                        ((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = ((int)remain.TotalMinutes).ToString() + ":" + remain.Seconds.ToString();
                        //((ListViewItem)listView_mybuffs_data_items[i]).SubItems[2].Text = cb.ID.ToString();
                    }
                }
                else
                {
                    dirty_items.Add(i);
                }
            }

            //need to remove all dirty items now
            for (int i = dirty_items.Count - 1; i >= 0; i--)
            {
                listView_mybuffs_data_items.RemoveAt((int)dirty_items[i]);
            }
            dirty_items.Clear();

            foreach (CharBuff cb in Globals.gamedata.mybuffs.Values)
            {
                if (!cb.InList)
                {
                    cb.InList = true;

                    System.TimeSpan remain = new System.TimeSpan(0);
                    if (cb.ExpiresTime == -1)
                    {
                    }
                    else
                    {
                        remain = new System.TimeSpan(cb.ExpiresTime - System.DateTime.Now.Ticks);
                    }

                    //add it
                    System.Windows.Forms.ListViewItem ObjListItem;
                    ObjListItem = new ListViewItem(Util.GetSkillName(cb.ID, cb.SkillLevel)); //Name
                    ObjListItem.SubItems.Add(cb.SkillLevel.ToString());                      //Title
                    if (cb.ExpiresTime == -1)
                    {
                        ObjListItem.SubItems.Add("ON");
                    }
                    else
                    {
                        ObjListItem.SubItems.Add(((int)remain.TotalMinutes).ToString() + ":" + remain.Seconds.ToString()); //Remaining Time
                    }
                    ObjListItem.SubItems.Add(cb.ID.ToString());                                                            //ObjID
                    ObjListItem.ImageIndex = AddInfo.Get_Skill_Image_Index(cb.ID);

                    listView_mybuffs_data_items.Add(ObjListItem);
                }
            }
        }
Exemple #6
0
        private void UpdateInventoryListInternal()
        {
            System.Collections.ArrayList dirty_items = new System.Collections.ArrayList();
            #region Equipped Items
            if (radioButton_inv_equipped.Checked)
            {
                for (int i = 0; i < listView_inventory_items.Count; i++)
                {
                    uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text);

                    if (Globals.gamedata.inventory.ContainsKey(id))
                    {
                        //already in the list...
                        InventoryInfo inv_inf = Util.GetInventory(id);
                        if (inv_inf.isEquipped == 0x01)
                        {
                            inv_inf.InList = true;

                            //update the entry
                            if (inv_inf.Enchant == 0)
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID);
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID);
                            }
                            ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString(); //Count
                            if (inv_inf.isEquipped == 0x01)                                                          //isEquipped
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X";
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " ";
                            }
                            //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot
                        }
                        else
                        {
                            //not in the list...
                            //delete this item
                            dirty_items.Add(i);
                        }
                    }
                    else
                    {
                        //not in the list...
                        //delete this item
                        dirty_items.Add(i);
                    }
                }

                //need to remove all dirty items now
                for (int i = dirty_items.Count - 1; i >= 0; i--)
                {
                    listView_inventory_items.RemoveAt((int)dirty_items[i]);
                }
                dirty_items.Clear();

                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (!inv_inf.InList && inv_inf.isEquipped == 0x01)
                    {
                        inv_inf.InList = true;

                        //add it
                        System.Windows.Forms.ListViewItem ObjListItem;

                        if (inv_inf.Enchant == 0)
                        {
                            ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID));
                        }
                        else
                        {
                            ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID));
                        }
                        ObjListItem.SubItems.Add(inv_inf.Count.ToString()); //Count
                        if (inv_inf.isEquipped == 0x01)                     //isEquipped
                        {
                            ObjListItem.SubItems.Add("X");
                            //Do_Equip(inv_inf);
                        }
                        else
                        {
                            ObjListItem.SubItems.Add(" ");
                        }
                        ObjListItem.SubItems.Add(inv_inf.Slot.ToString()); //Slot
                        ObjListItem.SubItems.Add(inv_inf.ID.ToString());   //ObjID
                        ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID);

                        listView_inventory_items.Add(ObjListItem);
                    }
                }
            }
            #endregion

            #region Normal Items
            if (radioButton_inv_items.Checked)
            {
                for (int i = 0; i < listView_inventory_items.Count; i++)
                {
                    uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text);

                    if (Globals.gamedata.inventory.ContainsKey(id))
                    {
                        //already in the list...
                        InventoryInfo inv_inf = Util.GetInventory(id);
                        if (inv_inf.isEquipped != 0x01 && inv_inf.Type2 != 0x03)
                        {
                            inv_inf.InList = true;

                            //update the entry
                            if (inv_inf.Enchant == 0)
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID);
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID);
                            }
                            ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString(); //Count
                            if (inv_inf.isEquipped == 0x01)                                                          //isEquipped
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X";
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " ";
                            }
                            //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot
                        }
                        else
                        {
                            //not in the list...
                            //delete this item
                            dirty_items.Add(i);
                        }
                    }
                    else
                    {
                        //not in the list...
                        //delete this item
                        dirty_items.Add(i);
                    }
                }

                //need to remove all dirty items now
                for (int i = dirty_items.Count - 1; i >= 0; i--)
                {
                    listView_inventory_items.RemoveAt((int)dirty_items[i]);
                }
                dirty_items.Clear();

                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (!inv_inf.InList && inv_inf.isEquipped != 0x01 && inv_inf.Type2 != 0x03)
                    {
                        inv_inf.InList = true;

                        //add it
                        System.Windows.Forms.ListViewItem ObjListItem;

                        if (inv_inf.Enchant == 0)
                        {
                            ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID));
                        }
                        else
                        {
                            ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID));
                        }
                        ObjListItem.SubItems.Add(inv_inf.Count.ToString()); //Count
                        if (inv_inf.isEquipped == 0x01)                     //isEquipped
                        {
                            ObjListItem.SubItems.Add("X");
                            //Do_Equip(inv_inf);
                        }
                        else
                        {
                            ObjListItem.SubItems.Add(" ");
                        }
                        ObjListItem.SubItems.Add(inv_inf.Slot.ToString()); //Slot
                        ObjListItem.SubItems.Add(inv_inf.ID.ToString());   //ObjID
                        ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID);

                        listView_inventory_items.Add(ObjListItem);
                    }
                }
            }
            #endregion

            #region Quest Items
            if (radioButton_inv_quest.Checked)
            {
                for (int i = 0; i < listView_inventory_items.Count; i++)
                {
                    uint id = Util.GetUInt32(((ListViewItem)listView_inventory_items[i]).SubItems[4].Text);

                    if (Globals.gamedata.inventory.ContainsKey(id))
                    {
                        //already in the list...
                        InventoryInfo inv_inf = Util.GetInventory(id);
                        if (inv_inf.Type2 == 0x03)
                        {
                            inv_inf.InList = true;

                            //update the entry
                            if (inv_inf.Enchant == 0)
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = Util.GetItemName(inv_inf.ItemID);
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[0].Text = "+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID);
                            }
                            ((ListViewItem)listView_inventory_items[i]).SubItems[1].Text = inv_inf.Count.ToString(); //Count
                            if (inv_inf.isEquipped == 0x01)                                                          //isEquipped
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = "X";
                            }
                            else
                            {
                                ((ListViewItem)listView_inventory_items[i]).SubItems[2].Text = " ";
                            }
                            //((ListViewItem)listView_inventory_items[i]).SubItems[3].Text = inv_inf.Slot.ToString();//Slot
                        }
                        else
                        {
                            //not in the list...
                            //delete this item
                            dirty_items.Add(i);
                        }
                    }
                    else
                    {
                        //not in the list...
                        //delete this item
                        dirty_items.Add(i);
                    }
                }

                //need to remove all dirty items now
                for (int i = dirty_items.Count - 1; i >= 0; i--)
                {
                    listView_inventory_items.RemoveAt((int)dirty_items[i]);
                }
                dirty_items.Clear();

                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (!inv_inf.InList && inv_inf.Type2 == 0x03)
                    {
                        inv_inf.InList = true;

                        //add it
                        System.Windows.Forms.ListViewItem ObjListItem;

                        if (inv_inf.Enchant == 0)
                        {
                            ObjListItem = new ListViewItem(Util.GetItemName(inv_inf.ItemID));
                        }
                        else
                        {
                            ObjListItem = new ListViewItem("+" + inv_inf.Enchant.ToString() + " " + Util.GetItemName(inv_inf.ItemID));
                        }
                        ObjListItem.SubItems.Add(inv_inf.Count.ToString()); //Count
                        if (inv_inf.isEquipped == 0x01)                     //isEquipped
                        {
                            ObjListItem.SubItems.Add("X");
                            //Do_Equip(inv_inf);
                        }
                        else
                        {
                            ObjListItem.SubItems.Add(" ");
                        }
                        ObjListItem.SubItems.Add(inv_inf.Slot.ToString()); //Slot
                        ObjListItem.SubItems.Add(inv_inf.ID.ToString());   //ObjID
                        ObjListItem.ImageIndex = AddInfo.Get_Item_Image_Index(inv_inf.ItemID);

                        listView_inventory_items.Add(ObjListItem);
                    }
                }
            }
            #endregion
        }
        private static void HandlePackets()
        {
            ByteBuffer buffe;
            uint       b0 = 0, b1 = 0; //byte
            string     last_p = "";    //, last_p2 = "";

            while (Globals.gamedata.GetCount_DataToBot() > 0)
            {
                try
                {
                    //buffe = null;

                    Globals.GameReadQueueLock.EnterWriteLock();
                    try
                    {
                        buffe = (ByteBuffer)Globals.gamedata.gamereadqueue.Dequeue();
                    }
                    catch (System.Exception e)
                    {
                        Globals.l2net_home.Add_Error("Packet Error Reading Queue : " + e.Message);
                        break;
                    }
                    finally
                    {
                        Globals.GameReadQueueLock.ExitWriteLock();
                    }

                    //buffe contains unencoded data
                    b0 = buffe.ReadByte();
                    //last_p2 = last_p;
                    last_p = b0.ToString("X2");

                    //do we have an event for this packet?
                    if (ScriptEngine.ServerPacketsContainsKey((int)b0))
                    {
                        ScriptEvent sc_ev = new ScriptEvent();
                        sc_ev.Type  = EventType.ServerPacket;
                        sc_ev.Type2 = (int)b0;
                        sc_ev.Variables.Add(new ScriptVariable(buffe, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                        sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                        ScriptEngine.SendToEventQueue(sc_ev);
                    }

                    switch ((PServer)b0)
                    {
                    case PServer.MTL:
                        ClientPackets.MoveToLocation(buffe);
                        break;

                    case PServer.NS:
                        ClientPackets.NPCSay(buffe);
                        break;

                    case PServer.CI:
                        ClientPackets.CharInfo(buffe);
                        break;

                    case PServer.RelationChanged:
                        ClientPackets.RelationChanged(buffe);
                        break;

                    case PServer.UI:
                        ClientPackets.UserInfo(buffe);
                        break;

                    case PServer.Attack:
                        ClientPackets.Attack_Packet(buffe);
                        break;

                    case PServer.Die:
                        ClientPackets.Die_Packet(buffe);
                        break;

                    case PServer.Revive:
                        ClientPackets.Revive(buffe.ReadUInt32());
                        break;

                    case PServer.ChangeMoveType:
                        ClientPackets.ChangeMoveType(buffe);
                        break;

                    case PServer.ChangeWaitType:
                        ClientPackets.ChangeWaitType(buffe);
                        break;

                    case PServer.AttackDeadTarget:
                        ClientPackets.AttackCanceled_Packet(buffe);
                        break;

                    case PServer.SpawnItem:    //add item (to ground)
                        ClientPackets.AddItem(buffe);
                        break;

                    case PServer.DropItem:
                        ClientPackets.ItemDrop(buffe);
                        break;

                    case PServer.GetItem:
                        ClientPackets.Get_Item(buffe);
                        break;

                    case PServer.StatusUpdate:
                        ClientPackets.StatusUpdate(buffe);
                        break;

                    case PServer.NpcHtmlMessage:
                        NPC_Chat.Npc_Chat(buffe);
                        break;

                    case PServer.BuyList:     //Buylist
                        ClientPackets.BuyList(buffe);
                        break;

                    case PServer.DeleteObject:
                        ClientPackets.DeleteItem(buffe);
                        break;

                    case PServer.CharacterSelectionInfo:
                        Globals.login_window.CharList(buffe);
                        //this is the list of chars
                        //not handled by ig

                        //need to handle this packet here and not on the oog login
                        //on ig, the list will just show up, then disappear on 0x15 CharSelected so its all good
                        break;

                    case PServer.CharSelected:
                        ClientPackets.CharSelected(buffe);
                        break;

                    case PServer.NpcInfo:
                        ClientPackets.NPCInfo(buffe);
                        break;

                    case PServer.ServerObjectInfo:
                        ClientPackets.ServerObjectInfo(buffe);
                        break;

                    case PServer.StaticObject:
                        ClientPackets.StaticObjectInfo(buffe);
                        break;

                    case PServer.ItemList:
                        ClientPackets.ItemList(buffe);
                        break;

                    case PServer.SunRise:
                        Globals.l2net_home.Add_Text("[The sun has just risen]", Globals.Gray, TextType.SYSTEM);
                        break;

                    case PServer.SunSet:
                        Globals.l2net_home.Add_Text("[The sun has just set]", Globals.Gray, TextType.SYSTEM);
                        break;

                    case PServer.TradeStart:
                        break;

                    case PServer.TradeDone:
                        try
                        {
                            Globals.tradewindow.Close();
                        }
                        catch
                        {
                            //trade window is not opened.
                        }
                        break;

                    case PServer.ActionFailed:
                        //l2j is ghei and throws this packet at us a lot
                        // (Freya) Retail also causes this packet to be sent before any Attack or skill use that requires CTRL
                        break;

                    case PServer.InventoryUpdate:
                        AddInfo.Inventory_Update(buffe);
                        break;

                    case PServer.TeleportToLocation:
                        ClientPackets.Teleport(buffe);
                        break;

                    case PServer.MyTargetSelected:
                        ClientPackets.MyTargetSelected(buffe);
                        break;

                    case PServer.TargetSelected:
                        ClientPackets.TargetSelected(buffe, true);
                        break;

                    case PServer.TargetUnselected:
                        ClientPackets.TargetSelected(buffe, false);
                        break;

                    case PServer.AutoAttackStart:
                        //4bytes target id
                        ClientPackets.EnterCombat(buffe, true);
                        break;

                    case PServer.AutoAttackStop:
                        //4bytes target id
                        ClientPackets.EnterCombat(buffe, false);
                        break;

                    case PServer.SocialAction:
                        ClientPackets.Social_Action(buffe);
                        break;

                    case PServer.AskJoinPledge:
                        ClientPackets.RequestJoinClan(buffe);
                        break;

                    case PServer.AskJoinParty:
                        ClientPackets.RequestJoinParty(buffe);
                        break;

                    case PServer.TradeRequest:
                        ClientPackets.TradeRequest(buffe);
                        break;

                    case PServer.ShortCutRegister:
                        ClientPackets.Load_Shortcut(buffe);
                        break;

                    case PServer.ShortCutInit:
                        ClientPackets.Load_Shortcuts(buffe);
                        break;

                    case PServer.StopMove:
                        ClientPackets.StopMove(buffe);
                        break;

                    case PServer.MagicSkillUser:
                        ClientPackets.MagicSkillUser(buffe);
                        break;

                    case PServer.MagicSkillCancelId:
                        //4bytes - ID of caster that canceled
                        ClientPackets.MagicSkillCancel(buffe);
                        break;

                    case PServer.CreatureSay:
                        ClientPackets.OtherMessage(buffe);
                        break;

                    case PServer.PartySmallWindowAll:
                        if (Globals.gamedata.yesno_state == 1)
                        {
                            Globals.l2net_home.Hide_YesNo();
                        }
                        ClientPackets.Load_PartyInfo(buffe);
                        AddInfo.Set_PartyVisible();
                        AddInfo.Set_PartyInfo();
                        break;

                    case PServer.PartySmallWindowAdd:
                        if (Globals.gamedata.yesno_state == 1)
                        {
                            Globals.l2net_home.Hide_YesNo();
                        }
                        ClientPackets.Add_PartyInfo(buffe);
                        AddInfo.Set_PartyVisible();
                        AddInfo.Set_PartyInfo();
                        break;

                    case PServer.PartySmallWindowDeleteAll:
                        ClientPackets.Delete_Party();
                        AddInfo.Set_PartyVisible();
                        AddInfo.Set_PartyInfo();
                        break;

                    case PServer.PartySmallWindowDelete:
                        ClientPackets.Delete_PartyInfo(buffe);
                        AddInfo.Set_PartyVisible();
                        AddInfo.Set_PartyInfo();
                        break;

                    case PServer.PartySmallWindowUpdate:
                        ClientPackets.Update_PartyInfo(buffe);
                        AddInfo.Set_PartyInfo();
                        break;

                    case PServer.PledgeShowMemberListAll:
                        ClientPackets.PledgeShowMemberListAll(buffe);
                        break;

                    case PServer.PledgeShowMemberListUpdate:
                        ClientPackets.PledgeShowMemberListUpdate(buffe);
                        break;

                    case PServer.PledgeShowMemberListAdd:
                        //changes the clan status of one char... need to update/add as needed
                        ClientPackets.PledgeShowMemberListAdd(buffe);
                        break;

                    case PServer.PledgeShowMemberListDelete:
                        ClientPackets.PledgeShowMemberListDelete(buffe);
                        break;

                    case PServer.PledgeShowInfoUpdate:
                        ClientPackets.PledgeShowInfoUpdate(buffe);
                        break;

                    case PServer.PledgeShowMemberListDeleteAll:
                        ClientPackets.PledgeShowMemberListDeleteAll(buffe);
                        break;

                    case PServer.AbnormalStatusUpdate:
                        ClientPackets.LoadBuffList(buffe);
                        break;

                    case PServer.PartySpelled:
                        ClientPackets.PartySpelled(buffe);
                        break;

                    case PServer.ShortBuffStatusUpdate:
                        ClientPackets.UpdateBuff(buffe);
                        break;

                    case PServer.SkillList:
                        ClientPackets.SkillList(buffe);
                        break;

                    case PServer.SkillCoolTime:
                        ClientPackets.SkillCoolTime(buffe);
                        break;

                    case PServer.RestartResponse:
                        ClientPackets.RestartResponse(buffe);
                        break;

                    case PServer.MoveToPawn:
                        ClientPackets.MoveToPawn(buffe);
                        break;

                    case PServer.ValidateLocation:
                        ClientPackets.Validate_Location(buffe, false);
                        //int id
                        //int rotation
                        break;

                    case PServer.SystemMessage:
                        ClientPackets.SystemMessage(buffe);
                        break;

                    case PServer.PledgeCrest:
                        ClientPackets.PledgeCrest(buffe);
                        break;

                    case PServer.PledgeInfo:
                        ClientPackets.PledgeInfo(buffe);
                        break;

                    case PServer.ValidateLocationInVehicle:
                        ClientPackets.Validate_Location(buffe, true);
                        break;

                    case PServer.MagicSkillLaunched:
                        ClientPackets.MagicSkillLaunched(buffe);
                        //Validate_Location(buffe,false);
                        break;

                    case PServer.FriendAddRequest:
                        ClientPackets.RequestJoinFriend(buffe);
                        break;

                    case PServer.LogOutOk:
                        //ok time to end
                        Globals.gamedata.running = false;
                        Globals.l2net_home.KillEverything();
                        break;

                    case PServer.PartyMemberPosition:
                        ClientPackets.Set_PartyLocations(buffe);
                        break;

                    case PServer.AskJoinAlly:
                        ClientPackets.RequestJoinAlly(buffe);
                        break;

                    case PServer.AllianceCrest:
                        ClientPackets.AllyCrest(buffe);
                        break;

                    case PServer.Earthquake:
                        //x,y,z,power,duration
                        Globals.l2net_home.Add_Text("[Earthquake at X:" + buffe.ReadInt32().ToString() + " Y:" + buffe.ReadInt32().ToString() + " Z:" + buffe.ReadInt32().ToString() + " Of Power:" + buffe.ReadInt32().ToString() + " For:" + buffe.ReadInt32().ToString() + "]", Globals.Gray, TextType.SYSTEM);
                        break;

                    case PServer.PledgeStatusChanged:
                        ClientPackets.ClanStatusChanged(buffe);
                        break;

                    case PServer.Dice:
                        ClientPackets.Dice(buffe);
                        break;

                    case PServer.HennaInfo:
                        ClientPackets.Set_Henna_Info(buffe);
                        break;

                    case PServer.ConfirmDlg:
                        ClientPackets.RequestReply(buffe);
                        break;

                    case PServer.SSQInfo:    //SignSky:
                        ClientPackets.SevenSignSky(buffe);
                        break;

                    case PServer.GameGuardQuery:
                        ClientPackets.GameGuardReply(buffe);
                        break;

                    case PServer.L2FriendSay:
                        ClientPackets.Get_Friend_Message(buffe);
                        break;

                    case PServer.EtcStatusUpdate:
                        ClientPackets.EtcStatusUpdate(buffe);
                        break;

                    case PServer.PetStatusShow:
                        ClientPackets.PetStatusShow(buffe);
                        break;

                    case PServer.PetInfo:
                        ClientPackets.PetInfo(buffe);
                        break;

                    case PServer.PetStatusUpdate:
                        ClientPackets.PetStatusUpdate(buffe);
                        break;

                    case PServer.PetDelete:
                        ClientPackets.PetDelete(buffe);
                        break;

                    case PServer.PetItemList:
                        ClientPackets.PetItemList(buffe);
                        if (Globals.petwindow != null)
                        {
                            Globals.petwindow.fill_pet_inventory();
                        }
                        break;

                    case PServer.PetInventoryUpdate:
                        AddInfo.PetInventory_Update(buffe);
                        if (Globals.petwindow != null)
                        {
                            Globals.petwindow.fill_pet_inventory();
                        }
                        break;

                    case PServer.NetPing:
                        ClientPackets.NetPing(buffe);
                        break;



                    case PServer.EXPacket:
                        b1 = buffe.ReadUInt16();
                        //buffe.ReadByte();

                        last_p = last_p + " " + b1.ToString("X2");

                        //do we have an event for this packet?
                        if (ScriptEngine.ServerPacketsEXContainsKey((int)b1))
                        {
                            ScriptEvent sc_ev = new ScriptEvent();
                            sc_ev.Type  = EventType.ServerPacketEX;
                            sc_ev.Type2 = (int)b1;
                            sc_ev.Variables.Add(new ScriptVariable(buffe, "PACKET", Var_Types.BYTEBUFFER, Var_State.PUBLIC));
                            sc_ev.Variables.Add(new ScriptVariable(System.DateTime.Now.Ticks, "TIMESTAMP", Var_Types.INT, Var_State.PUBLIC));
                            ScriptEngine.SendToEventQueue(sc_ev);
                        }
                        //Globals.l2net_home.Add_Text(last_p);
                        switch ((PServerEX)b1)
                        {
                        /*case PServerEX.ExPledgeCrestLarge:
                         *  //https://www.l2jserver.com/trac/browser/trunk/L2_GameServer_It/java/net/sf/l2j/gameserver/serverpackets/ExPledgeCrestLarge.java
                         *  break;*/
                        case PServerEX.ExMailArrived:
                            Globals.l2net_home.Add_Text("[Mail has arrived]");
                            VoicePlayer.PlaySound(8);
                            break;

                        case PServerEX.ExSetCompassZoneCode:
                            ClientPackets.ExSetCompassZoneCode(buffe);
                            break;

                        case PServerEX.ExShowScreenMessage:
                            ClientPackets.ExShowScreenMessage(buffe);
                            break;

                        case PServerEX.ExQuestHTML:
                            if (Globals.gamedata.Chron >= Chronicle.CT2_3)
                            {
                                NPC_Chat.Npc_Chat(buffe);
                            }
                            break;

                        case PServerEX.ExSendUIEventPacket:
                            if (Globals.gamedata.Chron >= Chronicle.CT3_2)
                            {
                                NPC_Chat.Npc_Chat(buffe);
                            }
                            break;

                        case PServerEX.ExQuestItemList:
                            if (Globals.gamedata.Chron >= Chronicle.CT2_5)
                            {
                                ClientPackets.ExQuestItemList(buffe);
                            }
                            break;

                        case PServerEX.ExVitalityUpdate:
                            if (Globals.gamedata.Chron >= Chronicle.CT2_1)
                            {
                                ClientPackets.ExVitalityUpdate(buffe);
                            }
                            break;

                        case PServerEX.ExShowReceivedPostList:
                            ClientPackets.Load_ReceivedMails(buffe);
                            break;

                        case PServerEX.ExShowSecurityPinWindow:
                            Globals.gamedata.SecurityPinWindow = true;
                            if ((!Globals.OOG) && (!System.String.IsNullOrEmpty(Globals.SecurityPin)) && (!Globals.gamedata.SecurityPinOldClient))
                            {
                                System.Threading.Thread.Sleep(3000);
                                ServerPackets.SecurityPin();
                                Globals.gamedata.SecurityPinSent = true;
                            }
                            break;

                        case PServerEX.ExSecurityPinCorrect:
                            Globals.gamedata.SecurityPinOk = true;
                            break;

                        case PServerEX.ExAcquireSkillInfo:
                            ClientPackets.ExAcquireSkillInfo(buffe);
                            break;

                        case PServerEX.ExNewSkillToLearnByLevelup:
                            //Glory days
                            ClientPackets.ExAcquireSkillInfo(buffe);
                            break;

                        case PServerEX.ExtargetBuffs:
                            ClientPackets.Extargetbuffs(buffe);
                            break;

                        case PServerEX.ExPartyPetWindowAdd:
                            ClientPackets.ExPartyPetWindowAdd(buffe);
                            break;

                        case PServerEX.ExPartyPetWindowDelete:
                            ClientPackets.ExPartyPetWindowDelete(buffe);
                            break;

                        case PServerEX.ExNpcInfo:
                            ClientPackets.ExNPCInfo(buffe);
                            break;

                        case PServerEX.ExUserinfoItems:
                            ClientPackets.ExUserInfoItems(buffe);
                            break;

                        case PServerEX.ExUserinfoStats:
                            ClientPackets.ExUserInfoStats(buffe);
                            break;

                        case PServerEX.ExUserInfo:
                            ClientPackets.EXUserInfo(buffe);
                            break;
                        }
                        break;
                    }//end of switch on packet type
                }
                catch (System.Exception e)
                {
                    //Globals.l2net_home.Add_Error("Packet Error: " + last_p + " Previous Packet: " + last_p2 + " : " + e.Message);
                    Globals.l2net_home.Add_Error("Packet Error: " + last_p + " :: " + e.Message);
                }
            } //end of loop to handle queue data
        }     //end of HandlePackets