public static void RetargetRunes_OnCommand(CommandEventArgs e)
        {
            ArrayList regionList = new ArrayList();

            if (HaveRegions(e, regionList))
            {
                try
                {
                    LogHelper Logger = new LogHelper("retarget.log", e.Mobile, true);

                    foreach (Item item in World.Items.Values)
                    {
                        if (item is RecallRune)
                        {
                            RecallRune rune = (RecallRune)item;

                            for (int ix = 0; ix < regionList.Count; ix++)
                            {
                                if (rune.Marked && rune.TargetMap != null && (regionList[ix] as Region).Contains(rune.Target))
                                {
                                    object root = item.RootParent;

                                    if (root is Mobile)
                                    {
                                        if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                        {
                                            Logger.Log(LogType.Item, rune, rune.Description);
                                            rune.Target = new Point3D(0, 0, 0);
                                        }
                                    }
                                    else
                                    {
                                        Logger.Log(LogType.Item, rune, rune.Description);
                                        rune.Target = new Point3D(0, 0, 0);
                                    }
                                }
                            }
                        }
                        else if (item is Moonstone)
                        {
                            Moonstone stone = (Moonstone)item;

                            for (int ix = 0; ix < regionList.Count; ix++)
                            {
                                if (stone.Marked && (regionList[ix] as Region).Contains(stone.Destination))
                                {
                                    object root = item.RootParent;

                                    if (root is Mobile)
                                    {
                                        if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                        {
                                            Logger.Log(LogType.Item, stone, stone.Description);
                                            stone.Destination = new Point3D(0, 0, 0);
                                        }
                                    }
                                    else
                                    {
                                        Logger.Log(LogType.Item, stone, stone.Description);
                                        stone.Destination = new Point3D(0, 0, 0);
                                    }
                                }
                            }
                        }
                        else if (item is Runebook)
                        {
                            Runebook book = (Runebook)item;

                            for (int ix = 0; ix < regionList.Count; ix++)
                            {
                                for (int i = 0; i < book.Entries.Count; ++i)
                                {
                                    RunebookEntry entry = (RunebookEntry)book.Entries[i];

                                    if (entry.Map != null && (regionList[ix] as Region).Contains(entry.Location))
                                    {
                                        object root = item.RootParent;

                                        if (root is Mobile)
                                        {
                                            if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                            {
                                                Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}",
                                                                                             i,
                                                                                             entry.Description,
                                                                                             book.Description));

                                                entry.Location = new Point3D(0, 0, 0);
                                            }
                                        }
                                        else
                                        {
                                            Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}",
                                                                                         i,
                                                                                         entry.Description,
                                                                                         book.Description));

                                            entry.Location = new Point3D(0, 0, 0);
                                        }
                                    }
                                }
                            }
                        }
                    }

                    Logger.Finish();
                    e.Mobile.SendMessage("DONE search for runes.");

                    return;
                }
                catch (Exception exc)
                {
                    LogHelper.LogException(exc);
                    e.Mobile.SendMessage("Exception in [Retarget -- see console.");
                    System.Console.WriteLine("Exception in [Retarget: {0}", exc.Message);
                    System.Console.WriteLine(exc.StackTrace);
                    return;
                }
            }
            else
            {
                e.Mobile.SendMessage("Usage: [Retarget <-regionName|-type|-point|-RegionUID> <name|type|point|uid>");
            }
        }
