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,6 +395,8 @@ 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 (Matchmaker.Players.Count > 1)
{
if (sindex < Online.Hacking.Matchmaker.Players.Count - 1) if (sindex < Online.Hacking.Matchmaker.Players.Count - 1)
{ {
sindex = 0; sindex = 0;
@ -403,6 +405,7 @@ private void btnjoinlobby_Click(object sender, EventArgs e)
{ {
sindex += 1; sindex += 1;
} }
}
}; };
t.Start(); t.Start();
} }

View file

@ -65,9 +65,11 @@ 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) if (Players[index] != API.CurrentSave.MyOnlineNetwork && Players[index].Name != null)
{ {
SelectedNetwork = Players[index]; SelectedNetwork = Players[index];
@ -76,7 +78,18 @@ public static void Matchmake(ServerInfo si)
SelectedNetworkTransmitter = new NetTransmitter(si, SelectedNetwork); SelectedNetworkTransmitter = new NetTransmitter(si, SelectedNetwork);
Package_Grabber.SendMessage(SelectedServer.IPAddress, $"leave_lobby", API.CurrentSave.MyOnlineNetwork); 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.
} }