Ejemplo n.º 1
0
        public void RemoveServer()
        {
            Server_Details server_detail = new Server_Details
            {
                game_type    = "Death Match",
                map_name     = map_select.Items[map_select.SelectedIndex].ToString(),
                max_players  = Convert.ToInt32(player_limit.Text),
                player_count = 1,
                server_name  = ServerName.Text,
                port         = Convert.ToInt32(ServerPort.Text)
            };

            string server_detail_serialized = JsonConvert.SerializeObject(server_detail);

            // this is an absolutely horrible thing to do security wise but, I'm being lazy.
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://t4mp.thedefaced.org/remove_server.php");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(server_detail_serialized);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                if (result == "-1")
                {
                    //MessageBox.Show("That server name is invalid please do not include symbols!");
                    return;
                }
            }

            this.Close();
        }
Ejemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Server_Details server_detail = new Server_Details
            {
                game_type    = "Death Match",
                map_name     = map_select.Items[map_select.SelectedIndex].ToString(),
                max_players  = Convert.ToInt32(player_limit.Text),
                player_count = 1,
                server_name  = ServerName.Text,
                port         = Convert.ToInt32(ServerPort.Text)
            };

            string server_detail_serialized = JsonConvert.SerializeObject(server_detail);

            // this is an absolutely horrible thing to do security wise but, I'm being lazy.
            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://t4mp.thedefaced.org/create_server.php");

            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method      = "POST";

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                streamWriter.Write(server_detail_serialized);
                streamWriter.Flush();
                streamWriter.Close();
            }

            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                if (result == "-1")
                {
                    MessageBox.Show("That server name is invalid please do not include symbols!");
                    return;
                }
            }



            History hist = new History(browser.GameDir);

            hist.map_id     = map_select.SelectedIndex;
            hist.time_limit = time_limit.Text;
            hist.frag_limit = frag_limit.Text;


            hist.Save(gameTypeOptions, WeaponSet, WeaponSpawn);

            set_frag_limit   = Convert.ToInt32(frag_limit.Text);
            set_time_limit   = Convert.ToInt32(time_limit.Text);
            set_player_limit = Convert.ToInt32(player_limit.Text);
            set_gametype     = GameTypeCombo;
            set_map          = map_select;

            weapon_available = WeaponSet;
            weapon_spawn     = WeaponSpawn;
            game_option      = gameTypeOptions;

            if (hosting == false)
            {
                if (browser.lobby != null)
                {
                    browser.lobby.Close();
                }

                browser.lobby = new Lobby(ServerName.Text, browser, "localhost", Convert.ToInt32(ServerPort.Text), true, this);
                this.Hide();
                this.Text       = "Editing Server Options";
                StartLobby.Text = "Edit Game Options";
                hosting         = true;
                browser.lobby.Show();
            }
            else
            {
                if (browser.lobby == null)
                {
                    MessageBox.Show("Something went seriously wrong!");
                }

                browser.lobby.UpdateHostLobby();
                this.Hide();
            }
        }