Пример #1
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;
            }
        }
Пример #2
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);
        }
Пример #3
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()
     };
 }
Пример #4
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);
            }
        }
Пример #5
0
 public void Read(MemoryStreamReader br, int size)
 {
     index         = br.ReadShort();
     equipLocation = br.ReadInt();
     ViewID        = br.ReadShort();
     result        = br.ReadByte();
 }
Пример #6
0
 public void Read(MemoryStreamReader br, int size)
 {
     GID     = br.ReadInt();
     Mapname = br.ReadBinaryString(16);
     IP      = new IPAddress(br.ReadBytes(4));
     Port    = br.ReadShort();
     br.Seek(128, System.IO.SeekOrigin.Current);
 }
Пример #7
0
        private static GND.Surface[] ParseSurfaces(GND gnd, MemoryStreamReader data)
        {
            var count = gnd.width * gnd.height;

            GND.Surface[] surfaces = new GND.Surface[count];

            for (int i = 0; i < count; i++)
            {
                var surface = surfaces[i] = new GND.Surface();
                surface.height    = new Vector4(data.ReadFloat() / 5, data.ReadFloat() / 5, data.ReadFloat() / 5, data.ReadFloat() / 5);
                surface.tileUp    = data.ReadInt();
                surface.tileFront = data.ReadInt();
                surface.tileRight = data.ReadInt();
            }

            return(surfaces);
        }
Пример #8
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();
        }
Пример #9
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();
        }
Пример #10
0
        public void Read(MemoryStreamReader br, int size)
        {
            Tick = br.ReadInt();
            var posDir = br.ReadPos();

            PosX = posDir[0];
            PosY = posDir[1];
            Dir  = posDir[2];

            br.Seek(2, SeekOrigin.Current);

            Font = br.ReadShort();
            Sex  = br.ReadByte();
        }
Пример #11
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);
            }
        }
Пример #12
0
        public static ACT Load(MemoryStreamReader data)
        {
            string header = data.ReadBinaryString(2);

            if (!header.Equals(ACT.Header))
            {
                throw new Exception("ActionLoader.Load: Header \"" + header + "\" is not \"AC\"");
            }

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

            version += "." + subversion;

            double dversion = double.Parse(version, CultureInfo.InvariantCulture);

            ACT act = new ACT();

            act.version = version;

            ReadActions(act, data);

            if (dversion >= 2.1)
            {
                //sounds
                var count = data.ReadInt();
                act.sounds = new string[count];

                for (int i = 0; i < count; i++)
                {
                    act.sounds[i] = data.ReadBinaryString(40);
                }

                //delay
                if (dversion >= 2.2)
                {
                    for (int i = 0; i < act.actions.Length; i++)
                    {
                        act.actions[i].delay = data.ReadFloat() * 25;
                    }
                }
            }

            return(act);
        }
Пример #13
0
        public void Read(MemoryStreamReader br, int size)
        {
            var count = Math.Max(0, (br.Length - br.Position) / BLOCK_SIZE);

            for (int i = 0; i < count; i++)
            {
                var skill = new SkillInfo()
                {
                    SkillID     = br.ReadShort(),
                    SkillType   = br.ReadInt(),
                    Level       = br.ReadShort(),
                    SpCost      = br.ReadShort(),
                    AttackRange = br.ReadShort(),
                    SkillName   = br.ReadBinaryString(24),
                    CanUpgrade  = br.ReadByte() == 1
                };

                skills.Add(skill);
            }
        }
Пример #14
0
 public void Read(MemoryStreamReader br, int size)
 {
     AID     = br.ReadUInt();
     Ranking = br.ReadInt();
     Total   = br.ReadInt();
 }
