Пример #1
0
 public void Read(MemoryStreamReader br, int size)
 {
     id       = br.ReadUInt();
     exp      = br.ReadUInt();  //negative if losing
     expType  = br.ReadShort(); //SP_BASEEXP, SP_JOBEXP
     questExp = br.ReadShort();
 }
Пример #2
0
        private static void ParseTextures(GND gnd, MemoryStreamReader data)
        {
            uint textureCount      = data.ReadUInt();
            uint texturePathLength = data.ReadUInt();

            int[]         lookupList = new int[textureCount];
            List <string> textures   = new List <string>();

            for (int i = 0; i < textureCount; i++)
            {
                string texture = data.ReadBinaryString(texturePathLength);
                int    pos     = textures.IndexOf(texture);

                if (pos == -1)
                {
                    textures.Add(texture);
                    pos = textures.Count - 1;
                }

                lookupList[i] = pos;
            }

            gnd.textures          = textures.ToArray();
            gnd.textureLookupList = lookupList;
        }
Пример #3
0
        public static GND Load(MemoryStreamReader data)
        {
            string header = data.ReadBinaryString(4);

            if (!string.Equals(header, GND.Header))
            {
                throw new Exception("GroundLoader.Load: Header (" + header + ") is not \"GRGN\"");
            }

            string version    = Convert.ToString(data.ReadByte());
            string subversion = Convert.ToString(data.ReadByte());

            version += "." + subversion;

            GND gnd = new GND(version);

            gnd.width  = data.ReadUInt();
            gnd.height = data.ReadUInt();
            gnd.zoom   = data.ReadFloat();

            ParseTextures(gnd, data);
            ParseLightmaps(gnd, data);

            gnd.tiles    = ParseTiles(gnd, data);
            gnd.surfaces = ParseSurfaces(gnd, data);

            return(gnd);
        }
Пример #4
0
        /// <summary>
        /// Load a GAT file
        /// </summary>
        /// <param name="data">GAT file data</param>
        public static GAT Load(MemoryStreamReader data)
        {
            string header = data.ReadBinaryString(4);

            //check for valid gat file
            if (!string.Equals(header, GAT.Header))
            {
                throw new Exception("AltitudeLoader.Load: Header (" + header + ") is not \"GRAT\"");
            }

            //load parameters
            string version    = Convert.ToString(data.ReadByte());
            string subversion = Convert.ToString(data.ReadByte());

            version += "." + subversion;
            uint width  = data.ReadUInt();
            uint height = data.ReadUInt();

            GAT.Cell[] cells = new GAT.Cell[width * height];

            //load the cells
            for (int i = 0; i < width * height; i++)
            {
                Vector4 heights = new Vector4();
                heights[0]       = data.ReadFloat() * 0.2f;         // height 1
                heights[1]       = data.ReadFloat() * 0.2f;         // height 2
                heights[2]       = data.ReadFloat() * 0.2f;         // height 3
                heights[3]       = data.ReadFloat() * 0.2f;         // height 4
                cells[i].Heights = heights;
                cells[i].type    = GAT.TYPE_TABLE[data.ReadUInt()]; // type
            }

            //exports
            return(new GAT(width, height, cells, version));
        }
Пример #5
0
 /// 009d <id>.L <name id>.W <identified>.B <x>.W <y>.W <amount>.W <subX>.B <subY>.B
 public void Read(MemoryStreamReader br, int size)
 {
     mapID      = (int)br.ReadUInt();
     id         = (int)br.ReadUInt();
     identified = br.ReadByte();
     x          = br.ReadShort();
     y          = br.ReadShort();
     amount     = br.ReadShort();
     subX       = br.ReadByte();
     subY       = br.ReadByte();
 }
Пример #6
0
 public void Read(MemoryStreamReader fp, int size)
 {
     AID          = fp.ReadUInt();
     targetID     = fp.ReadUInt();
     xPos         = fp.ReadShort();
     yPos         = fp.ReadShort();
     SKID         = fp.ReadUShort();
     property     = fp.ReadUInt();
     delayTime    = fp.ReadUInt();
     isDisposable = (byte)fp.ReadByte();
 }
Пример #7
0
        public void Read(MemoryStreamReader br, int size)
        {
            this.GID = br.ReadUInt();
            var moveData = br.ReadPos2();

            StartPosition = new int[2] {
                moveData[0], moveData[1]
            };
            EndPosition = new int[2] {
                moveData[2], moveData[3]
            };
            this.MoveStartTime = br.ReadUInt();
        }
