GetRecordInstanceCount() private method

private GetRecordInstanceCount ( int p ) : int
p int
return int
Exemplo n.º 1
0
        /// <summary>
        /// </summary>
        /// <param name="ItemNamesSql">
        /// </param>
        /// <returns>
        /// </returns>
        private static List <ItemTemplate> ExtractItemTemplates(List <string> ItemNamesSql)
        {
            var np = new NewParser();
            List <ItemTemplate> rawItemList = new List <ItemTemplate>(extractor.GetRecordInstanceCount(0xF4254));

            rawItemDictionary = new Dictionary <int, ItemTemplate>(extractor.GetRecordInstanceCount(0xF4254));
            int counter = 0;

            foreach (int recnum in extractor.GetRecordInstances(0xF4254))
            {
                ItemTemplate xt = np.ParseItem(0xF4254, recnum, extractor.GetRecordData(0xF4254, recnum), ItemNamesSql);
                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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// The main.
        /// </summary>
        /// <param name="args">
        /// The args.
        /// </param>
        private static void Main(string[] args)
        {
            OnScreenBanner.PrintCellAOBanner(ConsoleColor.White);

            Console.WriteLine();

            string AOPath = GetAOPath();

            if (AOPath == string.Empty)
            {
                // Exit
                return;
            }

            Console.WriteLine();
            Console.WriteLine("Loading item relations...");
            ReadItemRelations();

            PrepareItemNamesSQL();

            Console.WriteLine("Number of Items to extract: " + extractor.GetRecordInstances(Extractor.RecordType.Item).Length);

            // ITEM RECORD TYPE
            Console.WriteLine("Number of Nanos to extract: " + extractor.GetRecordInstances(Extractor.RecordType.Nano).Length);
            Console.WriteLine();

            // NANO RECORD TYPE

            // Console.WriteLine(extractor.GetRecordInstances(0xF4241).Length); // Playfields
            // Console.WriteLine(extractor.GetRecordInstances(0xF4266).Length); // Nano Strains
            // Console.WriteLine(extractor.GetRecordInstances(0xF4264).Length); // Perks

            // GetData(@"D:\c#\extractor serializer\data\items\",0xf4254);
            // GetData(@"D:\c#\extractor serializer\data\nanos\",0xfde85);
            // GetData(@"D:\c#\extractor serializer\data\playfields\",0xf4241);
            // GetData(@"D:\c#\extractor serializer\data\nanostrains\",0xf4266);
            // GetData(@"D:\c#\extractor serializer\data\perks\",0xf4264);

            Console.WriteLine();
            List <NanoFormula> rawNanoList = ReadNanoFormulas();

            Console.WriteLine();
            Console.WriteLine("Nanos extracted: " + rawNanoList.Count);
            Console.WriteLine();

            List <string>       ItemNamesSql = new List <string>(extractor.GetRecordInstanceCount(0xF4254));
            List <ItemTemplate> rawItemList  = ExtractItemTemplates(ItemNamesSql);

            Console.WriteLine("Items extracted: " + rawItemList.Count);

            SetItemRelations(rawItemList);

            CompactingItemNamesSql(ItemNamesSql);

            // SerializationContext.Default.Serializers.Register(new AOFunctionArgumentsSerializer());
            Console.WriteLine();
            Console.WriteLine("Items extracted: " + rawItemList.Count);

            Console.WriteLine();
            Console.WriteLine("Creating serialized nano data file - please wait");

            string version = GetVersion(AOPath);

            MessagePackZip.CompressData <NanoFormula>("nanos.dat", version, rawNanoList, (rawNanoList.Count / 12) + 1);

            Console.WriteLine();
            Console.WriteLine("Checking Nanos...");
            Console.WriteLine();
            NanoLoader.CacheAllNanos("nanos.dat");
            Console.WriteLine();
            Console.WriteLine("Nanos: " + NanoLoader.NanoList.Count + " successfully converted");

            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Creating serialized item data file - please wait");

            MessagePackZip.CompressData <ItemTemplate>("items.dat", GetVersion(AOPath), rawItemList, 10000);

            Console.WriteLine();
            Console.WriteLine("Checking Items...");
            Console.WriteLine();

            ItemLoader.CacheAllItems("items.dat");

            Console.WriteLine();
            Console.WriteLine("Items: " + ItemLoader.ItemList.Count + " successfully converted");

            Console.WriteLine("Extracting playfield walls/destinations/statels");
            List <PlayfieldData> playfields = ExtractPlayfieldData();

            ExtractPlayfieldStatels(playfields);
            Console.WriteLine();
            Console.WriteLine("Compressing playfield data...");
            MessagePackZip.CompressData <PlayfieldData>("playfields.dat", GetVersion(AOPath), playfields);
            Console.WriteLine();

            Console.WriteLine();
            Console.WriteLine("Further Instructions:");
            Console.WriteLine(
                "- Copy items.dat, nanos.dat and playfields.dat into your CellAO/Datafiles folder and overwrite.");
            Console.WriteLine("- Apply itemnames.sql to your database");
            Console.WriteLine();
            Console.WriteLine("   OR   ");
            Console.WriteLine();
            Console.WriteLine("Let me copy it over to the Source Tree");
            Console.WriteLine();
            while (true)
            {
                Console.WriteLine("Please choose:");
                Console.WriteLine("1: Copy the files to CellAO/Datafiles and CellAO/.../CellAO.Database/SqlTables.");
                Console.WriteLine("2: Exit and copy yourself");
                Console.WriteLine("[1,2]:");
                string line = Console.ReadLine();
                if (line.Trim() == "1")
                {
                    if (CopyDatafiles())
                    {
                        break;
                    }
                }

                if (line.Trim() == "2")
                {
                    break;
                }
            }

            while (true)
            {
                Console.WriteLine("Do you want to extract the icons for WebCore? [Y/N]");
                string line = Console.ReadLine();
                if (line.Trim().ToLower() == "y")
                {
                    ExtractIcons();
                    break;
                }
                if (line.Trim().ToLower() == "n")
                {
                    break;
                }
            }

            Console.WriteLine("Press a key to exit.");
            Console.ReadLine();
        }