protected void ProcessFiles(
            string[] files, Progress progress)
        {
            string info = "Reading UIDs from ";

            for (int i = 0; i < files.Length; ++i)
            {
                progress.Info =
                    info + Path.GetFileName(files[i]) + "...";

                TNGFile tng = new TNGFile(
                    FileDatabase.Instance.TNGDefinitions);

                tng.Load(files[i]);

                for (int j = 0; j < tng.SectionCount; ++j)
                {
                    foreach (Thing thing in tng.get_Sections(j).Things)
                    {
                        UIDManager.Add(thing.UID);
                    }
                }

                tng.Dispose();

                progress.Update();
            }
        }
示例#2
0
        protected void CheckUIDs(string[] files, Progress progress)
        {
            string info = "Checking ";

            int index = 0;

            for (int i = 0; i < files.Length; ++i)
            {
                progress.Info =
                    info + Path.GetFileName(files[i]) + "...";

                TNGFile tng = new TNGFile(
                    FileDatabase.Instance.TNGDefinitions);

                tng.Load(files[i]);

                List <CTCBlock> ctcs = GetOwned(tng);

                for (int j = 0; j < tng.SectionCount; ++j)
                {
                    foreach (Thing thing in tng.get_Sections(j).Things)
                    {
                        if (IsValid(thing))
                        {
                            int found = myUIDs.IndexOf(thing.UID);

                            if (found >= 0 && found != index)
                            {
                                /*
                                 * Console.WriteLine(
                                 *  "Update: Index={0} Found={1} Thing={2}",
                                 *  index,
                                 *  found,
                                 *  thing.DefinitionType);
                                 */

                                UpdateThing(thing, ctcs);

                                ++myCount;
                            }
                            else
                            {
                                // New uid, add to the list.
                                myUIDs.Add(thing.UID);
                            }

                            ++index;
                        }
                    }
                }

                if (tng.Modified)
                {
                    if (mySaves.IndexOf(files[i]) < 0)
                    {
                        mySaves.Add(files[i]);
                    }

                    tng.Save(files[i]);
                }

                ctcs = null;

                tng.Dispose();

                progress.Update();
            }
        }