public void method_2(byte[] data, int length) { try { int num = data[4]; int num2 = data[8]; World.int_9 = num2; ServerClass class2 = World.ServerList[num - 1]; byte[] bytes = Encoding.Default.GetBytes(class2.ServerList[num2 - 1].SERVER_IP); byte[] src = BitConverter.GetBytes(int.Parse(class2.ServerList[num2 - 1].SERVER_PORT)); byte[] buffer3 = Encoding.Default.GetBytes(class2.ServerList[num2 - 1].SERVER_NAME); byte[] buffer4 = BitConverter.GetBytes(bytes.Length); byte[] buffer5 = BitConverter.GetBytes(buffer3.Length); BitConverter.GetBytes((int)(((3 + bytes.Length) + src.Length) + buffer3.Length)); byte[] dst = new byte[((((6 + bytes.Length) + src.Length) + buffer3.Length) + 2) + buffer3.Length]; dst[0] = 100; dst[1] = 0x80; dst[4] = buffer4[0]; Buffer.BlockCopy(BitConverter.GetBytes((int)(dst.Length - 4)), 0, dst, 2, 2); Buffer.BlockCopy(bytes, 0, dst, 6, bytes.Length); Buffer.BlockCopy(src, 0, dst, 6 + bytes.Length, src.Length); Buffer.BlockCopy(buffer3, 0, dst, ((dst.Length - buffer3.Length) - buffer3.Length) - 2, buffer3.Length); Buffer.BlockCopy(buffer3, 0, dst, dst.Length - buffer3.Length, buffer3.Length); dst[(dst.Length - buffer3.Length) - 2] = buffer5[0]; dst[(((dst.Length - buffer3.Length) - 2) - buffer3.Length) - 2] = buffer5[0]; this.Client.Send(dst, dst.Length); } catch (Exception exception) { byte[] toSendBuff = this.SetMsg("系统错误,请联系客服人员"); Form1.WriteLine(1, "选定服务器列表 错误" + exception.Message); this.Client.Send(toSendBuff, toSendBuff.Length); } }
public void SetConfig2() { ServerCount = int.Parse(Config.IniReadValue("LoginServer", "serverCount")); ServerList.Clear(); for (int i = 0; i < ServerCount; i++) { ServerClass item = new ServerClass { SERVER_NAME = Config.IniReadValue("server" + i, "servername"), ServerCount = int.Parse(Config.IniReadValue("server" + i, "serverCount")) }; for (int j = 0; j < item.ServerCount; j++) { ServerXlClass class3 = new ServerXlClass(); string[] strArray = Config.IniReadValue("server" + i, "server" + j).Split(new char[] { ',' }); class3.SERVER_NAME = strArray[0]; class3.ServerId = j; class3.ServerZId = int.Parse(strArray[4]); class3.SERVER_IP = strArray[2]; class3.SERVER_PORT = strArray[3]; item.ServerList.Add(class3); } ServerList.Add(item); } Form1.WriteLine(2, "加载服务器列表完成:" + ServerList.Count); }
public byte[] method_6(int int_0) { ServerClass class2 = World.ServerList[int_0]; int serverCount = class2.ServerCount; byte[] bytes = Encoding.Default.GetBytes(class2.SERVER_NAME); int num2 = 0; List <byte[]> list = new List <byte[]>(); for (int i = 0; i < serverCount; i++) { byte[] item = this.method_5(class2.ServerList[i].ServerId, class2.ServerList[i].ServerZId, class2.ServerList[i].SERVER_NAME); num2 += item.Length; list.Add(item); } byte[] dst = new byte[12 + bytes.Length]; byte[] buffer4 = new byte[num2 + dst.Length]; num2 = 0; for (int j = 0; j < serverCount; j++) { byte[] src = list[j]; Buffer.BlockCopy(src, 0, buffer4, dst.Length + num2, src.Length); num2 += src.Length; } byte[] buffer6 = BitConverter.GetBytes((int)(int_0 + 1)); byte[] buffer7 = BitConverter.GetBytes(serverCount); byte[] buffer8 = BitConverter.GetBytes(bytes.Length); dst[0] = buffer6[0]; dst[dst.Length - 8] = 1; dst[2] = buffer8[0]; dst[dst.Length - 2] = buffer7[0]; dst[dst.Length - 4] = 1; Buffer.BlockCopy(bytes, 0, dst, 4, bytes.Length); Buffer.BlockCopy(dst, 0, buffer4, 0, dst.Length); return(buffer4); }