Пример #1
0
        private CacheItem[] GetMobs(string filename)
        {
            //Initialize
            CacheItem item;
            item.typeid = 0;
            item.clsid = 0;
            ArrayList itemList = new ArrayList();
            char[] sbuff = new char[256];
            byte[] rbuff = new byte[256];
            byte[] tmpbyte = new byte[256];
            byte[] byteinfo;
            String strread, npctitle;

            //Open the cache file
            BinaryReader fin;
            try
            {
                fin = new BinaryReader(new FileStream(filename, FileMode.Open));
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot open file.", "Error!");
                return null;
            }

            //Read the cache file
            try
            {
                sbuff = fin.ReadChars(4);
                strread = new string(sbuff);
                rbuff = fin.ReadBytes(4);
                sbuff = fin.ReadChars(4);
                NumberManipulator GetNum = new NumberManipulator();

                //Read NPC Info
                rbuff = fin.ReadBytes(12);
                rbuff = fin.ReadBytes(4);
                int npcid, length, tmplen, ptr;
                npcid = GetNum.CalcNum(ref rbuff);
                while (npcid > 0)
                {
                    //Read the NPC Name
                    rbuff = fin.ReadBytes(4);
                    length = GetNum.CalcNum(ref rbuff);
                    rbuff = fin.ReadBytes(8);
                    rbuff = fin.ReadBytes(8);
                    Array.Clear(tmpbyte, 0, tmpbyte.Length);
                    tmpbyte[0] = rbuff[7];
                    length -= 16;

                    rbuff = fin.ReadBytes(length);
                    tmplen = 1; ptr = 0;
                    while (rbuff[ptr] > 0)
                        tmpbyte[tmplen++] = rbuff[ptr++];
                    if (rbuff[ptr + 1] == tmpbyte[0] && rbuff[ptr + 2] == tmpbyte[1])
                        ptr += tmplen + 1;

                    byteinfo = new byte[tmplen];
                    Array.Copy(tmpbyte, byteinfo, tmplen);
                    strread = Encoding.UTF8.GetString(byteinfo);
                    item.typeid = (int)rbuff[ptr + 9];
                    item.clsid = (int)rbuff[ptr + 17];

                    //Title & Description
                    Array.Clear(tmpbyte, 0, tmpbyte.Length);
                    tmplen = 0;
                    int deslen = length - 2;
                    bool istitled = false;
                    if (rbuff[deslen] != 1)
                    {
                        while (rbuff[deslen] > 0)
                        {
                            tmpbyte[tmplen++] = rbuff[deslen--];
                            istitled = true;
                        }
                    }
                    if(istitled)
                    {
                        deslen--;
                        if (rbuff[deslen] > 0)
                        {
                            Array.Clear(tmpbyte, 0, tmpbyte.Length);
                            tmplen = 0;
                            while (rbuff[deslen] > 0)
                                tmpbyte[tmplen++] = rbuff[deslen--];
                        }
                    }

                    byteinfo = new byte[tmplen];
                    Array.Copy(tmpbyte, byteinfo, tmplen);
                    Array.Reverse(byteinfo);
                    npctitle = Encoding.UTF8.GetString(byteinfo);
                    //if (npctitle.Length > 0)
                    //    strread = strread + " <" + npctitle + ">";

                    /******Add to the Array List******/
                    item.itemID = npcid;
                    item.name = strread;
                    item.descrition = npctitle;
                    itemList.Add(item);
                    /****************************************/

                    rbuff = fin.ReadBytes(4);
                    npcid = GetNum.CalcNum(ref rbuff);
                }
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot read from file.", "Error!");
                return null;
            }
            //End
            fin.Close();
            return (CacheItem[])itemList.ToArray(typeof(CacheItem));
        }
