HaloMap.Meta.Meta.SaveRecursiveFunction C# (CSharp) Method

SaveRecursiveFunction() private method

The save recursive function.
private SaveRecursiveFunction ( Meta meta, ArrayList &metas, bool parsed, System.Windows.Forms.ToolStripProgressBar pb, float percent, float percentsize ) : void
meta Meta The meta.
metas System.Collections.ArrayList The metas.
parsed bool The parsed.
pb System.Windows.Forms.ToolStripProgressBar The pb.
percent float The percent.
percentsize float The percentsize.
return void
        private void SaveRecursiveFunction(
            Meta meta, 
            ref ArrayList metas, 
            bool parsed, 
            ToolStripProgressBar pb, 
            float percent, 
            float percentsize)
        {
            int wtf = metas.Count;
            if (meta.items.Count == 0)
            {
                return;
            }

            float test = meta.items.Count;

            float currentpercentsize = percentsize / test;

            Item i = null;

            try
            {
                for (int x = 0; x < meta.items.Count; x++)
                {
                    i = meta.items[x];
                    if (i.type != ItemType.Ident)
                    {
                        continue;
                    }

                    float currentpercentage = percent + (currentpercentsize * x);
                    pb.Value = (int)currentpercentage;
                    Application.DoEvents();

                    Ident id = (Ident)i;

                    if (id.ident == -1)
                    {
                        continue;
                    }

                    if (id.ident == 0)
                    {
                        int tagIndex = Map.Functions.ForMeta.FindByNameAndTagType("sbsp", i.intagname);
                        id.ident = Map.MetaInfo.Ident[tagIndex];
                    }

                    bool exists = false;

                    for (int e = 0; e < metas.Count; e++)
                    {
                        Meta tempmeta = (Meta)metas[e];

                        // if (id.pointstotagtype  ==tempmeta.type&&id.pointstotagname ==tempmeta.name )
                        if (id.ident == tempmeta.ident)
                        {
                            exists = true;
                            break;
                        }
                    }

                    if (exists)
                    {
                        continue;
                    }

                    // Drag & drop w/ recursive locks up. num == -1
                    int num = Map.Functions.ForMeta.FindMetaByID(id.ident);
                    if (num < 0)
                    {
                        MessageBox.Show("ERROR! Not Found!");
                    }

                    Meta m = new Meta(Map);
                    if (parsed)
                    {
                        m.parsed = true;
                    }

                    m.ReadMetaFromMap(num, false);
                    if (m.type == "ltmp" | m.type == "matg")
                    {
                        continue;
                    }

                    if (m.type == "phmo" | m.type == "coll" | m.type == "jmad")
                    {
                        m.parsed = false;
                    }

                    if (m.type != "jmad")
                    {
                        IFPIO ifp = IFPHashMap.GetIfp(m.type, Map.HaloVersion);
                        m.headersize = ifp.headerSize;

                        m.scanner.ScanWithIFP(ref ifp);
                    }
                    else
                    {
                        m.scanner.ScanManually();
                    }

                    m.SortItemsByOffset();

                    metas.Add(m);

                    Application.DoEvents();
                    SaveRecursiveFunction(m, ref metas, parsed, pb, currentpercentage, currentpercentsize);
                }
            }
            catch (Exception e)
            {
                string addOn = "\nin [" + meta.type + "] " + meta.name;
                if (i.type == ItemType.Ident)
                    addOn = "\n" + i.description + ", Ident: " + ((Ident)i).ident + addOn;
                throw new Exception(e.Message + addOn, e.InnerException);
            }
        }