Fix stuff, add listening address display and projectile shoot prediction
This commit is contained in:
@ -325,11 +325,6 @@ namespace RageCoop.Client
|
|||||||
public static void Disconnected(string reason)
|
public static void Disconnected(string reason)
|
||||||
{
|
{
|
||||||
|
|
||||||
Memory.RestorePatches();
|
|
||||||
DownloadManager.Cleanup();
|
|
||||||
Voice.ClearAll();
|
|
||||||
PlayerList.Cleanup();
|
|
||||||
LocalPlayerID = default;
|
|
||||||
|
|
||||||
Logger.Info($">> Disconnected << reason: {reason}");
|
Logger.Info($">> Disconnected << reason: {reason}");
|
||||||
QueueAction(() =>
|
QueueAction(() =>
|
||||||
@ -338,13 +333,18 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
MainChat.Focused = false;
|
MainChat.Focused = false;
|
||||||
}
|
}
|
||||||
|
PlayerList.Cleanup();
|
||||||
MainChat.Clear();
|
MainChat.Clear();
|
||||||
EntityPool.Cleanup();
|
EntityPool.Cleanup();
|
||||||
WorldThread.Traffic(true);
|
WorldThread.Traffic(true);
|
||||||
Function.Call(Hash.SET_ENABLE_VEHICLE_SLIPSTREAMING, false);
|
Function.Call(Hash.SET_ENABLE_VEHICLE_SLIPSTREAMING, false);
|
||||||
CoopMenu.DisconnectedMenuSetting();
|
CoopMenu.DisconnectedMenuSetting();
|
||||||
GTA.UI.Notification.Show("~r~Disconnected: " + reason);
|
GTA.UI.Notification.Show("~r~Disconnected: " + reason);
|
||||||
|
LocalPlayerID = default;
|
||||||
});
|
});
|
||||||
|
Memory.RestorePatches();
|
||||||
|
DownloadManager.Cleanup();
|
||||||
|
Voice.ClearAll();
|
||||||
Resources.Unload();
|
Resources.Unload();
|
||||||
}
|
}
|
||||||
private static void DoQueuedActions()
|
private static void DoQueuedActions()
|
||||||
|
@ -396,6 +396,7 @@ namespace RageCoop.Client
|
|||||||
p.Shooter = packet.Flags.HasProjDataFlag(ProjectileDataFlags.IsShotByVehicle) ?
|
p.Shooter = packet.Flags.HasProjDataFlag(ProjectileDataFlags.IsShotByVehicle) ?
|
||||||
(SyncedEntity)EntityPool.GetVehicleByID(packet.ShooterID) : EntityPool.GetPedByID(packet.ShooterID);
|
(SyncedEntity)EntityPool.GetVehicleByID(packet.ShooterID) : EntityPool.GetPedByID(packet.ShooterID);
|
||||||
p.LastSynced = Main.Ticked;
|
p.LastSynced = Main.Ticked;
|
||||||
|
p.LastSyncedStopWatch.Restart();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Resources;
|
using System.Resources;
|
||||||
|
|
||||||
// General Information
|
// General Information
|
||||||
@ -14,7 +16,7 @@ using System.Resources;
|
|||||||
|
|
||||||
|
|
||||||
// Version informationr(
|
// Version informationr(
|
||||||
[assembly: AssemblyVersion("1.5.3.155")]
|
[assembly: AssemblyVersion("1.5.3.174")]
|
||||||
[assembly: AssemblyFileVersion("1.5.3.155")]
|
[assembly: AssemblyFileVersion("1.5.3.174")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute("en-US")]
|
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ namespace RageCoop.Client
|
|||||||
CreateProjectile();
|
CreateProjectile();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainProjectile.Velocity = Velocity + (Position + Shooter.Owner.PacketTravelTime * Velocity - MainProjectile.Position);
|
MainProjectile.Velocity = Velocity + (Predict(Position) - MainProjectile.Position);
|
||||||
MainProjectile.Rotation = Rotation;
|
MainProjectile.Rotation = Rotation;
|
||||||
LastUpdated = Main.Ticked;
|
LastUpdated = Main.Ticked;
|
||||||
}
|
}
|
||||||
@ -113,6 +113,7 @@ namespace RageCoop.Client
|
|||||||
if (Shooter == null) { return; }
|
if (Shooter == null) { return; }
|
||||||
Entity owner;
|
Entity owner;
|
||||||
owner = (Shooter as SyncedPed)?.MainPed ?? (Entity)(Shooter as SyncedVehicle)?.MainVehicle;
|
owner = (Shooter as SyncedPed)?.MainPed ?? (Entity)(Shooter as SyncedVehicle)?.MainVehicle;
|
||||||
|
Position = (Owner.PacketTravelTime + 0.001f * LastSyncedStopWatch.ElapsedMilliseconds) * Shooter.Velocity + Position;
|
||||||
var end = Position + Velocity;
|
var end = Position + Velocity;
|
||||||
Function.Call(Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS_IGNORE_ENTITY, Position.X, Position.Y, Position.Z, end.X, end.Y, end.Z, 0, 1, WeaponHash, owner?.Handle ?? 0, 1, 0, -1, owner);
|
Function.Call(Hash.SHOOT_SINGLE_BULLET_BETWEEN_COORDS_IGNORE_ENTITY, Position.X, Position.Y, Position.Z, end.X, end.Y, end.Z, 0, 1, WeaponHash, owner?.Handle ?? 0, 1, 0, -1, owner);
|
||||||
var ps = World.GetAllProjectiles();
|
var ps = World.GetAllProjectiles();
|
||||||
|
@ -31,6 +31,7 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
internal void SetUpFixedData()
|
internal void SetUpFixedData()
|
||||||
{
|
{
|
||||||
|
if (MainVehicle == null) { return; }
|
||||||
|
|
||||||
IsAircraft = MainVehicle.IsAircraft;
|
IsAircraft = MainVehicle.IsAircraft;
|
||||||
IsMotorcycle = MainVehicle.IsMotorcycle;
|
IsMotorcycle = MainVehicle.IsMotorcycle;
|
||||||
|
@ -43,10 +43,10 @@ namespace RageCoop.Client
|
|||||||
#endregion
|
#endregion
|
||||||
public static void Cleanup(bool keepPlayer = true, bool keepMine = true)
|
public static void Cleanup(bool keepPlayer = true, bool keepMine = true)
|
||||||
{
|
{
|
||||||
foreach (int id in new List<int>(PedsByID.Keys))
|
foreach (var ped in PedsByID.Values)
|
||||||
{
|
{
|
||||||
if (keepPlayer && (id == Main.LocalPlayerID) || keepMine && (PedsByID[id].OwnerID == Main.LocalPlayerID)) { continue; }
|
if ((keepPlayer && (ped.ID == Main.LocalPlayerID)) || (keepMine && (ped.OwnerID == Main.LocalPlayerID))) { continue; }
|
||||||
RemovePed(id);
|
RemovePed(ped.ID);
|
||||||
}
|
}
|
||||||
PedsByID.Clear();
|
PedsByID.Clear();
|
||||||
PedsByHandle.Clear();
|
PedsByHandle.Clear();
|
||||||
@ -333,7 +333,7 @@ namespace RageCoop.Client
|
|||||||
if (p.MainProjectile.AttachedEntity == null)
|
if (p.MainProjectile.AttachedEntity == null)
|
||||||
{
|
{
|
||||||
// Prevent projectiles from exploding next to vehicle
|
// Prevent projectiles from exploding next to vehicle
|
||||||
if (p.WeaponHash == (WeaponHash)VehicleWeaponHash.Tank || p.MainProjectile.Position.DistanceTo(p.Origin) < 2)
|
if (p.WeaponHash == (WeaponHash)VehicleWeaponHash.Tank || (p.MainProjectile.OwnerEntity?.EntityType==EntityType.Vehicle && p.MainProjectile.Position.DistanceTo(p.Origin) < 2))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -115,12 +115,12 @@ namespace RageCoop.Client
|
|||||||
Function.Call(Hash.DISABLE_VEHICLE_DISTANTLIGHTS, true);
|
Function.Call(Hash.DISABLE_VEHICLE_DISTANTLIGHTS, true);
|
||||||
foreach (Ped ped in World.GetAllPeds())
|
foreach (Ped ped in World.GetAllPeds())
|
||||||
{
|
{
|
||||||
|
if (ped == Game.Player.Character) { continue; }
|
||||||
SyncedPed c = EntityPool.GetPedByHandle(ped.Handle);
|
SyncedPed c = EntityPool.GetPedByHandle(ped.Handle);
|
||||||
if ((c == null) || (c.IsLocal && (ped.Handle != Game.Player.Character.Handle) && ped.PopulationType != EntityPopulationType.Mission))
|
if ((c == null) || (c.IsLocal && (ped.Handle != Game.Player.Character.Handle) && ped.PopulationType != EntityPopulationType.Mission))
|
||||||
{
|
{
|
||||||
if (ped.Handle == Game.Player.Character.Handle) { continue; }
|
|
||||||
|
|
||||||
// Main.Logger.Trace($"Removing ped {ped.Handle}. Reason:RemoveTraffic");
|
Main.Logger.Trace($"Removing ped {ped.Handle}. Reason:RemoveTraffic");
|
||||||
ped.CurrentVehicle?.Delete();
|
ped.CurrentVehicle?.Delete();
|
||||||
ped.Kill();
|
ped.Kill();
|
||||||
ped.Delete();
|
ped.Delete();
|
||||||
|
@ -13,6 +13,7 @@ using System.Runtime.CompilerServices;
|
|||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
|
||||||
[assembly: InternalsVisibleTo("RageCoop.Server")]
|
[assembly: InternalsVisibleTo("RageCoop.Server")]
|
||||||
[assembly: InternalsVisibleTo("RageCoop.Client")]
|
[assembly: InternalsVisibleTo("RageCoop.Client")]
|
||||||
@ -193,8 +194,7 @@ namespace RageCoop.Core
|
|||||||
foreach (FileInfo file in source.GetFiles())
|
foreach (FileInfo file in source.GetFiles())
|
||||||
file.CopyTo(Path.Combine(target.FullName, file.Name), true);
|
file.CopyTo(Path.Combine(target.FullName, file.Name), true);
|
||||||
}
|
}
|
||||||
public
|
public static string GetInvariantRID()
|
||||||
static string GetInvariantRID()
|
|
||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
@ -211,6 +211,23 @@ namespace RageCoop.Core
|
|||||||
return "unknown";
|
return "unknown";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get local ip addresses on all network interfaces
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<IPAddress> GetLocalAddress()
|
||||||
|
{
|
||||||
|
var addresses = new List<IPAddress>();
|
||||||
|
foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
|
||||||
|
{
|
||||||
|
IPInterfaceProperties ipProps = netInterface.GetIPProperties();
|
||||||
|
foreach (UnicastIPAddressInformation addr in ipProps.UnicastAddresses)
|
||||||
|
{
|
||||||
|
addresses.Add(addr.Address);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return addresses;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
internal class IpInfo
|
internal class IpInfo
|
||||||
{
|
{
|
||||||
@ -502,5 +519,6 @@ namespace RageCoop.Core
|
|||||||
{
|
{
|
||||||
return IPAddress.Parse(ip);
|
return IPAddress.Parse(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ using Timer = System.Timers.Timer;
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using RageCoop.Core.Scripting;
|
using RageCoop.Core.Scripting;
|
||||||
|
using System.Net.NetworkInformation;
|
||||||
|
|
||||||
namespace RageCoop.Server
|
namespace RageCoop.Server
|
||||||
{
|
{
|
||||||
@ -117,13 +118,23 @@ namespace RageCoop.Server
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
Logger?.Info("================");
|
Logger?.Info("================");
|
||||||
Logger?.Info($"Server bound to: 0.0.0.0:{Settings.Port}");
|
Logger?.Info($"Listening port: {Settings.Port}");
|
||||||
Logger?.Info($"Server version: {Version}");
|
Logger?.Info($"Server version: {Version}");
|
||||||
Logger?.Info($"Compatible RAGECOOP versions: {Version.ToString(3)}");
|
Logger?.Info($"Compatible client version: {Version.ToString(3)}");
|
||||||
Logger?.Info($"Runtime: {CoreUtils.GetInvariantRID()} => {System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier}");
|
Logger?.Info($"Runtime: {CoreUtils.GetInvariantRID()} => {System.Runtime.InteropServices.RuntimeInformation.RuntimeIdentifier}");
|
||||||
Logger?.Info("================");
|
Logger?.Info("================");
|
||||||
|
Logger?.Info($"Listening addresses:");
|
||||||
|
foreach (NetworkInterface netInterface in NetworkInterface.GetAllNetworkInterfaces())
|
||||||
|
{
|
||||||
|
Logger?.Info($"[{netInterface.Description}]:");
|
||||||
|
IPInterfaceProperties ipProps = netInterface.GetIPProperties();
|
||||||
|
foreach (UnicastIPAddressInformation addr in ipProps.UnicastAddresses)
|
||||||
|
{
|
||||||
|
Logger.Info(string.Join(", ", addr.Address));
|
||||||
|
}
|
||||||
|
Logger.Info("");
|
||||||
|
}
|
||||||
if (Settings.UseZeroTier)
|
if (Settings.UseZeroTier)
|
||||||
{
|
{
|
||||||
Logger?.Info($"Joining ZeroTier network: "+Settings.ZeroTierNetworkID);
|
Logger?.Info($"Joining ZeroTier network: "+Settings.ZeroTierNetworkID);
|
||||||
@ -152,12 +163,12 @@ namespace RageCoop.Server
|
|||||||
|
|
||||||
MainNetServer = new NetServer(config);
|
MainNetServer = new NetServer(config);
|
||||||
MainNetServer.Start();
|
MainNetServer.Start();
|
||||||
Logger?.Info(string.Format("Server listening on {0}:{1}", config.LocalAddress.ToString(), config.Port));
|
|
||||||
|
|
||||||
BaseScript.API=API;
|
BaseScript.API=API;
|
||||||
BaseScript.OnStart();
|
BaseScript.OnStart();
|
||||||
Resources.LoadAll();
|
Resources.LoadAll();
|
||||||
_listenerThread.Start();
|
_listenerThread.Start();
|
||||||
|
Logger?.Info("Listening for clients");
|
||||||
|
|
||||||
_playerUpdateTimer.Enabled=true;
|
_playerUpdateTimer.Enabled=true;
|
||||||
if (Settings.AnnounceSelf)
|
if (Settings.AnnounceSelf)
|
||||||
{
|
{
|
||||||
@ -170,7 +181,6 @@ namespace RageCoop.Server
|
|||||||
_antiAssholesTimer.Enabled = true;
|
_antiAssholesTimer.Enabled = true;
|
||||||
|
|
||||||
|
|
||||||
Logger?.Info("Listening for clients");
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Terminate threads and stop the server
|
/// Terminate threads and stop the server
|
||||||
|
@ -15,7 +15,7 @@ using System.Resources;
|
|||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
// Version information
|
// Version information
|
||||||
[assembly: AssemblyVersion("1.5.3.137")]
|
[assembly: AssemblyVersion("1.5.3.156")]
|
||||||
[assembly: AssemblyFileVersion("1.5.3.137")]
|
[assembly: AssemblyFileVersion("1.5.3.156")]
|
||||||
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user