Пример #15
0
    public static CharacterData parse(MemoryStreamReader br)
    {
        CharacterData cd = new CharacterData();

        cd.GID = br.ReadInt();
        cd.Exp = br.ReadInt();
        br.Seek(4, SeekOrigin.Current);
        cd.Zeny   = br.ReadInt();
        cd.JobExp = br.ReadInt();
        br.Seek(4, SeekOrigin.Current);
        cd.JobLevel    = br.ReadInt();
        cd.BodyState   = br.ReadInt();
        cd.HealthState = br.ReadInt();
        cd.Option      = br.ReadInt();
        cd.Karma       = br.ReadInt();
        cd.Manner      = br.ReadInt();

        cd.StatusPoint = br.ReadShort();

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

        cd.SP           = br.ReadShort();
        cd.MaxSP        = br.ReadShort();
        cd.Speed        = br.ReadShort();
        cd.Job          = br.ReadShort();
        cd.Hair         = br.ReadShort();
        cd.Body         = br.ReadShort();
        cd.Weapon       = br.ReadShort();
        cd.BaseLevel    = br.ReadShort();
        cd.SkillPoint   = br.ReadShort();
        cd.Accessory    = br.ReadShort();
        cd.Shield       = br.ReadShort();
        cd.Accessory2   = br.ReadShort();
        cd.Accessory3   = br.ReadShort();
        cd.HairColor    = br.ReadShort();
        cd.ClothesColor = br.ReadShort();

        cd.Name = br.ReadBinaryString(24);

        cd.Str = (byte)br.ReadByte();
        cd.Agi = (byte)br.ReadByte();
        cd.Vit = (byte)br.ReadByte();
        cd.Int = (byte)br.ReadByte();
        cd.Dex = (byte)br.ReadByte();
        cd.Luk = (byte)br.ReadByte();

        cd.Slot   = br.ReadShort();
        cd.Rename = br.ReadShort();

        cd.MapName = br.ReadBinaryString(16);

        cd.DeleteDate = br.ReadInt();
        cd.Robe       = br.ReadInt();
        cd.Moves      = br.ReadInt();
        cd.AddOns     = br.ReadInt();

        cd.Sex = br.ReadByte();

        return(cd);
    }
Пример #16
0
 public void Read(MemoryStreamReader br, int size)
 {
     var type = br.ReadShort();
     var flag = br.ReadInt();
 }
Пример #17
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
            });
        }
Пример #18
0
 public void Read(MemoryStreamReader br, int size)
 {
     varID = (EntityStatus)br.ReadUShort();
     value = br.ReadInt();
 }
