aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaelTheShifter <[email protected]>2016-06-26 07:46:56 -0400
committerMichaelTheShifter <[email protected]>2016-06-26 07:46:56 -0400
commita14470ce12c09a87665521387bee2f982cd5a6d0 (patch)
tree4d6e41b24905341966bbae29256163f212eb88e9
parent2963b1bff26afef38e40ba6b04644cb5996316af (diff)
downloadshiftos-c-_theultimatehacker-a14470ce12c09a87665521387bee2f982cd5a6d0.tar.gz
shiftos-c-_theultimatehacker-a14470ce12c09a87665521387bee2f982cd5a6d0.tar.bz2
shiftos-c-_theultimatehacker-a14470ce12c09a87665521387bee2f982cd5a6d0.zip
Fix crash with phantom clients while matchmaking
-rw-r--r--source/WindowsFormsApplication1/Apps/NetworkBrowser.cs40
-rw-r--r--source/WindowsFormsApplication1/Online/Hacking/Matchmaker.cs2
2 files changed, 41 insertions, 1 deletions
diff --git a/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs b/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs
index 92c87cb..1890744 100644
--- a/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs
+++ b/source/WindowsFormsApplication1/Apps/NetworkBrowser.cs
@@ -9,6 +9,7 @@ using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
+using ShiftOS.Online.Hacking;
namespace ShiftOS
{
@@ -388,6 +389,45 @@ Those above values only matter if the leader decides to become a friend. If they
API.CurrentSave.MyOnlineNetwork.Codepoints = API.Codepoints;
Package_Grabber.SendMessage(selected_server.IPAddress, "join_lobby", API.CurrentSave.MyOnlineNetwork);
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)
diff --git a/source/WindowsFormsApplication1/Online/Hacking/Matchmaker.cs b/source/WindowsFormsApplication1/Online/Hacking/Matchmaker.cs
index aa673e4..fca22ac 100644
--- a/source/WindowsFormsApplication1/Online/Hacking/Matchmaker.cs
+++ b/source/WindowsFormsApplication1/Online/Hacking/Matchmaker.cs
@@ -68,7 +68,7 @@ namespace ShiftOS.Online.Hacking
MakerTimer.Tick += (o, e) =>
{
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];
MakerTimer.Stop();