コード例 #1
0
ファイル: CSS.cs プロジェクト: evildude807/kaltar
        public override void Load(BinaryReader idx, BinaryReader tdb, BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            m_Loaded = new Hashtable();

            switch (version)
            {
                case 0:
                    {
                        int keys = reader.ReadInt();
                        for (int i = 0; i < keys; i++)
                        {
                            School school = (School)reader.ReadInt();
                            ArrayList valuelist = new ArrayList();

                            int values = reader.ReadInt();
                            for (int j = 0; j < values; j++)
                            {
                                valuelist.Add(new CSpellInfo(reader));
                            }

                            m_Loaded.Add(school, valuelist);
                        }

                        CSSettings.FullSpellbooks = reader.ReadBool();
                        PrevVersion = reader.ReadInt();

                        Refresh();
                        Update();
                        break;
                    }
            }
        }
コード例 #2
0
        private IAnimationFrame[] LoadAnimation(BinaryFileReader reader, AnimationFrame.SittingTransformation sitting)
        {
            ushort[] palette = GetPalette(reader); // 0x100 * 2 = 0x0200 bytes
            int read_start = (int)reader.Position; // save file position after palette.

            int frameCount = reader.ReadInt(); // 0x04 bytes

            int[] lookups = new int[frameCount]; // frameCount * 0x04 bytes
            for (int i = 0; i < frameCount; ++i) { lookups[i] = reader.ReadInt(); }

            IAnimationFrame[] frames = new AnimationFrame[frameCount];
            for (int i = 0; i < frameCount; ++i)
            {
                if (lookups[i] < lookups[0])
                {
                    frames[i] = AnimationFrame.Empty; // Fix for broken animations, per issue13
                }
                else
                {
                    reader.Seek(read_start + lookups[i], SeekOrigin.Begin);
                    frames[i] = new AnimationFrame(m_Graphics, palette, reader, sitting);
                }
            }
            return frames;
        }
コード例 #3
0
        public static void OnLoad()
        {
            //don't load the file if it don't exist!
            if (!File.Exists(Path.Combine(SAVE_PATH, FILENAME)))
            {
                return;
            }

            using (
                var bin = new FileStream(Path.Combine(SAVE_PATH, FILENAME), FileMode.Open, FileAccess.Read,
                                         FileShare.Read))
            {
                GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                int version = reader.ReadInt();

                int count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    GameData.Add(new BoardGameData(reader));
                }

                reader.End();
            }
        }
コード例 #4
0
        public static AnimationFrame[] GetAnimation(BinaryFileReader reader)
        {
            uint[] palette    = getPalette(reader);   // 0x100 * 2 = 0x0200 bytes
            int    read_start = (int)reader.Position; // save file position after palette.

            int frameCount = reader.ReadInt();        // 0x04 bytes

            int[] lookups = new int[frameCount];      // frameCount * 0x04 bytes
            for (int i = 0; i < frameCount; ++i)
            {
                lookups[i] = reader.ReadInt();
            }

            AnimationFrame[] frames = new AnimationFrame[frameCount];
            for (int i = 0; i < frameCount; ++i)
            {
                if (lookups[i] < lookups[0])
                {
                    frames[i] = AnimationFrame.Empty; // Fix for broken animations, per issue13
                }
                else
                {
                    reader.Seek(read_start + lookups[i], SeekOrigin.Begin);
                    frames[i] = new AnimationFrame(m_graphics, palette, reader);
                }
            }
            return(frames);
        }
コード例 #5
0
ファイル: Data.cs プロジェクト: furkanugur/imaginenation
        public static void LoadMsgs()
        {
            if (!File.Exists(Path.Combine(General.SavePath, "Pms.bin")))
            {
                return;
            }

            using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "Pms.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                int version = reader.ReadInt();

                Mobile m     = null;
                int    count = reader.ReadInt();
                for (int i = 0; i < count; ++i)
                {
                    m = reader.ReadMobile();
                    if (m != null)
                    {
                        GetData(m).LoadMsgs(reader);
                    }
                    else
                    {
                        (new Data()).LoadMsgs(reader);
                    }
                }
            }
        }
コード例 #6
0
        public override void Load(BinaryReader idx, BinaryReader tdb, BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            m_Loaded = new Hashtable();

            switch (version)
            {
            case 0:
            {
                int keys = reader.ReadInt();
                for (int i = 0; i < keys; i++)
                {
                    School    school    = (School)reader.ReadInt();
                    ArrayList valuelist = new ArrayList();

                    int values = reader.ReadInt();
                    for (int j = 0; j < values; j++)
                    {
                        valuelist.Add(new CSpellInfo(reader));
                    }

                    m_Loaded.Add(school, valuelist);
                }

                CSSettings.FullSpellbooks = reader.ReadBool();
                PrevVersion = reader.ReadInt();

                Refresh();
                Update();
                break;
            }
            }
        }
コード例 #7
0
        AAnimationFrame[] LoadAnimation(BinaryFileReader reader, int uniqueAnimationIndex, AnimationFrame.SittingTransformation sitting)
        {
            var palette    = GetPalette(reader);   // 0x100 * 2 = 0x0200 bytes
            var read_start = (int)reader.Position; // save file position after palette.
            var frameCount = reader.ReadInt();     // 0x04 bytes
            var lookups    = new int[frameCount];  // frameCount * 0x04 bytes

            for (var i = 0; i < frameCount; ++i)
            {
                lookups[i] = reader.ReadInt();
            }
            var frames = new AnimationFrame[frameCount];

            for (var i = 0; i < frameCount; ++i)
            {
                if (lookups[i] < lookups[0])
                {
                    frames[i] = AnimationFrame.NullFrame; // Fix for broken animations, per issue13
                }
                else
                {
                    reader.Seek(read_start + lookups[i], SeekOrigin.Begin);
                    frames[i] = new AnimationFrame(uniqueAnimationIndex + (i & 0xff), _graphics, palette, reader, sitting);
                }
            }
            return(frames);
        }
