public void Check_Data_Remaining_FixedLength_Unicode_BigEndian(string str, int remains) { Span <byte> data = Encoding.BigEndianUnicode.GetBytes(str); StackDataReader reader = new StackDataReader(data); reader.ReadUnicodeBE(str.Length); Assert.Equal(reader.Remaining, remains); reader.ReadUnicodeBE(remains); Assert.Equal(0, reader.Remaining); reader.Release(); }
public void Read_More_Data_Than_Remains_Unicode(string str, int length) { Span <byte> data = Encoding.BigEndianUnicode.GetBytes(str); StackDataReader reader = new StackDataReader(data); string s = reader.ReadUnicodeBE(length); Assert.Equal(str, s); reader.Release(); }
public void Read_Unicode_BigEndian(string str, string result) { Span <byte> data = Encoding.BigEndianUnicode.GetBytes(str); StackDataReader reader = new StackDataReader(data); string s = reader.ReadUnicodeBE(); Assert.Equal(s, result); reader.Release(); }
public void Read_Unicode_BigEndian_With_FixedLength(string str, string result) { Span <byte> data = Encoding.BigEndianUnicode.GetBytes(str); StackDataReader reader = new StackDataReader(data); string s = reader.ReadUnicodeBE(str.Length); Assert.Equal(s, result); Assert.Equal(0, reader.Remaining); reader.Release(); }
public void ParsePacket(ref StackDataReader p) { byte code = p.ReadUInt8(); bool add = false; switch (code) { case 1: add = true; goto case 2; case 2: byte count = p.ReadUInt8(); if (count <= 1) { Leader = 0; Inviter = 0; for (int i = 0; i < PARTY_SIZE; i++) { if (Members[i] == null || Members[i].Serial == 0) { break; } BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(Members[i].Serial); if (gump != null) { if (code == 2) { Members[i].Serial = 0; } gump.RequestUpdateContents(); } } Clear(); UIManager.GetGump <PartyGump>()?.RequestUpdateContents(); break; } Clear(); uint to_remove = 0xFFFF_FFFF; if (!add) { to_remove = p.ReadUInt32BE(); UIManager.GetGump <BaseHealthBarGump>(to_remove)?.RequestUpdateContents(); } bool remove_all = !add && to_remove == World.Player; int done = 0; for (int i = 0; i < count; i++) { uint serial = p.ReadUInt32BE(); bool remove = !add && serial == to_remove; if (remove && serial == to_remove && i == 0) { remove_all = true; } if (!remove && !remove_all) { if (!Contains(serial)) { Members[i] = new PartyMember(serial); } done++; } if (i == 0 && !remove && !remove_all) { Leader = serial; } BaseHealthBarGump gump = UIManager.GetGump <BaseHealthBarGump>(serial); if (gump != null) { gump.RequestUpdateContents(); } else { if (serial == World.Player) { } } } if (done <= 1 && !add) { for (int i = 0; i < PARTY_SIZE; i++) { if (Members[i] != null && SerialHelper.IsValid(Members[i].Serial)) { uint serial = Members[i].Serial; Members[i] = null; UIManager.GetGump <BaseHealthBarGump>(serial)?.RequestUpdateContents(); } } Clear(); } UIManager.GetGump <PartyGump>()?.RequestUpdateContents(); break; case 3: case 4: uint ser = p.ReadUInt32BE(); string name = p.ReadUnicodeBE(); for (int i = 0; i < PARTY_SIZE; i++) { if (Members[i] != null && Members[i].Serial == ser) { MessageManager.HandleMessage ( null, name, Members[i].Name, ProfileManager.CurrentProfile.PartyMessageHue, MessageType.Party, 3, TextType.GUILD_ALLY ); break; } } break; case 7: Inviter = p.ReadUInt32BE(); if (ProfileManager.CurrentProfile.PartyInviteGump) { UIManager.Add(new PartyInviteGump(Inviter)); } break; } }