示例#2
0
        public static void FindItem_OnCommand(CommandEventArgs e)
        {
            if (e.Length > 1)
            {
                LogHelper Logger = new LogHelper("finditem.log", e.Mobile, false);

                // Extract property & value from command parameters

                string sProp = e.GetString(0);
                string sVal  = "";

                if (e.Length > 2)
                {
                    sVal = e.GetString(1);

                    // Concatenate the strings
                    for (int argi = 2; argi < e.Length; argi++)
                    {
                        sVal += " " + e.GetString(argi);
                    }
                }
                else
                {
                    sVal = e.GetString(1);
                }

                Regex PattMatch = new Regex("= \"*" + sVal, RegexOptions.IgnoreCase);

                // Loop through assemblies and add type if has property

                Type[]     types;
                Assembly[] asms = ScriptCompiler.Assemblies;

                ArrayList MatchTypes = new ArrayList();

                for (int i = 0; i < asms.Length; ++i)
                {
                    types = ScriptCompiler.GetTypeCache(asms[i]).Types;

                    foreach (Type t in types)
                    {
                        if (typeof(Item).IsAssignableFrom(t))
                        {
                            // Reflect type
                            PropertyInfo[] allProps = t.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                            foreach (PropertyInfo prop in allProps)
                            {
                                if (prop.Name.ToLower() == sProp.ToLower())
                                {
                                    MatchTypes.Add(t);
                                }
                            }
                        }
                    }
                }

                // Loop items and check vs. types

                foreach (Item item in World.Items.Values)
                {
                    Type t     = item.GetType();
                    bool match = false;

                    foreach (Type MatchType in MatchTypes)
                    {
                        if (t == MatchType)
                        {
                            match = true;
                            break;
                        }
                    }

                    if (match == false)
                    {
                        continue;
                    }

                    // Reflect instance of type (matched)

                    if (PattMatch.IsMatch(Properties.GetValue(e.Mobile, item, sProp)))
                    {
                        Logger.Log(LogType.ItemSerial, item);
                    }
                }

                Logger.Finish();
            }
            else
            {
                // Badly formatted
                e.Mobile.SendMessage("Format: FindItem <property> <value>");
            }
        }
        public static void FindItemByType_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false)
                {
                    return;
                }

                string sProp = null;
                string sVal  = null;
                string name  = null;

                if (e.Length >= 1)
                {
                    name = e.GetString(0);

                    if (e.Length >= 2)
                    {
                        sProp = e.GetString(1);
                    }

                    if (e.Length >= 3)
                    {
                        sVal = e.GetString(2);
                    }

                    // if you are a GM the world needs to be in 'Build' mode to access this comand
                    if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false)
                    {
                        e.Mobile.SendMessage("The server must be in build mode for you to access this command.");
                        return;
                    }

                    PlayerMobile pm     = e.Mobile as PlayerMobile;
                    LogHelper    Logger = new LogHelper("FindItemByType.log", e.Mobile, false);

                    // reset jump table
                    pm.JumpIndex = 0;
                    pm.JumpList  = new ArrayList();
                    Type tx = ScriptCompiler.FindTypeByName(name);

                    if (tx != null)
                    {
                        foreach (Item item in World.Items.Values)
                        {
                            if (item != null && !item.Deleted && tx.IsAssignableFrom(item.GetType()))
                            {
                                // read the properties
                                PropertyInfo[] allProps = item.GetType().GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                                if (sProp != null)
                                {
                                    foreach (PropertyInfo prop in allProps)
                                    {
                                        if (prop.Name.ToLower() == sProp.ToLower())
                                        {
                                            bool   ok  = false;
                                            string val = Properties.GetValue(e.Mobile, item, sProp);

                                            // match a null value
                                            if ((val == null || val.Length == 0 || val.EndsWith("(-null-)", StringComparison.CurrentCultureIgnoreCase)) && (sVal == null || sVal.Length == 0))
                                            {
                                                ok = true;
                                            }

                                            // see if the property matches
                                            else if (val != null && sVal != null)
                                            {
                                                string[] toks = val.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                                                if (toks.Length >= 3 && toks[2].Equals(sVal, StringComparison.CurrentCultureIgnoreCase))
                                                {
                                                    ok = true;
                                                }
                                                else
                                                {
                                                    break;
                                                }
                                            }

                                            if (ok)
                                            {
                                                pm.JumpList.Add(item);
                                                Logger.Log(LogType.Item, item);
                                                break;
                                            }
                                        }
                                    }
                                }
                                else
                                {                                       // no prop to check, everything matches
                                    pm.JumpList.Add(item);
                                    Logger.Log(LogType.Item, item);
                                }
                            }
                        }
                    }
                    else
                    {
                        e.Mobile.SendMessage("{0} is not a recognized type.", name);
                    }
                    Logger.Finish();
                }
                else
                {
                    e.Mobile.SendMessage("Format: FindItemByType <type>");
                }
            }
            catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
        }
