Beispiel #1
0
        /// <summary>
        /// Constructor
        /// </summary>
        public Ngbh(Interfaces.IProviderRegistry provider) : base()
        {
            this.provider = provider;


            this.id = new byte []
            {
                (byte)'H',
                (byte)'B',
                (byte)'G',
                (byte)'N'
            };

            this.Version = NgbhVersion.University;

            this.header = new byte []
            {
                0, 0, 0, 0,
                0x80, 0x00, 0x00, 0x00,
                0x80, 0x00, 0x00, 0x00
            };
            zonename = Helper.ToBytes("temperate", 9);
            zero     = new byte[0x10];
            preitems = new NgbhSlotList[0x02];
            for (int i = 0; i < preitems.Length; i++)
            {
                preitems[i] = new NgbhSlotList(this);
            }

            slota = new Collections.NgbhSlots(this, Data.NeighborhoodSlots.Lots);
            slotb = new Collections.NgbhSlots(this, Data.NeighborhoodSlots.Families);
            slotc = new Collections.NgbhSlots(this, Data.NeighborhoodSlots.Sims);
        }
Beispiel #2
0
        public void DeleteMemoryEchoes(Collections.NgbhItems items, uint ownerID)
        {
            int deletedCount       = 0;
            ExceptionBuilder trace = new ExceptionBuilder();

            trace.Append("Memories found:" + Helper.lbr);

            Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims);
            foreach (NgbhSlot slot in slots)
            {
                // skip my own memories?
                if (ownerID == slot.SlotID)
                {
                    continue;
                }

                SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[(ushort)slot.SlotID] as SDesc;
                Collections.NgbhItems simMemories = slot.ItemsB;

                Collections.NgbhItems memoryToRemove = new SimPe.Plugin.Collections.NgbhItems(null);
                for (int j = 0; j < simMemories.Length; j++)
                {
                    for (int i = 0; i < items.Length; i++)
                    {
                        NgbhItem item      = items[i];
                        NgbhItem simMemory = simMemories[j];

                        if (
                            simMemory.IsMemory && item.IsMemory &&
                            simMemory.Guid == item.Guid &&
                            ArrayEquals(simMemory.Data, item.Data) &&
                            !simMemory.Flags.IsVisible
                            )
                        {
                            memoryToRemove.Add(simMemory);                             // simMemory.RemoveFromParentB();
                        }
                    }
                }

                if (memoryToRemove.Count > 0)
                {
                    deletedCount += memoryToRemove.Count;
                    trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count);
                    foreach (NgbhItem item in memoryToRemove)
                    {
                        trace.AppendFormat("\t- {0}\r\n", item.ToString());
                    }
                    trace.Append("\t\r\n\r\n");
                    slot.ItemsB.Remove(memoryToRemove);
                }
            }

            if (deletedCount > 0)
            {
                Message.Show(String.Format("Deleted {0} memories from the sim pool", deletedCount) + Helper.lbr + Helper.lbr + trace.ToString());
            }
        }
Beispiel #3
0
        public NgbhSlots Clone(Ngbh newparent)
        {
            NgbhSlots ret = new NgbhSlots(newparent, type);

            foreach (NgbhSlot s in list)
            {
                ret.Add(s);
            }

            return(ret);
        }
Beispiel #4
0
        public Collections.NgbhItems GetItems(Data.NeighborhoodSlots id, uint inst)
        {
            Collections.NgbhSlots slots = Sims;
            if (id == Data.NeighborhoodSlots.Families || id == Data.NeighborhoodSlots.FamiliesIntern)
            {
                slots = Families;
            }

            if (id == Data.NeighborhoodSlots.Lots || id == Data.NeighborhoodSlots.LotsIntern)
            {
                slots = Lots;
            }

            NgbhSlot slot = slots.GetInstanceSlot(inst);

            if (slot != null)
            {
                return(slot.GetItems(id));
            }

            return(null);
        }
Beispiel #5
0
        private void miNuke_Activate(object sender, System.EventArgs e)
        {
            if (spc.SelectedSim != null)
            {
                Collections.NgbhSlots slots = this.Ngbh.GetSlots(Data.NeighborhoodSlots.Sims);
                if (slots != null)
                {
                    NgbhSlot slot = slots.GetInstanceSlot(spc.SelectedSim.Instance);
                    if (slot != null)
                    {
                        slot.RemoveMyMemories();
                        int deletedCount = slot.RemoveMemoriesAboutMe();

                        if (deletedCount > 0)
                        {
                            Message.Show(String.Format("Deleted {0} memories from the sim pool", deletedCount));
                        }

                        spc.Refresh();
                    }
                }
            }
        }
