More matchmaking fixes

This commit is contained in:
MichaelTheShifter 2016-06-26 12:31:01 -04:00
parent a14470ce12
commit 902b89212c
2 changed files with 30 additions and 13 deletions

View file

@ -395,13 +395,16 @@ private void btnjoinlobby_Click(object sender, EventArgs e)
t.Tick += (o, a) => t.Tick += (o, a) =>
{ {
SetupSidePane(Online.Hacking.Matchmaker.Players[sindex]); SetupSidePane(Online.Hacking.Matchmaker.Players[sindex]);
if(sindex < Online.Hacking.Matchmaker.Players.Count - 1) if (Matchmaker.Players.Count > 1)
{ {
sindex = 0; if (sindex < Online.Hacking.Matchmaker.Players.Count - 1)
} {
else sindex = 0;
{ }
sindex += 1; else
{
sindex += 1;
}
} }
}; };
t.Start(); t.Start();

View file

@ -65,18 +65,31 @@ public static void Matchmake(ServerInfo si)
} }
}; };
Package_Grabber.SendMessage(si.IPAddress, "get_matchmaking"); Package_Grabber.SendMessage(si.IPAddress, "get_matchmaking");
int index = 0;
MakerTimer.Tick += (o, e) => MakerTimer.Tick += (o, e) =>
{ {
int index = rnd.Next(0, Players.Count - 1); try
if (Players[index] != API.CurrentSave.MyOnlineNetwork && Players[index].Name != null)
{ {
SelectedNetwork = Players[index]; if (Players[index] != API.CurrentSave.MyOnlineNetwork && Players[index].Name != null)
MakerTimer.Stop(); {
SelectedNetworkListener = new NetListener(si, SelectedNetwork); SelectedNetwork = Players[index];
SelectedNetworkTransmitter = new NetTransmitter(si, SelectedNetwork); MakerTimer.Stop();
Package_Grabber.SendMessage(SelectedServer.IPAddress, $"leave_lobby", API.CurrentSave.MyOnlineNetwork); SelectedNetworkListener = new NetListener(si, SelectedNetwork);
SelectedNetworkTransmitter = new NetTransmitter(si, SelectedNetwork);
Package_Grabber.SendMessage(SelectedServer.IPAddress, $"leave_lobby", API.CurrentSave.MyOnlineNetwork);
}
else
{
index += 1;
}
}
catch (Exception ex)
{
invoke(() => { API.CreateInfoboxSession("Cannot make a match.", "Network Browser had trouble making a match with another network. Error: " + ex.Message, infobox.InfoboxMode.Info); });
} }
}; };
MakerTimer.Interval = 50;
MakerTimer.Start();
} }
@ -186,6 +199,7 @@ public NetTransmitter(ServerInfo si, Network enemy)
EnemyIdent = enemy.Name + ";" + enemy.Description; EnemyIdent = enemy.Name + ";" + enemy.Description;
serverInfo = si; serverInfo = si;
var h = new HackUI(this, Matchmaker.SelectedNetworkListener); var h = new HackUI(this, Matchmaker.SelectedNetworkListener);
h.Show();
//HackUI will handle everything else to do with our network. //HackUI will handle everything else to do with our network.
} }