Пример #8
0
 public void Read(MemoryStreamReader br, int size)
 {
     mapID          = (int)br.ReadUInt();
     id             = (int)br.ReadUInt();
     itemType       = br.ReadUShort();
     identified     = (byte)br.ReadByte();
     x              = br.ReadShort();
     y              = br.ReadShort();
     subX           = (byte)br.ReadByte();
     subY           = (byte)br.ReadByte();
     amount         = br.ReadShort();
     showDropEffect = br.ReadByte();
     dropEffectMode = br.ReadShort();
 }
Пример #9
0
 public void Read(MemoryStreamReader fp, int size)
 {
     ActionRequest = new EntityActionRequest()
     {
         GID         = fp.ReadUInt(),
         targetGID   = fp.ReadUInt(),
         startTime   = fp.ReadUInt(),
         sourceSpeed = (ushort)fp.ReadInt(),
         targetSpeed = (ushort)fp.ReadInt(),
         damage      = fp.ReadShort(),
         count       = fp.ReadShort(),
         action      = (ActionRequestType)fp.ReadByte(),
         leftDamage  = fp.ReadShort()
     };
 }
Пример #10
0
 public void Read(MemoryStreamReader br, int size)
 {
     GID    = br.ReadUInt();
     type   = br.ReadByte();
     value  = br.ReadShort();
     value2 = br.ReadShort();
 }
Пример #11
0
        public void Read(MemoryStreamReader br, int size)
        {
            LoginID1  = br.ReadInt();
            AccountID = br.ReadInt();
            LoginID2  = br.ReadInt();

            br.Seek(30, SeekOrigin.Current);

            Sex = (byte)br.ReadByte();

            br.Seek(17, SeekOrigin.Current);

            long serverCount = (br.Length - br.Position) / BLOCK_SIZE;

            Servers = new CharServerInfo[serverCount];
            for (int i = 0; i < serverCount; i++)
            {
                CharServerInfo csi = new CharServerInfo();
                csi.IP        = new IPAddress(br.ReadUInt());
                csi.Port      = br.ReadUShort();
                csi.Name      = br.ReadBinaryString(20);
                csi.UserCount = br.ReadUShort();
                csi.State     = br.ReadShort();
                csi.Property  = br.ReadUShort();

                Servers[i] = csi;
            }
        }
Пример #12
0
        private static void ParseLightmaps(GND gnd, MemoryStreamReader data)
        {
            uint lightmapCount  = data.ReadUInt();
            int  lightmapWidth  = data.ReadInt();
            int  lightmapHeight = data.ReadInt();
            int  gridSizeCell   = data.ReadInt();
            int  perCell        = lightmapWidth * lightmapHeight * gridSizeCell;

            if (perCell != 64)
            {
                throw new Exception("Non supported lightmap");
            }


            var lightmap = gnd.lightmap = new GND.Lightmap();

            lightmap.count = lightmapCount;
            //lightmap.perCell = perCell;
            lightmap.data = new byte[lightmapCount][];

            for (int i = 0; i < lightmapCount; i++)
            {
                lightmap.data[i] = new byte[256];
                data.Read(lightmap.data[i], 0, 256);
            }
            //data.Read(lightmap.data, 0, lightmap.data.Length);
        }
Пример #13
0
 /// 01c8 <index>.W <name id>.W <id>.L <amount>.W <result>.B (ZC_USE_ITEM_ACK2)
 public void Read(MemoryStreamReader fp, int size)
 {
     this.index  = fp.ReadShort();
     this.id     = fp.ReadShort();
     this.AID    = fp.ReadUInt();
     this.count  = fp.ReadShort();
     this.result = (byte)fp.ReadByte();
 }
Пример #14
0
        public void Read(MemoryStreamReader br, int size)
        {
            ActionRequest = new EntityActionRequest()
            {
                GID         = br.ReadUInt(),
                targetGID   = br.ReadUInt(),
                startTime   = br.ReadUInt(),
                sourceSpeed = (ushort)br.ReadInt(),
                targetSpeed = (ushort)br.ReadInt(),
                damage      = br.ReadInt()
            };

            br.Seek(1, SeekOrigin.Current);

            ActionRequest.count      = br.ReadShort();
            ActionRequest.action     = (ActionRequestType)br.ReadByte();
            ActionRequest.leftDamage = br.ReadInt();
        }
