public static ServerListEntry Create(ref StackDataReader p) { ServerListEntry entry = new ServerListEntry() { Index = p.ReadUInt16BE(), Name = p.ReadASCII(32, true), PercentFull = p.ReadUInt8(), Timezone = p.ReadUInt8(), Address = p.ReadUInt32BE() }; // some server sends invalid ip. try { entry._ipAddress = new IPAddress ( new byte[] { (byte)((entry.Address >> 24) & 0xFF), (byte)((entry.Address >> 16) & 0xFF), (byte)((entry.Address >> 8) & 0xFF), (byte)(entry.Address & 0xFF) } ); } catch (Exception e) { Log.Error(e.ToString()); } entry._pinger.PingCompleted += entry.PingerOnPingCompleted; return(entry); }
public static PopupMenuData Parse(ref StackDataReader p) { ushort mode = p.ReadUInt16BE(); bool isNewCliloc = mode >= 2; uint serial = p.ReadUInt32BE(); byte count = p.ReadUInt8(); PopupMenuItem[] items = new PopupMenuItem[count]; for (int i = 0; i < count; i++) { ushort hue = 0xFFFF, replaced = 0; int cliloc; ushort index, flags; if (isNewCliloc) { cliloc = (int)p.ReadUInt32BE(); index = p.ReadUInt16BE(); flags = p.ReadUInt16BE(); } else { index = p.ReadUInt16BE(); cliloc = p.ReadUInt16BE() + 3000000; flags = p.ReadUInt16BE(); if ((flags & 0x84) != 0) { p.Skip(2); } if ((flags & 0x40) != 0) { p.Skip(2); } if ((flags & 0x20) != 0) { replaced = (ushort)(p.ReadUInt16BE()); } } if ((flags & 0x01) != 0) { hue = 0x0386; } items[i] = new PopupMenuItem ( cliloc, index, hue, replaced, flags ); } return(new PopupMenuData(serial, items)); }
public void HandleErrorCode(ref StackDataReader p) { byte code = p.ReadUInt8(); PopupMessage = ServerErrorMessages.GetError(p[0], code); CurrentLoginStep = LoginSteps.PopUpMessage; }
public void ServerListReceived(ref StackDataReader p) { byte flags = p.ReadUInt8(); ushort count = p.ReadUInt16BE(); DisposeAllServerEntries(); Servers = new ServerListEntry[count]; for (ushort i = 0; i < count; i++) { Servers[i] = ServerListEntry.Create(ref p); } CurrentLoginStep = LoginSteps.ServerSelection; if (CanAutologin) { if (Servers.Length != 0) { int index = GetServerIndexFromSettings(); SelectServer((byte)Servers[index].Index); } } }
private static void ReceiveZuluPacket(ref StackDataReader p) { byte type = p.ReadUInt8(); switch (type) { case 0x1: HandleStatusUpdate(ref p); break; } }
private void ParseCharacterList(ref StackDataReader p) { int count = p.ReadUInt8(); Characters = new string[count]; for (ushort i = 0; i < count; i++) { Characters[i] = p.ReadASCII(30).TrimEnd('\0'); p.Skip(30); } }
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; } }
private void ParseCities(ref StackDataReader p) { byte count = p.ReadUInt8(); Cities = new CityInfo[count]; bool isNew = Client.Version >= ClientVersion.CV_70130; string[] descriptions = null; if (!isNew) { descriptions = ReadCityTextFile(count); } Point[] oldtowns = { new Point(105, 130), new Point(245, 90), new Point(165, 200), new Point(395, 160), new Point(200, 305), new Point(335, 250), new Point(160, 395), new Point(100, 250), new Point(270, 130), new Point(0xFFFF, 0xFFFF) }; for (int i = 0; i < count; i++) { CityInfo cityInfo; if (isNew) { byte cityIndex = p.ReadUInt8(); string cityName = p.ReadASCII(32); string cityBuilding = p.ReadASCII(32); ushort cityX = (ushort)p.ReadUInt32BE(); ushort cityY = (ushort)p.ReadUInt32BE(); sbyte cityZ = (sbyte)p.ReadUInt32BE(); uint cityMapIndex = p.ReadUInt32BE(); uint cityDescription = p.ReadUInt32BE(); p.Skip(4); cityInfo = new CityInfo ( cityIndex, cityName, cityBuilding, ClilocLoader.Instance.GetString((int)cityDescription), cityX, cityY, cityZ, cityMapIndex, isNew ); } else { byte cityIndex = p.ReadUInt8(); string cityName = p.ReadASCII(31); string cityBuilding = p.ReadASCII(31); cityInfo = new CityInfo ( cityIndex, cityName, cityBuilding, descriptions != null ? descriptions[i] : string.Empty, (ushort)oldtowns[i % oldtowns.Length].X, (ushort)oldtowns[i % oldtowns.Length].Y, 0, 0, isNew ); } Cities[i] = cityInfo; } }