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(); } }
protected List <CTCBlock> GetOwned(TNGFile tng) { List <CTCBlock> ctcs = new List <CTCBlock>(100); for (int i = 0; i < tng.SectionCount; ++i) { foreach (Thing thing in tng.get_Sections(i).Things) { CTCBlock ctc = thing.get_CTCs("CTCOwnedEntity"); if (ctc != null) { Variable v = ctc.get_Variables("OwnerUID"); if (UIDManager.IsNormal(v.StringValue)) { ctcs.Add(ctc); } } } } return(ctcs); }
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(); } }