Пример #15
0
        public void Read(MemoryStreamReader br, int size)
        {
            var count = (br.Length - br.Position) / 24;

            for (var i = 0; i < count; i++)
            {
                var GID          = br.ReadUInt();
                var szExpireDate = br.ReadBinaryString(20);
            }
        }
Пример #16
0
        /**
         * 0a37
         * <index>.W
         * <amount>.W
         * <name id>.W
         * <identified>.B
         * <damaged>.B
         * <refine>.B
         * <card1>.W
         * <card2>.W
         * <card3>.W
         * <card4>.W
         * <equip location>.L
         * <item type>.B
         * <result>.B
         * <expire time>.L
         * <bindOnEquipType>.W
         * { <option id>.W <option value>.W <option param>.B }*5
         * <favorite>.B
         * <view id>.W
         * (ZC_ITEM_PICKUP_ACK_V7)
         */
        public void Read(MemoryStreamReader br, int size)
        {
            itemInfo = new ItemInfo {
                index  = br.ReadShort(),
                amount = br.ReadShort(),
                ItemID = (int)br.ReadUInt()
            };
            IsIdentified       = br.ReadByte() == 1;
            itemInfo.IsDamaged = br.ReadByte() == 1;
            itemInfo.refine    = (byte)br.ReadByte();

            itemInfo.slot = new ItemInfo.Slot()
            {
                card1 = (int)br.ReadUInt(),
                card2 = (int)br.ReadUInt(),
                card3 = (int)br.ReadUInt(),
                card4 = (int)br.ReadUInt()
            };

            itemInfo.location    = br.ReadInt();
            itemInfo.itemType    = br.ReadByte();
            result               = br.ReadByte();
            itemInfo.expireTime  = br.ReadInt();
            itemInfo.bindOnEquip = br.ReadUShort();

            itemInfo.options = new List <ItemInfo.Option>();
            for (int j = 0; j < 5; j++)
            {
                itemInfo.options.Add(new ItemInfo.Option()
                {
                    optIndex = br.ReadShort(),
                    value    = br.ReadShort(),
                    param1   = (byte)br.ReadByte()
                });
            }

            IsFavorite      = br.ReadByte() == 1;
            itemInfo.flag   = IsIdentified ? 0x1 : 0;
            itemInfo.flag  |= IsFavorite ? 0x2 : 0;
            itemInfo.viewID = br.ReadShort();
        }
Пример #17
0
        public void Read(MemoryStreamReader br, int size)
        {
            movementTick = br.ReadUInt();
            var moveData = br.ReadPos2();

            startPosition = new int[2] {
                moveData[0], moveData[1]
            };
            endPosition = new int[2] {
                moveData[2], moveData[3]
            };
        }
Пример #18
0
        public void Read(MemoryStreamReader br, int size)
        {
            byte invType = (byte)br.ReadByte();

            var count = (br.Length - br.Position) / BLOCK_SIZE;

            for (int i = 0; i < count; i++)
            {
                var itemInfo = new ItemInfo();

                itemInfo.index     = br.ReadShort();     // 2
                itemInfo.ItemID    = (int)br.ReadUInt(); // 4
                itemInfo.itemType  = br.ReadByte();      // 1
                itemInfo.amount    = br.ReadShort();     // 2
                itemInfo.wearState = (int)br.ReadUInt(); // 4
                itemInfo.slot      = new ItemInfo.Slot() // 8
                {
                    card1 = (int)br.ReadUInt(),
                    card2 = (int)br.ReadUInt(),
                    card3 = (int)br.ReadUInt(),
                    card4 = (int)br.ReadUInt()
                };
                itemInfo.expireTime = br.ReadInt();  // 4
                itemInfo.flag       = br.ReadByte(); // 4

                Inventory.Add(itemInfo);
            }
        }
Пример #19
0
        private static ACT.Frame[] ReadMotions(ACT act, MemoryStreamReader data)
        {
            var count   = data.ReadUInt();
            var motions = new ACT.Frame[count];

            for (int i = 0; i < count; i++)
            {
                data.Seek(32, System.IO.SeekOrigin.Current);
                motions[i] = ReadLayers(act, data);
            }

            return(motions);
        }
