private void connectToolStripMenuItem_Click(object sender, EventArgs e) { if (clientState == ClientState.Disconnected) { try { using (ConnectForm connectForm = new ConnectForm()) { // THIS IS CONFIRMED TO WORK! //float playerBase = codeInjector.ReadFloat(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(0x004C67BC) + 0x60) + 0xA8) + 0x114) + 0x40) + 0x130); //Console.WriteLine(playerBase); connectForm.ShowDialog(); participant.Nickname = connectForm.Nickname; client = new Client(); client.PacketReceived += client_PacketReceived; client.Connect(IPAddress.Parse(connectForm.Server), 3031, 3030); client.Send(ProtocolType.Tcp, new Packet() { PacketType = PacketType.Connect, Content = connectForm.Nickname }); clientState = ClientState.Connecting; /*if (connectForm.Server != null && connectForm.Nickname != null) { ipEndPoint = new IPEndPoint(IPAddress.Parse(connectForm.Server), 3030); tcpClient.Connect(new IPEndPoint(IPAddress.Parse(connectForm.Server), 3031)); stream = tcpClient.GetStream(); Packet packet = new Packet() { PacketType = PacketType.Connect, Content = connectForm.Nickname }; stream.Write(packet.ToBytes(), 0, packet.Length); listenerThread.Start(); /* client = new UdpClient(); client.Connect(ipEndPoint); Packet packet = SendPacket(new Packet() { PacketType = PacketType.Nickname, Content = connectForm.Nickname }); if (packet.PacketType != PacketType.Nickname || packet.Content != "OK") { MessageBox.Show("An error occured during the handshake with the Server. A response was received, but the Server rejected your request. Please try again.", "Error while handshaking"); } else { participants = new List<Participant>(); playerCount = 0; participant.Nickname = connectForm.Nickname; clientState = ClientState.Connected; SetStatus("Connected (" + connectForm.Server + ")"); } }*/ } } catch (Exception exc) { ErrorHandler.ShowDialog("Connect dialog failed to load", "The connect dialog failed to load.", exc); } } else { MessageBox.Show("Disconnect from the current game to connect to a new game.","Already connected"); } }
private void connectToolStripMenuItem_Click(object sender, EventArgs e) { if (clientState == ClientState.Disconnected) { try { using (ConnectForm connectForm = new ConnectForm()) { // THIS IS CONFIRMED TO WORK! //float playerBase = codeInjector.ReadFloat(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(codeInjector.ReadUInt(0x004C67BC) + 0x60) + 0xA8) + 0x114) + 0x40) + 0x130); //Console.WriteLine(playerBase); connectForm.ShowDialog(); participant.Nickname = connectForm.Nickname; client = new Client(); client.PacketReceived += client_PacketReceived; client.Connect(IPAddress.Parse(connectForm.Server), 3031, 3030); client.Send(ProtocolType.Tcp, new Packet() { PacketType = PacketType.Connect, Content = connectForm.Nickname }); clientState = ClientState.Connecting; /*if (connectForm.Server != null && connectForm.Nickname != null) * { * ipEndPoint = new IPEndPoint(IPAddress.Parse(connectForm.Server), 3030); * * tcpClient.Connect(new IPEndPoint(IPAddress.Parse(connectForm.Server), 3031)); * * stream = tcpClient.GetStream(); * * Packet packet = new Packet() * { * PacketType = PacketType.Connect, * Content = connectForm.Nickname * }; * * stream.Write(packet.ToBytes(), 0, packet.Length); * * listenerThread.Start(); * * /* * * client = new UdpClient(); * client.Connect(ipEndPoint); * * Packet packet = SendPacket(new Packet() * { * PacketType = PacketType.Nickname, * Content = connectForm.Nickname * }); * * if (packet.PacketType != PacketType.Nickname || packet.Content != "OK") * { * MessageBox.Show("An error occured during the handshake with the Server. A response was received, but the Server rejected your request. Please try again.", "Error while handshaking"); * } * else * { * participants = new List<Participant>(); * playerCount = 0; * participant.Nickname = connectForm.Nickname; * clientState = ClientState.Connected; * * SetStatus("Connected (" + connectForm.Server + ")"); * } * }*/ } } catch (Exception exc) { ErrorHandler.ShowDialog("Connect dialog failed to load", "The connect dialog failed to load.", exc); } } else { MessageBox.Show("Disconnect from the current game to connect to a new game.", "Already connected"); } }
public void Connect() { if (isAlreadyConnecting) return; isAlreadyConnecting = true; // Empty list box CuCoForm = new ConnectingForm(); CoForm = new ConnectForm(); //this.treeView1.Nodes.Clear(); //lbUserList.Items.Clear(); this.dataGridView_users.Rows.Clear(); bool connected = false; bool firstrun = true; while (!connected) { if (!firstrun || (firstrun && !Program.AppConfig.AutoConnect) || hasTriedFirstConnection && WindowState != FormWindowState.Minimized) { if (CoForm.ShowDialog(this) != DialogResult.OK) { // Clean exit Application.Exit(); return; } } firstrun = false; // Create the player info Player = new PlayerCarac(); Player.Nick = Program.AppConfig.Nick; Player.Type = (PlayerClass)CoForm.lbClass.SelectedIndex; Player.TextColor = Program.AppConfig.TextColor; hasTriedFirstConnection = true; connected = (CuCoForm.ShowDialog(this) == DialogResult.OK); } // Change text color tbInput.ForeColor = Program.AppConfig.TextColor; isAlreadyConnecting = false; this.toolStripStatusLabel3.Text = Player.Nick; }