コード例 #8
0
        private static void LoadLists()
        {
            if (!File.Exists(SaveFile))
            {
                return;
            }

            using (FileStream stream = new FileStream(SaveFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int count = reader.ReadInt();

                for (int i = 0; i < count; i++)
                {
                    int serial = reader.ReadInt();

                    if (serial > -1)
                    {
                        Mobile   m    = World.FindMobile((Serial)serial);
                        ChatInfo info = new ChatInfo(reader);

                        if (m != null && !m.Deleted)
                        {
                            if (info != null && !_userListTable.ContainsKey(m))
                            {
                                _userListTable.Add(m, info);
                            }
                        }
                    }
                }
            }

            ChatMessageManager.DeserializeMessages();
        }
コード例 #9
0
        private static void OnLoad()
        {
            try{
                if (!File.Exists(Path.Combine("Saves/Commands/", "Commands.bin")))
                {
                    return;
                }

                using (FileStream bin = new FileStream(Path.Combine("Saves/Commands/", "Commands.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                    int version = reader.ReadInt();

                    int count = reader.ReadInt();

                    object[] obj;
                    for (int i = 0; i < count; ++i)
                    {
                        obj    = new object[3];
                        obj[0] = reader.ReadString();
                        obj[1] = reader.ReadString();
                        obj[2] = reader.ReadInt();
                        s_InitInfo.Add(obj);
                    }
                }
            }catch { Errors.Report("Commands-> OnLoad"); }
        }
コード例 #10
0
        /// <summary>
        /// Loads serialized data
        /// </summary>
        private static void OnWorldLoad()
        {
            if (!File.Exists(DataFile))
            {
                return;
            }

            using (FileStream stream = new FileStream(DataFile, FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int version = reader.ReadInt();

                switch (version)
                {
                case 0:
                    int tableCount = reader.ReadInt();
                    PerkTable = new Dictionary <Player, Tuple <Perk, Perk> >(tableCount);

                    Player player;
                    Perk   p1, p2;

                    try
                    {
                        for (int i = 0; i < tableCount; i++)
                        {
                            player = reader.ReadMobile <Player>();

                            if (player == null || player.Deleted)
                            {
                                continue;
                            }

                            ConstructorInfo ctor = GetPerkCtor(reader.ReadString());
                            p1 = ctor.Invoke(new object[] { reader }) as Perk;

                            ctor = GetPerkCtor(reader.ReadString());
                            p2   = ctor.Invoke(new object[] { reader }) as Perk;

                            PerkTable[player] = Tuple.Create <Perk, Perk>(p1, p2);
                        }
                    }

                    catch (Exception e)
                    {
                        Utilities.ExceptionManager.LogException("Perk", e);
                    }

                    break;
                }

                reader.Close();
            }
        }
コード例 #11
0
        public override void Load(BinaryReader idx, BinaryReader tdb, BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            m_CategoryList = new List <PGCategory>();

            for (int i = reader.ReadInt(); i > 0; i--)
            {
                m_CategoryList.Add(new PGCategory(reader));
            }
        }
コード例 #12
0
        private static void EventSink_WorldLoad()
        {
            try
            {
                Console.Write("Loading SectorNodes...");
                DateTime dt = DateTime.Now;
                using (FileStream fs = new FileStream("Data/SectorPathData.dat", FileMode.Open))
                {
                    using (BinaryReader br = new BinaryReader(fs))
                    {
                        BinaryFileReader reader = new BinaryFileReader(br);

                        if (reader.ReadInt() != (Map.Felucca.Width >> Map.SectorShift))
                        {
                            throw new Exception("SectorNode data has different width than current map.");
                        }
                        if (reader.ReadInt() != (Map.Felucca.Height >> Map.SectorShift))
                        {
                            throw new Exception("SectorNode data has different height than current map.");
                        }

                        m_Nodes = new SectorNode[Map.Felucca.Width >> Map.SectorShift, Map.Felucca.Height >> Map.SectorShift];

                        for (int y = 0; y < (Map.Felucca.Height >> Map.SectorShift); y++)
                        {
                            for (int x = 0; x < (Map.Felucca.Width >> Map.SectorShift); x++)
                            {
                                m_Nodes[x, y] = new SectorNode();
                            }
                        }

                        for (int y = 0; y < (Map.Felucca.Height >> Map.SectorShift); y++)
                        {
                            for (int x = 0; x < (Map.Felucca.Width >> Map.SectorShift); x++)
                            {
                                m_Nodes[x, y].Deserialize(reader);
                            }
                        }

                        reader.Close();
                    }
                }
                Console.WriteLine("done in {0}ms.", (DateTime.Now - dt).TotalMilliseconds);
            }
            catch (Exception e)
            {
                LogHelper.LogException(e);
                Console.WriteLine("error:");
                Console.WriteLine(e.Message);
                Console.WriteLine("SectorNode data must be recomputed.");
                m_Nodes = null;
            }
        }
コード例 #13
0
ファイル: PlayerMacros.cs プロジェクト: uotools/JuicyUO
        private bool Unserialize(BinaryFileReader reader)
        {
            uint magic = reader.ReadUInt();

            if (magic != MAGIC)
            {
                return(false);
            }

            if (m_Macros == null)
            {
                m_Macros = new List <Action>();
            }
            m_Macros.Clear();

            int version = reader.ReadInt();
            int count   = reader.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Action action = new Action();
                action.Keystroke = (WinKeys)reader.ReadUShort();
                action.Ctrl      = reader.ReadBool();
                action.Alt       = reader.ReadBool();
                action.Shift     = reader.ReadBool();
                reader.ReadBool(); // unused filler byte

                int macroCount = reader.ReadUShort();
                for (int j = 0; j < macroCount; j++)
                {
                    int type = reader.ReadInt();
                    Macro.ValueTypes valueType = (Macro.ValueTypes)reader.ReadByte();
                    if (valueType == Macro.ValueTypes.Integer)
                    {
                        action.Macros.Add(new Macro((MacroType)type, reader.ReadInt()));
                    }
                    else if (valueType == Macro.ValueTypes.String)
                    {
                        action.Macros.Add(new Macro((MacroType)type, reader.ReadString()));
                    }
                    else
                    {
                        action.Macros.Add(new Macro((MacroType)type));
                    }
                }

                m_Macros.Add(action);
            }

            return(true);
        }
コード例 #14
0
ファイル: PlayerMacros.cs プロジェクト: BclEx/object-assets
        private bool Unserialize(BinaryFileReader r)
        {
            var magic = r.ReadUInt();

            if (magic != MAGIC)
            {
                return(false);
            }

            if (_macros == null)
            {
                _macros = new List <Action>();
            }
            _macros.Clear();
            var version = r.ReadInt();
            var count   = r.ReadInt();

            for (var i = 0; i < count; i++)
            {
                var action = new Action();
                action.Keystroke = (WinKeys)r.ReadUShort();
                action.Ctrl      = r.ReadBool();
                action.Alt       = r.ReadBool();
                action.Shift     = r.ReadBool();
                r.ReadBool(); // unused filler byte

                var macroCount = r.ReadUShort();
                for (var j = 0; j < macroCount; j++)
                {
                    var type      = r.ReadInt();
                    var valueType = (Macro.ValueTypes)r.ReadByte();
                    if (valueType == Macro.ValueTypes.Integer)
                    {
                        action.Macros.Add(new Macro((MacroType)type, r.ReadInt()));
                    }
                    else if (valueType == Macro.ValueTypes.String)
                    {
                        action.Macros.Add(new Macro((MacroType)type, r.ReadString()));
                    }
                    else
                    {
                        action.Macros.Add(new Macro((MacroType)type));
                    }
                }
                _macros.Add(action);
            }

            return(true);
        }
コード例 #15
0
        public void Deserialize(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            if (version >= 0)
            {
                m_CombatantMobile = reader.ReadMobile() as PlayerMobile;
                m_combatRating    = reader.ReadInt();

                m_Rank = (CombatRank)reader.ReadInt();

                m_totalDeaths = reader.ReadInt();
                m_totalKills  = reader.ReadInt();
            }
        }
コード例 #16
0
        public static void LoadData()
        {
            if (File.Exists(SavePath))
            {
                using (FileStream fs = new FileStream(SavePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        BinaryReader     br     = new BinaryReader(fs);
                        BinaryFileReader reader = new BinaryFileReader(br);

                        int version = reader.ReadInt();

                        int count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            Serial   serial = reader.ReadInt();
                            DuelInfo info   = new DuelInfo(null);

                            info.Deserialize(reader);

                            m_Infos.Add(serial, info);
                        }

                        count = reader.ReadInt();

                        for (int i = 0; i < count; ++i)
                        {
                            DuelArena arena = new DuelArena("Loading...");
                            arena.Deserialize(reader);

                            m_Arenas.Add(arena);
                        }

                        m_Enabled = reader.ReadBool();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e);
                    }
                    finally
                    {
                        fs.Close();
                    }
                }
            }
        }
コード例 #17
0
        private static void OnLoad()
        {
            if (!File.Exists(Path.Combine(SavePath, SaveFile)))
            {
                return;
            }

            using (FileStream bin = new FileStream(Path.Combine(SavePath, SaveFile), FileMode.Open, FileAccess.Read, FileShare.Read))
            {
                GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                m_LastResetTime = reader.ReadDateTime();

                int count = reader.ReadInt();

                for (int i = 0; i < count; ++i)
                {
                    Mobile mobile = reader.ReadMobile();

                    MobileRateInfo info = new MobileRateInfo();

                    info.Deserialize(reader);

                    if (mobile != null)
                    {
                        MobileRateInfo.Entries.Add(mobile, info);
                    }
                }
            }
        }
コード例 #18
0
        private static void Deserialize()
        {
            if (File.Exists(m_FilePath))
            {
                using (FileStream fs = new FileStream(m_FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        BinaryReader     br     = new BinaryReader(fs);
                        BinaryFileReader reader = new BinaryFileReader(br);

                        int version = reader.ReadInt();

                        if (version != Version)
                        {
                            NewVersion();
                        }
                    }

                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    finally
                    {
                        fs.Close();
                    }
                }
            }
        }
コード例 #19
0
        public static void OnLoad()
        {
            for (int mapId = 0; mapId < RegrowthMasterLookupTable.Count; ++mapId)
            {
                string   filename     = Path.Combine(UltimaLiveSettings.LumberHarvestFallenTreeSaveLocation, "TreeLocations." + mapId);
                FileInfo treeFileInfo = new FileInfo(filename);

                if (treeFileInfo.Exists)
                {
                    using (FileStream fs = new FileStream(filename, FileMode.Open))
                    {
                        using (BinaryReader br = new BinaryReader(fs))
                        {
                            GenericReader reader = new BinaryFileReader(br);

                            while (fs.Position < fs.Length)
                            {
                                Point3D p      = reader.ReadPoint3D();
                                int     itemId = reader.ReadInt();
                                if (!RegrowthMasterLookupTable[mapId].ContainsKey(p))
                                {
                                    RegrowthMasterLookupTable[mapId].Add(p, itemId);
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #20
0
        public static void LoadHistory(Mobile player)
        {
            m_History.Remove(player);
            m_History[player] = new ArrayList();

            try
            {
                if (!Directory.Exists("Saves/ResourcePool"))
                {
                    Directory.CreateDirectory("Saves/ResourcePool");
                }
                if (!Directory.Exists("Saves/ResourcePool/TransactionHistories"))
                {
                    Directory.CreateDirectory("Saves/ResourcePool/TransactionHistories");
                }

                FileStream       fs     = new FileStream("Saves/ResourcePool/TransactionHistories/" + player.Serial.Value.ToString() + ".dat", FileMode.Open, FileAccess.Read);
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(fs));
                for (int i = reader.ReadInt(); i > 0; i--)
                {
                    ((ArrayList)m_History[player]).Add(new ResourceTransaction(reader));
                }
                fs.Close();
            }
            catch (FileNotFoundException) { }
        }
コード例 #21
0
        public void Deserialize()
        {
            FileInfo info = new FileInfo("Data/VoteSystem.cfg");

            if (!info.Exists)
            {
                info.Create().Close();
            }

            if (info.Length == 0)
            {
                return;
            }

            using (BinaryReader br = new BinaryReader(info.OpenRead()))
            {
                GenericReader reader = new BinaryFileReader(br);

                int version = reader.ReadInt();

                switch (version)
                {
                case 0:
                {
                    _DefaultName     = reader.ReadString();
                    _DefaultURL      = reader.ReadString();
                    _DefaultCoolDown = reader.ReadTimeSpan();
                } break;
                }
            }
        }
コード例 #22
0
        public bool Unserialize(BinaryFileReader reader)
        {
            string id = reader.ReadString();

            if (id != c_SerializeIdentifier)
            {
                return(false);
            }
            int version = reader.ReadInt();

            if (version >= 0)
            {
                // version 0
                // 16 byte header
                m_PaletteZero = reader.ReadByte();
                for (int i = 0; i < 4; i++)
                {
                    m_Palettes[i] = reader.ReadByte();
                }
                for (int i = 0; i < 3; i++)
                {
                    reader.ReadByte();
                }

                m_Tilegfx.Reset();
                m_Tilegfx.NextIndex = reader.ReadInt();
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    int  index = reader.ReadInt();
                    byte tile  = reader.ReadByte();
                    byte page  = reader.ReadByte();
                    m_Tilegfx.AddIndexTilePage(index, tile, page);
                }

                for (int i = 0; i < TilesPerSet; i++)
                {
                    for (int j = 0; j < 4; j++)
                    {
                        m_Metatiles[i][j] = reader.ReadInt();
                    }
                    m_Bitfields[i]  = reader.ReadByte();
                    m_Attributes[i] = reader.ReadByte();
                }
            }
            return(true);
        }
コード例 #23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="KinCityData"/> class.
        /// </summary>
        /// <param name="reader">The reader.</param>
        public KinCityData(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 2:
            {
                m_Treasury = reader.ReadInt();
                m_TaxRate  = reader.ReadDouble();
                goto case 1;
            }

            case 1:
            {
                m_UnassignedGuardSlots = reader.ReadInt();
                goto case 0;
            }

            case 0:
            {
                m_City                = (KinFactionCities)reader.ReadInt();
                m_ControlingKin       = (IOBAlignment)reader.ReadInt();
                m_CaptureTime         = reader.ReadDeltaTime();
                m_CityLeader          = (PlayerMobile)reader.ReadMobile();
                m_IsVotingStage       = reader.ReadBool();
                m_Sigil               = (KinSigil)reader.ReadItem();
                m_ControlPoints       = reader.ReadInt();
                m_ControlPointDelta   = reader.ReadInt();
                m_NPCFlags            = (NPCFlags)reader.ReadInt();
                m_GuardOption         = (GuardOptions)reader.ReadInt();
                m_LastGuardChangeTime = reader.ReadDeltaTime();

                int length = reader.ReadInt();

                if (length > 0)
                {
                    for (int i = 0; i < length; ++i)
                    {
                        m_BeneficiaryDataList.Add(new BeneficiaryData(reader));
                    }
                }

                break;
            }
            }
        }
コード例 #24
0
        unsafe void ReadStaticTexture(int index, out Texture2D texture)
        {
            texture = null;
            int  length, extra;
            bool is_patched;
            // get a reader inside Art.Mul
            BinaryFileReader reader = m_FileIndex.Seek(index, out length, out extra, out is_patched);

            if (reader == null)
            {
                return;
            }
            reader.ReadInt(); // don't need this, see Art.mul file format.
            // get the dimensions of the texture
            int width  = reader.ReadShort();
            int height = reader.ReadShort();

            if (width <= 0 || height <= 0)
            {
                return;
            }
            // read the texture data!
            ushort[] lookups = reader.ReadUShorts(height);
            ushort[] data    = reader.ReadUShorts(length - lookups.Length * 2 - 8);
            Metrics.ReportDataRead(sizeof(ushort) * (data.Length + lookups.Length + 2));
            ushort[] pixels = new ushort[width * height];
            fixed(ushort *pData = pixels)
            {
                ushort *dataRef = pData;
                int     i;

                for (int y = 0; y < height; y++, dataRef += width)
                {
                    i = lookups[y];

                    ushort *start = dataRef;

                    int count, offset;

                    while (((offset = data[i++]) + (count = data[i++])) != 0)
                    {
                        start += offset;
                        ushort *end = start + count;

                        while (start < end)
                        {
                            ushort color   = data[i++];
                            *      start++ = (ushort)(color | 0x8000);
                        }
                    }
                }
            }

            texture = new Texture2D(m_Graphics, width, height, false, SurfaceFormat.Bgra5551);
            texture.SetData(pixels);
            m_StaticPicking.Set(index, width, height, pixels);
            return;
        }
コード例 #25
0
        public unsafe AnimationFrame(GraphicsDevice graphics, uint[] palette, BinaryFileReader reader)
        {
            int xCenter = reader.ReadShort();
            int yCenter = reader.ReadShort();

            int width  = reader.ReadUShort();
            int height = reader.ReadUShort();

            // Fix for animations with no IO.
            if ((width == 0) || (height == 0))
            {
                m_Texture = null;
                return;
            }

            uint[] data = new uint[width * height];

            int header;

            int xBase = xCenter - 0x200;
            int yBase = (yCenter + height) - 0x200;

            fixed(uint *pData = data)
            {
                uint *dataRef = pData;
                int   delta   = width;

                int dataRead = 0;

                dataRef += xBase;
                dataRef += (yBase * delta);

                while ((header = reader.ReadInt()) != 0x7FFF7FFF)
                {
                    header ^= DoubleXor;

                    uint *cur = dataRef + ((((header >> 12) & 0x3FF) * delta) + ((header >> 22) & 0x3FF));
                    uint *end = cur + (header & 0xFFF);

                    int    filecounter = 0;
                    byte[] filedata    = reader.ReadBytes(header & 0xFFF);

                    while (cur < end)
                    {
                        *cur++ = palette[filedata[filecounter++]];
                    }

                    dataRead += header & 0xFFF;
                }

                Metrics.ReportDataRead(dataRead);
            }

            m_Center = new Microsoft.Xna.Framework.Point(xCenter, yCenter);

            m_Texture = new Texture2D(graphics, width, height);
            m_Texture.SetData <uint>(data);
        }
コード例 #26
0
        public static void LoadBackup(Mobile mobile, ArrayList ArgsList, string filePath)
        {
            ArrayList HideSpawnerList   = (ArrayList)ArgsList[6];
            ArrayList MSGCheckBoxesList = (ArrayList)ArgsList[13];

            MC.SetProcess(Process.LoadBackup);

            FileStream       fs;
            BinaryFileReader reader;

            mobile.SendMessage("Loading backup file...");

            try
            {
                fs     = new FileStream(filePath, (FileMode)3, (FileAccess)1, (FileShare)1);
                reader = new BinaryFileReader(new BinaryReader(fs));
            }
            catch (Exception ex)
            {
                MC.SetProcess(Process.None);

                ArgsList[2] = "Load Backup File";
                ArgsList[4] = String.Format("Exception caught:\n{0}", ex);

                mobile.SendGump(new FileBrowserGump(mobile, ArgsList));

                return;
            }

            int amountOfSpawners = reader.ReadInt();
            int cnt = 0;

            for (int i = 0; i < amountOfSpawners; i++)
            {
                if (Deserialize((GenericReader)reader))
                {
                    HideSpawnerList.Add((bool)false);
                    MSGCheckBoxesList.Add((bool)false);

                    cnt++;
                }
            }

            if (fs != null)
            {
                fs.Close();
            }

            MC.SetProcess(Process.None);

            ArgsList[2]  = "Load Backup File";
            ArgsList[4]  = String.Format("Loading of backup file complete. {0} Mega Spawner{1} been installed.", cnt, cnt == 1 ? " has" : "s have");
            ArgsList[6]  = HideSpawnerList;
            ArgsList[13] = MSGCheckBoxesList;

            mobile.SendGump(new FileMenuGump(mobile, ArgsList));
        }
コード例 #27
0
        private static void Deserialize(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            if (version >= 0)
            {
                int profileCount = reader.ReadInt();
                if (profileCount > 0)
                {
                    for (int z = 0; z < profileCount; z++)
                    {
                        CombatantProfile p = new CombatantProfile();
                        p.Deserialize(reader);
                        m_CombatProfiles.Add(p);
                    }
                }
            }
        }
コード例 #28
0
        public static void Load()
        {
            try
            {
                if (!File.Exists(Path.Combine(General.SavePath, "Channels.bin")))
                {
                    PredefinedChannels();
                    return;
                }

                using (FileStream bin = new FileStream(Path.Combine(General.SavePath, "Channels.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                    int version = reader.ReadInt();

                    int     count = reader.ReadInt();
                    Channel c;
                    for (int i = 0; i < count; ++i)
                    {
                        c = Activator.CreateInstance(ScriptCompiler.FindTypeByFullName(reader.ReadString())) as Channel;
                        if (c == null)
                        {
                            c = new Channel();
                            c.Load(reader);
                            s_Channels.Remove(c);
                        }
                        else
                        {
                            c.Load(reader);
                        }
                    }
                }

                PredefinedChannels();
            }
            catch (Exception e)
            {
                Errors.Report(General.Local(186));
                Console.WriteLine(e.Message);
                Console.WriteLine(e.Source);
                Console.WriteLine(e.StackTrace);
            }
        }
コード例 #29
0
        private static void OnLoad()
        {
            try{
                if (!File.Exists(Path.Combine("Saves/Gumps/", "Gumps.bin")))
                {
                    return;
                }

                using (FileStream bin = new FileStream(Path.Combine("Saves/Gumps/", "Gumps.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                    int version = reader.ReadInt();

                    if (version >= 0)
                    {
                        int      count = reader.ReadInt();
                        GumpInfo info;

                        for (int i = 0; i < count; ++i)
                        {
                            info = new GumpInfo();
                            info.Load(reader);

                            if (info.Mobile == null || info.Type == null)
                            {
                                continue;
                            }

                            if (s_Infos[info.Mobile] == null)
                            {
                                s_Infos[info.Mobile] = new Hashtable();
                            }

                            ((Hashtable)s_Infos[info.Mobile])[info.Type] = info;
                        }
                    }

                    reader.End();
                }
            }catch { Errors.Report("GumpInfo-> OnLoad"); }
        }
コード例 #30
0
        public static void Deserialize(BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            if (version >= 0)
            {
                AllianceLimit = reader.ReadInt();
                useXML        = reader.ReadBool();
                int count = reader.ReadInt();

                for (int i = 1; i <= count; i++)
                {
                    BaseAlliance alliance = new BaseAlliance();
                    alliance.Deserialize(reader);
                    Alliances.Add(alliance);
                }
            }

            reader.Close();
        }
コード例 #31
0
        private static ushort[] readStaticDimensions(int index)
        {
            int  length, extra;
            bool is_patched;

            BinaryFileReader reader = m_Index.Seek(index, out length, out extra, out is_patched);

            reader.ReadInt();

            return(new ushort[] { reader.ReadUShort(), reader.ReadUShort() });
        }
コード例 #32
0
ファイル: XNBReader.cs プロジェクト: FreeReign/UltimaXNA
        private static List<Encoder> InternalGetEncoders(GraphicsDevice device, BinaryFileReader reader)
        {
            List<Encoder> list = new List<Encoder>();
            int reader_count = reader.Read7BitEncodedInt();
            Regex regex = new Regex(@"\b([a-z0-9_]+)(,|$)", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);

            for (int i = 0; i < reader_count; i++)
            {
                string reader_name = reader.ReadString();
                int reader_version = reader.ReadInt();
                string typeReaderShortName = regex.Match(reader_name).Groups[1].Value;
                if (typeReaderShortName.IndexOf("Reader") != -1)
                    typeReaderShortName = typeReaderShortName.Substring(0, typeReaderShortName.IndexOf("Reader"));
                bool isList = (reader_name.IndexOf("ListReader") != -1);

                Encoder encoder = new Encoder(typeReaderShortName, isList);
                list.Add(encoder);
            }

            return list;
        }
コード例 #33
0
ファイル: XNBReader.cs プロジェクト: FreeReign/UltimaXNA
        private static Texture2D InternalReadTexture(GraphicsDevice device, BinaryFileReader reader, List<Encoder> encoders)
        {
            SurfaceFormat format = (SurfaceFormat)reader.ReadInt();
            int width = reader.ReadInt(), height = reader.ReadInt(), mip_levels = reader.ReadInt();

            Texture2D texture = new Texture2D(device, width, height, (mip_levels > 1), format);
            for (int i = 0; i < mip_levels; i++)
            {
                int data_count = reader.ReadInt();
                byte[] data = reader.ReadBytes(data_count);
                texture.SetData<byte>(data);
            }
            return texture;
        }
コード例 #34
0
ファイル: XNBReader.cs プロジェクト: FreeReign/UltimaXNA
        private static YSpriteFont InternalReadSpriteFont(GraphicsDevice device, BinaryFileReader reader, List<Encoder> encoders)
        {
            Texture2D texture = (Texture2D)InternalReadObject(device, reader, encoders);
            List<Rectangle> glyphBounds = (List<Rectangle>)InternalReadObject(device, reader, encoders);
            List<Rectangle> cropping = (List<Rectangle>)InternalReadObject(device, reader, encoders);
            List<char> characters = (List<char>)InternalReadObject(device, reader, encoders);
            int lineSpacing = reader.ReadInt();
            float spacing = reader.ReadFloat();
            List<Vector3> kerning = (List<Vector3>)InternalReadObject(device, reader, encoders);
            char? defaultChar = null;
            int default_char = (int)reader.ReadCharUTF8();
            if (default_char != 0)
                defaultChar = (char)default_char;

            YSpriteFont ysf = new YSpriteFont(texture, glyphBounds, cropping, characters, lineSpacing, spacing, kerning, defaultChar);
            return ysf;
        }
コード例 #35
0
ファイル: XNBReader.cs プロジェクト: FreeReign/UltimaXNA
 private static Rectangle InternalReadRectangle(GraphicsDevice device, BinaryFileReader reader, List<Encoder> encoders)
 {
     Rectangle rectangle = new Rectangle(
         reader.ReadInt(), reader.ReadInt(), reader.ReadInt(), reader.ReadInt());
     return rectangle;
 }
コード例 #36
0
ファイル: XNBReader.cs プロジェクト: FreeReign/UltimaXNA
 private static List<Vector3> InternalReadListVector3(GraphicsDevice device, BinaryFileReader reader, List<Encoder> encoders)
 {
     int count = reader.ReadInt();
     List<Vector3> list = new List<Vector3>(count);
     for (int i = 0; i < count; i++)
         list.Add(InternalReadVector3(device, reader, encoders));
     return list;
 }
コード例 #37
0
        private static void Deserialize()
        {
            if (File.Exists(m_FilePath))
            {
                using (FileStream fs = new FileStream(m_FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        BinaryReader br = new BinaryReader(fs);
                        BinaryFileReader reader = new BinaryFileReader(br);

                        int version = reader.ReadInt();

                        int count = reader.ReadInt();
                        for (int i = 0; i < count; i++)
                        {
                            string subject = reader.ReadString();
                            string body = reader.ReadString();

                            int linkcount = reader.ReadInt();
                            ArrayList links = new ArrayList();
                            for (int j = 0; j < linkcount; j++)
                                links.Add(reader.ReadString());

                            m_Messages.Add(new MotDStruct(subject, body, links));
                        }
                    }

                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    finally
                    {
                        fs.Close();
                    }
                }
            }
        }
コード例 #38
0
ファイル: JailRC1.cs プロジェクト: greeduomacro/vivre-uo
        public static void onLoad()
        {
            //System.Console.WriteLine("Loading Jailings");
            FileStream idxFileStream;
            FileStream binFileStream;
            //BinaryReader idxReader;
            BinaryFileReader idxReader;
            BinaryFileReader binReader;
            //GenericReader idxReader;
            long tPos;
            int tID;
            int tLength;
            JailSystem tJail;
            int JailCount = 0;
            int temp = 0;

            // Scriptiz : false pour annuler le if et pour qu'on charge toujours les paramètres par défaut !
            if (false && (File.Exists(idxPath)) && (File.Exists(binPath)))
            {
                idxFileStream = new FileStream(idxPath, (FileMode)3, (FileAccess)1, (FileShare)1);
                binFileStream = new FileStream(binPath, (FileMode)3, (FileAccess)1, (FileShare)1);
                try
                {
                    idxReader = new BinaryFileReader(new BinaryReader(idxFileStream));
                    binReader = new BinaryFileReader(new BinaryReader(binFileStream));
                    JailCount = idxReader.ReadInt();

                    if (JailCount > 0)
                    {
                        for (int i = 0; i < JailCount; i++)
                        {
                            temp = idxReader.ReadInt();//catch the version number which we wont use
                            tID = idxReader.ReadInt();
                            tPos = idxReader.ReadLong();
                            tLength = idxReader.ReadInt();
                            tJail = new JailSystem(tID);
                            binReader.Seek(tPos, 0);
                            try
                            {
                                tJail.Deserialize((GenericReader)binReader);
                                if (binReader.Position != ((long)tPos + tLength))
                                    throw new Exception(String.Format("***** Bad serialize on {0} *****", tID));
                            }
                            catch
                            { }
                        }
                    }
                    loadingameeditsettings((GenericReader)binReader);

                }
                finally
                {
                    if (idxFileStream != null)
                        idxFileStream.Close();
                    if (binFileStream != null)
                        binFileStream.Close();
                }
            }
            else
            {
                JailSystem.defaultSettings();
                //System.Console.WriteLine("{0}: No prior Jailsystem save, using default settings", JailSystem.JSName);
            }
            //System.Console.WriteLine("{0} Jailings Loaded:{1}", JailCount, list.Count);
        }
コード例 #39
0
ファイル: PGSystem.cs プロジェクト: FreeReign/realmofdarkness
        /* ID's:
         101 = Button Manage System
         102 = Button Import Page
         103 = Button Apply Location
         104 = Button Apply Category
         105 = Text   Name
         106 = Text   X
         107 = Text   Y
         108 = Text   Z
         109 = Text   Hue
         110 = Text   Cost
         111 = Radio  Trammel
         112 = Radio  Malas
         113 = Radio  Felucca
         114 = Radio  Ilshenar
         115 = Radio  Tokuno
         116 = Check  Generate
         117 = Check  StaffOnly
         118 = Check  Reds
         119 = Check  Charge
         120 = Check  Young
         121 = Button Add Category
         122 = Button Add Location
         123 = Button Export
         124 = Button Import Systems
         125 = Button Import Categories
         126 = Button Import Locations
         300+ = Imports 
          */
        public override void OnResponse(NetState state, RelayInfo info, ACCGumpParams subParams)
        {
            if (info.ButtonID == 0 || state.Mobile.AccessLevel < ACC.GlobalMinimumAccessLevel)
                return;

            if (subParams is PGGumpParams)
                Params = subParams as PGGumpParams;

            PGGumpParams newParams = new PGGumpParams();

            if (info.ButtonID == 101)
                newParams.Page = Pages.Manage;

            else if (info.ButtonID == 102)
                newParams.Page = Pages.Import;

            #region Add/Remove
            else if (info.ButtonID == 103 || info.ButtonID == 104 || info.ButtonID == 121 || info.ButtonID == 122)
            {
                SetFlag(EntryFlag.Generate, info.IsSwitched(116));
                SetFlag(EntryFlag.StaffOnly, info.IsSwitched(117));
                SetFlag(EntryFlag.Reds, info.IsSwitched(118));
                SetFlag(EntryFlag.Charge, info.IsSwitched(119));

                Map Map = info.IsSwitched(111) ? Map.Trammel : info.IsSwitched(112) ? Map.Malas : info.IsSwitched(113) ? Map.Felucca : info.IsSwitched(114) ? Map.Ilshenar : info.IsSwitched(115) ? Map.Tokuno : Map.Trammel;

                string Name = GetString(info, 105);
                string X = GetString(info, 106);
                string Y = GetString(info, 107);
                string Z = GetString(info, 108);
                string H = GetString(info, 109);
                string C = GetString(info, 110);

                if (Name == null || Name.Length == 0)
                {
                    try
                    {
                        state.Mobile.SendMessage("Removed the entry");
                        if (info.ButtonID == 103)
                            Params.SelectedCategory.Key.Locations.Remove(Params.SelectedLocation.Key);
                        else
                            m_CategoryList.Remove(Params.SelectedCategory.Key);
                    }
                    catch
                    {
                        Console.WriteLine("Exception caught removing entry");
                    }
                }

                else
                {
                    if (info.ButtonID == 103 || info.ButtonID == 122)
                    {
                        int x, y, z, h, c = 0;
                        Point3D Loc;
                        int Hue;
                        int Cost;
                        PGLocation PGL;

                        if (X == null || X.Length == 0 ||
                            Y == null || Y.Length == 0 ||
                            Z == null || Z.Length == 0 ||
                            H == null || H.Length == 0 ||
                            C == null || C.Length == 0)
                        {
                            if (info.ButtonID == 122)
                            {
                                Hue = 0;
                                Loc = new Point3D(0, 0, 0);
                                Cost = 0;

                                PGL = new PGLocation(Name, Flags, Loc, Map, Hue, Cost);
                                if (PGL == null)
                                {
                                    state.Mobile.SendMessage("Error adding Location.");
                                    return;
                                }

                                m_CategoryList[Params.SelectedCategory.Value].Locations.Add(PGL);
                            }

                            state.Mobile.SendMessage("Please fill in each field.");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        try
                        {
                            x = Int32.Parse(X);
                            y = Int32.Parse(Y);
                            z = Int32.Parse(Z);
                            h = Int32.Parse(H);
                            c = Int32.Parse(C);
                            Loc = new Point3D(x, y, z);
                            Hue = h;
                            Cost = c;
                        }
                        catch
                        {
                            state.Mobile.SendMessage("Please enter an integer in each of the info fields. (X, Y, Z, H, Cost)");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        PGL = new PGLocation(Name, Flags, Loc, Map, Hue, Cost);
                        if (PGL == null)
                        {
                            state.Mobile.SendMessage("Bad Location information, can't add!");
                        }
                        else
                        {
                            try
                            {
                                if (info.ButtonID == 122)
                                {
                                    m_CategoryList[Params.SelectedCategory.Value].Locations.Add(PGL);
                                    state.Mobile.SendMessage("Added the Location.");
                                }
                                else
                                {
                                    state.Mobile.SendMessage("Changed the Location.");
                                    m_CategoryList[Params.SelectedCategory.Value].Locations[Params.SelectedLocation.Value] = PGL;
                                }
                            }
                            catch
                            {
                                Console.WriteLine("Problem adding/changing Location!");
                            }
                        }
                    }

                    else
                    {
                        if (C == null || C.Length == 0)
                        {
                            state.Mobile.SendMessage("Please fill in each field.");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        int c = 0;
                        int Cost;
                        try
                        {
                            c = Int32.Parse(C);
                            Cost = c;
                        }
                        catch
                        {
                            state.Mobile.SendMessage("Please enter an integer for the Cost");
                            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), Params));
                            return;
                        }

                        try
                        {
                            if (info.ButtonID == 121)
                            {
                                m_CategoryList.Add(new PGCategory(Name, Flags, Cost));
                                state.Mobile.SendMessage("Added the Category.");
                            }
                            else
                            {
                                m_CategoryList[Params.SelectedCategory.Value].Name = Name;
                                m_CategoryList[Params.SelectedCategory.Value].Flags = Flags;
                                m_CategoryList[Params.SelectedCategory.Value].Cost = Cost;
                                state.Mobile.SendMessage("Changed the Category.");
                            }
                        }
                        catch
                        {
                            Console.WriteLine("Problems adding/changing Category!");
                        }
                    }
                }
            }
            #endregion //Add/Remove

            #region Imports/Exports
            #region Exports
            else if (info.ButtonID == 123)
            {
                if (!Directory.Exists("ACC Exports"))
                    Directory.CreateDirectory("ACC Exports");

                string fileName;
                string Path = "ACC Exports/";

                if (Params.SelectedLocation.Key != null)
                    fileName = String.Format("Location - {0}.pgl", Params.SelectedLocation.Key.Name);
                else if (Params.SelectedCategory.Key != null)
                    fileName = String.Format("Category - {0}.pgc", Params.SelectedCategory.Key.Name);
                else
                    fileName = String.Format("System - {0:yyMMdd-HHmmss}.pgs", DateTime.Now);

                try
                {
                    using (FileStream m_FileStream = new FileStream(Path + fileName, FileMode.Create, FileAccess.Write))
                    {
                        GenericWriter writer = new BinaryFileWriter(m_FileStream, true);

                        if (Params.SelectedLocation.Key != null)
                        {
                            Params.SelectedLocation.Key.Serialize(writer);
                            state.Mobile.SendMessage("Exported the Location to {0}{1}", Path, fileName);
                        }
                        else if (Params.SelectedCategory.Key != null)
                        {
                            Params.SelectedCategory.Key.Serialize(writer);
                            state.Mobile.SendMessage("Exported the Category (and all Locations contained within) to {0}{1}", Path, fileName);
                        }
                        else
                        {
                            writer.Write((int)0); //version

                            writer.Write(m_CategoryList.Count);
                            for (int i = 0; i < m_CategoryList.Count; i++)
                            {
                                m_CategoryList[i].Serialize(writer);
                            }
                            state.Mobile.SendMessage("Exported the entire Public Gates System to {0}{1}", Path, fileName);
                        }

                        writer.Close();
                        m_FileStream.Close();
                    }
                }
                catch (Exception e)
                {
                    state.Mobile.SendMessage("Problem exporting the selection.  Please contact the admin.");
                    Console.WriteLine("Error exporting PGSystem : {0}", e);
                }
            }
            #endregion //Exports
            #region Imports
            //Switch between import types
            else if (info.ButtonID == 124 || info.ButtonID == 125 || info.ButtonID == 126)
            {
                newParams.Page = Pages.Import;
                switch (info.ButtonID)
                {
                    case 124: newParams.ImportSelection = ImportSelections.Systems; break;
                    case 125: newParams.ImportSelection = ImportSelections.Categories; break;
                    case 126: newParams.ImportSelection = ImportSelections.Locations; break;
                }
            }
            //Perform the import
            else if (info.ButtonID >= 300 && Dirs != null && Dirs.Length > 0)
            {
                if (!Directory.Exists("ACC Exports"))
                    Directory.CreateDirectory("ACC Exports");

                string Path = null;
                try
                {
                    Path = Dirs[info.ButtonID - 300];

                    if (File.Exists(Path))
                    {
                        using (FileStream m_FileStream = new FileStream(Path, FileMode.Open, FileAccess.Read, FileShare.Read))
                        {
                            BinaryFileReader reader = new BinaryFileReader(new BinaryReader(m_FileStream));

                            switch ((int)Params.ImportSelection)
                            {
                                case (int)ImportSelections.Systems:
                                    {//Systems
                                        int version = reader.ReadInt();
                                        int count = reader.ReadInt();
                                        List<PGCategory> list = new List<PGCategory>();
                                        for (int i = 0; i < count; i++)
                                            list.Add(new PGCategory(reader));

                                        state.Mobile.CloseGump(typeof(SysChoiceGump));
                                        state.Mobile.SendGump(new SysChoiceGump(this.ToString(), Params, list));
                                        reader.Close();
                                        return;
                                    }
                                case (int)ImportSelections.Categories:
                                    {//Categories
                                        if (m_CategoryList == null)
                                            m_CategoryList = new List<PGCategory>();

                                        m_CategoryList.Add(new PGCategory(reader));
                                        state.Mobile.SendMessage("Added the Category.");
                                        break;
                                    }
                                case (int)ImportSelections.Locations:
                                    {//Locations
                                        state.Mobile.CloseGump(typeof(CatSelGump));
                                        state.Mobile.SendMessage("Please choose a Category to put this Location in.");
                                        state.Mobile.SendGump(new CatSelGump(this.ToString(), Params, new PGLocation(reader)));
                                        reader.Close();
                                        return;
                                    }
                            }

                            reader.Close();
                        }
                    }
                }
                catch
                {
                }
            }
            #endregion //Imports
            #endregion //Imports/Exports

            else if (info.ButtonID >= 150 && info.ButtonID < m_CategoryList.Count + 150)
                newParams.SelectedCategory = new KeyValuePair<PGCategory, int>(m_CategoryList[info.ButtonID - 150], info.ButtonID - 150);

            else if (info.ButtonID >= 200 && info.ButtonID < 200 + Params.SelectedCategory.Key.Locations.Count)
            {
                newParams.SelectedCategory = Params.SelectedCategory;
                newParams.SelectedLocation = new KeyValuePair<PGLocation, int>(Params.SelectedCategory.Key.Locations[info.ButtonID - 200], info.ButtonID - 200);
            }

            state.Mobile.SendGump(new ACCGump(state.Mobile, this.ToString(), newParams));
        }
コード例 #40
0
        public static bool ImportBuilding(string filename)
        {
            bool finished = false;
            string binpath = Path.Combine(BaseBuilding.SavePath, filename + ".bin");

            if (File.Exists(binpath))
            {
                using (FileStream bin = CustomSaving.GetFileStream(binpath))
                {
                    BinaryFileReader reader = new BinaryFileReader(new BinaryReader(bin));
                    try
                    {
                        int count = reader.ReadInt();
                        for (int i = 0; i < count; i++)
                        {
                            string name = reader.ReadString();
                            int type = reader.ReadInt();

                            switch (type)
                            {
                                case 0: m_BuildingTable[name] = new BuildingEntry(reader, type); break;
                                case 1: m_BuildingTable[name] = new ComponentEntry(reader); break;
                                case 2: m_BuildingTable[name] = new AddonEntry(reader); break;
                            }
                        }
                        finished = true;
                    }
                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    finally
                    {
                        reader.Close();
                    }
                }
            }
            return finished;
        }
コード例 #41
0
ファイル: EoCGenerator.cs プロジェクト: greeduomacro/hubroot
        /// <summary>
        /// Loads serialized data
        /// </summary>
        private static void OnWorldLoad()
        {
            if( !File.Exists(DataFile) )
                return;

            using( FileStream stream = new FileStream(DataFile, FileMode.Open, FileAccess.Read, FileShare.Read) )
            {
                BinaryFileReader reader = new BinaryFileReader(new BinaryReader(stream));

                int tableCount = reader.ReadInt();
                EoCTable = new Dictionary<Player, EoCContext>(tableCount);

                for( int i = 0; i < tableCount; i++ )
                {
                    if( !reader.ReadBool() )
                        continue;

                    Player pl = reader.ReadMobile<Player>();

                    if( pl != null && !pl.Deleted )
                        EoCTable[pl] = new EoCContext(reader);
                }

                int hitsCount = reader.ReadInt();
                HitsTable = new Dictionary<Player, HitsTimer>(hitsCount);

                for( int i = 0; i < hitsCount; i++ )
                {
                    if( !reader.ReadBool() )
                        continue;

                    Player player = reader.ReadMobile<Player>();

                    if( player == null || player.Deleted )
                        continue;

                    HitsTable[player] = new HitsTimer(player);

                    DateTime next = reader.ReadDateTime();

                    if( next < DateTime.Now )
                        next = DateTime.Now;

                    HitsTable[player].Delay = (next - DateTime.Now);
                }

                reader.Close();
            }
        }
コード例 #42
0
ファイル: ForumCore.cs プロジェクト: greeduomacro/last-wish
		private static void Load()
		{
			try
			{
				string SavePath = Path.Combine( m_SavePath, "forumdata.sig" );

				using( FileStream fs = new FileStream( SavePath, FileMode.Open, FileAccess.Read, FileShare.Read ) )
				{
					BinaryReader br = new BinaryReader( fs );
					BinaryFileReader reader = new BinaryFileReader( br );

					int version = reader.ReadInt();
					switch( version )
					{
						case 0:
							{
								m_PlayerStatistics = ReadPlayerStatistics( reader );
								int count = reader.ReadInt();
								for( int i = 0; i < count; i++ )
								{
									ThreadEntry te = new ThreadEntry();
									te.Deserialize( reader );
									m_Threads.Add( te );
								}
								m_Moderators = reader.ReadMobileList();
								m_ThreadDeleteAccessLevel = (AccessLevel)reader.ReadInt();
								m_ThreadLockAccesLevel = ( AccessLevel )reader.ReadInt();
								m_AutoCleanup = reader.ReadBool();
								m_AutoCleanupDays = reader.ReadInt();
								m_MinPostCharactersCount = reader.ReadInt();
								m_MaxPostCharactersCount = reader.ReadInt();
								break;
							}
					}
				}

				m_Threads.Sort( new DateSort() );
				Console.WriteLine( "Loading...done" );
			}
			catch(Exception err)
			{
				Console.WriteLine( "An error occured while loading the forums...{0}", err.ToString() );
			}
		}
コード例 #43
0
ファイル: VoteConfig.cs プロジェクト: FreeReign/imaginenation
		public void Deserialize()
		{
			//Console.WriteLine("[Vote System]: Loading Config...");

			FileInfo info = new FileInfo("Data\\VoteSystem.cfg");

			if (!info.Exists)
				info.Create().Close();

			if (info.Length == 0)
				return;

			using (BinaryReader br = new BinaryReader(info.OpenRead()))
			{
				BinaryFileReader bin = new BinaryFileReader(br);
	
				int version = bin.ReadInt();

			    switch(version)
			    {
                    case 1:
			            _DefaultGold = bin.ReadInt();
			            goto case 0;
                    case 0:
                        _DefaultName = bin.ReadString();
				        _DefaultURL = bin.ReadString();
				        _DefaultCoolDown = bin.ReadTimeSpan();
			            break;

			    }
				bin.Close();
			}

			//Console.WriteLine("[Vote System]: Done.");
		}
コード例 #44
0
        private static void Deserialize()
        {
            if (File.Exists(m_FilePath))
            {
                using (FileStream fs = new FileStream(m_FilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    try
                    {
                        BinaryReader br = new BinaryReader(fs);
                        BinaryFileReader reader = new BinaryFileReader(br);

                        int version = reader.ReadInt();

                        if (version != Version)
                            NewVersion();
                    }

                    catch (Exception error)
                    {
                        Console.WriteLine(error.ToString());
                    }
                    finally
                    {
                        fs.Close();
                    }
                }
            }
        }
コード例 #45
0
ファイル: PGSystem.cs プロジェクト: FreeReign/realmofdarkness
        public override void Load(BinaryReader idx, BinaryReader tdb, BinaryFileReader reader)
        {
            int version = reader.ReadInt();

            m_CategoryList = new List<PGCategory>();

            for (int i = reader.ReadInt(); i > 0; i--)
            {
                m_CategoryList.Add(new PGCategory(reader));
            }
        }
コード例 #46
0
ファイル: XmlAttach.cs プロジェクト: jasegiffin/JustUO
		public static void Load()
		{
			string filePath = Path.Combine("Saves/Attachments", "Attachments.bin"); // the attachment serializations
			string imaPath = Path.Combine("Saves/Attachments", "Attachments.ima"); // the item/mob attachment tables
			string fpiPath = Path.Combine("Saves/Attachments", "Attachments.fpi"); // the file position indices

			if (!File.Exists(filePath))
			{
				return;
			}

			FileStream fs = null;
			BinaryFileReader reader = null;
			FileStream imafs = null;
			BinaryFileReader imareader = null;
			FileStream fpifs = null;
			BinaryFileReader fpireader = null;

			try
			{
				fs = new FileStream(filePath, (FileMode)3, (FileAccess)1, (FileShare)1);
				reader = new BinaryFileReader(new BinaryReader(fs));
				imafs = new FileStream(imaPath, (FileMode)3, (FileAccess)1, (FileShare)1);
				imareader = new BinaryFileReader(new BinaryReader(imafs));
				fpifs = new FileStream(fpiPath, (FileMode)3, (FileAccess)1, (FileShare)1);
				fpireader = new BinaryFileReader(new BinaryReader(fpifs));
			}
			catch (Exception e)
			{
				ErrorReporter.GenerateErrorReport(e.ToString());
				return;
			}

			if (reader != null && imareader != null && fpireader != null)
			{
				// restore the current global attachment serial state
				try
				{
					ASerial.GlobalDeserialize(reader);
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				ASerial.serialInitialized = true;

				// read in the serial attachment hash table information
				int count = 0;
				try
				{
					count = reader.ReadInt();
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				for (int i = 0; i < count; i++)
				{
					// read the serial
					ASerial serialno = null;
					try
					{
						serialno = new ASerial(reader.ReadInt());
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					// read the attachment type
					string valuetype = null;
					try
					{
						valuetype = reader.ReadString();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					// read the position of the beginning of the next attachment deser within the .bin file
					long position = 0;
					try
					{
						position = fpireader.ReadLong();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					bool skip = false;

					XmlAttachment o = null;
					try
					{
						o = (XmlAttachment)Activator.CreateInstance(Type.GetType(valuetype), new object[] {serialno});
					}
					catch
					{
						skip = true;
					}

					if (skip)
					{
						if (!AlreadyReported(valuetype))
						{
							Console.WriteLine("\nError deserializing attachments {0}.\nMissing a serial constructor?\n", valuetype);
							ReportDeserError(valuetype, "Missing a serial constructor?");
						}
						// position the .ima file at the next deser point
						try
						{
							reader.Seek(position, SeekOrigin.Begin);
						}
						catch
						{
							ErrorReporter.GenerateErrorReport(
								"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
							return;
						}
						continue;
					}

					try
					{
						o.Deserialize(reader);
					}
					catch
					{
						skip = true;
					}

					// confirm the read position
					if (reader.Position != position || skip)
					{
						if (!AlreadyReported(valuetype))
						{
							Console.WriteLine("\nError deserializing attachments {0}\n", valuetype);
							ReportDeserError(valuetype, "save file corruption or incorrect Serialize/Deserialize methods?");
						}
						// position the .ima file at the next deser point
						try
						{
							reader.Seek(position, SeekOrigin.Begin);
						}
						catch
						{
							ErrorReporter.GenerateErrorReport(
								"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
							return;
						}
						continue;
					}

					// add it to the hash table
					try
					{
						AllAttachments.Add(serialno.Value, o);
					}
					catch
					{
						ErrorReporter.GenerateErrorReport(
							String.Format(
								"\nError deserializing {0} serialno {1}. Attachments save file corrupted. Attachment load aborted.\n",
								valuetype,
								serialno.Value));
						return;
					}
				}

				// read in the mobile attachment hash table information
				try
				{
					count = imareader.ReadInt();
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				for (int i = 0; i < count; i++)
				{
					Mobile key = null;
					try
					{
						key = imareader.ReadMobile();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					int nattach = 0;
					try
					{
						nattach = imareader.ReadInt();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					for (int j = 0; j < nattach; j++)
					{
						// and serial
						ASerial serialno = null;
						try
						{
							serialno = new ASerial(imareader.ReadInt());
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the attachment type
						string valuetype = null;
						try
						{
							valuetype = imareader.ReadString();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the position of the beginning of the next attachment deser within the .bin file
						long position = 0;
						try
						{
							position = fpireader.ReadLong();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						XmlAttachment o = FindAttachmentBySerial(serialno.Value);

						if (o == null || imareader.Position != position)
						{
							if (!AlreadyReported(valuetype))
							{
								Console.WriteLine("\nError deserializing attachments of type {0}.\n", valuetype);
								ReportDeserError(valuetype, "save file corruption or incorrect Serialize/Deserialize methods?");
							}
							// position the .ima file at the next deser point
							try
							{
								imareader.Seek(position, SeekOrigin.Begin);
							}
							catch
							{
								ErrorReporter.GenerateErrorReport(
									"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
								return;
							}
							continue;
						}

						// attachment successfully deserialized so attach it
						AttachTo(key, o, false);
					}
				}

				// read in the item attachment hash table information
				try
				{
					count = imareader.ReadInt();
				}
				catch (Exception e)
				{
					ErrorReporter.GenerateErrorReport(e.ToString());
					return;
				}

				for (int i = 0; i < count; i++)
				{
					Item key = null;
					try
					{
						key = imareader.ReadItem();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					int nattach = 0;
					try
					{
						nattach = imareader.ReadInt();
					}
					catch (Exception e)
					{
						ErrorReporter.GenerateErrorReport(e.ToString());
						return;
					}

					for (int j = 0; j < nattach; j++)
					{
						// and serial
						ASerial serialno = null;
						try
						{
							serialno = new ASerial(imareader.ReadInt());
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the attachment type
						string valuetype = null;
						try
						{
							valuetype = imareader.ReadString();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						// read the position of the beginning of the next attachment deser within the .bin file
						long position = 0;
						try
						{
							position = fpireader.ReadLong();
						}
						catch (Exception e)
						{
							ErrorReporter.GenerateErrorReport(e.ToString());
							return;
						}

						XmlAttachment o = FindAttachmentBySerial(serialno.Value);

						if (o == null || imareader.Position != position)
						{
							if (!AlreadyReported(valuetype))
							{
								Console.WriteLine("\nError deserializing attachments of type {0}.\n", valuetype);
								ReportDeserError(valuetype, "save file corruption or incorrect Serialize/Deserialize methods?");
							}
							// position the .ima file at the next deser point
							try
							{
								imareader.Seek(position, SeekOrigin.Begin);
							}
							catch
							{
								ErrorReporter.GenerateErrorReport(
									"Error deserializing. Attachments save file corrupted. Attachment load aborted.");
								return;
							}
							continue;
						}

						// attachment successfully deserialized so attach it
						AttachTo(key, o, false);
					}
				}
				if (fs != null)
				{
					fs.Close();
				}
				if (imafs != null)
				{
					imafs.Close();
				}
				if (fpifs != null)
				{
					fpifs.Close();
				}

				if (desererror != null)
				{
					ErrorReporter.GenerateErrorReport("Error deserializing particular attachments.");
				}
			}
		}