Beispiel #6
0
        /// <summary>
        /// 1. Delete my memories shared by others,
        /// 2. Delete others' memories whose subject is me
        /// </summary>
        /// <returns>Number of deleted Memories</returns>
        public int RemoveMemoriesAboutMe()
        {
            int deletedCount = 0;

            Collections.NgbhItems memoriesToRemove = new SimPe.Plugin.Collections.NgbhItems(null);

            Collections.NgbhSlots slots = Parent.GetSlots(Data.NeighborhoodSlots.Sims);
            foreach (NgbhSlot slot in slots)
            {
                memoriesToRemove.Clear();
                foreach (NgbhItem simMemory in slot.ItemsB)
                {
                    if (
                        simMemory.IsMemory && (

                            //1,
                            simMemory.SimInstance == this.SlotID ||

                            //2.
                            simMemory.OwnerInstance == this.SlotID
                            )
                        )
                    {
                        memoriesToRemove.Add(simMemory);
                    }
                }


                if (memoriesToRemove.Count > 0)
                {
                    deletedCount += memoriesToRemove.Count;
                    slot.ItemsB.Remove(memoriesToRemove);
                }
            }

            return(deletedCount);
        }
Beispiel #7
0
        public void FixNeighborhoodMemories()
        {
            int deletedCount = 0;
            int fixedCount   = 0;

            ExceptionBuilder trace = new ExceptionBuilder();

            trace.Append("Invalid memories found:" + Helper.lbr);

            Collections.NgbhSlots slots = this.GetSlots(Data.NeighborhoodSlots.Sims);

            foreach (NgbhSlot slot in slots)
            {
                SDesc simDesc = FileTable.ProviderRegistry.SimDescriptionProvider.SimInstance[slot.SlotID] as SDesc;
                Collections.NgbhItems simMemories = slot.ItemsB;

                ArrayList memoryToRemove = new ArrayList();
                ArrayList memoryToFix    = new ArrayList();


                NgbhItem lastSpamMemory = null;

                for (int j = 0; j < simMemories.Length; j++)
                {
                    NgbhItem simMemory = simMemories[j];

                    // skip tokens...
                    if (simMemory.IsMemory)
                    {
                        // ...and the lame "Met Unknown" memories
                        if (simMemory.SimInstance != 0)
                        {
                            // fix invalid sim instances
                            ushort inst = FileTable.ProviderRegistry.SimDescriptionProvider.GetInstance(simMemory.SimID);
                            if (simMemory.SimInstance != inst)
                            {
                                simMemory.SimInstance = inst;
                                memoryToFix.Add(simMemory);
                            }


                            if (simDesc == null)
                            {
                                memoryToRemove.Add(simMemory);
                            }
                        }

                        // it could be spam...
                        // collapse duplicate items
                        if (simMemory.IsSpam)
                        {
                            if (
                                lastSpamMemory != null &&
                                lastSpamMemory.Guid == simMemory.Guid &&
                                lastSpamMemory.SimInstance == simMemory.SimInstance
                                )
                            {
                                memoryToRemove.Add(simMemory);
                            }

                            lastSpamMemory = simMemory;
                        }
                        else
                        {
                            lastSpamMemory = null;
                        }
                    }
                }                 // for simMemories


                if (memoryToRemove.Count > 0 || memoryToFix.Count > 0)
                {
                    deletedCount += memoryToRemove.Count;
                    fixedCount   += memoryToFix.Count;

                    trace.AppendFormat("{0} {1}: {2} \r\n", simDesc.SimName, simDesc.SimFamilyName, memoryToRemove.Count + memoryToFix.Count);

                    foreach (NgbhItem item in memoryToFix)
                    {
                        trace.AppendFormat("[FIX]- {0}\r\n", item.ToString());
                    }

                    NgbhItem[] itemsToRemove = (NgbhItem[])memoryToRemove.ToArray(typeof(NgbhItem));
                    foreach (NgbhItem item in itemsToRemove)
                    {
                        trace.AppendFormat("[DEL]- {0}\r\n", item.ToString());
                    }

                    trace.Append("\t\r\n\r\n");
                    slot.ItemsB.Remove(itemsToRemove);
                }
            }

            if (deletedCount > 0 || fixedCount > 0)
            {
                Helper.ExceptionMessage(String.Format("Fixed/Deleted {0} invalid memories.", deletedCount + fixedCount), trace);
            }
        }