private void InitSpectatorLocation(GameSession player, CardLocation loc) { for (int index = 0; index < 2; index++) { int flag = loc == CardLocation.MonsterZone ? 0x91fff : 0x81fff; byte[] result = m_duel.QueryFieldCard(index, loc, flag, false); using (MemoryStream ms = new MemoryStream(result)) { BinaryReader reader = new BinaryReader(ms); BinaryWriter writer = new BinaryWriter(ms); while (ms.Position < ms.Length) { int len = reader.ReadInt32(); if (len == 4) continue; long pos = ms.Position; reader.ReadBytes(len - 4); long endPos = ms.Position; ms.Position = pos; ClientCard card = new ClientCard(); card.Update(reader); ms.Position = endPos; bool facedown = ((card.Position & (int)CardPosition.FaceDown) != 0); using (GameServerPacket move = new GameServerPacket(GameMessage.Move)) { move.Write(facedown ? 0 : card.Code); move.Write(0); move.Write((byte)card.Controler); move.Write((byte)card.Location); move.Write((byte)card.Sequence); move.Write((byte)card.Position); move.Write(0); player.Send(move, false); } foreach (ClientCard material in card.Overlay) { using (GameServerPacket xyzcreate = new GameServerPacket(GameMessage.Move)) { xyzcreate.Write(material.Code); xyzcreate.Write(0); xyzcreate.Write((byte)index); xyzcreate.Write((byte)CardLocation.Grave); xyzcreate.Write((byte)0); xyzcreate.Write((byte)0); xyzcreate.Write(0); player.Send(xyzcreate, false); } using (GameServerPacket xyzmove = new GameServerPacket(GameMessage.Move)) { xyzmove.Write(material.Code); xyzmove.Write((byte)index); xyzmove.Write((byte)CardLocation.Grave); xyzmove.Write((byte)0); xyzmove.Write((byte)0); xyzmove.Write((byte)material.Controler); xyzmove.Write((byte)material.Location); xyzmove.Write((byte)material.Sequence); xyzmove.Write((byte)material.Position); xyzmove.Write(0); player.Send(xyzmove, false); } } if (facedown) { ms.Position = pos; writer.Write(new byte[len - 4]); } } writer.Close(); reader.Close(); } if (loc == CardLocation.MonsterZone) { result = m_duel.QueryFieldCard(index, loc, 0x81fff, false); using (MemoryStream ms = new MemoryStream(result)) { BinaryReader reader = new BinaryReader(ms); BinaryWriter writer = new BinaryWriter(ms); while (ms.Position < ms.Length) { int len = reader.ReadInt32(); if (len == 4) continue; long pos = ms.Position; byte[] raw = reader.ReadBytes(len - 4); bool facedown = ((raw[11] & (int)CardPosition.FaceDown) != 0); if (facedown) { ms.Position = pos; writer.Write(new byte[len - 4]); } } reader.Close(); writer.Close(); } } using (GameServerPacket update = new GameServerPacket(GameMessage.UpdateData)) { update.Write((byte)index); update.Write((byte)loc); update.Write(result); player.Send(update); } } }
public void Update(BinaryReader reader) { int flag = reader.ReadInt32(); if ((flag & (int)Query.Code) != 0) Code = reader.ReadInt32(); if ((flag & (int)Query.Position) != 0) { Controler = reader.ReadByte(); Location = reader.ReadByte(); Sequence = reader.ReadByte(); Position = reader.ReadByte(); } if ((flag & (int)Query.Alias) != 0) reader.ReadInt32(); if ((flag & (int)Query.Type) != 0) reader.ReadInt32(); if ((flag & (int)Query.Level) != 0) reader.ReadInt32(); if ((flag & (int)Query.Rank) != 0) reader.ReadInt32(); if ((flag & (int)Query.Attribute) != 0) reader.ReadInt32(); if ((flag & (int)Query.Race) != 0) reader.ReadInt32(); if ((flag & (int)Query.Attack) != 0) reader.ReadInt32(); if ((flag & (int)Query.Defence) != 0) reader.ReadInt32(); if ((flag & (int)Query.BaseAttack) != 0) reader.ReadInt32(); if ((flag & (int)Query.BaseDefence) != 0) reader.ReadInt32(); if ((flag & (int)Query.Reason) != 0) reader.ReadInt32(); if ((flag & (int)Query.ReasonCard) != 0) reader.ReadInt32(); // Int8 * 4 if ((flag & (int)Query.EquipCard) != 0) reader.ReadInt32(); // Int8 * 4 if ((flag & (int)Query.TargetCard) != 0) { int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) reader.ReadInt32(); // Int8 * 4 } if ((flag & (int)Query.OverlayCard) != 0) { int count = reader.ReadInt32(); Overlay.Clear(); for (int i = 0; i < count; ++i) { ClientCard xyz = new ClientCard(reader.ReadInt32()); Overlay.Add(xyz); xyz.Controler = Controler; xyz.Location = Location | (int)CardLocation.Overlay; xyz.Sequence = Sequence; xyz.Position = 0; } } if ((flag & (int)Query.Counters) != 0) { int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) reader.ReadInt32(); // Int16 * 2 } if ((flag & (int)Query.Owner) != 0) reader.ReadInt32(); if ((flag & (int)Query.IsDisabled) != 0) reader.ReadInt32(); if ((flag & (int)Query.IsPublic) != 0) reader.ReadInt32(); if ((flag & (int)Query.LScale) != 0) reader.ReadInt32(); if ((flag & (int)Query.RScale) != 0) reader.ReadInt32(); }
public void Update(BinaryReader reader) { int flag = reader.ReadInt32(); if ((flag & (int)Query.Code) != 0) { Code = reader.ReadInt32(); } if ((flag & (int)Query.Position) != 0) { Controler = reader.ReadByte(); Location = reader.ReadByte(); Sequence = reader.ReadByte(); Position = reader.ReadByte(); } if ((flag & (int)Query.Alias) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Type) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Level) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Rank) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Attribute) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Race) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Attack) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Defence) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.BaseAttack) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.BaseDefence) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.Reason) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.ReasonCard) != 0) { reader.ReadInt32(); // Int8 * 4 } if ((flag & (int)Query.EquipCard) != 0) { reader.ReadInt32(); // Int8 * 4 } if ((flag & (int)Query.TargetCard) != 0) { int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) { reader.ReadInt32(); // Int8 * 4 } } if ((flag & (int)Query.OverlayCard) != 0) { int count = reader.ReadInt32(); Overlay.Clear(); for (int i = 0; i < count; ++i) { ClientCard xyz = new ClientCard(reader.ReadInt32()); Overlay.Add(xyz); xyz.Controler = Controler; xyz.Location = Location | (int)CardLocation.Overlay; xyz.Sequence = Sequence; xyz.Position = 0; } } if ((flag & (int)Query.Counters) != 0) { int count = reader.ReadInt32(); for (int i = 0; i < count; ++i) { reader.ReadInt32(); // Int16 * 2 } } if ((flag & (int)Query.Owner) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.IsDisabled) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.IsPublic) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.LScale) != 0) { reader.ReadInt32(); } if ((flag & (int)Query.RScale) != 0) { reader.ReadInt32(); } }