Пример #19
0
        public static RSW Load(MemoryStreamReader data)
        {
            //read header
            string header     = data.ReadBinaryString(4);
            string version    = Convert.ToString(data.ReadByte());
            string subversion = Convert.ToString(data.ReadByte());

            version += "." + subversion;
            double dversion = double.Parse(version, CultureInfo.InvariantCulture);

            //check for valid .rsw file
            if (!string.Equals(header, RSW.Header))
            {
                throw new Exception("WorldLoader.Load: Header (" + header + ") is not \"GRSW\"");
            }

            RSW rsw = new RSW(version);

            //read sub files
            files.ini = data.ReadBinaryString(40);
            files.gnd = data.ReadBinaryString(40);
            files.gat = data.ReadBinaryString(40);

            if (dversion >= 1.4)
            {
                files.src = data.ReadBinaryString(40);
            }

            //read water info
            if (dversion >= 1.3)
            {
                rsw.water.level = data.ReadFloat() / 5;

                if (dversion >= 1.8)
                {
                    rsw.water.type       = data.ReadInt();
                    rsw.water.waveHeight = data.ReadFloat() / 5;
                    rsw.water.waveSpeed  = data.ReadFloat();
                    rsw.water.wavePitch  = data.ReadFloat();

                    if (dversion >= 1.9)
                    {
                        rsw.water.animSpeed = data.ReadInt();
                    }
                }
            }

            //read lightmap
            if (dversion >= 1.5)
            {
                rsw.light.longitude = data.ReadInt();
                rsw.light.latitude  = data.ReadInt();
                for (int i = 0; i < 3; i++)
                {
                    rsw.light.diffuse[i] = data.ReadFloat();
                }
                for (int i = 0; i < 3; i++)
                {
                    rsw.light.ambient[i] = data.ReadFloat();
                }

                if (dversion >= 1.7)
                {
                    rsw.light.intensity = data.ReadFloat();
                }
            }

            // Read ground
            if (dversion >= 1.6)
            {
                rsw.ground.top    = data.ReadInt();
                rsw.ground.bottom = data.ReadInt();
                rsw.ground.left   = data.ReadInt();
                rsw.ground.right  = data.ReadInt();
            }

            // Read Object
            int count   = data.ReadInt();
            var models  = rsw.modelDescriptors = new List <RSW.ModelDescriptor>(count);
            var lights  = rsw.lights = new List <RSW.Light>(count);
            var sounds  = rsw.sounds = new List <RSW.Sound>(count);
            var effects = rsw.effects = new List <RSW.Effect>(count);

            for (int i = 0; i < count; i++)
            {
                switch (data.ReadInt())
                {
                case 1:     //load model
                    var model = new RSW.ModelDescriptor();
                    model.name      = dversion >= 1.3 ? data.ReadBinaryString(40) : null;
                    model.animType  = dversion >= 1.3 ? data.ReadInt() : 0;
                    model.animSpeed = dversion >= 1.3 ? data.ReadFloat() : 0f;
                    model.blockType = dversion >= 1.3 ? data.ReadInt() : 0;
                    model.filename  = data.ReadBinaryString(80);
                    model.nodename  = data.ReadBinaryString(80);
                    model.position  = new float[3];
                    for (int j = 0; j < model.position.Length; j++)
                    {
                        model.position[j] = data.ReadFloat() / 5;
                    }
                    model.rotation = new float[3];
                    for (int j = 0; j < model.rotation.Length; j++)
                    {
                        model.rotation[j] = data.ReadFloat();
                    }
                    model.scale = new float[3];
                    for (int j = 0; j < model.scale.Length; j++)
                    {
                        model.scale[j] = data.ReadFloat() / 5;
                    }
                    models.Add(model);
                    continue;

                case 2:     //load light
                    var light = new RSW.Light();
                    light.name = data.ReadBinaryString(80);
                    light.pos  = new float[3];
                    for (int j = 0; j < light.pos.Length; j++)
                    {
                        light.pos[j] = data.ReadFloat() / 5;
                    }
                    light.color = new float[3];
                    for (int j = 0; j < light.color.Length; j++)
                    {
                        light.color[j] = data.ReadFloat();
                    }
                    light.range = data.ReadFloat();
                    lights.Add(light);
                    continue;

                case 3:     //load sound
                    var sound = new RSW.Sound();
                    sound.name = data.ReadBinaryString(80);
                    sound.file = "data/wav/" + data.ReadBinaryString(80);
                    sound.pos  = new float[3];
                    for (int j = 0; j < sound.pos.Length; j++)
                    {
                        sound.pos[j] = data.ReadFloat() / 5;
                    }
                    sound.vol    = data.ReadFloat();
                    sound.width  = data.ReadInt();
                    sound.height = data.ReadInt();
                    sound.range  = data.ReadFloat();
                    sound.cycle  = dversion >= 2.0 ? data.ReadFloat() : 0f;
                    sounds.Add(sound);
                    continue;

                case 4:     //load effect
                    var effect = new RSW.Effect();
                    effect.name = data.ReadBinaryString(80);
                    effect.pos  = new float[3];
                    for (int j = 0; j < effect.pos.Length; j++)
                    {
                        effect.pos[j] = data.ReadFloat() / 5;
                    }
                    effect.id    = data.ReadInt();
                    effect.delay = data.ReadFloat() * 10;
                    effect.param = new float[4];
                    for (int j = 0; j < effect.param.Length; j++)
                    {
                        effect.param[j] = data.ReadFloat();
                    }
                    effects.Add(effect);
                    continue;
                }
            }

            models.TrimExcess();
            sounds.TrimExcess();
            lights.TrimExcess();
            effects.TrimExcess();

            return(rsw);
        }
