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;
}
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)

View File

@ -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>

View File

@ -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,6 +91,12 @@ namespace CoopServer
{
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 --
new Thread(async () =>
{
@ -106,14 +119,14 @@ namespace CoopServer
}
catch
{
info = new() { ip = MainNetServer.Configuration.LocalAddress.ToString(), country = "?" };
info = new() { country = "?" };
}
while (!Program.ReadyToStop)
{
string msg =
"{ " +
"\"address\": \"" + info.ip + "\", " +
"\"address\": \"" + MainSettings.Address + "\", " +
"\"port\": \"" + MainSettings.Port + "\", " +
"\"name\": \"" + MainSettings.Name + "\", " +
"\"version\": \"" + _compatibleVersion.Replace("_", ".") + "\", " +
@ -129,29 +142,27 @@ namespace CoopServer
try
{
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)
{
Logging.Error($"MasterServer: {ex.Message}");
break;
}
if (response.StatusCode != System.Net.HttpStatusCode.OK)
{
Logging.Error($"MasterServer: [{(int)response.StatusCode}]");
// Wait 5 seconds before trying again
// Sleep for 5s
Thread.Sleep(5000);
continue;
}
// Sleep for 12.5s
Thread.Sleep(12500);
if (response == null)
{
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)
@ -165,11 +176,10 @@ namespace CoopServer
}).Start();
#endregion
}
}
if (!string.IsNullOrEmpty(MainSettings.Resource))
{
Commands = new();
try
{
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 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;
}
}