Пример #2
0
        private void LoadFile(string filename)
        {
            statusStrip1.Items[0].Text = "Ready.";
            //Open the cache file
            FileStream   filestream;
            BinaryReader fin;

            try
            {
                filestream = new FileStream(filename, FileMode.Open);
                fin        = new BinaryReader(filestream);
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot open file.", "Error!");
                return;
            }

            char[] sbuff = new char[256];
            byte[] rbuff = new byte[256];
            string strread, locale, cachetype;
            int    build;

            try
            {
                //Cache File Type
                sbuff = fin.ReadChars(4);
                Array.Reverse(sbuff);
                strread = new string(sbuff);
                if (strread != "WMOB" && strread != "WGOB")
                {
                    MessageBox.Show("This is not a WoW Creature or GameObject Cache file!", "Error!");
                    filestream.Close();
                    return;
                }
                cachetype = strread == "WMOB" ? "Creature" : "GameObject";
                //WoW Build
                rbuff = fin.ReadBytes(4);
                NumberManipulator GetNum = new NumberManipulator();
                build = GetNum.CalcNum(ref rbuff);
                //WoW Locale
                sbuff = fin.ReadChars(4);
                Array.Reverse(sbuff);
                locale = new string(sbuff);
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot read from file.", "Error!");
                filestream.Close();
                return;
            }
            filestream.Close();

            ReadFromFile CacheReader = new ReadFromFile(strread);

            Item    = CacheReader.ReadCacheFile(filename);
            ItemNum = Item.Count();
            toolStripStatusLabel1.Text = ">>> " + ItemNum.ToString() + " " + cachetype + "s found.   Locale: " + locale + "  Build: " + build;

            //Display Grid
            int rowindex, typecol = 2, clscol = 3;

            dataGridView1.Rows.Clear();
            dataGridView1.Visible         = true;
            toolStripProgressBar1.Visible = true;
            for (int i = 1; i <= ItemNum; i++)
            {
                rowindex = dataGridView1.Rows.Add();
                dataGridView1.Rows[rowindex].Cells[0].Value = Item[i - 1].itemID;
                dataGridView1.Rows[rowindex].Cells[1].Value = Item[i - 1].name;
                dataGridView1.Rows[rowindex].Cells[4].Value = Item[i - 1].descrition;
                switch (Item[i - 1].typeid)
                {
                case 1: dataGridView1.Rows[rowindex].Cells[typecol].Value = "野兽"; break;

                case 2: dataGridView1.Rows[rowindex].Cells[typecol].Value = "龙类"; break;

                case 3: dataGridView1.Rows[rowindex].Cells[typecol].Value = "恶魔"; break;

                case 4: dataGridView1.Rows[rowindex].Cells[typecol].Value = "元素生物"; break;

                case 5: dataGridView1.Rows[rowindex].Cells[typecol].Value = "巨人"; break;

                case 6: dataGridView1.Rows[rowindex].Cells[typecol].Value = "亡灵"; break;

                case 7: dataGridView1.Rows[rowindex].Cells[typecol].Value = "人型生物"; break;

                case 8: dataGridView1.Rows[rowindex].Cells[typecol].Value = "小动物"; break;

                case 9: dataGridView1.Rows[rowindex].Cells[typecol].Value = "机械"; break;

                case 10: dataGridView1.Rows[rowindex].Cells[typecol].Value = "未指定"; break;

                case 11: dataGridView1.Rows[rowindex].Cells[typecol].Value = "图腾"; break;

                case 12: dataGridView1.Rows[rowindex].Cells[typecol].Value = "非战斗宠物"; break;

                case 13: dataGridView1.Rows[rowindex].Cells[typecol].Value = "气体云雾"; break;

                case 14: dataGridView1.Rows[rowindex].Cells[typecol].Value = "野生宠物"; break;

                case 15: dataGridView1.Rows[rowindex].Cells[typecol].Value = "畸变怪"; break;

                default: dataGridView1.Rows[rowindex].Cells[typecol].Value = "——"; break;
                }
                switch (Item[i - 1].clsid)
                {
                case 1: dataGridView1.Rows[rowindex].Cells[clscol].Value = "精英"; break;

                case 2: dataGridView1.Rows[rowindex].Cells[clscol].Value = "稀有精英"; break;

                case 3: dataGridView1.Rows[rowindex].Cells[clscol].Value = "首领"; break;

                case 4: dataGridView1.Rows[rowindex].Cells[clscol].Value = "稀有"; break;

                default: dataGridView1.Rows[rowindex].Cells[clscol].Value = "普通"; break;
                }
                toolStripProgressBar1.Value = i * 100 / ItemNum;
            }
            toolStripProgressBar1.Visible = false;
        }
