Other small changes
This commit is contained in:
@ -226,7 +226,6 @@ namespace CoopClient.Entities.Player
|
||||
MainVehicle.IsEngineRunning = VehIsEngineRunning;
|
||||
}
|
||||
|
||||
|
||||
if (MainVehicle.IsPlane)
|
||||
{
|
||||
if (VehLandingGear != (byte)MainVehicle.LandingGearState)
|
||||
@ -253,6 +252,15 @@ namespace CoopClient.Entities.Player
|
||||
}
|
||||
}
|
||||
|
||||
if (MainVehicle.HasRoof)
|
||||
{
|
||||
bool roofOpened = MainVehicle.RoofState == VehicleRoofState.Opened || MainVehicle.RoofState == VehicleRoofState.Opening;
|
||||
if (roofOpened != VehRoofOpened)
|
||||
{
|
||||
MainVehicle.RoofState = VehRoofOpened ? VehicleRoofState.Opening : VehicleRoofState.Closing;
|
||||
}
|
||||
}
|
||||
|
||||
if (VehAreLightsOn != MainVehicle.AreLightsOn)
|
||||
{
|
||||
MainVehicle.AreLightsOn = VehAreLightsOn;
|
||||
@ -283,23 +291,14 @@ namespace CoopClient.Entities.Player
|
||||
_lastHornActive = false;
|
||||
MainVehicle.SoundHorn(1);
|
||||
}
|
||||
|
||||
if (MainVehicle.HasRoof)
|
||||
{
|
||||
bool roofOpened = MainVehicle.RoofState == VehicleRoofState.Opened || MainVehicle.RoofState == VehicleRoofState.Opening;
|
||||
if (roofOpened != VehRoofOpened)
|
||||
{
|
||||
MainVehicle.RoofState = VehRoofOpened ? VehicleRoofState.Opening : VehicleRoofState.Closing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MainVehicle.CurrentRPM = VehRPM;
|
||||
}
|
||||
|
||||
private void UpdateVehiclePosition()
|
||||
{
|
||||
MainVehicle.CurrentRPM = VehRPM;
|
||||
|
||||
float avrLat = Math.Min(1.5f, (Util.GetTickCount64() - LastUpdateReceived) / AverageLatency);
|
||||
|
||||
if (_lastVehicleSteeringAngle != VehicleSteeringAngle)
|
||||
|
@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<AssemblyVersion>1.47.5.0001</AssemblyVersion>
|
||||
<AssemblyVersion>1.52.1.0001</AssemblyVersion>
|
||||
<FileVersion>1.0.0.0</FileVersion>
|
||||
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
|
||||
</PropertyGroup>
|
||||
|
148
Server/Server.cs
148
Server/Server.cs
@ -16,7 +16,6 @@ namespace CoopServer
|
||||
{
|
||||
internal class IpInfo
|
||||
{
|
||||
public string ip { get; set; }
|
||||
public string country { get; set; }
|
||||
}
|
||||
|
||||
@ -39,14 +38,22 @@ namespace CoopServer
|
||||
|
||||
public Server()
|
||||
{
|
||||
if (IPAddress.TryParse(MainSettings.Address, out IPAddress parsedAddress) == false)
|
||||
{
|
||||
throw new Exception($"Something went wrong while parsing IP {MainSettings.Address}!");
|
||||
}
|
||||
|
||||
if (parsedAddress.AddressFamily != System.Net.Sockets.AddressFamily.InterNetwork)
|
||||
{
|
||||
throw new Exception("Please use a valid IPv4 address!");
|
||||
}
|
||||
|
||||
Logging.Info("================");
|
||||
Logging.Info($"Server bound to: {MainSettings.Address}:{MainSettings.Port}");
|
||||
Logging.Info($"Server version: {Assembly.GetCallingAssembly().GetName().Version}");
|
||||
Logging.Info($"Compatible RAGECOOP versions: {_compatibleVersion.Replace('_', '.')}.x");
|
||||
Logging.Info("================");
|
||||
|
||||
IPAddress parsedAddress = IPAddress.Parse(MainSettings.Address);
|
||||
|
||||
// 623c92c287cc392406e7aaaac1c0f3b0 = RAGECOOP
|
||||
NetPeerConfiguration config = new("623c92c287cc392406e7aaaac1c0f3b0")
|
||||
{
|
||||
@ -84,92 +91,95 @@ namespace CoopServer
|
||||
{
|
||||
Logging.Info("Announcing to master server...");
|
||||
|
||||
#region -- MASTERSERVER --
|
||||
new Thread(async () =>
|
||||
if (new string[5] { "127.0.0.1", "192.168.", "0.0.0.0", "1.1.1.1", "1.2.3.4" }.Any(el => MainSettings.Address.Contains(el, StringComparison.CurrentCultureIgnoreCase)))
|
||||
{
|
||||
try
|
||||
Logging.Error($"Announcing to the master server failed because this is not a public address!");
|
||||
}
|
||||
else
|
||||
{
|
||||
#region -- MASTERSERVER --
|
||||
new Thread(async () =>
|
||||
{
|
||||
// TLS only
|
||||
ServicePointManager.Expect100Continue = true;
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
HttpClient httpClient = new();
|
||||
|
||||
IpInfo info;
|
||||
|
||||
try
|
||||
{
|
||||
string data = await httpClient.GetStringAsync("https://ipinfo.io/json");
|
||||
// TLS only
|
||||
ServicePointManager.Expect100Continue = true;
|
||||
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls13 | SecurityProtocolType.Tls12;
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
info = JsonConvert.DeserializeObject<IpInfo>(data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
info = new() { ip = MainNetServer.Configuration.LocalAddress.ToString(), country = "?" };
|
||||
}
|
||||
HttpClient httpClient = new();
|
||||
|
||||
while (!Program.ReadyToStop)
|
||||
{
|
||||
string msg =
|
||||
"{ " +
|
||||
"\"address\": \"" + info.ip + "\", " +
|
||||
"\"port\": \"" + MainSettings.Port + "\", " +
|
||||
"\"name\": \"" + MainSettings.Name + "\", " +
|
||||
"\"version\": \"" + _compatibleVersion.Replace("_", ".") + "\", " +
|
||||
"\"players\": \"" + MainNetServer.ConnectionsCount + "\", " +
|
||||
"\"maxPlayers\": \"" + MainSettings.MaxPlayers + "\", " +
|
||||
"\"allowlist\": \"" + _mainAllowlist.Username.Any() + "\", " +
|
||||
"\"mods\": \"" + MainSettings.ModsAllowed + "\", " +
|
||||
"\"npcs\": \"" + MainSettings.NpcsAllowed + "\", " +
|
||||
"\"country\": \"" + info.country + "\"" +
|
||||
" }";
|
||||
IpInfo info;
|
||||
|
||||
HttpResponseMessage response = null;
|
||||
try
|
||||
{
|
||||
response = await httpClient.PostAsync(MainSettings.MasterServer, new StringContent(msg, Encoding.UTF8, "application/json"));
|
||||
string data = await httpClient.GetStringAsync("https://ipinfo.io/json");
|
||||
|
||||
info = JsonConvert.DeserializeObject<IpInfo>(data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
info = new() { country = "?" };
|
||||
}
|
||||
|
||||
while (!Program.ReadyToStop)
|
||||
{
|
||||
string msg =
|
||||
"{ " +
|
||||
"\"address\": \"" + MainSettings.Address + "\", " +
|
||||
"\"port\": \"" + MainSettings.Port + "\", " +
|
||||
"\"name\": \"" + MainSettings.Name + "\", " +
|
||||
"\"version\": \"" + _compatibleVersion.Replace("_", ".") + "\", " +
|
||||
"\"players\": \"" + MainNetServer.ConnectionsCount + "\", " +
|
||||
"\"maxPlayers\": \"" + MainSettings.MaxPlayers + "\", " +
|
||||
"\"allowlist\": \"" + _mainAllowlist.Username.Any() + "\", " +
|
||||
"\"mods\": \"" + MainSettings.ModsAllowed + "\", " +
|
||||
"\"npcs\": \"" + MainSettings.NpcsAllowed + "\", " +
|
||||
"\"country\": \"" + info.country + "\"" +
|
||||
" }";
|
||||
|
||||
HttpResponseMessage response = null;
|
||||
try
|
||||
{
|
||||
response = await httpClient.PostAsync(MainSettings.MasterServer, new StringContent(msg, Encoding.UTF8, "application/json"));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Error($"MasterServer: {ex.Message}");
|
||||
|
||||
// Sleep for 5s
|
||||
Thread.Sleep(5000);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (response == null)
|
||||
{
|
||||
Logging.Error("MasterServer: Something went wrong!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Error($"MasterServer: {ex.Message}");
|
||||
break;
|
||||
}
|
||||
else if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
Logging.Error($"MasterServer: [{(int)response.StatusCode}]");
|
||||
}
|
||||
|
||||
if (response.StatusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
Logging.Error($"MasterServer: [{(int)response.StatusCode}]");
|
||||
|
||||
// Wait 5 seconds before trying again
|
||||
Thread.Sleep(5000);
|
||||
continue;
|
||||
// Sleep for 10s
|
||||
Thread.Sleep(10000);
|
||||
}
|
||||
|
||||
// Sleep for 12.5s
|
||||
Thread.Sleep(12500);
|
||||
}
|
||||
}
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Logging.Error($"MasterServer: {ex.InnerException.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Error($"MasterServer: {ex.Message}");
|
||||
}
|
||||
}).Start();
|
||||
#endregion
|
||||
catch (HttpRequestException ex)
|
||||
{
|
||||
Logging.Error($"MasterServer: {ex.InnerException.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logging.Error($"MasterServer: {ex.Message}");
|
||||
}
|
||||
}).Start();
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(MainSettings.Resource))
|
||||
{
|
||||
Commands = new();
|
||||
|
||||
try
|
||||
{
|
||||
string resourcepath = AppDomain.CurrentDomain.BaseDirectory + "resources" + Path.DirectorySeparatorChar + MainSettings.Resource + ".dll";
|
||||
|
@ -13,7 +13,7 @@
|
||||
public bool ModsAllowed { get; set; } = false;
|
||||
public bool UPnP { get; set; } = true;
|
||||
public bool AnnounceSelf { get; set; } = false;
|
||||
public string MasterServer { get; set; } = "https://ragecoop.online/servers";
|
||||
public string MasterServer { get; set; } = "https://ragecoop.online/gtav/servers";
|
||||
public bool DebugMode { get; set; } = false;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user