protected override void Perform(SimDescription obj, object parent, FieldInfo field) { //if (obj.IsValidDescription) return; if (mSims == null) { mSims = SimListing.AllSims <SimDescription>(null, true); } // All residents, ancestors, and urnstone sims are considered valid if (mSims.ContainsKey(obj.SimDescriptionId)) { return; } GameObjectReference reference = ObjectLookup.GetReference(new ReferenceWrapper(obj)); if (!DereferenceManager.Perform(obj, reference, false, false)) { return; } DereferenceManager.Perform(obj, reference, true, false); string fullName = obj.FullName; if (!string.IsNullOrEmpty(fullName)) { fullName = fullName.Trim(); } if (!string.IsNullOrEmpty(fullName)) { bool found = false; foreach (List <SimDescription> list in mSims.Values) { foreach (SimDescription sim in list) { if (sim.FullName == fullName) { found = true; break; } } } if (!found) { if (reference.Count > 0) { ErrorTrap.LogCorrection("SimDescription Removed: " + fullName); } else { ErrorTrap.DebugLogCorrection("Zero Reference SimDescription Removed: " + fullName); } } } }
protected override bool PrePerform(MoonDial dial, bool postLoad) { if ((World.GetLunarPhase() < 0) || (World.GetLunarPhase() >= dial.mLunarFXLookUp.Length)) { World.SetLunarPhase(0); ErrorTrap.LogCorrection("LunarPhase Repaired"); } return(true); }
public static void MergePlantSeed(HarvestPlant plant, Ingredient ingredient) { plant.Seed = ingredient; plant.PlantDef = PlantHelper.GetPlantDefinition(plant.Seed); plant.mQualityLevel = ingredient.Plantable.QualityLevel; plant.SetGrowthState(plant.GrowthState); sMergedPlants.Add(plant); ErrorTrap.LogCorrection("Plant Seed Merged: " + ErrorTrap.GetName(plant)); }
public void LogReferences() { Dictionary <ReferenceWrapper, bool> processed = new Dictionary <ReferenceWrapper, bool>(); List <StackFrame> references = new List <StackFrame>(); foreach (KeyValuePair <object, FieldInfo> obj in this) { references.Add(new StackFrame(new ReferenceWrapper(obj.Key), obj.Value, "")); } int index = 0; while (index < references.Count) { StackFrame stack = references[index]; index++; bool repeat = false; if (processed.ContainsKey(stack.mReference)) { repeat = true; } else { processed.Add(stack.mReference, true); } GameObjectReference reference = ObjectLookup.GetReference(stack.mReference); ErrorTrap.LogCorrection(" Reference: " + stack.mDepth + stack.mReference.mObject.GetType() + " " + stack.mField + (repeat ? " (Recursion)" : "")); if (stack.mReference.mObject is GameObject) { continue; } if (repeat) { continue; } if (reference != null) { foreach (KeyValuePair <object, FieldInfo> obj in reference) { references.Insert(index, new StackFrame(new ReferenceWrapper(obj.Key), obj.Value, stack.mDepth + " ")); } } } }
protected override void Perform(GameObject obj, object referenceParent, FieldInfo field) { if (obj is Ocean) { if (LotManager.sOceanObject == obj) { return; } } else if (obj is Terrain) { if (Terrain.sTerrain == obj) { return; } } if (DereferenceManager.HasBeenDestroyed(obj)) { if (obj is Sim) { LotManager.sActorList.Remove(obj as Sim); DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), true, false); } else { GameObjectReference refObj = ObjectLookup.GetReference(new ReferenceWrapper(obj)); if (DereferenceManager.Perform(obj, refObj, false, false)) { DereferenceManager.Perform(obj, refObj, true, false); ErrorTrap.LogCorrection("Destroyed Object Found: " + obj.GetType()); } } return; } if (kShowFullReferencing) { DereferenceManager.Perform(obj, ObjectLookup.GetReference(new ReferenceWrapper(obj)), false, true); } if (obj.InWorld) { return; } if (obj.InInventory) { if (Inventories.ParentInventory(obj) == null) { if ((obj.Parent != null) || (Consignment.ContainsKey(obj))) { obj.SetFlags(GameObject.FlagField.InInventory, false); ErrorTrap.LogCorrection("Invalid Inventory Object Unflagged: " + obj.GetType()); } else { ErrorTrap.LogCorrection("Invalid Inventory Object Found: " + obj.GetType()); ErrorTrap.AddToBeDeleted(obj, true); } } return; } else { if (SharedInventories.ContainsKey(obj.ObjectId)) { obj.SetFlags(GameObject.FlagField.InInventory, true); ErrorTrap.LogCorrection("Inventory Object Flagged: " + obj.GetType()); return; } } if (EventItems.ContainsKey(obj.ObjectId)) { return; } bool hasParent = false; IGameObject parent = obj.Parent; while (parent != null) { hasParent = true; if (DereferenceManager.HasBeenDestroyed(parent)) { ErrorTrap.LogCorrection("Destroyed Parent Object Found: " + parent.GetType()); ErrorTrap.AddToBeDeleted(obj, true); hasParent = false; break; } parent = parent.Parent; } if (!hasParent) { ReferenceWrapper refObj = new ReferenceWrapper(obj); GameObjectReference reference = ObjectLookup.GetReference(refObj); if ((reference != null) && (reference.HasReferences)) { if (DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), false, false)) { IScriptProxy proxy = Simulator.GetProxy(obj.ObjectId); if (proxy != null) { IScriptLogic logic = proxy.Target; if (object.ReferenceEquals(logic, obj)) { bool log = !sSilentDestroy.ContainsKey(obj.GetType()); if (log) { ErrorTrap.LogCorrection("Out of World Object Found 2: " + obj.GetType()); } else { ErrorTrap.DebugLogCorrection("Out of World Object Found 3: " + obj.GetType()); } ErrorTrap.AddToBeDeleted(obj, log); } else { ErrorTrap.DebugLogCorrection("Out of World Object Found 4: " + obj.GetType()); ErrorTrap.DebugLogCorrection("Out of World Object Found 5: " + logic.GetType()); } } else { DereferenceManager.Perform(obj, ObjectLookup.GetReference(refObj), true, false); } } } else { ErrorTrap.LogCorrection("Out of World Object Found 1: " + obj.GetType()); ErrorTrap.AddToBeDeleted(obj, true); } } }
protected static Delegate ProcessDuplicates(Delegate del) { Delegate result = del; Delegate[] subs = del.GetInvocationList(); if (subs.Length > 1) { List <Delegate> exists = new List <Delegate>(); bool first = true; foreach (Delegate sub in subs) { if (exists.Contains(sub)) { del = Delegate.Remove(del, sub); // return parameter result = del; bool record = Common.kDebugging; if (record) { // Some objects are written incorrectly and continually add a new delegate each time the game is loaded // without removing the old one. Fix these, but don't record them if (sub.Target is ICanHasTombObjectComponent) { record = false; } else if (sub.Target is CollectionDisplaySingleItem) { record = false; } else if (sub.Target is CookingProcess) { record = false; } } if (record) { if (first) { first = false; ErrorTrap.LogCorrection("Delegate: " + del); } string text = sub.ToString(); text += ": " + sub.Method + " (" + sub.Target + ")"; ErrorTrap.LogCorrection("Duplicate Delegate Call Dropped: " + text); } } else { exists.Add(sub); } } } return(result); }
protected void LogCorrection(string text) { ErrorTrap.LogCorrection(text); }