public Decode(Socket wSock, byte[] buffer, Client net, object packetf) { try { UInt16 security; packet = packetf; ms = new MemoryStream(buffer); br = new BinaryReader(ms); dataSize = br.ReadUInt16(); byte[] b = new byte[dataSize]; Array.Copy(buffer, 6, b, 0, dataSize); BUFFER = b; OPCODE = br.ReadUInt16(); security = br.ReadUInt16(); socket = wSock; NET = net; } catch (Exception) { } }
public Decode(Socket wSock, byte[] buffer, Client net, object packetf, int size) { try { packet = packetf; ms = new MemoryStream(buffer); br = new BinaryReader(ms); byte[] b = new byte[size]; Array.Copy(buffer, 0, b, 0, size); BUFFER = b; OPCODE = 0; socket = wSock; NET = net; } catch (Exception) { } }
public Systems(Client de) { client = de; }
public bool CompareVersionEqual(Client.Version compver) { if ((client_version.Major == compver.Major) && (client_version.Minor == compver.Minor) && (client_version.Revision == compver.Revision) && (client_version.Patch == compver.Patch)) return true; return false; }
public bool CompareVersion(Client.Version compver) { if (client_version.Major > compver.Major) return true; else if (client_version.Major < compver.Major) return false; else if (client_version.Minor > compver.Minor) return true; else if (client_version.Minor < compver.Minor) return false; else if (client_version.Revision > compver.Revision) return true; else if (client_version.Revision < compver.Revision) return false; else if (client_version.Patch > compver.Patch) return true; else if (client_version.Patch < compver.Patch) return false; return true; }
private static void SendServerList(ref NetworkStream ns, Client client) { ServerList sl = Program.server_list; MemoryStream ms = new MemoryStream(6 + 40 * sl.ServerCount); short server_count = (short)sl.ServerCount; ms.WriteByte(0xA8); // Game Server List CMD WriteBE16(ms, (short)(6 + 40*server_count)); // MsgLen ms.WriteByte(0x00); // System Info Flag (0x64: Spy on client, 0xCC: no spy) WriteBE16(ms, server_count); // # of Servers short index = 0; foreach (ServerInfo server in sl.Servers) { if (client.CompareVersionInSARange()) //UO:SA Beta hack WriteBE16(ms, 0x3D); else WriteBE16(ms, index); index++; byte[] name = GetBytes(server.Name, 32); ms.Write(name, 0, 32); // 32 bytes ms.WriteByte(0); // percent full ms.WriteByte(0); // timezone WriteBE(ms, server.ip); } byte[] tmp = ms.ToArray(); ns.Write(tmp, 0, tmp.Length); }
public static void SendConnectGameServer(ref NetworkStream ns, int index, Client client) { MemoryStream ms = new MemoryStream(11); ServerInfo server = Program.server_list.Servers[index]; ms.WriteByte(0x8C); WriteBEflipped(ms, server.ip); WriteBE16(ms, (short)server.port); //Pol like seed ms.WriteByte(0xFE); ms.WriteByte(0xFE); if (client.CompareVersion(Client.VER60142)) ms.WriteByte(0xFD); else if (client.CompareVersionInSARange()) //UO:SA Beta hack (for 0xb9 packet) ms.WriteByte(0xFD); else ms.WriteByte(0xFE); //if (client.isUOKR) // ms.WriteByte(0xFC); //else if (client.CompareVersion(Client.VER6017)) ms.WriteByte(0xFD); else ms.WriteByte(0xFE); byte[] tmp = ms.ToArray(); ns.Write(tmp, 0, tmp.Length); }
public static void ServerSelectPacket(ref NetworkStream ns, Client client) { int index = ReadBE16(ns); if (client.CompareVersionInSARange()) //UO:SA Beta hack index = 0; if (index >= Program.server_list.ServerCount) return; SendConnectGameServer(ref ns, index, client); }
static public void LoginPacket(ref NetworkStream ns, Client client) { string username, password; { byte[] byte_username = new byte[30]; byte[] byte_password = new byte[30]; ns.Read(byte_username, 0, 30); ns.Read(byte_password, 0, 30); ns.ReadByte(); // next-login-key; username = Packets.GetString(byte_username); password = Packets.GetString(byte_password); } if (Auth.CanLogin(username, password)) { Console.WriteLine("Client connected: {0}", username); SendServerList(ref ns,client); } else { SendLoginDenied(ref ns, (byte)00); } }
static public void SeedPacket(ref NetworkStream ns, ref Client.Version ver) { int seed = ReadInt32(ns); ver.Major = ReadInt32(ns); ver.Minor = ReadInt32(ns); ver.Revision = ReadInt32(ns); ver.Patch = ReadInt32(ns); Console.WriteLine("Seed: 0x{0:X}", seed); Console.WriteLine("Client Version {0}.{1}.{2}.{3}", ver.Major, ver.Minor, ver.Revision, ver.Patch); }
private void ClientConnect(IAsyncResult ar) { try { Socket wSocket = serverSocket.EndAccept(ar); wSocket.DontFragment = false; object p = null; Client Player = new Client(); try { OnConnect(ref p, Player); } catch (Exception) { } Player.Packets = p; Player.clientSocket = wSocket; serverSocket.BeginAccept(new AsyncCallback(ClientConnect), null); try { wSocket.BeginReceive(Player.tmpbuf, 0, Player.tmpbuf.Length, SocketFlags.None, new AsyncCallback(Player.ReceiveData), wSocket); } catch (SocketException){} catch (Exception) { } } catch (ObjectDisposedException) { } catch (Exception ex) { OnError(ex); } }