Пример #20
0
 public void Read(MemoryStreamReader br, int size)
 {
     GID      = br.ReadUInt();
     EffectId = br.ReadInt();
 }
Пример #21
0
        private static RSM.Node LoadNode(RSM rsm, MemoryStreamReader data, double version)
        {
            RSM.Node node = new RSM.Node();

            node.model  = rsm;
            node.isOnly = rsm.nodes.Length == 1;

            node.name       = data.ReadBinaryString(40);
            node.parentName = data.ReadBinaryString(40);

            //read textures
            int textureCount = data.ReadInt();

            node.textures = new long[textureCount];

            for (int i = 0; i < textureCount; ++i)
            {
                node.textures[i] = data.ReadInt();
            }

            //read options
            node.mat3 = new Vector3[] {
                new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat()),
                new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat()),
                new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat())
            };

            node.offset   = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat());
            node.pos      = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat());
            node.rotAngle = data.ReadFloat();
            node.rotAxis  = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat());
            node.scale    = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat());

            //read vertices
            int verticeCount = data.ReadInt();

            node.vertices = new List <Vector3>();
            for (int i = 0; i < verticeCount; ++i)
            {
                node.vertices.Add(new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat()));
            }

            //read textures vertices
            int tverticeCount = data.ReadInt();

            node.tVertices = new float[tverticeCount * 6];
            for (int i = 0; i < tverticeCount; ++i)
            {
                if (version >= 1.2)
                {
                    node.tVertices[i * 6 + 0] = data.ReadByte() / 255f;
                    node.tVertices[i * 6 + 1] = data.ReadByte() / 255f;
                    node.tVertices[i * 6 + 2] = data.ReadByte() / 255f;
                    node.tVertices[i * 6 + 3] = data.ReadByte() / 255f;
                }
                node.tVertices[i * 6 + 4] = data.ReadFloat() * 0.98f + 0.01f;
                node.tVertices[i * 6 + 5] = data.ReadFloat() * 0.98f + 0.01f;
            }

            //read faces
            int faceCount = data.ReadInt();

            node.faces = new RSM.Face[faceCount];
            for (int i = 0; i < faceCount; ++i)
            {
                node.faces[i] = new RSM.Face()
                {
                    vertidx     = new Vector3Int(data.ReadUShort(), data.ReadUShort(), data.ReadUShort()),
                    tvertidx    = new Vector3Int(data.ReadUShort(), data.ReadUShort(), data.ReadUShort()),
                    texid       = data.ReadUShort(),
                    padding     = data.ReadUShort(),
                    twoSided    = data.ReadInt(),
                    smoothGroup = version >= 1.2 ? data.ReadInt() : 0
                };
            }

            //read position keyframes
            // DIFF: roBrowser and open-ragnarok use (version >= 1.5) here.
            // BrowEdit does not read position keyframes at all for any version.
            if (version > 1.5)
            {
                int pkfCount = data.ReadInt();
                for (int i = 0; i < pkfCount; ++i)
                {
                    var key = data.ReadInt();

                    if (!node.posKeyframes.ContainsKey(key))
                    {
                        node.posKeyframes.Add(key, new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat()));
                    }
                }
            }

            //read rotation keyframes
            int rkfCount = data.ReadInt();

            for (int i = 0; i < rkfCount; ++i)
            {
                int        time = data.ReadInt();
                Quaternion quat = new Quaternion(data.ReadFloat(), data.ReadFloat(), data.ReadFloat(), data.ReadFloat());

                if (!node.rotKeyframes.ContainsKey(time))
                {
                    //some models have multiple keyframes with the
                    //same timestamp, here we just keep the first one
                    //and throw out the rest.
                    node.rotKeyframes.Add(time, quat);
                }
            }

            node.box = new RSM.Box();

            return(node);
        }