Пример #3
0
        private CacheItem[] GetMobs(string filename)
        {
            //Initialize
            CacheItem item;

            item.typeid = 0;
            item.clsid  = 0;
            ArrayList itemList = new ArrayList();

            char[] sbuff   = new char[256];
            byte[] rbuff   = new byte[256];
            byte[] tmpbyte = new byte[256];
            byte[] byteinfo;
            String strread, npctitle;

            //Open the cache file
            BinaryReader fin;

            try
            {
                fin = new BinaryReader(new FileStream(filename, FileMode.Open));
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot open file.", "Error!");
                return(null);
            }

            //Read the cache file
            try
            {
                sbuff   = fin.ReadChars(4);
                strread = new string(sbuff);
                rbuff   = fin.ReadBytes(4);
                sbuff   = fin.ReadChars(4);
                NumberManipulator GetNum = new NumberManipulator();

                //Read NPC Info
                rbuff = fin.ReadBytes(12);
                rbuff = fin.ReadBytes(4);
                int npcid, length, tmplen, ptr;
                npcid = GetNum.CalcNum(ref rbuff);
                while (npcid > 0)
                {
                    //Read the NPC Name
                    rbuff  = fin.ReadBytes(4);
                    length = GetNum.CalcNum(ref rbuff);
                    rbuff  = fin.ReadBytes(8);
                    rbuff  = fin.ReadBytes(8);
                    Array.Clear(tmpbyte, 0, tmpbyte.Length);
                    tmpbyte[0] = rbuff[7];
                    length    -= 16;


                    rbuff  = fin.ReadBytes(length);
                    tmplen = 1; ptr = 0;
                    while (rbuff[ptr] > 0)
                    {
                        tmpbyte[tmplen++] = rbuff[ptr++];
                    }
                    if (rbuff[ptr + 1] == tmpbyte[0] && rbuff[ptr + 2] == tmpbyte[1])
                    {
                        ptr += tmplen + 1;
                    }

                    byteinfo = new byte[tmplen];
                    Array.Copy(tmpbyte, byteinfo, tmplen);
                    strread     = Encoding.UTF8.GetString(byteinfo);
                    item.typeid = (int)rbuff[ptr + 9];
                    item.clsid  = (int)rbuff[ptr + 17];

                    //Title & Description
                    Array.Clear(tmpbyte, 0, tmpbyte.Length);
                    tmplen = 0;
                    int  deslen   = length - 2;
                    bool istitled = false;
                    if (rbuff[deslen] != 1)
                    {
                        while (rbuff[deslen] > 0)
                        {
                            tmpbyte[tmplen++] = rbuff[deslen--];
                            istitled          = true;
                        }
                    }
                    if (istitled)
                    {
                        deslen--;
                        if (rbuff[deslen] > 0)
                        {
                            Array.Clear(tmpbyte, 0, tmpbyte.Length);
                            tmplen = 0;
                            while (rbuff[deslen] > 0)
                            {
                                tmpbyte[tmplen++] = rbuff[deslen--];
                            }
                        }
                    }

                    byteinfo = new byte[tmplen];
                    Array.Copy(tmpbyte, byteinfo, tmplen);
                    Array.Reverse(byteinfo);
                    npctitle = Encoding.UTF8.GetString(byteinfo);
                    //if (npctitle.Length > 0)
                    //    strread = strread + " <" + npctitle + ">";

                    /******Add to the Array List******/
                    item.itemID     = npcid;
                    item.name       = strread;
                    item.descrition = npctitle;
                    itemList.Add(item);
                    /****************************************/

                    rbuff = fin.ReadBytes(4);
                    npcid = GetNum.CalcNum(ref rbuff);
                }
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot read from file.", "Error!");
                return(null);
            }
            //End
            fin.Close();
            return((CacheItem[])itemList.ToArray(typeof(CacheItem)));
        }
