Skip to content

Commit

Permalink
Update server browser
Browse files Browse the repository at this point in the history
  • Loading branch information
oldnapalm committed Apr 17, 2024
1 parent fb94801 commit f5685d1
Showing 1 changed file with 18 additions and 42 deletions.
60 changes: 18 additions & 42 deletions Client/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ public Main()
_serverBrowserMenu = new NativeMenu("GTA CooP", "Server Browser");
_serverBrowserMenu.Width += 300;
_serverBrowserMenu.UseMouse = false;
_serverBrowserMenu.ItemCount = CountVisibility.Always;
_serverBrowserMenu.Opening += (object sender, System.ComponentModel.CancelEventArgs e) =>
{
RebuildServerBrowser();
Expand Down Expand Up @@ -307,12 +308,10 @@ public Main()
}
};

var aboutItem = new NativeItem("~g~GTA V~w~ Coop mod v" + ReadableScriptVersion() + " by ~b~community~w~");
var aboutItem = new NativeItem("About", "~g~GTA V~w~ Coop mod v" + ReadableScriptVersion() + " by ~b~community~w~");
aboutItem.Activated += (menu, item) =>
{
Notification.Show("GTA V Coop mod version " + ReadableScriptVersion());
Notification.Show("Credits: Guad, Bluscream, wolfmitchell, TheIndra, oldnapalm, EntenKoeniq, BsCaBl");
Notification.Show("Website: www.gtacoop.com");
};

_mainMenu.AddSubMenu(_serverBrowserMenu);
Expand Down Expand Up @@ -530,7 +529,22 @@ private void RebuildServerBrowser()
{
_serverBrowserMenu.Clear();

DiscoverLan();
if (_client == null)
{
var port = GetOpenUdpPort();
if (port == 0)
{
Notification.Show("No available UDP port was found.");
return;
}
_config.Port = port;
_client = new NetClient(_config);
_client.Start();

DebugLogger.NetClient = _client;
}

_client.DiscoverLocalPeers(4499);

if (string.IsNullOrEmpty(PlayerSettings.MasterServerAddress))
{
Expand Down Expand Up @@ -590,24 +604,6 @@ private void RebuildServerBrowser()
}

Console.WriteLine("Servers returned by master server: " + response.List.Count);
_serverBrowserMenu.Name = "Servers listed: ~g~~h~" + response.List.Count;
var item = new NativeItem(response.List.Count + " Servers listed.");
item.LeftBadge = new LemonUI.Elements.ScaledTexture("commonmenu", "shop_new_star");

if (_client == null)
{
var port = GetOpenUdpPort();
if (port == 0)
{
Notification.Show("No available UDP port was found.");
return;
}
_config.Port = port;
_client = new NetClient(_config);
_client.Start();

DebugLogger.NetClient = _client;
}

foreach (var server in response.List)
{
Expand All @@ -621,26 +617,6 @@ private void RebuildServerBrowser()
}
}

private void DiscoverLan()
{
if (_client == null)
{
var port = GetOpenUdpPort();
if (port == 0)
{
Notification.Show("No available UDP port was found.");
return;
}
_config.Port = port;
_client = new NetClient(_config);
_client.Start();

DebugLogger.NetClient = _client;
}

_client.DiscoverLocalPeers(4499);
}

private static int _lastDataSend;
private static int _tickRate = 60;

Expand Down

2 comments on commit f5685d1

@moonday363
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, oldnapalm Is it possible to add traffic NPC to the server itself, so that not the players add it, but the server itself? And another question, will there be normal synchronization? I will wait for an answer.

@oldnapalm
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fork has only small fixes and library updates, keeping compatibility with the last official release (discontinued), I won't add any new features or make big improvements. For better synchronization I recommend moving to https://ragecoop.com

Please sign in to comment.