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; } }
public static SPR Load(MemoryStreamReader data) { var header = data.ReadBinaryString(2); if (!header.Equals(SPR.Header)) { throw new Exception("SpriteLoader.Load: Header (" + header + ") is not \"SP\""); } SPR spr = new SPR(); string subversion = Convert.ToString(data.ReadByte()); string version = Convert.ToString(data.ReadByte()); version += "." + subversion; spr.version = version; spr.indexedCount = data.ReadUShort(); spr._indexedCount = spr.indexedCount; var dversion = double.Parse(version, CultureInfo.InvariantCulture); if (dversion > 1.1) { spr.rgbaCount = data.ReadUShort(); } spr.frames = new SPR.Frame[spr.indexedCount + spr.rgbaCount]; spr.rgbaIndex = spr.indexedCount; if (dversion < 2.1) { ReadIndexedImage(spr, data); } else { ReadIndexedImageRLE(spr, data); } ReadRgbaImage(spr, data); if (dversion > 1.0) { long position = data.Position; data.Seek(-1024, System.IO.SeekOrigin.End); spr.palette = data.ReadBytes(1024); data.Seek(position, System.IO.SeekOrigin.Begin); } return(spr); }
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); } }
private static void ReadIndexedImage(SPR spr, MemoryStreamReader data) { for (int i = 0; i < spr.indexedCount; i++) { var width = data.ReadUShort(); var height = data.ReadUShort(); spr.frames[i] = new SPR.Frame() { type = SPR.TYPE_PAL, width = width, height = height, data = data.ReadBytes(width * height) }; } }
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(); }
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); }
private static void ReadIndexedImageRLE(SPR spr, MemoryStreamReader data) { for (int i = 0; i < spr.indexedCount; i++) { var width = data.ReadUShort(); var height = data.ReadUShort(); var _data = new byte[width * height]; var end = data.ReadUShort() + data.Position; var index = 0; while (data.Position < end) { var c = _data[index++] = (byte)data.ReadByte(); if (c == 0) { var count = data.ReadByte(); if (count == 0) { _data[index++] = 0; } else { for (int j = 1; j < count; j++) { _data[index++] = c; } } } } spr.frames[i] = new SPR.Frame() { type = SPR.TYPE_PAL, width = width, height = height, data = _data }; } }
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(); }
private static void ReadActions(ACT act, MemoryStreamReader data) { var count = data.ReadUShort(); data.Seek(10, System.IO.SeekOrigin.Current); act.actions = new ACT.Action[count]; for (int i = 0; i < count; i++) { act.actions[i] = new ACT.Action() { frames = ReadMotions(act, data), delay = 150f }; } }
/** * 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(); }
public void Read(MemoryStreamReader br, int size) { MessageID = br.ReadUShort(); }
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); }
public void Read(MemoryStreamReader br, int size) { varID = (EntityStatus)br.ReadUShort(); value = br.ReadInt(); }
public void Read(MemoryStreamReader br, int size) { this.DeleteType = br.ReadShort(); this.Index = br.ReadUShort(); this.Count = br.ReadUShort(); }
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); }