Пример #4
0
        private void LoadFile(string filename)
        {
            statusStrip1.Items[0].Text = "Ready.";
            //Open the cache file
            FileStream filestream;
            BinaryReader fin;
            try
            {
                filestream = new FileStream(filename, FileMode.Open);
                fin = new BinaryReader(filestream);
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot open file.", "Error!");
                return;
            }

            char[] sbuff = new char[256];
            byte[] rbuff = new byte[256];
            string strread, locale, cachetype;
            int build;
            try
            {
                //Cache File Type
                sbuff = fin.ReadChars(4);
                Array.Reverse(sbuff);
                strread = new string(sbuff);
                if (strread != "WMOB" && strread != "WGOB")
                {
                    MessageBox.Show("This is not a WoW Creature or GameObject Cache file!","Error!");
                    filestream.Close();
                    return;
                }
                cachetype = strread == "WMOB" ? "Creature" : "GameObject";
                //WoW Build
                rbuff = fin.ReadBytes(4);
                NumberManipulator GetNum = new NumberManipulator();
                build = GetNum.CalcNum(ref rbuff);
                //WoW Locale
                sbuff = fin.ReadChars(4);
                Array.Reverse(sbuff);
                locale = new string(sbuff);
            }
            catch (IOException e)
            {
                MessageBox.Show(e.Message + "\nCannot read from file.", "Error!");
                filestream.Close();
                return;
            }
            filestream.Close();

            ReadFromFile CacheReader = new ReadFromFile(strread);
            Item = CacheReader.ReadCacheFile(filename);
            ItemNum = Item.Count();
            toolStripStatusLabel1.Text = ">>> " + ItemNum.ToString() + " " + cachetype + "s found.   Locale: " + locale + "  Build: " + build;

            //Display Grid
            int rowindex, typecol = 2, clscol = 3;
            dataGridView1.Rows.Clear();
            dataGridView1.Visible = true;
            toolStripProgressBar1.Visible = true;
            for (int i = 1; i <= ItemNum; i++)
            {
                rowindex = dataGridView1.Rows.Add();
                dataGridView1.Rows[rowindex].Cells[0].Value = Item[i - 1].itemID;
                dataGridView1.Rows[rowindex].Cells[1].Value = Item[i - 1].name;
                dataGridView1.Rows[rowindex].Cells[4].Value = Item[i - 1].descrition;
                switch(Item[i - 1].typeid)
                {
                    case 1: dataGridView1.Rows[rowindex].Cells[typecol].Value = "野兽"; break;
                    case 2: dataGridView1.Rows[rowindex].Cells[typecol].Value = "龙类"; break;
                    case 3: dataGridView1.Rows[rowindex].Cells[typecol].Value = "恶魔"; break;
                    case 4: dataGridView1.Rows[rowindex].Cells[typecol].Value = "元素生物"; break;
                    case 5: dataGridView1.Rows[rowindex].Cells[typecol].Value = "巨人"; break;
                    case 6: dataGridView1.Rows[rowindex].Cells[typecol].Value = "亡灵"; break;
                    case 7: dataGridView1.Rows[rowindex].Cells[typecol].Value = "人型生物"; break;
                    case 8: dataGridView1.Rows[rowindex].Cells[typecol].Value = "小动物"; break;
                    case 9: dataGridView1.Rows[rowindex].Cells[typecol].Value = "机械"; break;
                    case 10: dataGridView1.Rows[rowindex].Cells[typecol].Value = "未指定"; break;
                    case 11: dataGridView1.Rows[rowindex].Cells[typecol].Value = "图腾"; break;
                    case 12: dataGridView1.Rows[rowindex].Cells[typecol].Value = "非战斗宠物"; break;
                    case 13: dataGridView1.Rows[rowindex].Cells[typecol].Value = "气体云雾"; break;
                    case 14: dataGridView1.Rows[rowindex].Cells[typecol].Value = "野生宠物"; break;
                    case 15: dataGridView1.Rows[rowindex].Cells[typecol].Value = "畸变怪"; break;
                    default: dataGridView1.Rows[rowindex].Cells[typecol].Value = "——"; break;
                }
                switch (Item[i - 1].clsid)
                {
                    case 1: dataGridView1.Rows[rowindex].Cells[clscol].Value = "精英"; break;
                    case 2: dataGridView1.Rows[rowindex].Cells[clscol].Value = "稀有精英"; break;
                    case 3: dataGridView1.Rows[rowindex].Cells[clscol].Value = "首领"; break;
                    case 4: dataGridView1.Rows[rowindex].Cells[clscol].Value = "稀有"; break;
                    default: dataGridView1.Rows[rowindex].Cells[clscol].Value = "普通"; break;
                }
                toolStripProgressBar1.Value = i * 100 / ItemNum;
            }
            toolStripProgressBar1.Visible = false;
        }