Пример #20
0
        public void Read(MemoryStreamReader br, int size)
        {
            byte invType = (byte)br.ReadByte();

            var count = (br.Length - br.Position) / BLOCK_SIZE;

            for (int i = 0; i < count; i++)
            {
                var itemInfo = new ItemInfo {
                    index = br.ReadShort(),

                    ItemID = (int)br.ReadUInt(),

                    itemType = br.ReadByte(),

                    location  = (int)br.ReadUInt(),
                    wearState = (int)br.ReadUInt(),
                    refine    = (byte)br.ReadByte(),

                    slot = new ItemInfo.Slot()
                    {
                        card1 = (int)br.ReadUInt(),
                        card2 = (int)br.ReadUInt(),
                        card3 = (int)br.ReadUInt(),
                        card4 = (int)br.ReadUInt()
                    },

                    expireTime        = br.ReadInt(),
                    bindOnEquip       = br.ReadUShort(),
                    wItemSpriteNumber = br.ReadUShort(),
                    randomOptionCount = (byte)br.ReadByte(),
                    options           = new List <ItemInfo.Option>()
                };

                for (int j = 0; j < 5; j++)
                {
                    itemInfo.options.Add(new ItemInfo.Option()
                    {
                        optIndex = br.ReadShort(),
                        value    = br.ReadShort(),
                        param1   = (byte)br.ReadByte()
                    });
                }

                itemInfo.flag = br.ReadByte();

                Inventory.Add(itemInfo);
            }
        }
Пример #21
0
        private static GND.Tile[] ParseTiles(GND gnd, MemoryStreamReader data)
        {
            uint count = data.ReadUInt();

            GND.Tile[] tiles = new GND.Tile[count];

            var ATLAS_COLS     = Math.Round(Math.Sqrt(gnd.textures.Length));
            var ATLAS_ROWS     = Math.Ceiling(Math.Sqrt(gnd.textures.Length));
            var ATLAS_WIDTH    = Math.Pow(2, Math.Ceiling(Math.Log(ATLAS_COLS * 258) / Math.Log(2)));
            var ATLAS_HEIGHT   = Math.Pow(2, Math.Ceiling(Math.Log(ATLAS_ROWS * 258) / Math.Log(2)));
            var ATLAS_FACTOR_U = ATLAS_COLS * 258 / ATLAS_WIDTH;
            var ATLAS_FACTOR_V = ATLAS_ROWS * 258 / ATLAS_HEIGHT;
            var ATLAS_PX_U     = 1 / 258f;
            var ATLAS_PX_V     = 1 / 258f;

            for (int i = 0; i < count; i++)
            {
                var tile = tiles[i] = new GND.Tile();
                tile.textureStart = new Vector4(data.ReadFloat(), data.ReadFloat(), data.ReadFloat(), data.ReadFloat());
                tile.textureEnd   = new Vector4(data.ReadFloat(), data.ReadFloat(), data.ReadFloat(), data.ReadFloat());
                tile.texture      = data.ReadUShort();
                tile.light        = data.ReadUShort();
                var r = (byte)data.ReadByte();
                var g = (byte)data.ReadByte();
                var b = (byte)data.ReadByte();
                var a = (byte)data.ReadByte();
                tile.color   = new byte[] { r, g, b, a };
                tile.texture = (ushort)gnd.textureLookupList[tile.texture];

                var start = tile.texture % ATLAS_COLS;
                var end   = Math.Floor(tile.texture / ATLAS_COLS);

                for (int j = 0; j < 4; j++)
                {
                    tile.textureStart[j] = (float)((start + tile.textureStart[j] * (1 - ATLAS_PX_U * 2) + ATLAS_PX_U) * ATLAS_FACTOR_U / ATLAS_COLS);
                    tile.textureEnd[j]   = (float)((end + tile.textureEnd[j] * (1 - ATLAS_PX_V * 2) + ATLAS_PX_V) * ATLAS_FACTOR_V / ATLAS_ROWS);
                }
            }

            return(tiles);
        }
Пример #22
0
 public void Read(MemoryStreamReader br, int size)
 {
     GID   = br.ReadUInt();
     Style = br.ReadShort();
     Item  = br.ReadByte();
 }
Пример #23
0
 public void Read(MemoryStreamReader fp, int size)
 {
     this.GID   = fp.ReadUInt();
     this.Hp    = fp.ReadInt();
     this.MaxHp = fp.ReadInt();
 }
Пример #24
0
 public void Read(MemoryStreamReader fp, int size)
 {
     this.GID  = fp.ReadUInt();
     this.type = (byte)fp.ReadByte();
 }
Пример #25
0
 public void Read(MemoryStreamReader br, int size)
 {
     this.GID        = br.ReadUInt();
     this.objecttype = (byte)br.ReadByte();
     this.value      = br.ReadUInt();
 }
