country road, take me home...

This commit is contained in:
Sardelka
2022-06-01 17:55:38 +08:00
parent 7aa41a6e0c
commit 7eec12486f
4 changed files with 29 additions and 26 deletions

View File

@ -10,8 +10,11 @@ namespace RageCoop.Client.Menus
{
internal class ServerListClass
{
[JsonProperty("ip")]
public string IP { get; set; }
[JsonProperty("address")]
public string Address { get; set; }
[JsonProperty("port")]
public string Port { get; set; }
[JsonProperty("name")]
public string Name { get; set; }
@ -24,6 +27,9 @@ namespace RageCoop.Client.Menus
[JsonProperty("maxPlayers")]
public int MaxPlayers { get; set; }
[JsonProperty("country")]
public string Country { get; set; }
}
/// <summary>
@ -53,7 +59,6 @@ namespace RageCoop.Client.Menus
Menu.Add(ResultItem = new NativeItem("Loading..."));
// Prevent freezing
if (GetServersThread!=null && GetServersThread.IsAlive) { GetServersThread?.Abort(); }
GetServersThread=new Thread(()=> GetAllServers());
GetServersThread.Start();
};
@ -84,12 +89,17 @@ namespace RageCoop.Client.Menus
serverList = JsonConvert.DeserializeObject<List<ServerListClass>>(data);
}
catch (Exception ex)
{
Main.QueueAction(() =>
{
ResultItem.Title = "Download failed!";
ResultItem.Description = ex.Message;
});
return;
}
// Need to be processed in main thread
Main.QueueAction(() =>
{
if (serverList == null)
{
ResultItem.Title = "Something went wrong!";
@ -100,17 +110,11 @@ namespace RageCoop.Client.Menus
ResultItem.Title = "No server was found!";
return;
}
// Need to be processed in main thread
Main.QueueAction(() =>
{
CleanUpList();
foreach (ServerListClass server in serverList)
{
string address = server.IP;
NativeItem tmpItem = new NativeItem($"{server.Name}", $"~b~{address}~s~~n~~g~Version {server.Version}.x~s~") { AltTitle = $"[{server.Players}/{server.MaxPlayers}]" };
string address = $"{server.Address}:{server.Port}";
NativeItem tmpItem = new NativeItem($"[{server.Country}] {server.Name}", $"~b~{address}~s~~n~~g~Version {server.Version}.x~s~") { AltTitle = $"[{server.Players}/{server.MaxPlayers}]" };
tmpItem.Activated += (object sender, EventArgs e) =>
{
try

View File

@ -18,7 +18,7 @@ namespace RageCoop.Client
/// <summary>
/// Don't use it!
/// </summary>
public string MasterServer { get; set; } = "https://ragecoop.000webhostapp.com/master.php";
public string MasterServer { get; set; } = "https://masterserver.ragecoop.online/";
/// <summary>
/// Don't use it!
/// </summary>

View File

@ -77,7 +77,6 @@ namespace RageCoop.Server
if (MainSettings.AnnounceSelf)
{
Program.Logger.Info("Announcing to master server...");
#region -- MASTERSERVER --
new Thread(async () =>
@ -102,7 +101,7 @@ namespace RageCoop.Server
string content = await response.Content.ReadAsStringAsync();
info = JsonConvert.DeserializeObject<IpInfo>(content);
Program.Logger.Info($"Your public IP is {info.Address}");
Program.Logger.Info($"Your public IP is {info.Address}, announcing to master server...");
}
catch (Exception ex)
{

View File

@ -10,7 +10,7 @@
public string Resource { get; set; } = "";
public bool UPnP { get; set; } = true;
public bool AnnounceSelf { get; set; } = false;
public string MasterServer { get; set; } = "https://ragecoop.000webhostapp.com/master.php";
public string MasterServer { get; set; } = "https://masterserver.ragecoop.online/";
public bool DebugMode { get; set; } = false;
/// <summary>
/// NPC data won't be sent to a player if their distance is greater than this value. -1 for unlimited.