示例#4
0
        public static void FindItemByType_OnCommand(CommandEventArgs e)
        {
            try
            {
                if (e == null || e.Mobile == null || e.Mobile is PlayerMobile == false)
                {
                    return;
                }

                string name = null;

                if (e.Length >= 1)
                {
                    name = e.GetString(0);

                    // if you are a GM the world needs to be in 'Build' mode to access this comand
                    if (e.Mobile.AccessLevel < AccessLevel.Administrator && Core.Building == false)
                    {
                        e.Mobile.SendMessage("The server must be in build mode for you to access this command.");
                        return;
                    }

                    PlayerMobile pm     = e.Mobile as PlayerMobile;
                    LogHelper    Logger = new LogHelper("FindNPCResourceByType.log", e.Mobile, false);

                    // reset jump table
                    pm.JumpIndex = 0;
                    pm.JumpList  = new ArrayList();
                    Type tx = ScriptCompiler.FindTypeByName(name);

                    if (tx != null)
                    {
                        foreach (Mobile mob in World.Mobiles.Values)
                        {
                            if (mob is BaseVendor == false)
                            {
                                continue;
                            }

                            BaseVendor vendor = mob as BaseVendor;

                            if (vendor.Inventory == null || vendor.Inventory.Count == 0)
                            {
                                continue;
                            }

                            foreach (object ox in vendor.Inventory)
                            {
                                if (ox is SBInfo == false)
                                {
                                    continue;
                                }

                                SBInfo sbi = ox as SBInfo;

                                if (sbi.BuyInfo == null || sbi.BuyInfo.Count == 0)
                                {
                                    continue;
                                }

                                ArrayList bi = sbi.BuyInfo;

                                foreach (GenericBuyInfo gbi in bi)
                                {
                                    if (tx.IsAssignableFrom(gbi.Type))
                                    {
                                        pm.JumpList.Add(vendor);
                                        Logger.Log(LogType.Mobile, vendor);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        e.Mobile.SendMessage("{0} is not a recognized type.", name);
                    }
                    Logger.Finish();
                }
                else
                {
                    e.Mobile.SendMessage("Format: FindNPCResourceByType <type>");
                }
            }
            catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); }
        }
示例#5
0
            public void GoToPrison()
            {
                try
                {
                    if (m_Player == null || m_Player.Deleted)
                    {
                        return;
                    }

                    Account acct = m_Player.Account as Account;

                    // stable the players pets
                    StablePets(m_Staff, m_Player);

                    // drop holding
                    Item held = m_Player.Holding;
                    if (held != null)
                    {
                        held.ClearBounce();
                        if (m_Player.Backpack != null)
                        {
                            m_Player.Backpack.DropItem(held);
                        }
                    }
                    m_Player.Holding = null;

                    // move their items to the bank, overload if needed
                    Backpack  bag   = new Backpack();
                    ArrayList equip = new ArrayList(m_Player.Items);

                    if (m_Player.Backpack != null)
                    {
                        // count clothing items
                        int WornCount = 0;
                        foreach (Item i in equip)
                        {
                            if (Moongate.RestrictedItem(m_Player, i) == false)
                            {
                                continue;                                       // not clothes
                            }
                            else
                            {
                                WornCount++;
                            }
                        }

                        // Unequip any items being worn
                        foreach (Item i in equip)
                        {
                            if (Moongate.RestrictedItem(m_Player, i) == false)
                            {
                                continue;
                            }
                            else
                            {
                                m_Player.Backpack.DropItem(i);
                            }
                        }

                        // Get a count of all items in the player's backpack.
                        ArrayList items = new ArrayList(m_Player.Backpack.Items);

                        // Drop our new bag in the player's bank
                        m_Player.BankBox.DropItem(bag);

                        // Run through all items in player's pack, move them to the bag we just dropped in the bank
                        foreach (Item i in items)
                        {
                            m_Player.Backpack.RemoveItem(i);
                            bag.DropItem(i);
                        }
                    }

                    // handle imprisoning of logged out players
                    m_Player.MoveToWorld(m_Location, Map.Felucca);
                    if (m_Player.NetState == null)
                    {
                        m_Player.LogoutLocation = m_Location;
                        m_Player.Map            = Map.Internal;
                    }

                    // make them an inmate
                    m_Player.Inmate = true;

                    // Give them a Deathrobe, Stinger dagger, and a blank spell book
                    if (m_Player.Alive)
                    {
                        Item robe = new Server.Items.DeathRobe();
                        if (!m_Player.EquipItem(robe))
                        {
                            robe.Delete();
                        }
                    }

                    Item aiStinger = new Server.Items.AIStinger();
                    if (!m_Player.AddToBackpack(aiStinger))
                    {
                        aiStinger.Delete();
                    }

                    Item spellbook = new Server.Items.Spellbook();
                    if (!m_Player.AddToBackpack(spellbook))
                    {
                        spellbook.Delete();
                    }

                    m_Player.ShortTermCriminalCounts += 3;                                                              // how long you will stay
                    m_Player.LongTermCriminalCounts++;                                                                  // how many times you've been to prison

                    if (!m_Player.Alive && m_Player.NetState != null)
                    {
                        m_Player.CloseGump(typeof(Server.Gumps.ResurrectGump));
                        m_Player.SendGump(new Server.Gumps.ResurrectGump(m_Player, Server.Gumps.ResurrectMessage.Healer));
                    }

                    int sentence = (int)m_Player.ShortTermCriminalCounts * 4;                     // decay time in prison is 4 hours per count
                    m_Player.SendMessage("You have been imprisoned for {0} hours.", sentence);
                    m_Staff.SendMessage("{0} has been imprisoned for {1} hours.", m_Player.Name, sentence);

                    LogHelper Logger = new LogHelper("Prison.log", false, true);

                    Logger.Log(LogType.Mobile, m_Player, string.Format("{0}:{1}:{2}:{3}",
                                                                       m_Staff.Name,
                                                                       m_Staff.Location,
                                                                       m_Comment,
                                                                       sentence));
                    Logger.Finish();

                    Commands.CommandLogging.WriteLine(m_Staff, "{0} imprisoned {1}(Username: {2}) for {4} hours with reason: {3}.",
                                                      m_Staff.Name, m_Player.Name, acct.Username, m_Comment, sentence);
                    acct.Comments.Add(new AccountComment(m_Staff.Name, DateTime.Now + "\nTag count: " + (acct.Comments.Count + 1) + "\nImprisoned for " + sentence + " hours. Reason: " + m_Comment));
                }
                catch (Exception ex)
                {
                    LogHelper.LogException(ex);
                }
            }
示例#6
0
        public static void WipeMagicToTarget(Mobile from, object target)
        {
            try
            {
                Region region = null;
                if (target is HouseSign)
                {
                    BaseHouse bh = (target as HouseSign).Structure;
                    if (bh == null)
                    {
                        from.SendMessage("This house sign is not associated with any house.");
                        return;
                    }

                    region = bh.Region;
                    if (region == null)
                    {
                        from.SendMessage("This house is not associated with any region.");
                        return;
                    }
                }
                else if (target is TownshipStone)
                {
                    region = (target as TownshipStone).MyRegion;
                    if (region == null)
                    {
                        from.SendMessage("This township stone is not associated with any region.");
                        return;
                    }
                }

                from.SendMessage("Searching for runes marked for this region");

                LogHelper Logger = new LogHelper("WipeMagicToTarget.log", from, false);

                foreach (Item item in World.Items.Values)
                {
                    if (item is RecallRune)
                    {
                        RecallRune rune = (RecallRune)item;

                        if (rune.Marked && rune.TargetMap != null && region.Contains(rune.Target))
                        {
                            object root = item.RootParent;

                            if (root is Mobile)
                            {
                                if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                {
                                    Logger.Log(LogType.Item, rune, rune.Description);
                                    rune.Target = new Point3D(0, 0, 0);
                                }
                            }
                            else
                            {
                                Logger.Log(LogType.Item, rune, rune.Description);
                                rune.Target = new Point3D(0, 0, 0);
                            }
                        }
                    }
                    else if (item is Moonstone)
                    {
                        Moonstone stone = (Moonstone)item;

                        if (stone.Marked && region.Contains(stone.Destination))
                        {
                            object root = item.RootParent;

                            if (root is Mobile)
                            {
                                if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                {
                                    Logger.Log(LogType.Item, stone, stone.Description);
                                    stone.Destination = new Point3D(0, 0, 0);
                                }
                            }
                            else
                            {
                                Logger.Log(LogType.Item, stone, stone.Description);
                                stone.Destination = new Point3D(0, 0, 0);
                            }
                        }
                    }
                    else if (item is Runebook)
                    {
                        Runebook book = (Runebook)item;

                        for (int i = 0; i < book.Entries.Count; ++i)
                        {
                            RunebookEntry entry = (RunebookEntry)book.Entries[i];

                            if (entry.Map != null && region.Contains(entry.Location))
                            {
                                object root = item.RootParent;

                                if (root is Mobile)
                                {
                                    if (((Mobile)root).AccessLevel < AccessLevel.GameMaster)
                                    {
                                        Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}",
                                                                                     i,
                                                                                     entry.Description,
                                                                                     book.Description));

                                        entry.Location = new Point3D(0, 0, 0);
                                    }
                                }
                                else
                                {
                                    Logger.Log(LogType.Item, item, string.Format("{0}:{1}:{2}",
                                                                                 i,
                                                                                 entry.Description,
                                                                                 book.Description));

                                    entry.Location = new Point3D(0, 0, 0);
                                }
                            }
                        }
                    }
                }

                Logger.Finish();
                from.SendMessage("Done searching for runes withing house regions");

                // okay, now turn off all house security
                //int houseschecked =	Server.Multis.BaseHouse.SetSecurity(false);
                //e.Mobile.SendMessage("Setting {0} houses to insecure",houseschecked);

                return;
            }
            catch (Exception exc)
            {
                from.SendMessage("Exception in [findrunes -- see console.");
                System.Console.WriteLine("Exception in [findrunes: {0}", exc.Message);
                System.Console.WriteLine(exc.StackTrace);
                return;
            }
        }
