mirror of
https://github.com/seriocomedy/ShiftOS-C-.git
synced 2025-01-22 17:22:14 +00:00
Fix crash with phantom clients while matchmaking
This commit is contained in:
parent
2963b1bff2
commit
a14470ce12
2 changed files with 41 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using ShiftOS.Online.Hacking;
|
||||||
|
|
||||||
namespace ShiftOS
|
namespace ShiftOS
|
||||||
{
|
{
|
||||||
|
@ -388,6 +389,45 @@ private void btnjoinlobby_Click(object sender, EventArgs e)
|
||||||
API.CurrentSave.MyOnlineNetwork.Codepoints = API.Codepoints;
|
API.CurrentSave.MyOnlineNetwork.Codepoints = API.Codepoints;
|
||||||
Package_Grabber.SendMessage(selected_server.IPAddress, "join_lobby", API.CurrentSave.MyOnlineNetwork);
|
Package_Grabber.SendMessage(selected_server.IPAddress, "join_lobby", API.CurrentSave.MyOnlineNetwork);
|
||||||
Online.Hacking.Matchmaker.Matchmake(selected_server);
|
Online.Hacking.Matchmaker.Matchmake(selected_server);
|
||||||
|
var t = new System.Windows.Forms.Timer();
|
||||||
|
t.Interval = 5000;
|
||||||
|
int sindex = 0;
|
||||||
|
t.Tick += (o, a) =>
|
||||||
|
{
|
||||||
|
SetupSidePane(Online.Hacking.Matchmaker.Players[sindex]);
|
||||||
|
if(sindex < Online.Hacking.Matchmaker.Players.Count - 1)
|
||||||
|
{
|
||||||
|
sindex = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sindex += 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
t.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetupSidePane(Network network)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lbtitle.Text = network.Name;
|
||||||
|
lbnetdesc.Text = $@"{network.Description}
|
||||||
|
|
||||||
|
- {network.Codepoints} codepoints.
|
||||||
|
- {network.Wins} wins, {network.Losses} losses.";
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
lbtitle.Text = "<null>";
|
||||||
|
lbnetdesc.Text = @"<no description>
|
||||||
|
|
||||||
|
- unknown codepoints.
|
||||||
|
- unknown wins, unknown losses.
|
||||||
|
|
||||||
|
|
||||||
|
If you see this happen, it's a phantom client. The server won't pair you with it.";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void stop_matchmake(object sender, FormClosingEventArgs e)
|
private void stop_matchmake(object sender, FormClosingEventArgs e)
|
||||||
|
|
|
@ -68,7 +68,7 @@ public static void Matchmake(ServerInfo si)
|
||||||
MakerTimer.Tick += (o, e) =>
|
MakerTimer.Tick += (o, e) =>
|
||||||
{
|
{
|
||||||
int index = rnd.Next(0, Players.Count - 1);
|
int index = rnd.Next(0, Players.Count - 1);
|
||||||
if (Players[index] != API.CurrentSave.MyOnlineNetwork)
|
if (Players[index] != API.CurrentSave.MyOnlineNetwork && Players[index].Name != null)
|
||||||
{
|
{
|
||||||
SelectedNetwork = Players[index];
|
SelectedNetwork = Players[index];
|
||||||
MakerTimer.Stop();
|
MakerTimer.Stop();
|
||||||
|
|
Loading…
Reference in a new issue