Extractor_Serializer.NewParser.ParseItem C# (CSharp) Method

ParseItem() public method

The parse item.
public ParseItem ( Extractor recordType, int recnum, byte data, List itemNamesSqlList ) : ZoneEngine.GameObject.Items.ItemTemplate
recordType Extractor
recnum int /// The recnum. ///
data byte /// The data. ///
itemNamesSqlList List ///
return ZoneEngine.GameObject.Items.ItemTemplate
        public ItemTemplate ParseItem(Extractor.RecordType recordType, int recnum, byte[] data, List<string> itemNamesSqlList)
        {
            int rectype = (int)recordType;
            this.br = new BufferedReader(rectype, recnum, data);
            ItemTemplate aoi = new ItemTemplate();

            aoi.ID = recnum;
            this.br.Skip(16);

            int num = this.br.Read3F1();
            int argc0 = 0;

            int num2 = num - 1;
            int num3 = argc0;

            while (true)
            {
                int arg1c2 = num3;
                int num4 = num2;
                if (arg1c2 > num4)
                {
                    break;
                }

                int attrkey = this.br.ReadInt32();
                int attrval = this.br.ReadInt32();
                if (attrkey == 54)
                {
                    aoi.Quality = attrval;
                }
                else
                {
                    aoi.Stats.Add(attrkey, attrval);
                }

                num3++;
            }

            this.br.Skip(8);

            short num5 = this.br.ReadInt16();
            short num6 = this.br.ReadInt16();
            string itemname = string.Empty;
            if (num5 > 0)
            {
                itemname = this.br.ReadString(num5);
            }

            if (itemNamesSqlList != null)
            {
                itemNamesSqlList.Add(string.Format("( {0} , '{1}' , '{2}', '{3}' ) ",
                    recnum,
                    itemname.Replace("'", "''"),
                    Enum.GetName(typeof(Extractor.RecordType), recordType),
                    aoi.getItemAttribute(79)));
            }

            if (num6 > 0)
            {
                this.br.ReadString(num6); // Read and discard Description
            }

            bool flag4 = true;
            checked
            {
                while (this.br.Ptr < this.br.Buffer.Length - 8 && flag4)
                {
                    switch (this.br.ReadInt32()) // what are these ints ?
                    {
                        case 2:
                            this.ParseFunctionSet(aoi.Events);
                            break;
                        case 3:
                        case 5:
                        case 7:
                        case 8:
                        case 9:
                        case 10:
                        case 11:
                        case 12:
                        case 13:
                        case 15:
                        case 16:
                        case 17:
                        case 18:
                        case 19:
                        case 21:
                            goto IL_4BF;
                        case 4:
                            this.ParseAtkDefSet(aoi.Attack, aoi.Defend);
                            break;
                        case 6:
                            {
                                this.br.Skip(4);
                                int count = this.br.Read3F1() * 8;
                                this.br.Skip(count);
                                break;
                            }

                        case 14:
                            this.ParseAnimSoundSet(1, aoi);
                            break;
                        case 20:
                            this.ParseAnimSoundSet(2, aoi);
                            break;
                        case 22:
                            this.ParseActionSet(aoi.Actions);
                            break;
                        case 23:
                            this.ParseShopHash(aoi.Events);
                            break;
                        default:
                            goto IL_4BF;
                    }

                    continue;
                IL_4BF:
                    flag4 = false;
                }
            }

            return aoi;
        }

Usage Example

Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="itemNamesSqls">
        /// </param>
        /// <returns>
        /// </returns>
        private static List <ItemTemplate> ExtractItemTemplates(List <string> itemNamesSqls)
        {
            var np = new NewParser();

            int[] instances = extractor.GetRecordInstances(Extractor.RecordType.Item);
            List <ItemTemplate> rawItemList = new List <ItemTemplate>(instances.Length);

            rawItemDictionary = new Dictionary <int, ItemTemplate>(instances.Length);
            int counter = 0;

            foreach (int recnum in instances)
            {
                byte[]       data = extractor.GetRecordData(Extractor.RecordType.Item, recnum);
                ItemTemplate xt   = np.ParseItem(Extractor.RecordType.Item, recnum, data, itemNamesSqls);

                rawItemList.Add(xt);
                rawItemDictionary.Add(recnum, xt);

                if ((counter % 7500) == 0)
                {
                    Console.Write("\rItem ID: " + recnum.ToString().PadLeft(9));
                }

                counter++;
            }

            Console.Write("\rItem ID: " + rawItemList[rawItemList.Count - 1].ID.ToString().PadLeft(9));

            Console.WriteLine();
            return(rawItemList);
        }
All Usage Examples Of Extractor_Serializer.NewParser::ParseItem