Пример #22
0
 public void Read(MemoryStreamReader br, int size)
 {
     var totalCnt = br.ReadInt();
 }
Пример #23
0
 public void Read(MemoryStreamReader br, int size)
 {
     var seed      = br.ReadInt();
     var accountId = br.ReadInt();
     var state     = br.ReadShort();
 }
Пример #24
0
 public void Read(MemoryStreamReader fp, int size)
 {
     this.GID   = fp.ReadUInt();
     this.Hp    = fp.ReadInt();
     this.MaxHp = fp.ReadInt();
 }
Пример #25
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);
        }
Пример #26
0
        public static RSM Load(MemoryStreamReader data)
        {
            var header = data.ReadBinaryString(4);

            if (header != RSM.Header)
            {
                throw new Exception("ModelLoader.Load: Header (" + header + ") is not \"GRSM\"");
            }

            RSM rsm = new RSM();

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

            version += "." + subversion;
            double dversion = double.Parse(version, CultureInfo.InvariantCulture);

            rsm.version   = version;
            rsm.animLen   = data.ReadInt();
            rsm.shadeType = (RSM.SHADING)data.ReadInt();

            rsm.alpha = dversion >= 1.4 ? data.ReadByte() / 255f : 1;
            data.Seek(16, System.IO.SeekOrigin.Current);

            //read textures
            int textureCount = data.ReadInt();

            rsm.textures = new string[textureCount];
            for (int i = 0; i < textureCount; ++i)
            {
                rsm.textures[i] = data.ReadBinaryString(40);
            }

            //read nodes (meshes)
            rsm.name = data.ReadBinaryString(40);
            int nodeCount = data.ReadInt();

            rsm.nodes = new RSM.Node[nodeCount];

            for (int i = 0; i < nodeCount; ++i)
            {
                var node = rsm.nodes[i] = LoadNode(rsm, data, dversion);
                if (string.Equals(node.name, rsm.name))
                {
                    rsm.mainNode = node;
                }
            }

            //fallback for non defined main node
            if (rsm.mainNode == null)
            {
                rsm.mainNode = rsm.nodes[0];
            }

            //read poskeyframes
            if (dversion < 1.5)
            {
                int count = data.ReadInt();
                rsm.posKeyframes = new RSM.PositionKeyframe[count];
                for (int i = 0; i < count; ++i)
                {
                    rsm.posKeyframes[i] = new RSM.PositionKeyframe()
                    {
                        frame = data.ReadInt(),
                        p     = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat())
                    };
                }
            }
            else
            {
                rsm.posKeyframes = new RSM.PositionKeyframe[0];
            }

            //read volume box
            short vbCount = (short)data.ReadInt();

            rsm.volumeBoxes = new RSM.VolumeBox[vbCount];

            for (int i = 0; i < vbCount; ++i)
            {
                rsm.volumeBoxes[i] = new RSM.VolumeBox()
                {
                    size = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat()),
                    pos  = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat()),
                    rot  = new Vector3(data.ReadFloat(), data.ReadFloat(), data.ReadFloat()),
                    flag = dversion >= 1.3 ? data.ReadInt() : 0
                };
            }

            rsm.instances = new List <RSW.ModelDescriptor>();
            rsm.box       = new RSM.Box();

            CalcBoundingBox(rsm);

            return(rsm);
        }
 public void Read(MemoryStreamReader br, int size)
 {
     WeightPercentage = br.ReadInt();
 }
