From f4d6c677dec34b4a5b336e0a5a7e4aa3a9d06eb0 Mon Sep 17 00:00:00 2001
From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com>
Date: Thu, 9 May 2024 23:55:34 +0530
Subject: [PATCH] more stun servers and make server list a bit better
---
src/gui/MPServerListGui.hx | 3 ++-
src/net/Net.hx | 10 ++++++++--
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/src/gui/MPServerListGui.hx b/src/gui/MPServerListGui.hx
index 1f436a05..671500db 100644
--- a/src/gui/MPServerListGui.hx
+++ b/src/gui/MPServerListGui.hx
@@ -97,7 +97,8 @@ class MPServerListGui extends GuiImage {
var platformToString = ["unknown", "pc", "mac", "web", "android"];
function updateServerListDisplay() {
- serverDisplays = ourServerList.map(x -> return '
${x.name}');
+ serverDisplays = ourServerList.map(x -> return
+ '
${x.players}/${x.maxPlayers} ${x.name}');
serverList.setTexts(serverDisplays);
}
diff --git a/src/net/Net.hx b/src/net/Net.hx
index 7896bccf..9f89ea78 100644
--- a/src/net/Net.hx
+++ b/src/net/Net.hx
@@ -79,6 +79,12 @@ class Net {
public static var serverInfo:ServerInfo;
public static var remoteServerInfo:RemoteServerInfo;
+ static var stunServers = [
+ "stun.l.google.com:19302", "stun1.l.google.com:19302", "stun2.l.google.com:19302", "stun3.l.google.com:19302", "stun4.l.google.com:19302",
+ "stun:relay.metered.ca:80", "stun.ekiga.net", "stun.ideasip.com", "stun.rixtelecom.se", "stun.schlund.de", "stun.stunprotocol.org:3478",
+ "stun.voiparound.com", "stun.voipbuster.com", "stun.voipstunt.com", "stun.voxgratia.org"
+ ];
+
public static function hostServer(name:String, maxPlayers:Int, privateSlots:Int, privateServer:Bool, onHosted:() -> Void) {
serverInfo = new ServerInfo(name, 1, maxPlayers, privateSlots, privateServer, Std.int(999999 * Math.random()), "LOBBY", getPlatform());
MasterServerClient.connectToMasterServer(() -> {
@@ -92,7 +98,7 @@ class Net {
}
public static function addClientFromSdp(sdpString:String, privateJoin:Bool, onFinishSdp:String->Void) {
- var peer = new RTCPeerConnection(["stun:stun.l.google.com:19302"], "0.0.0.0");
+ var peer = new RTCPeerConnection(stunServers, "0.0.0.0");
var sdpObj = Json.parse(sdpString);
peer.setRemoteDescription(sdpObj.sdp, sdpObj.type);
addClient(peer, privateJoin, onFinishSdp);
@@ -140,7 +146,7 @@ class Net {
public static function joinServer(serverName:String, isInvite:Bool, connectedCb:() -> Void) {
MasterServerClient.connectToMasterServer(() -> {
- client = new RTCPeerConnection(["stun:stun.l.google.com:19302"], "0.0.0.0");
+ client = new RTCPeerConnection(stunServers, "0.0.0.0");
var candidates = [];
client.onLocalCandidate = (c) -> {