public Launcher(string[] args) { InitializeComponent(); settings.GetSettings(); sq = new ServerQuerier(); ServerInfoListViewAdder silva = new ServerInfoListViewAdder(sq, this); try { sq.SetMasterServer(settings.msAddress, Convert.ToUInt16(settings.msPort)); } catch (Exception exception) { MSFail = exception.Message; } sq.StartListening(silva); backgroundWorkerQueryServers.RunWorkerAsync(); foreach (string arg in args) { if (arg == "-debug") { debug.Show(); break; } } RandomBanner(); }
public ServerInfoListViewAdder(ServerQuerier sq, Launcher form1) : base(sq) { this.form1 = form1; // Gametypes. dicGametypes.Add(0, "Co-op"); dicGametypes.Add(1, "Match"); dicGametypes.Add(2, "Race"); dicGametypes.Add(3, "Tag"); dicGametypes.Add(4, "CTF"); dicGametypes.Add(5, "Chaos"); // Don't think these are actually used. dicGametypes.Add(42, "Team Match"); dicGametypes.Add(43, "Time-Only Race"); }
public ServerInfoReceiveHandler(ServerQuerier sq) { ipepRemote = new IPEndPoint(IPAddress.Any, 0); udpclient = sq.udpclient; }
public override void ProcessServerInfo(ServerQuerier.SRB2ServerInfo srb2si) { ListView lv = form1.listViewServers; // Build a list item. ListViewItem lvi = new ListViewItem(srb2si.strName); // So we can get address and whatever else we might need. lvi.Tag = srb2si; // Gametype string, or number if not recognised. if (dicGametypes.ContainsKey(srb2si.byGametype)) lvi.SubItems.Add(dicGametypes[srb2si.byGametype]); else lvi.SubItems.Add(Convert.ToString(srb2si.byGametype)); lvi.SubItems.Add(Convert.ToString(srb2si.uiTime)); lvi.SubItems.Add(srb2si.byPlayers + "/" + srb2si.byMaxplayers); lvi.SubItems.Add(srb2si.strVersion); // Make the tooltip. BuildTooltip(lvi, form1.settings.ShowDefaultWads); // Is the game full? if (srb2si.byPlayers >= srb2si.byMaxplayers) lvi.ForeColor = Color.DimGray; // Modified? else if (srb2si.bModified) lvi.ForeColor = Color.Red; // Thread-safe goodness. if (lv.InvokeRequired) { // Call ourselves in the context of the form's thread. AddToListCallback addtolistcallback = new AddToListCallback(lv.Items.Add); lv.Invoke(addtolistcallback, new object[] { lvi }); } else { // Add it! lv.Items.Add(lvi); } }