Пример #28
0
        public static STR Load(MemoryStreamReader data, string path)
        {
            var header = data.ReadBinaryString(4);

            if (!header.Equals(STR.Header))
            {
                throw new Exception("EffectLoader.Load: Header (" + header + ") is not \"STRM\"");
            }

            var version = data.ReadUInt();

            if (version != 0x94)
            {
                throw new Exception("EffectLoader.Load: Unsupported STR version (v" + version + ")");
            }

            STR str = new STR();

            str.version = version;
            str.fps     = data.ReadUInt();
            str.maxKey  = data.ReadUInt();
            var layerCount = data.ReadUInt();

            data.Seek(16, System.IO.SeekOrigin.Current);


            //read layers
            str.layers = new STR.Layer[layerCount];
            for (uint i = 0; i < layerCount; i++)
            {
                STR.Layer layer = str.layers[i] = new STR.Layer();

                //read texture filenames
                var textureCount = data.ReadInt();
                layer.textures    = new Texture2D[textureCount];
                layer.texturesIds = new List <int>();
                for (int j = 0; j < textureCount; j++)
                {
                    var tex     = data.ReadBinaryString(128);
                    var texture = FileManager.Load(path + "/" + tex) as Texture2D;
                    layer.textures[j] = texture;

                    if (!textureNames.Contains(tex))
                    {
                        layer.texturesIds.Add(textureNames.Count);
                        textureIdLookup.Add(tex, textureNames.Count);
                        textureNames.Add(tex);
                        textures.Add(texture);
                    }
                    else
                    {
                        layer.texturesIds.Add(textureIdLookup[tex]);
                    }
                }

                //read animations
                var animCount = data.ReadInt();
                layer.animations = new STR.Animation[animCount];
                for (int j = 0; j < animCount; j++)
                {
                    var entry = new STR.Animation()
                    {
                        frame    = data.ReadInt(),
                        type     = data.ReadUInt(),
                        position = new Vector2(data.ReadFloat(), data.ReadFloat())
                    };

                    var uv = new float[] {
                        data.ReadFloat(), data.ReadFloat(), data.ReadFloat(), data.ReadFloat(),
                        data.ReadFloat(), data.ReadFloat(), data.ReadFloat(), data.ReadFloat()
                    };
                    var xy = new float[] {
                        data.ReadFloat(), data.ReadFloat(), data.ReadFloat(), data.ReadFloat(),
                        data.ReadFloat(), data.ReadFloat(), data.ReadFloat(), data.ReadFloat()
                    };

                    entry.uv    = new Vector2[4];
                    entry.uv[0] = new Vector2(0, 0);
                    entry.uv[1] = new Vector2(1, 0);
                    entry.uv[2] = new Vector2(0, 1);
                    entry.uv[3] = new Vector2(1, 1);

                    entry.xy    = new Vector2[4];
                    entry.xy[0] = new Vector2(xy[0], -xy[4]);
                    entry.xy[1] = new Vector2(xy[1], -xy[5]);
                    entry.xy[2] = new Vector2(xy[3], -xy[7]);
                    entry.xy[3] = new Vector2(xy[2], -xy[6]);

                    entry.animFrame = data.ReadFloat();
                    entry.animType  = data.ReadUInt();
                    entry.delay     = data.ReadFloat();
                    entry.angle     = data.ReadFloat() / (1024f / 360f);
                    entry.color     = new Color(data.ReadFloat() / 255, data.ReadFloat() / 255, data.ReadFloat() / 255, data.ReadFloat() / 255);
                    entry.srcAlpha  = data.ReadUInt();
                    entry.destAlpha = data.ReadUInt();
                    entry.mtPreset  = data.ReadUInt();

                    layer.animations[j] = entry;
                }
            }

            return(MakeAtlas(str, path));
        }
Пример #29
0
 public void Read(MemoryStreamReader br, int size)
 {
     status    = (EntityStatus)br.ReadUInt();
     value     = br.ReadInt();
     plusValue = br.ReadInt();
 }