Other small changes

This commit is contained in:
EntenKoeniq
2022-04-14 12:18:07 +02:00
parent d2bb91edcc
commit 146cc709eb
4 changed files with 93 additions and 84 deletions

View File

@ -226,7 +226,6 @@ namespace CoopClient.Entities.Player
MainVehicle.IsEngineRunning = VehIsEngineRunning; MainVehicle.IsEngineRunning = VehIsEngineRunning;
} }
if (MainVehicle.IsPlane) if (MainVehicle.IsPlane)
{ {
if (VehLandingGear != (byte)MainVehicle.LandingGearState) 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) if (VehAreLightsOn != MainVehicle.AreLightsOn)
{ {
MainVehicle.AreLightsOn = VehAreLightsOn; MainVehicle.AreLightsOn = VehAreLightsOn;
@ -283,23 +291,14 @@ namespace CoopClient.Entities.Player
_lastHornActive = false; _lastHornActive = false;
MainVehicle.SoundHorn(1); MainVehicle.SoundHorn(1);
} }
}
}
if (MainVehicle.HasRoof) MainVehicle.CurrentRPM = VehRPM;
{
bool roofOpened = MainVehicle.RoofState == VehicleRoofState.Opened || MainVehicle.RoofState == VehicleRoofState.Opening;
if (roofOpened != VehRoofOpened)
{
MainVehicle.RoofState = VehRoofOpened ? VehicleRoofState.Opening : VehicleRoofState.Closing;
}
}
}
}
} }
private void UpdateVehiclePosition() private void UpdateVehiclePosition()
{ {
MainVehicle.CurrentRPM = VehRPM;
float avrLat = Math.Min(1.5f, (Util.GetTickCount64() - LastUpdateReceived) / AverageLatency); float avrLat = Math.Min(1.5f, (Util.GetTickCount64() - LastUpdateReceived) / AverageLatency);
if (_lastVehicleSteeringAngle != VehicleSteeringAngle) if (_lastVehicleSteeringAngle != VehicleSteeringAngle)

View File

@ -3,7 +3,7 @@
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<AssemblyVersion>1.47.5.0001</AssemblyVersion> <AssemblyVersion>1.52.1.0001</AssemblyVersion>
<FileVersion>1.0.0.0</FileVersion> <FileVersion>1.0.0.0</FileVersion>
<RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl> <RepositoryUrl>https://github.com/GTACOOP-R/GTACoop-R</RepositoryUrl>
</PropertyGroup> </PropertyGroup>

View File

@ -16,7 +16,6 @@ namespace CoopServer
{ {
internal class IpInfo internal class IpInfo
{ {
public string ip { get; set; }
public string country { get; set; } public string country { get; set; }
} }
@ -39,14 +38,22 @@ namespace CoopServer
public Server() 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("================");
Logging.Info($"Server bound to: {MainSettings.Address}:{MainSettings.Port}"); Logging.Info($"Server bound to: {MainSettings.Address}:{MainSettings.Port}");
Logging.Info($"Server version: {Assembly.GetCallingAssembly().GetName().Version}"); Logging.Info($"Server version: {Assembly.GetCallingAssembly().GetName().Version}");
Logging.Info($"Compatible RAGECOOP versions: {_compatibleVersion.Replace('_', '.')}.x"); Logging.Info($"Compatible RAGECOOP versions: {_compatibleVersion.Replace('_', '.')}.x");
Logging.Info("================"); Logging.Info("================");
IPAddress parsedAddress = IPAddress.Parse(MainSettings.Address);
// 623c92c287cc392406e7aaaac1c0f3b0 = RAGECOOP // 623c92c287cc392406e7aaaac1c0f3b0 = RAGECOOP
NetPeerConfiguration config = new("623c92c287cc392406e7aaaac1c0f3b0") NetPeerConfiguration config = new("623c92c287cc392406e7aaaac1c0f3b0")
{ {
@ -84,6 +91,12 @@ namespace CoopServer
{ {
Logging.Info("Announcing to master server..."); Logging.Info("Announcing to master server...");
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)))
{
Logging.Error($"Announcing to the master server failed because this is not a public address!");
}
else
{
#region -- MASTERSERVER -- #region -- MASTERSERVER --
new Thread(async () => new Thread(async () =>
{ {
@ -106,14 +119,14 @@ namespace CoopServer
} }
catch catch
{ {
info = new() { ip = MainNetServer.Configuration.LocalAddress.ToString(), country = "?" }; info = new() { country = "?" };
} }
while (!Program.ReadyToStop) while (!Program.ReadyToStop)
{ {
string msg = string msg =
"{ " + "{ " +
"\"address\": \"" + info.ip + "\", " + "\"address\": \"" + MainSettings.Address + "\", " +
"\"port\": \"" + MainSettings.Port + "\", " + "\"port\": \"" + MainSettings.Port + "\", " +
"\"name\": \"" + MainSettings.Name + "\", " + "\"name\": \"" + MainSettings.Name + "\", " +
"\"version\": \"" + _compatibleVersion.Replace("_", ".") + "\", " + "\"version\": \"" + _compatibleVersion.Replace("_", ".") + "\", " +
@ -129,29 +142,27 @@ namespace CoopServer
try try
{ {
response = await httpClient.PostAsync(MainSettings.MasterServer, new StringContent(msg, Encoding.UTF8, "application/json")); response = await httpClient.PostAsync(MainSettings.MasterServer, new StringContent(msg, Encoding.UTF8, "application/json"));
if (response == null)
{
Logging.Error("MasterServer: Something went wrong!");
break;
}
} }
catch (Exception ex) catch (Exception ex)
{ {
Logging.Error($"MasterServer: {ex.Message}"); Logging.Error($"MasterServer: {ex.Message}");
break;
}
if (response.StatusCode != System.Net.HttpStatusCode.OK) // Sleep for 5s
{
Logging.Error($"MasterServer: [{(int)response.StatusCode}]");
// Wait 5 seconds before trying again
Thread.Sleep(5000); Thread.Sleep(5000);
continue; continue;
} }
// Sleep for 12.5s if (response == null)
Thread.Sleep(12500); {
Logging.Error("MasterServer: Something went wrong!");
}
else if (response.StatusCode != System.Net.HttpStatusCode.OK)
{
Logging.Error($"MasterServer: [{(int)response.StatusCode}]");
}
// Sleep for 10s
Thread.Sleep(10000);
} }
} }
catch (HttpRequestException ex) catch (HttpRequestException ex)
@ -165,11 +176,10 @@ namespace CoopServer
}).Start(); }).Start();
#endregion #endregion
} }
}
if (!string.IsNullOrEmpty(MainSettings.Resource)) if (!string.IsNullOrEmpty(MainSettings.Resource))
{ {
Commands = new();
try try
{ {
string resourcepath = AppDomain.CurrentDomain.BaseDirectory + "resources" + Path.DirectorySeparatorChar + MainSettings.Resource + ".dll"; string resourcepath = AppDomain.CurrentDomain.BaseDirectory + "resources" + Path.DirectorySeparatorChar + MainSettings.Resource + ".dll";

View File

@ -13,7 +13,7 @@
public bool ModsAllowed { get; set; } = false; public bool ModsAllowed { get; set; } = false;
public bool UPnP { get; set; } = true; public bool UPnP { get; set; } = true;
public bool AnnounceSelf { get; set; } = false; 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; public bool DebugMode { get; set; } = false;
} }
} }