示例#7
0
        public static void AddressDump_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            // check arguments
            if (e.Length < 1)
            {
                Usage(from);
                return;
            }

            int iChecked  = 0;
            int Reminders = 0;

            try
            {
                // loop through the accouints looking for current users
                ArrayList results = new ArrayList();

                // assume DaysActive
                if (e.Length == 1 && LooksLikeInt(e.GetString(0)))
                {
                    int days = 0;
                    try { days = Convert.ToInt32(e.GetString(0)); }
                    catch { Usage(from); return; }
                    foreach (Account acct in Accounts.Table.Values)
                    {
                        iChecked++;
                        // logged in the last n days.
                        if (Server.Engines.CronScheduler.EmailHelpers.RecentLogin(acct, days) == true)
                        {
                            if (ValidEmail(acct.EmailAddress))
                            {
                                Reminders++;
                                results.Add(acct.EmailAddress);
                            }
                        }
                    }
                }
                // assume activations since date
                else
                {
                    string buff = null;
                    for (int ix = 0; ix < e.Length; ix++)
                    {
                        buff += e.GetString(ix) + " ";
                    }

                    DateTime Since;
                    try { Since = DateTime.Parse(buff); }
                    catch { Usage(from); return; }

                    foreach (Account acct in Accounts.Table.Values)
                    {
                        iChecked++;
                        // account created since...
                        if (acct.Created >= Since && acct.EmailAddress != null)
                        {
                            if (ValidEmail(acct.EmailAddress))
                            {
                                Reminders++;
                                results.Add(acct.EmailAddress);
                            }
                        }
                    }
                }

                if (Reminders > 0)
                {
                    from.SendMessage("Logging {0} email address(es).", Reminders);
                    LogHelper Logger = new LogHelper("accountEmails.log", true);

                    foreach (object ox in results)
                    {
                        string address = ox as string;
                        if (address == null)
                        {
                            continue;
                        }
                        Logger.Log(LogType.Text, address);
                    }
                    Logger.Finish();
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                System.Console.WriteLine("Exception Caught in generic emailer: " + ex.Message);
                System.Console.WriteLine(ex.StackTrace);
            }

            return;
        }