Пример #26
0
        private static ACT.Frame ReadLayers(ACT act, MemoryStreamReader data)
        {
            var count   = data.ReadUInt();
            var layers  = new ACT.Layer[count];
            var version = double.Parse(act.version, CultureInfo.InvariantCulture);

            for (int i = 0; i < count; i++)
            {
                var layer = layers[i] = new ACT.Layer()
                {
                    pos      = new Vector2Int(data.ReadInt(), data.ReadInt()),
                    index    = data.ReadInt(),
                    isMirror = data.ReadInt() != 0,
                    scale    = Vector2.one,
                    color    = Color.white
                };

                // RoRebuild checks if only if it's greater
                if (version > 2.0)
                {
                    layer.color[0] = data.ReadByte() / 255f; //r
                    layer.color[1] = data.ReadByte() / 255f; //g
                    layer.color[2] = data.ReadByte() / 255f; //b
                    layer.color[3] = data.ReadByte() / 255f; //a

                    layer.scale[0] = data.ReadFloat();
                    layer.scale[1] = version <= 2.3 ? layer.scale[0] : data.ReadFloat();

                    layer.angle   = data.ReadInt();
                    layer.sprType = data.ReadInt();

                    if (version >= 2.5)
                    {
                        layer.width  = data.ReadInt();
                        layer.height = data.ReadInt();
                    }
                }
            }

            var soundId = version >= 2.0 ? data.ReadInt() : -1;

            Vector2Int[] pos = null;

            if (version >= 2.3)
            {
                pos = new Vector2Int[data.ReadInt()];
                for (int i = 0; i < pos.Length; i++)
                {
                    data.Seek(4, System.IO.SeekOrigin.Current);
                    pos[i] = new Vector2Int(data.ReadInt(), data.ReadInt());
                    data.Seek(4, System.IO.SeekOrigin.Current);
                }
            }

            return(new ACT.Frame()
            {
                layers = layers.Where(t => t.index >= 0).ToArray(),
                soundId = soundId,
                pos = pos
            });
        }
Пример #27
0
        public void Read(MemoryStreamReader br, int size)
        {
            entityData = new EntitySpawnData();

            entityData.objecttype = (EntityType)br.ReadByte();

            entityData.AID = br.ReadUInt();
            entityData.GID = br.ReadUInt();

            entityData.speed       = br.ReadShort();
            entityData.bodyState   = br.ReadShort();
            entityData.healthState = br.ReadShort();

            entityData.effectState = br.ReadInt();

            entityData.job = br.ReadShort();

            entityData.head = br.ReadUShort();

            entityData.Weapon        = br.ReadUInt();
            entityData.Accessory     = br.ReadUShort();
            entityData.moveStartTime = br.ReadUInt();
            entityData.Shield        = br.ReadUInt();

            /**
             * might represent emblem/guild_id1/guild_id0
             * rA clif.cpp #1102
             */
            entityData.Accessory2 = br.ReadUShort();
            entityData.Accessory3 = br.ReadUShort();

            entityData.HairColor    = br.ReadShort();
            entityData.ClothesColor = br.ReadShort();
            entityData.headDir      = br.ReadShort();

            entityData.Robe = br.ReadUShort();

            entityData.GUID = br.ReadUInt();

            entityData.GEmblemVer = br.ReadShort();
            entityData.honor      = br.ReadShort();

            entityData.virtue = br.ReadInt();

            entityData.isPKModeON = (byte)br.ReadByte();
            entityData.sex        = (byte)br.ReadByte();

            entityData.PosDir = br.ReadPos2();

            entityData.xSize = (byte)br.ReadByte();
            entityData.ySize = (byte)br.ReadByte();
            entityData.state = (byte)br.ReadByte();

            entityData.clevel = br.ReadShort();
            entityData.font   = br.ReadShort();

            entityData.MaxHP = br.ReadInt();
            entityData.HP    = br.ReadInt();

            entityData.isBoss = (byte)br.ReadByte();

            entityData.body = br.ReadUShort();
            entityData.name = br.ReadBinaryString(24);
        }
Пример #28
0
 public void Read(MemoryStreamReader br, int size)
 {
     NAID    = br.ReadUInt();
     Message = br.ReadBinaryString(br.Length - br.Position);
 }
Пример #29
0
 public void Read(MemoryStreamReader br, int size)
 {
     AID = br.ReadUInt();
 }
Пример #30
0
 public void Read(MemoryStreamReader br, int size)
 {
     AID  = br.ReadUInt();
     PosX = br.ReadShort();
     PosY = br.ReadShort();
 }