Ejemplo n.º 1
0
        public BOBSmallEntry(IGenericReader reader)
        {
            int version = reader.ReadEncodedInt();

            switch (version)
            {
            case 0:
            {
                string type = reader.ReadString();

                if (type != null)
                {
                    ItemType = AssemblyHandler.FindTypeByFullName(type);
                }

                RequireExceptional = reader.ReadBool();

                DeedType = (BODType)reader.ReadEncodedInt();

                Material  = (BulkMaterialType)reader.ReadEncodedInt();
                AmountCur = reader.ReadEncodedInt();
                AmountMax = reader.ReadEncodedInt();
                Number    = reader.ReadEncodedInt();
                Graphic   = reader.ReadEncodedInt();
                Price     = reader.ReadEncodedInt();

                break;
            }
            }
        }
Ejemplo n.º 2
0
        public static MLQuest ReadQuestRef(IGenericReader reader)
        {
            string typeName = reader.ReadString();

            if (typeName == null)
            {
                return(null); // not serialized
            }
            Type questType = AssemblyHandler.FindTypeByFullName(typeName);

            if (questType == null)
            {
                return(null); // no longer a type
            }
            return(FindQuest(questType));
        }
Ejemplo n.º 3
0
        public LargeBulkEntry(LargeBOD owner, IGenericReader reader)
        {
            Owner    = owner;
            m_Amount = reader.ReadInt();

            Type realType = null;

            var type = reader.ReadString();

            if (type != null)
            {
                realType = AssemblyHandler.FindTypeByFullName(type);
            }

            Details = new SmallBulkEntry(realType, reader.ReadInt(), reader.ReadInt());
        }
Ejemplo n.º 4
0
        public CAGObject(CAGCategory parent, XmlTextReader xml)
        {
            Parent = parent;

            if (xml.MoveToAttribute("type"))
            {
                Type = AssemblyHandler.FindTypeByFullName(xml.Value, false);
            }

            if (xml.MoveToAttribute("gfx"))
            {
                ItemID = XmlConvert.ToInt32(xml.Value);
            }

            if (xml.MoveToAttribute("hue"))
            {
                Hue = XmlConvert.ToInt32(xml.Value);
            }
        }
        public TalismanAttribute(IGenericReader reader)
        {
            var version = reader.ReadInt();

            var flags = (SaveFlag)reader.ReadEncodedInt();

            if (GetSaveFlag(flags, SaveFlag.Type))
            {
                Type = AssemblyHandler.FindTypeByFullName(reader.ReadString());
            }

            if (GetSaveFlag(flags, SaveFlag.Name))
            {
                Name = TextDefinition.Deserialize(reader);
            }

            if (GetSaveFlag(flags, SaveFlag.Amount))
            {
                Amount = reader.ReadEncodedInt();
            }
        }
        public BOBLargeSubEntry(IGenericReader reader)
        {
            var version = reader.ReadEncodedInt();

            switch (version)
            {
            case 0:
            {
                var type = reader.ReadString();

                if (type != null)
                {
                    ItemType = AssemblyHandler.FindTypeByFullName(type);
                }

                AmountCur = reader.ReadEncodedInt();
                Number    = reader.ReadEncodedInt();
                Graphic   = reader.ReadEncodedInt();

                break;
            }
            }
        }
Ejemplo n.º 7
0
        public static Type ReadType(Type[] referenceTable, IGenericReader reader)
        {
            int encoding = reader.ReadEncodedInt();

            switch (encoding)
            {
            default:
            {
                return(null);
            }

            case 0x01: // indexed
            {
                int index = reader.ReadEncodedInt();

                if (index >= 0 && index < referenceTable.Length)
                {
                    return(referenceTable[index]);
                }

                return(null);
            }

            case 0x02: // by name
            {
                string fullName = reader.ReadString();

                if (fullName == null)
                {
                    return(null);
                }

                return(AssemblyHandler.FindTypeByFullName(fullName, false));
            }
            }
        }
Ejemplo n.º 8
0
        public static Spell NewSpell(string name, Mobile caster, Item scroll)
        {
            for (int i = 0; i < m_CircleNames.Length; ++i)
            {
                Type t = AssemblyHandler.FindTypeByFullName($"Server.Spells.{m_CircleNames[i]}.{name}");

                if (t?.IsSubclassOf(typeof(SpecialMove)) == false)
                {
                    m_Params[0] = caster;
                    m_Params[1] = scroll;

                    try
                    {
                        return((Spell)Activator.CreateInstance(t, m_Params));
                    }
                    catch
                    {
                        // ignored
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 9
0
        public static void ProfileWorld(string type, string opFile)
        {
            try
            {
                var types = new List <Type>();

                using (var bin = new BinaryReader(
                           new FileStream(
                               string.Format("Saves/{0}/{0}.tdb", type),
                               FileMode.Open,
                               FileAccess.Read,
                               FileShare.Read
                               )
                           ))
                {
                    var count = bin.ReadInt32();

                    for (var i = 0; i < count; ++i)
                    {
                        types.Add(AssemblyHandler.FindTypeByFullName(bin.ReadString()));
                    }
                }

                long total = 0;

                var table = new Dictionary <Type, int>();

                using (var bin = new BinaryReader(
                           new FileStream(
                               string.Format("Saves/{0}/{0}.idx", type),
                               FileMode.Open,
                               FileAccess.Read,
                               FileShare.Read
                               )
                           ))
                {
                    var count = bin.ReadInt32();

                    for (var i = 0; i < count; ++i)
                    {
                        var typeID  = bin.ReadInt32();
                        var serial  = bin.ReadInt32();
                        var pos     = bin.ReadInt64();
                        var length  = bin.ReadInt32();
                        var objType = types[typeID];

                        while (objType != null && objType != typeof(object))
                        {
                            table[objType] = length + (table.TryGetValue(objType, out var value) ? value : 0);
                            objType        = objType.BaseType;
                            total         += length;
                        }
                    }
                }

                var list = table.ToList();

                list.Sort(new CountSorter());

                using var op = new StreamWriter(opFile);
                op.WriteLine("# Profile of world {0}", type);
                op.WriteLine("# Generated on {0}", Core.Now);
                op.WriteLine();
                op.WriteLine();

                list.ForEach(
                    kvp =>
                    op.WriteLine("{0}\t{1:F2}%\t{2}", kvp.Value, 100.0 * kvp.Value / total, kvp.Key)
                    );
            }
            catch
            {
                // ignored
            }
        }