示例#8
0
        public static void On_RHFile(CommandEventArgs e)
        {
            if (e.Arguments.Length != 1)
            {
                e.Mobile.SendMessage("Usage: [LoadCont <filename>");
                return;
            }

            try
            {
                int       loaded = 0;
                int       count;
                LogHelper log = new LogHelper(e.Arguments[0] + " LoadCont.log");
                log.Log(LogType.Text, String.Format("Reload process initiated by {0}, with {1} as backup data.", e.Mobile, e.Arguments[0]));

                using (FileStream idxfs = new FileStream(e.Arguments[0] + ".idx", FileMode.Open, FileAccess.Read))
                {
                    using (FileStream binfs = new FileStream(e.Arguments[0] + ".bin", FileMode.Open, FileAccess.Read))
                    {
                        GenericReader bin = new BinaryFileReader(new BinaryReader(binfs));
                        GenericReader idx = new BinaryFileReader(new BinaryReader(idxfs));

                        count = idx.ReadInt();
                        if (count == -1)
                        {
                            log.Log(LogType.Text, "No item data to reload.");                             // do nothing
                        }
                        else
                        {
                            ArrayList items = new ArrayList(count);
                            log.Log(LogType.Text, String.Format("Attempting to reload {0} items.", count));

                            Type[]   ctortypes = new Type[] { typeof(Serial) };
                            object[] ctorargs  = new object[1];

                            for (int i = 0; i < count; i++)
                            {
                                string type     = idx.ReadString();
                                Serial serial   = (Serial)idx.ReadInt();
                                long   position = idx.ReadLong();
                                int    length   = idx.ReadInt();

                                Type t = ScriptCompiler.FindTypeByFullName(type);
                                if (t == null)
                                {
                                    Console.WriteLine("Warning: Tried to load nonexistent type {0}. Ignoring item.", type);
                                    log.Log(String.Format("Warning: Tried to load nonexistent type {0}. Ignoring item.", type));
                                    continue;
                                }

                                ConstructorInfo ctor = t.GetConstructor(ctortypes);
                                if (ctor == null)
                                {
                                    Console.WriteLine("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type);
                                    log.Log(String.Format("Warning: Tried to load type {0} which has no serialization constructor. Ignoring item.", type));
                                    continue;
                                }

                                Item item = null;
                                try
                                {
                                    if (World.FindItem(serial) != null)
                                    {
                                        log.Log(LogType.Item, World.FindItem(serial), "Serial already in use!! Loading of saved item failed.");
                                    }
                                    else if (!World.IsReserved(serial))
                                    {
                                        log.Log(String.Format("Serial {0} is not reserved!! Loading of saved item failed.", serial));
                                    }
                                    else
                                    {
                                        ctorargs[0] = serial;
                                        item        = (Item)(ctor.Invoke(ctorargs));
                                    }
                                }
                                catch (Exception ex)
                                {
                                    LogHelper.LogException(ex);
                                    Console.WriteLine("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName);
                                    Console.WriteLine(ex.ToString());
                                    log.Log(String.Format("An exception occurred while trying to invoke {0}'s serialization constructor.", t.FullName));
                                    log.Log(ex.ToString());
                                }

                                if (item != null)
                                {
                                    World.FreeSerial(serial);

                                    World.AddItem(item);
                                    items.Add(new object[] { item, position, length });
                                    log.Log(String.Format("Successfully created item {0}", item));
                                }
                            }

                            for (int i = 0; i < items.Count; i++)
                            {
                                object[] entry    = (object[])items[i];
                                Item     item     = entry[0] as Item;
                                long     position = (long)entry[1];
                                int      length   = (int)entry[2];

                                if (item != null)
                                {
                                    bin.Seek(position, SeekOrigin.Begin);

                                    try
                                    {
                                        item.Deserialize(bin);

                                        // take care of parent hierarchy
                                        object p = item.Parent;
                                        if (p is Item)
                                        {
                                            ((Item)p).RemoveItem(item);
                                            item.Parent = null;
                                            ((Item)p).AddItem(item);
                                        }
                                        else if (p is Mobile)
                                        {
                                            ((Mobile)p).RemoveItem(item);
                                            item.Parent = null;
                                            ((Mobile)p).AddItem(item);
                                        }
                                        else
                                        {
                                            item.Delta(ItemDelta.Update);
                                        }

                                        item.ClearProperties();

                                        object rp = item.RootParent;
                                        if (rp is Item)
                                        {
                                            ((Item)rp).UpdateTotals();
                                        }
                                        else if (rp is Mobile)
                                        {
                                            ((Mobile)rp).UpdateTotals();
                                        }
                                        else
                                        {
                                            item.UpdateTotals();
                                        }

                                        if (bin.Position != (position + length))
                                        {
                                            throw new Exception(String.Format("Bad serialize on {0}", item));
                                        }

                                        log.Log(LogType.Item, item, "Successfully loaded.");
                                        loaded++;
                                    }
                                    catch (Exception ex)
                                    {
                                        LogHelper.LogException(ex);
                                        Console.WriteLine("Caught exception while deserializing {0}:", item);
                                        Console.WriteLine(ex.ToString());
                                        Console.WriteLine("Deleting item.");
                                        log.Log(String.Format("Caught exception while deserializing {0}:", item));
                                        log.Log(ex.ToString());
                                        log.Log("Deleting item.");
                                        item.Delete();
                                    }
                                }
                            }
                        }
                        idx.Close();
                        bin.Close();
                    }
                }

                Console.WriteLine("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded);
                log.Log(String.Format("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded));
                e.Mobile.SendMessage("Attempted to load {0} items: {1} loaded, {2} failed.", count, loaded, count - loaded);
                log.Finish();
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
                Console.WriteLine(ex.ToString());
                e.Mobile.SendMessage("Exception: {0}", ex.Message);
            }
        }
        private static void InvBox_Callback(Mobile from, Map map, Point3D start, Point3D end, object state)
        {
            LogHelper Logger = new LogHelper("inventory.log", true);

            Logger.Log(LogType.Text, string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
                                                   "Qty ---",
                                                   "Item ------------",
                                                   "Damage / Protection --",
                                                   "Durability -----",
                                                   "Accuracy -----",
                                                   "Exceptional",
                                                   "Slayer ----",
                                                   "Serial ----"));

            // Create rec and retrieve items within from bounding box callback
            // result
            Rectangle2D       rect  = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);
            IPooledEnumerable eable = map.GetItemsInBounds(rect);

            // Loop through and add objects returned
            foreach (object obj in eable)
            {
                if (m_ItemType == null || obj is BaseContainer)
                {
                    AddInv(obj);
                }
                else
                {
                    Type ot = obj.GetType();

                    if (ot.IsSubclassOf(m_ItemType) || ot == m_ItemType)
                    {
                        AddInv(obj);
                    }
                }
            }

            eable.Free();

            m_Inv.Sort();               // Sort results

            // Loop and log
            foreach (InvItem ir in m_Inv)
            {
                // ir.m_description += String.Format(" ({0})", it.Serial.ToString());
                string output = string.Format("{0}\t{1,-25}\t{7,-25}\t{2,-25}\t{3,-20}\t{4,-20}\t{5,-20}\t{6,-20}",
                                              ir.m_count + ",",
                                              (ir.GetDescription()) + ",",
                                              (ir.m_damage != null ? ir.m_damage : "N/A") + ",",
                                              (ir.m_durability != null ? ir.m_durability : "N/A") + ",",
                                              (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
                                              (ir.m_quality != null ? ir.m_quality : "N/A") + ",",
                                              (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
                                              ir.m_serial.ToString()
                                              );

                Logger.Log(LogType.Text, output);

                if (m_verbose)
                {
                    output = string.Format("{0}{1}{7}{2}{3}{4}{5}{6}",
                                           ir.m_count + ",",
                                           (ir.GetDescription()) + ",",
                                           (ir.m_damage != null ? ir.m_damage : "N/A") + ",",
                                           (ir.m_durability != null ? ir.m_durability : "N/A") + ",",
                                           (ir.m_accuracy != null ? ir.m_accuracy : "N/A") + ",",
                                           (ir.m_quality != null ? ir.m_quality : "N/A") + ",",
                                           (ir.m_slayer != null ? ir.m_slayer : "N/A") + ",",
                                           ir.m_serial.ToString()
                                           );

                    from.SendMessage(output);
                }
            }

            Logger.Count--;             // count-1 for header
            Logger.Finish();
        }