commit
b583618e6c
@ -173,13 +173,11 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
if (Networking.ShowNetworkInfo)
|
if (Networking.ShowNetworkInfo)
|
||||||
{
|
{
|
||||||
|
|
||||||
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 0), $"L: {Networking.Latency * 1000:N0}ms", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
|
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 0), $"L: {Networking.Latency * 1000:N0}ms", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
|
||||||
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 30), $"R: {Lidgren.Network.NetUtility.ToHumanReadable(Statistics.BytesDownPerSecond)}/s", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
|
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 30), $"R: {Lidgren.Network.NetUtility.ToHumanReadable(Statistics.BytesDownPerSecond)}/s", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
|
||||||
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 60), $"S: {Lidgren.Network.NetUtility.ToHumanReadable(Statistics.BytesUpPerSecond)}/s", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
|
new LemonUI.Elements.ScaledText(new PointF(Screen.PrimaryScreen.Bounds.Width / 2, 60), $"S: {Lidgren.Network.NetUtility.ToHumanReadable(Statistics.BytesUpPerSecond)}/s", 0.5f) { Alignment = GTA.UI.Alignment.Center }.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MainChat.Tick();
|
MainChat.Tick();
|
||||||
PlayerList.Tick();
|
PlayerList.Tick();
|
||||||
if (!Scripting.API.Config.EnableAutoRespawn)
|
if (!Scripting.API.Config.EnableAutoRespawn)
|
||||||
@ -203,10 +201,8 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
Function.Call(Hash.DISPLAY_HUD, true);
|
Function.Call(Hash.DISPLAY_HUD, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (P.IsDead && !_lastDead)
|
else if (P.IsDead && !_lastDead)
|
||||||
{
|
{
|
||||||
|
@ -49,7 +49,6 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
||||||
Main.Logger.Error("Error occurred when loading server resource:");
|
Main.Logger.Error("Error occurred when loading server resource:");
|
||||||
Main.Logger.Error(ex);
|
Main.Logger.Error(ex);
|
||||||
return new Packets.FileTransferResponse() { ID=0, Response=FileResponse.LoadFailed };
|
return new Packets.FileTransferResponse() { ID=0, Response=FileResponse.LoadFailed };
|
||||||
@ -134,7 +133,6 @@ namespace RageCoop.Client
|
|||||||
Main.Logger.Trace($"Received unhandled file chunk:{id}");
|
Main.Logger.Trace($"Received unhandled file chunk:{id}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Complete(int id)
|
public static void Complete(int id)
|
||||||
|
@ -29,6 +29,7 @@ namespace RageCoop.Client
|
|||||||
Peer?.Shutdown("Bye");
|
Peer?.Shutdown("Bye");
|
||||||
if (IsOnServer)
|
if (IsOnServer)
|
||||||
{
|
{
|
||||||
|
// ?
|
||||||
}
|
}
|
||||||
else if (IsConnecting) {
|
else if (IsConnecting) {
|
||||||
_publicKeyReceived.Set();
|
_publicKeyReceived.Set();
|
||||||
@ -117,10 +118,7 @@ namespace RageCoop.Client
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static bool IsOnServer
|
public static bool IsOnServer { get => ServerConnection?.Status == NetConnectionStatus.Connected; }
|
||||||
{
|
|
||||||
get { return ServerConnection?.Status == NetConnectionStatus.Connected; }
|
|
||||||
}
|
|
||||||
|
|
||||||
#region -- PLAYER --
|
#region -- PLAYER --
|
||||||
private static void PlayerConnect(Packets.PlayerConnect packet)
|
private static void PlayerConnect(Packets.PlayerConnect packet)
|
||||||
@ -149,7 +147,6 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
#endregion // -- PLAYER --
|
#endregion // -- PLAYER --
|
||||||
#region -- GET --
|
#region -- GET --
|
||||||
|
|
||||||
private static bool GetServerPublicKey(string address, int timeout = 10000)
|
private static bool GetServerPublicKey(string address, int timeout = 10000)
|
||||||
{
|
{
|
||||||
Security.ServerRSA=null;
|
Security.ServerRSA=null;
|
||||||
@ -181,8 +178,7 @@ namespace RageCoop.Client
|
|||||||
private static int NewRequestID()
|
private static int NewRequestID()
|
||||||
{
|
{
|
||||||
int ID = 0;
|
int ID = 0;
|
||||||
while ((ID==0)
|
while ((ID==0) || PendingResponses.ContainsKey(ID))
|
||||||
|| PendingResponses.ContainsKey(ID))
|
|
||||||
{
|
{
|
||||||
byte[] rngBytes = new byte[4];
|
byte[] rngBytes = new byte[4];
|
||||||
|
|
||||||
|
@ -25,7 +25,6 @@ namespace RageCoop.Client
|
|||||||
return EntityPool.ServerBlips[reader.ReadInt32()].Handle;
|
return EntityPool.ServerBlips[reader.ReadInt32()].Handle;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException("Cannot resolve server side argument: "+t);
|
throw new ArgumentException("Cannot resolve server side argument: "+t);
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private static readonly AutoResetEvent _publicKeyReceived = new AutoResetEvent(false);
|
private static readonly AutoResetEvent _publicKeyReceived = new AutoResetEvent(false);
|
||||||
@ -43,7 +42,6 @@ namespace RageCoop.Client
|
|||||||
case NetConnectionStatus.InitiatedConnect:
|
case NetConnectionStatus.InitiatedConnect:
|
||||||
if (message.SenderConnection==ServerConnection)
|
if (message.SenderConnection==ServerConnection)
|
||||||
{
|
{
|
||||||
|
|
||||||
CoopMenu.InitiateConnectionMenuSetting();
|
CoopMenu.InitiateConnectionMenuSetting();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -103,8 +101,7 @@ namespace RageCoop.Client
|
|||||||
Main.QueueAction(() => Main.CleanUp());
|
Main.QueueAction(() => Main.CleanUp());
|
||||||
CoopMenu.DisconnectedMenuSetting();
|
CoopMenu.DisconnectedMenuSetting();
|
||||||
Main.Logger.Info($">> Disconnected << reason: {reason}");
|
Main.Logger.Info($">> Disconnected << reason: {reason}");
|
||||||
Main.QueueAction(() =>
|
Main.QueueAction(() => GTA.UI.Notification.Show("~r~Disconnected: " + reason));
|
||||||
GTA.UI.Notification.Show("~r~Disconnected: " + reason));
|
|
||||||
Main.Resources.Unload();
|
Main.Resources.Unload();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -112,12 +109,10 @@ namespace RageCoop.Client
|
|||||||
break;
|
break;
|
||||||
case NetIncomingMessageType.Data:
|
case NetIncomingMessageType.Data:
|
||||||
{
|
{
|
||||||
|
|
||||||
if (message.LengthBytes==0) { break; }
|
if (message.LengthBytes==0) { break; }
|
||||||
var packetType = PacketType.Unknown;
|
var packetType = PacketType.Unknown;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
// Get packet type
|
// Get packet type
|
||||||
packetType = (PacketType)message.ReadByte();
|
packetType = (PacketType)message.ReadByte();
|
||||||
switch (packetType)
|
switch (packetType)
|
||||||
@ -246,10 +241,7 @@ namespace RageCoop.Client
|
|||||||
case PacketType.ChatMessage:
|
case PacketType.ChatMessage:
|
||||||
{
|
{
|
||||||
|
|
||||||
Packets.ChatMessage packet = new Packets.ChatMessage((b) =>
|
Packets.ChatMessage packet = new Packets.ChatMessage((b) => Security.Decrypt(b));
|
||||||
{
|
|
||||||
return Security.Decrypt(b);
|
|
||||||
});
|
|
||||||
packet.Deserialize(data);
|
packet.Deserialize(data);
|
||||||
|
|
||||||
Main.QueueAction(() => { Main.MainChat.AddMessage(packet.Username, packet.Message); return true; });
|
Main.QueueAction(() => { Main.MainChat.AddMessage(packet.Username, packet.Message); return true; });
|
||||||
|
@ -53,14 +53,7 @@ namespace RageCoop.Client
|
|||||||
c.LastSentStopWatch.Restart();
|
c.LastSentStopWatch.Restart();
|
||||||
if (full)
|
if (full)
|
||||||
{
|
{
|
||||||
if (packet.Flags.HasPedFlag(PedDataFlags.IsInVehicle))
|
packet.CurrentWeaponHash = packet.Flags.HasPedFlag(PedDataFlags.IsInVehicle) ? (uint)p.VehicleWeapon : (uint)p.Weapons.Current.Hash;
|
||||||
{
|
|
||||||
packet.CurrentWeaponHash=(uint)p.VehicleWeapon;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
packet.CurrentWeaponHash=(uint)p.Weapons.Current.Hash;
|
|
||||||
}
|
|
||||||
packet.Flags |= PedDataFlags.IsFullSync;
|
packet.Flags |= PedDataFlags.IsFullSync;
|
||||||
packet.Clothes=p.GetPedClothes();
|
packet.Clothes=p.GetPedClothes();
|
||||||
packet.ModelHash=p.Model.Hash;
|
packet.ModelHash=p.Model.Hash;
|
||||||
@ -176,13 +169,7 @@ namespace RageCoop.Client
|
|||||||
#endregion
|
#endregion
|
||||||
public static void SendChatMessage(string message)
|
public static void SendChatMessage(string message)
|
||||||
{
|
{
|
||||||
|
Peer.SendTo(new Packets.ChatMessage(new Func<string, byte[]>((s) => Security.Encrypt(s.GetBytes())))
|
||||||
|
|
||||||
|
|
||||||
Peer.SendTo(new Packets.ChatMessage(new Func<string, byte[]>((s) =>
|
|
||||||
{
|
|
||||||
return Security.Encrypt(s.GetBytes());
|
|
||||||
}))
|
|
||||||
{ Username = Main.Settings.Username, Message = message },ServerConnection, ConnectionChannel.Chat, NetDeliveryMethod.ReliableOrdered);
|
{ Username = Main.Settings.Username, Message = message },ServerConnection, ConnectionChannel.Chat, NetDeliveryMethod.ReliableOrdered);
|
||||||
Peer.FlushSendQueue();
|
Peer.FlushSendQueue();
|
||||||
}
|
}
|
||||||
|
@ -137,10 +137,8 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
Players=new Dictionary<int, Player> { };
|
Players=new Dictionary<int, Player> { };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal class Player
|
internal class Player
|
||||||
{
|
{
|
||||||
public byte HolePunchStatus { get; set; } = 1;
|
public byte HolePunchStatus { get; set; } = 1;
|
||||||
|
@ -15,10 +15,7 @@ namespace RageCoop.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsLocal
|
public bool IsLocal
|
||||||
{
|
{
|
||||||
get
|
get => OwnerID == Main.LocalPlayerID;
|
||||||
{
|
|
||||||
return OwnerID==Main.LocalPlayerID;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -33,10 +30,7 @@ namespace RageCoop.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int OwnerID
|
public int OwnerID
|
||||||
{
|
{
|
||||||
get
|
get => _ownerID;
|
||||||
{
|
|
||||||
return _ownerID;
|
|
||||||
}
|
|
||||||
internal set
|
internal set
|
||||||
{
|
{
|
||||||
if (value==_ownerID && Owner!=null) { return; }
|
if (value==_ownerID && Owner!=null) { return; }
|
||||||
@ -51,19 +45,16 @@ namespace RageCoop.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsOutOfSync
|
public bool IsOutOfSync
|
||||||
{
|
{
|
||||||
get
|
get => Main.Ticked - LastSynced > 200 && ID != 0;
|
||||||
{
|
|
||||||
return Main.Ticked-LastSynced>200 && ID!=0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
internal bool IsReady
|
internal bool IsReady
|
||||||
{
|
{
|
||||||
get { return (LastSynced>0||LastFullSynced==0); }
|
get => LastSynced > 0 || LastFullSynced == 0;
|
||||||
}
|
}
|
||||||
internal bool IsInvincible { get; set; } = false;
|
internal bool IsInvincible { get; set; } = false;
|
||||||
internal bool NeedUpdate
|
internal bool NeedUpdate
|
||||||
{
|
{
|
||||||
get { return LastSynced>=LastUpdated; }
|
get => LastSynced >= LastUpdated;
|
||||||
}
|
}
|
||||||
#region LAST STATE
|
#region LAST STATE
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -100,6 +91,5 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
LastUpdated=Main.Ticked+frames;
|
LastUpdated=Main.Ticked+frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace RageCoop.Client
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates whether this ped is a player
|
/// Indicates whether this ped is a player
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPlayer { get { return (OwnerID==ID)&&(ID!=0); } }
|
public bool IsPlayer { get => OwnerID == ID && ID != 0; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// real entity
|
/// real entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -80,7 +80,6 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
private WeaponAsset WeaponAsset { get; set; }
|
private WeaponAsset WeaponAsset { get; set; }
|
||||||
|
|
||||||
|
|
||||||
internal override void Update()
|
internal override void Update()
|
||||||
{
|
{
|
||||||
if (IsPlayer)
|
if (IsPlayer)
|
||||||
@ -97,12 +96,7 @@ namespace RageCoop.Client
|
|||||||
if (!IsReady) { return; }
|
if (!IsReady) { return; }
|
||||||
|
|
||||||
// Skip update if no new sync message has arrived.
|
// Skip update if no new sync message has arrived.
|
||||||
if (!NeedUpdate)
|
if (!NeedUpdate) { return; }
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (MainPed == null || !MainPed.Exists())
|
if (MainPed == null || !MainPed.Exists())
|
||||||
{
|
{
|
||||||
@ -112,11 +106,6 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Need to update state
|
// Need to update state
|
||||||
if (LastFullSynced>=LastUpdated)
|
if (LastFullSynced>=LastUpdated)
|
||||||
{
|
{
|
||||||
@ -126,7 +115,6 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((byte)BlipColor==255) && (PedBlip!=null))
|
if (((byte)BlipColor==255) && (PedBlip!=null))
|
||||||
@ -165,8 +153,6 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (MainPed.IsDead)
|
if (MainPed.IsDead)
|
||||||
{
|
{
|
||||||
if (Health>0)
|
if (Health>0)
|
||||||
@ -201,10 +187,9 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
DisplayOnFoot();
|
DisplayOnFoot();
|
||||||
}
|
}
|
||||||
LastUpdated=Main.Ticked;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
LastUpdated=Main.Ticked;
|
||||||
|
}
|
||||||
|
|
||||||
private void RenderNameTag()
|
private void RenderNameTag()
|
||||||
{
|
{
|
||||||
@ -225,7 +210,6 @@ namespace RageCoop.Client
|
|||||||
Color=Owner.HasDirectConnection? Color.FromArgb(179, 229, 252) : Color.White,
|
Color=Owner.HasDirectConnection? Color.FromArgb(179, 229, 252) : Color.White,
|
||||||
}.Draw();
|
}.Draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CreateCharacter()
|
private bool CreateCharacter()
|
||||||
@ -261,7 +245,6 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
Model.MarkAsNoLongerNeeded();
|
Model.MarkAsNoLongerNeeded();
|
||||||
|
|
||||||
|
|
||||||
MainPed.BlockPermanentEvents = true;
|
MainPed.BlockPermanentEvents = true;
|
||||||
MainPed.CanWrithe=false;
|
MainPed.CanWrithe=false;
|
||||||
MainPed.CanBeDraggedOutOfVehicle = true;
|
MainPed.CanBeDraggedOutOfVehicle = true;
|
||||||
@ -278,7 +261,6 @@ namespace RageCoop.Client
|
|||||||
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
Function.Call(Hash._SET_PED_CAN_PLAY_INJURED_ANIMS, false);
|
||||||
Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
|
Function.Call(Hash.SET_PED_CAN_EVASIVE_DIVE, MainPed.Handle, false);
|
||||||
|
|
||||||
|
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DrownsInWater, false);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DrownsInWater, false);
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableHurt, true);
|
||||||
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableExplosionReactions, true);
|
MainPed.SetConfigFlag((int)PedConfigFlags.CPED_CONFIG_FLAG_DisableExplosionReactions, true);
|
||||||
@ -288,10 +270,7 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
SetClothes();
|
SetClothes();
|
||||||
|
|
||||||
if (IsPlayer)
|
if (IsPlayer) { MainPed.IsInvincible=true; }
|
||||||
{
|
|
||||||
MainPed.IsInvincible=true;
|
|
||||||
}
|
|
||||||
if (IsInvincible) { MainPed.IsInvincible=true; }
|
if (IsInvincible) { MainPed.IsInvincible=true; }
|
||||||
|
|
||||||
lock (EntityPool.PedsLock)
|
lock (EntityPool.PedsLock)
|
||||||
@ -517,12 +496,9 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
_lastRagdoll = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
_lastRagdoll = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (IsReloading)
|
if (IsReloading)
|
||||||
{
|
{
|
||||||
@ -546,8 +522,6 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
else if (IsInCover)
|
else if (IsInCover)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if (!_lastInCover)
|
if (!_lastInCover)
|
||||||
{
|
{
|
||||||
Function.Call(Hash.TASK_STAY_IN_COVER, MainPed.Handle);
|
Function.Call(Hash.TASK_STAY_IN_COVER, MainPed.Handle);
|
||||||
@ -563,7 +537,6 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
SmoothTransition();
|
SmoothTransition();
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else if (_lastInCover)
|
else if (_lastInCover)
|
||||||
{
|
{
|
||||||
@ -601,17 +574,13 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
foreach (KeyValuePair<uint, bool> comp in WeaponComponents)
|
foreach (KeyValuePair<uint, bool> comp in WeaponComponents)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (comp.Value)
|
if (comp.Value)
|
||||||
{
|
{
|
||||||
Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, _lastWeaponObj, comp.Key);
|
Function.Call(Hash.GIVE_WEAPON_COMPONENT_TO_WEAPON_OBJECT, _lastWeaponObj, comp.Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Function.Call(Hash.GIVE_WEAPON_OBJECT_TO_PED, _lastWeaponObj, MainPed.Handle);
|
Function.Call(Hash.GIVE_WEAPON_OBJECT_TO_PED, _lastWeaponObj, MainPed.Handle);
|
||||||
|
|
||||||
}
|
}
|
||||||
_lastWeaponComponents = WeaponComponents;
|
_lastWeaponComponents = WeaponComponents;
|
||||||
}
|
}
|
||||||
|
@ -52,8 +52,6 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
|
|
||||||
#region LAST STATE
|
#region LAST STATE
|
||||||
|
|
||||||
|
|
||||||
private byte[] _lastVehicleColors = new byte[] { 0, 0 };
|
private byte[] _lastVehicleColors = new byte[] { 0, 0 };
|
||||||
private Dictionary<int, int> _lastVehicleMods = new Dictionary<int, int>();
|
private Dictionary<int, int> _lastVehicleMods = new Dictionary<int, int>();
|
||||||
#endregion
|
#endregion
|
||||||
@ -67,25 +65,22 @@ namespace RageCoop.Client
|
|||||||
internal float DeluxoWingRatio { get; set; } = -1;
|
internal float DeluxoWingRatio { get; set; } = -1;
|
||||||
internal bool IsFlipped
|
internal bool IsFlipped
|
||||||
{
|
{
|
||||||
get
|
get => _isMotorcycle || ((Quaternion * Vector3.RelativeTop).Z - (Quaternion * Vector3.RelativeBottom).Z) < 0.5;
|
||||||
{
|
|
||||||
return _isMotorcycle||((Quaternion*Vector3.RelativeTop).Z - (Quaternion*Vector3.RelativeBottom).Z)<0.5;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
private bool _isMotorcycle;
|
private bool _isMotorcycle;
|
||||||
#endregion
|
#endregion
|
||||||
#region FLAGS
|
#region FLAGS
|
||||||
internal bool EngineRunning { get { return Flags.HasVehFlag(VehicleDataFlags.IsEngineRunning); } }
|
internal bool EngineRunning { get => Flags.HasVehFlag(VehicleDataFlags.IsEngineRunning); }
|
||||||
private bool _lastTransformed = false;
|
private bool _lastTransformed = false;
|
||||||
internal bool Transformed { get { return Flags.HasVehFlag(VehicleDataFlags.IsTransformed); } }
|
internal bool Transformed { get => Flags.HasVehFlag(VehicleDataFlags.IsTransformed); }
|
||||||
private bool _lastHornActive = false;
|
private bool _lastHornActive = false;
|
||||||
internal bool HornActive { get { return Flags.HasVehFlag(VehicleDataFlags.IsHornActive); } }
|
internal bool HornActive { get => Flags.HasVehFlag(VehicleDataFlags.IsHornActive); }
|
||||||
internal bool LightsOn { get { return Flags.HasVehFlag(VehicleDataFlags.AreLightsOn); } }
|
internal bool LightsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreLightsOn); }
|
||||||
internal bool BrakeLightsOn { get { return Flags.HasVehFlag(VehicleDataFlags.AreBrakeLightsOn); } }
|
internal bool BrakeLightsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreBrakeLightsOn); }
|
||||||
internal bool HighBeamsOn { get { return Flags.HasVehFlag(VehicleDataFlags.AreHighBeamsOn); } }
|
internal bool HighBeamsOn { get => Flags.HasVehFlag(VehicleDataFlags.AreHighBeamsOn); }
|
||||||
internal bool SireneActive { get { return Flags.HasVehFlag(VehicleDataFlags.IsSirenActive); } }
|
internal bool SireneActive { get => Flags.HasVehFlag(VehicleDataFlags.IsSirenActive); }
|
||||||
internal bool IsDead { get { return Flags.HasVehFlag(VehicleDataFlags.IsDead); } }
|
internal bool IsDead { get => Flags.HasVehFlag(VehicleDataFlags.IsDead); }
|
||||||
internal bool IsDeluxoHovering { get { return Flags.HasVehFlag(VehicleDataFlags.IsDeluxoHovering); } }
|
internal bool IsDeluxoHovering { get => Flags.HasVehFlag(VehicleDataFlags.IsDeluxoHovering); }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region -- VEHICLE STATE --
|
#region -- VEHICLE STATE --
|
||||||
@ -139,14 +134,7 @@ namespace RageCoop.Client
|
|||||||
MainVehicle.ThrottlePower=ThrottlePower;
|
MainVehicle.ThrottlePower=ThrottlePower;
|
||||||
MainVehicle.BrakePower=BrakePower;
|
MainVehicle.BrakePower=BrakePower;
|
||||||
var v = Main.P.CurrentVehicle;
|
var v = Main.P.CurrentVehicle;
|
||||||
if (v!= null && MainVehicle.IsTouching(v))
|
DisplayVehicle(v != null && MainVehicle.IsTouching(v));
|
||||||
{
|
|
||||||
DisplayVehicle(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DisplayVehicle(false);
|
|
||||||
}
|
|
||||||
#region FLAGS
|
#region FLAGS
|
||||||
if (IsDead)
|
if (IsDead)
|
||||||
{
|
{
|
||||||
@ -154,10 +142,8 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
MainVehicle.Explode();
|
||||||
MainVehicle.Explode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -280,7 +266,6 @@ namespace RageCoop.Client
|
|||||||
// check passengers (and driver).
|
// check passengers (and driver).
|
||||||
if (_checkSeat)
|
if (_checkSeat)
|
||||||
{
|
{
|
||||||
|
|
||||||
var currentPassengers = MainVehicle.GetPassengers();
|
var currentPassengers = MainVehicle.GetPassengers();
|
||||||
|
|
||||||
lock (Passengers)
|
lock (Passengers)
|
||||||
@ -290,7 +275,6 @@ namespace RageCoop.Client
|
|||||||
VehicleSeat seat = (VehicleSeat)i;
|
VehicleSeat seat = (VehicleSeat)i;
|
||||||
if (Passengers.ContainsKey(seat))
|
if (Passengers.ContainsKey(seat))
|
||||||
{
|
{
|
||||||
|
|
||||||
SyncedPed c = Passengers[seat];
|
SyncedPed c = Passengers[seat];
|
||||||
if (c?.ID==Main.LocalPlayerID && (RadioStation!=Function.Call<int>(Hash.GET_PLAYER_RADIO_STATION_INDEX)))
|
if (c?.ID==Main.LocalPlayerID && (RadioStation!=Function.Call<int>(Hash.GET_PLAYER_RADIO_STATION_INDEX)))
|
||||||
{
|
{
|
||||||
@ -336,8 +320,6 @@ namespace RageCoop.Client
|
|||||||
_lastVehicleMods = Mods;
|
_lastVehicleMods = Mods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (Function.Call<string>(Hash.GET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle)!=LicensePlate)
|
if (Function.Call<string>(Hash.GET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle)!=LicensePlate)
|
||||||
{
|
{
|
||||||
Function.Call(Hash.SET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle, LicensePlate);
|
Function.Call(Hash.SET_VEHICLE_NUMBER_PLATE_TEXT, MainVehicle, LicensePlate);
|
||||||
@ -366,34 +348,32 @@ namespace RageCoop.Client
|
|||||||
var dist = current.DistanceTo(Position);
|
var dist = current.DistanceTo(Position);
|
||||||
var cali = ((Velocity.Length()<0.1 && !touching)?dist*4:dist)*(_predictedPos - current);
|
var cali = ((Velocity.Length()<0.1 && !touching)?dist*4:dist)*(_predictedPos - current);
|
||||||
|
|
||||||
if (dist<8)
|
if (dist>=8)
|
||||||
{
|
{
|
||||||
|
MainVehicle.Position = _predictedPos;
|
||||||
MainVehicle.Velocity = Velocity;
|
MainVehicle.Velocity = Velocity;
|
||||||
MainVehicle.ApplyForce(cali);
|
MainVehicle.Quaternion = Quaternion;
|
||||||
if (IsFlipped)
|
return;
|
||||||
{
|
}
|
||||||
MainVehicle.Quaternion=Quaternion.Slerp(MainVehicle.ReadQuaternion(), Quaternion, 0.5f);
|
|
||||||
MainVehicle.RotationVelocity=RotationVelocity;
|
MainVehicle.Velocity = Velocity;
|
||||||
}
|
MainVehicle.ApplyForce(cali);
|
||||||
else
|
if (IsFlipped)
|
||||||
{
|
{
|
||||||
Vector3 calirot = GetCalibrationRotation();
|
MainVehicle.Quaternion = Quaternion.Slerp(MainVehicle.ReadQuaternion(), Quaternion, 0.5f);
|
||||||
if (calirot.Length()<50)
|
MainVehicle.RotationVelocity = RotationVelocity;
|
||||||
{
|
return;
|
||||||
MainVehicle.RotationVelocity = RotationVelocity+calirot*0.2f;
|
}
|
||||||
}
|
|
||||||
else
|
Vector3 calirot = GetCalibrationRotation();
|
||||||
{
|
if (calirot.Length() < 50)
|
||||||
MainVehicle.Quaternion=Quaternion;
|
{
|
||||||
MainVehicle.RotationVelocity=RotationVelocity;
|
MainVehicle.RotationVelocity = RotationVelocity + calirot * 0.2f;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
MainVehicle.Position=_predictedPos;
|
MainVehicle.Quaternion = Quaternion;
|
||||||
MainVehicle.Velocity=Velocity;
|
MainVehicle.RotationVelocity = RotationVelocity;
|
||||||
MainVehicle.Quaternion=Quaternion;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private Vector3 GetCalibrationRotation()
|
private Vector3 GetCalibrationRotation()
|
||||||
@ -411,7 +391,6 @@ namespace RageCoop.Client
|
|||||||
if (r.Z>180) { r.Z=r.Z-360; }
|
if (r.Z>180) { r.Z=r.Z-360; }
|
||||||
else if (r.Z<-180) { r.Z=360+r.Z; }
|
else if (r.Z<-180) { r.Z=360+r.Z; }
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
}
|
}
|
||||||
private bool CreateVehicle()
|
private bool CreateVehicle()
|
||||||
{
|
{
|
||||||
@ -489,5 +468,4 @@ namespace RageCoop.Client
|
|||||||
internal Vector3 LastVelocity { get; set; }
|
internal Vector3 LastVelocity { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -46,8 +46,7 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
foreach (int id in new List<int>(PedsByID.Keys))
|
foreach (int id in new List<int>(PedsByID.Keys))
|
||||||
{
|
{
|
||||||
if (keepPlayer&&(id==Main.LocalPlayerID)) { continue; }
|
if (keepPlayer && (id==Main.LocalPlayerID)|| keepMine && (PedsByID[id].OwnerID == Main.LocalPlayerID)) { continue; }
|
||||||
if (keepMine&&(PedsByID[id].OwnerID==Main.LocalPlayerID)) { continue; }
|
|
||||||
RemovePed(id);
|
RemovePed(id);
|
||||||
}
|
}
|
||||||
PedsByID.Clear();
|
PedsByID.Clear();
|
||||||
@ -88,55 +87,44 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region PEDS
|
#region PEDS
|
||||||
public static SyncedPed GetPedByID(int id)
|
public static SyncedPed GetPedByID(int id) => PedsByID.ContainsKey(id) ? PedsByID[id] : null;
|
||||||
{
|
public static SyncedPed GetPedByHandle(int handle) => PedsByHandle.ContainsKey(handle) ? PedsByHandle[handle] : null;
|
||||||
return PedsByID.ContainsKey(id) ? PedsByID[id] : null;
|
public static List<int> GetPedIDs() => new List<int>(PedsByID.Keys);
|
||||||
}
|
|
||||||
public static SyncedPed GetPedByHandle(int handle)
|
|
||||||
{
|
|
||||||
return PedsByHandle.ContainsKey(handle) ? PedsByHandle[handle] : null;
|
|
||||||
}
|
|
||||||
public static List<int> GetPedIDs()
|
|
||||||
{
|
|
||||||
return new List<int>(PedsByID.Keys);
|
|
||||||
}
|
|
||||||
public static bool AddPlayer()
|
public static bool AddPlayer()
|
||||||
{
|
{
|
||||||
Ped p = Game.Player.Character;
|
Ped p = Game.Player.Character;
|
||||||
SyncedPed player = GetPedByID(Main.LocalPlayerID);
|
SyncedPed player = GetPedByID(Main.LocalPlayerID);
|
||||||
if (player!=null)
|
if (player==null)
|
||||||
{
|
|
||||||
if (player.MainPed!=p)
|
|
||||||
{
|
|
||||||
// Player model changed
|
|
||||||
player.MainPed = p;
|
|
||||||
|
|
||||||
// Remove it from Handle_Characters
|
|
||||||
var pairs = PedsByHandle.Where(x => x.Value==player);
|
|
||||||
if (pairs.Any())
|
|
||||||
{
|
|
||||||
var pair = pairs.First();
|
|
||||||
|
|
||||||
// Re-add
|
|
||||||
PedsByHandle.Remove(pair.Key);
|
|
||||||
if (PedsByHandle.ContainsKey(p.Handle))
|
|
||||||
{
|
|
||||||
RemovePed(PedsByHandle[p.Handle].ID);
|
|
||||||
}
|
|
||||||
PedsByHandle.Add(p.Handle, player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Main.Logger.Debug($"Creating SyncEntity for player, handle:{p.Handle}");
|
Main.Logger.Debug($"Creating SyncEntity for player, handle:{p.Handle}");
|
||||||
SyncedPed c = new SyncedPed(p);
|
SyncedPed c = new SyncedPed(p);
|
||||||
Main.LocalPlayerID=c.OwnerID=c.ID;
|
Main.LocalPlayerID = c.OwnerID = c.ID;
|
||||||
Add(c);
|
Add(c);
|
||||||
Main.Logger.Debug($"Local player ID is:{c.ID}");
|
Main.Logger.Debug($"Local player ID is:{c.ID}");
|
||||||
PlayerList.SetPlayer(c.ID, Main.Settings.Username);
|
PlayerList.SetPlayer(c.ID, Main.Settings.Username);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player.MainPed != p)
|
||||||
|
{
|
||||||
|
// Player model changed
|
||||||
|
player.MainPed = p;
|
||||||
|
|
||||||
|
// Remove it from Handle_Characters
|
||||||
|
var pairs = PedsByHandle.Where(x => x.Value == player);
|
||||||
|
if (pairs.Any())
|
||||||
|
{
|
||||||
|
var pair = pairs.First();
|
||||||
|
|
||||||
|
// Re-add
|
||||||
|
PedsByHandle.Remove(pair.Key);
|
||||||
|
if (PedsByHandle.ContainsKey(p.Handle))
|
||||||
|
{
|
||||||
|
RemovePed(PedsByHandle[p.Handle].ID);
|
||||||
|
}
|
||||||
|
PedsByHandle.Add(p.Handle, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public static void Add(SyncedPed c)
|
public static void Add(SyncedPed c)
|
||||||
@ -194,18 +182,9 @@ namespace RageCoop.Client
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region VEHICLES
|
#region VEHICLES
|
||||||
public static SyncedVehicle GetVehicleByID(int id)
|
public static SyncedVehicle GetVehicleByID(int id) => VehiclesByID.ContainsKey(id) ? VehiclesByID[id] : null;
|
||||||
{
|
public static SyncedVehicle GetVehicleByHandle(int handle) => VehiclesByHandle.ContainsKey(handle) ? VehiclesByHandle[handle] : null;
|
||||||
return VehiclesByID.ContainsKey(id) ? VehiclesByID[id] : null;
|
public static List<int> GetVehicleIDs() => new List<int>(VehiclesByID.Keys);
|
||||||
}
|
|
||||||
public static SyncedVehicle GetVehicleByHandle(int handle)
|
|
||||||
{
|
|
||||||
return VehiclesByHandle.ContainsKey(handle) ? VehiclesByHandle[handle] : null;
|
|
||||||
}
|
|
||||||
public static List<int> GetVehicleIDs()
|
|
||||||
{
|
|
||||||
return new List<int>(VehiclesByID.Keys);
|
|
||||||
}
|
|
||||||
public static void Add(SyncedVehicle v)
|
public static void Add(SyncedVehicle v)
|
||||||
{
|
{
|
||||||
if (VehiclesByID.ContainsKey(v.ID))
|
if (VehiclesByID.ContainsKey(v.ID))
|
||||||
@ -300,18 +279,9 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool PedExists(int id)
|
public static bool PedExists(int id) => PedsByID.ContainsKey(id);
|
||||||
{
|
public static bool VehicleExists(int id) => VehiclesByID.ContainsKey(id);
|
||||||
return PedsByID.ContainsKey(id);
|
public static bool ProjectileExists(int id) => ProjectilesByID.ContainsKey(id);
|
||||||
}
|
|
||||||
public static bool VehicleExists(int id)
|
|
||||||
{
|
|
||||||
return VehiclesByID.ContainsKey(id);
|
|
||||||
}
|
|
||||||
public static bool ProjectileExists(int id)
|
|
||||||
{
|
|
||||||
return ProjectilesByID.ContainsKey(id);
|
|
||||||
}
|
|
||||||
#endregion
|
#endregion
|
||||||
static int vehStateIndex;
|
static int vehStateIndex;
|
||||||
static int pedStateIndex;
|
static int pedStateIndex;
|
||||||
@ -358,26 +328,21 @@ namespace RageCoop.Client
|
|||||||
if (!ProjectilesByHandle.ContainsKey(p.Handle))
|
if (!ProjectilesByHandle.ContainsKey(p.Handle))
|
||||||
{
|
{
|
||||||
Add(new SyncedProjectile(p));
|
Add(new SyncedProjectile(p));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SyncedProjectile p in ProjectilesByID.Values.ToArray())
|
foreach (SyncedProjectile p in ProjectilesByID.Values.ToArray())
|
||||||
{
|
{
|
||||||
|
|
||||||
// Outgoing sync
|
// Outgoing sync
|
||||||
if (p.IsLocal)
|
if (p.IsLocal)
|
||||||
{
|
{
|
||||||
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 (WeaponUtil.VehicleProjectileWeapons.Contains((VehicleWeaponHash)p.MainProjectile.WeaponHash))
|
if (WeaponUtil.VehicleProjectileWeapons.Contains((VehicleWeaponHash)p.MainProjectile.WeaponHash) &&
|
||||||
|
p.MainProjectile.WeaponHash != (WeaponHash)VehicleWeaponHash.Tank && p.Origin.DistanceTo(p.MainProjectile.Position) < 2)
|
||||||
{
|
{
|
||||||
if (p.MainProjectile.WeaponHash!=(WeaponHash)VehicleWeaponHash.Tank && p.Origin.DistanceTo(p.MainProjectile.Position)<2)
|
continue;
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Networking.SendProjectile(p);
|
Networking.SendProjectile(p);
|
||||||
@ -393,11 +358,8 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
p.Update();
|
p.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
i=-1;
|
i=-1;
|
||||||
@ -411,20 +373,15 @@ namespace RageCoop.Client
|
|||||||
SyncedPed c = EntityPool.GetPedByHandle(p.Handle);
|
SyncedPed c = EntityPool.GetPedByHandle(p.Handle);
|
||||||
if (c==null && (p!=Game.Player.Character))
|
if (c==null && (p!=Game.Player.Character))
|
||||||
{
|
{
|
||||||
if (allPeds.Length>Main.Settings.WorldPedSoftLimit)
|
if (allPeds.Length>Main.Settings.WorldPedSoftLimit && p.PopulationType != EntityPopulationType.RandomAmbient)
|
||||||
{
|
{
|
||||||
if (p.PopulationType!=EntityPopulationType.RandomAmbient)
|
p.Delete();
|
||||||
{
|
continue;
|
||||||
p.Delete();
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Main.Logger.Trace($"Creating SyncEntity for ped, handle:{p.Handle}");
|
// Main.Logger.Trace($"Creating SyncEntity for ped, handle:{p.Handle}");
|
||||||
c=new SyncedPed(p);
|
c=new SyncedPed(p);
|
||||||
|
|
||||||
EntityPool.Add(c);
|
EntityPool.Add(c);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
@ -437,6 +394,7 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
pedStateIndex=0;
|
pedStateIndex=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SyncedPed c in ps)
|
foreach (SyncedPed c in ps)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@ -457,7 +415,6 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
Networking.SendPed(c, (i-pedStateIndex)<pedStatesPerFrame);
|
Networking.SendPed(c, (i-pedStateIndex)<pedStatesPerFrame);
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
|
|
||||||
Debug.TimeStamps[TimeStamp.SendPed]=PerfCounter2.ElapsedTicks-start;
|
Debug.TimeStamps[TimeStamp.SendPed]=PerfCounter2.ElapsedTicks-start;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -472,13 +429,11 @@ namespace RageCoop.Client
|
|||||||
RemovePed(c.ID, "OutOfSync");
|
RemovePed(c.ID, "OutOfSync");
|
||||||
}
|
}
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
|
|
||||||
Debug.TimeStamps[TimeStamp.UpdatePed]=PerfCounter2.ElapsedTicks-start;
|
Debug.TimeStamps[TimeStamp.UpdatePed]=PerfCounter2.ElapsedTicks-start;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
|
|
||||||
Debug.TimeStamps[TimeStamp.PedTotal]=PerfCounter.ElapsedTicks;
|
Debug.TimeStamps[TimeStamp.PedTotal]=PerfCounter.ElapsedTicks;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -487,7 +442,6 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
lock (VehiclesLock)
|
lock (VehiclesLock)
|
||||||
{
|
{
|
||||||
|
|
||||||
foreach (Vehicle veh in allVehicles)
|
foreach (Vehicle veh in allVehicles)
|
||||||
{
|
{
|
||||||
if (!VehiclesByHandle.ContainsKey(veh.Handle))
|
if (!VehiclesByHandle.ContainsKey(veh.Handle))
|
||||||
@ -513,12 +467,9 @@ namespace RageCoop.Client
|
|||||||
// Main.Logger.Debug($"Creating SyncEntity for vehicle, handle:{veh.Handle}");
|
// Main.Logger.Debug($"Creating SyncEntity for vehicle, handle:{veh.Handle}");
|
||||||
|
|
||||||
Add(new SyncedVehicle(veh));
|
Add(new SyncedVehicle(veh));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
|
|
||||||
Debug.TimeStamps[TimeStamp.AddVehicles]=PerfCounter.ElapsedTicks;
|
Debug.TimeStamps[TimeStamp.AddVehicles]=PerfCounter.ElapsedTicks;
|
||||||
#endif
|
#endif
|
||||||
var vs = VehiclesByID.Values.ToArray();
|
var vs = VehiclesByID.Values.ToArray();
|
||||||
@ -527,6 +478,7 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
vehStateIndex=0;
|
vehStateIndex=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SyncedVehicle v in vs)
|
foreach (SyncedVehicle v in vs)
|
||||||
{
|
{
|
||||||
i++;
|
i++;
|
||||||
@ -543,20 +495,15 @@ namespace RageCoop.Client
|
|||||||
SyncEvents.Check(v);
|
SyncEvents.Check(v);
|
||||||
|
|
||||||
Networking.SendVehicle(v, (i-vehStateIndex)<vehStatesPerFrame);
|
Networking.SendVehicle(v, (i-vehStateIndex)<vehStatesPerFrame);
|
||||||
|
|
||||||
}
|
}
|
||||||
else // Incoming sync
|
else // Incoming sync
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
v.Update();
|
v.Update();
|
||||||
if (v.IsOutOfSync)
|
if (v.IsOutOfSync)
|
||||||
{
|
{
|
||||||
RemoveVehicle(v.ID, "OutOfSync");
|
RemoveVehicle(v.ID, "OutOfSync");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
@ -586,6 +533,7 @@ namespace RageCoop.Client
|
|||||||
RemovePed(p.ID);
|
RemovePed(p.ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (SyncedVehicle v in VehiclesByID.Values.ToArray())
|
foreach (SyncedVehicle v in VehiclesByID.Values.ToArray())
|
||||||
{
|
{
|
||||||
if (v.OwnerID==playerPedId)
|
if (v.OwnerID==playerPedId)
|
||||||
@ -598,10 +546,7 @@ namespace RageCoop.Client
|
|||||||
public static int RequestNewID()
|
public static int RequestNewID()
|
||||||
{
|
{
|
||||||
int ID = 0;
|
int ID = 0;
|
||||||
while ((ID==0)
|
while ((ID==0) || PedsByID.ContainsKey(ID) || VehiclesByID.ContainsKey(ID) || ProjectilesByID.ContainsKey(ID))
|
||||||
|| PedsByID.ContainsKey(ID)
|
|
||||||
|| VehiclesByID.ContainsKey(ID)
|
|
||||||
|| ProjectilesByID.ContainsKey(ID))
|
|
||||||
{
|
{
|
||||||
byte[] rngBytes = new byte[4];
|
byte[] rngBytes = new byte[4];
|
||||||
|
|
||||||
@ -619,16 +564,14 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
public static string DumpDebug()
|
public static string DumpDebug()
|
||||||
{
|
{
|
||||||
string s = "";
|
return $"\nID_Peds: {PedsByID.Count}" +
|
||||||
s+="\nID_Peds: "+PedsByID.Count;
|
$"\nHandle_Peds: {PedsByHandle.Count}" +
|
||||||
s+="\nHandle_Peds: "+PedsByHandle.Count;
|
$"\nID_Vehicles: {VehiclesByID.Count}" +
|
||||||
s+="\nID_Vehicles: "+VehiclesByID.Count;
|
$"\nHandle_vehicles: {VehiclesByHandle.Count}" +
|
||||||
s+="\nHandle_Vehicles: "+VehiclesByHandle.Count;
|
$"\nID_Projectiles: {ProjectilesByID.Count}" +
|
||||||
s+="\nID_Projectiles: "+ProjectilesByID.Count;
|
$"\nHandle_Projectiles: {ProjectilesByHandle.Count}" +
|
||||||
s+="\nHandle_Projectiles: "+ProjectilesByHandle.Count;
|
$"\npedStatesPerFrame: {pedStatesPerFrame}" +
|
||||||
s+="\npedStatesPerFrame:"+pedStatesPerFrame;
|
$"\nvehStatesPerFrame: {vehStatesPerFrame}";
|
||||||
s+="\nvehStatesPerFrame:"+vehStatesPerFrame;
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
public static class ThreadSafe
|
public static class ThreadSafe
|
||||||
{
|
{
|
||||||
|
@ -136,12 +136,9 @@ namespace RageCoop.Client
|
|||||||
var v = EntityPool.GetVehicleByID(vehId);
|
var v = EntityPool.GetVehicleByID(vehId);
|
||||||
var p = EntityPool.GetPedByID(pedId)?.MainPed;
|
var p = EntityPool.GetPedByID(pedId)?.MainPed;
|
||||||
if (v==null||p==null) { return; }
|
if (v==null||p==null) { return; }
|
||||||
if (!v.MainVehicle.IsSeatFree(seat))
|
if (!v.MainVehicle.IsSeatFree(seat) && v.MainVehicle.GetPedOnSeat(seat) != p)
|
||||||
{
|
{
|
||||||
if (v.MainVehicle.GetPedOnSeat(seat)!=p)
|
v.MainVehicle.GetPedOnSeat(seat).Task.WarpOutOfVehicle(v.MainVehicle);
|
||||||
{
|
|
||||||
v.MainVehicle.GetPedOnSeat(seat).Task.WarpOutOfVehicle(v.MainVehicle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
p.SetIntoVehicle(v.MainVehicle, seat);
|
p.SetIntoVehicle(v.MainVehicle, seat);
|
||||||
}
|
}
|
||||||
@ -215,14 +212,10 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
World.CreateParticleEffectNonLooped(CorePFXAsset, "muz_assault_rifle", p.GetMuzzlePosition(), w.Rotation, 1);
|
World.CreateParticleEffectNonLooped(CorePFXAsset, "muz_assault_rifle", p.GetMuzzlePosition(), w.Rotation, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (p.VehicleWeapon!=VehicleWeaponHash.Invalid)
|
else if (p.VehicleWeapon!=VehicleWeaponHash.Invalid && p.VehicleWeapon == VehicleWeaponHash.Tank)
|
||||||
{
|
{
|
||||||
if (p.VehicleWeapon==VehicleWeaponHash.Tank)
|
World.CreateParticleEffectNonLooped(CorePFXAsset, "muz_tank", p.CurrentVehicle.GetMuzzleInfo().Position, p.CurrentVehicle.Bones[35].ForwardVector.ToEulerRotation(p.CurrentVehicle.Bones[35].UpVector), 1);
|
||||||
{
|
|
||||||
World.CreateParticleEffectNonLooped(CorePFXAsset, "muz_tank", p.CurrentVehicle.GetMuzzleInfo().Position, p.CurrentVehicle.Bones[35].ForwardVector.ToEulerRotation(p.CurrentVehicle.Bones[35].UpVector), 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void HandleEvent(PacketType type, byte[] data)
|
public static void HandleEvent(PacketType type, byte[] data)
|
||||||
@ -303,32 +296,10 @@ namespace RageCoop.Client
|
|||||||
Vector3 endPos = subject.LastWeaponImpactPosition;
|
Vector3 endPos = subject.LastWeaponImpactPosition;
|
||||||
if (endPos==default)
|
if (endPos==default)
|
||||||
{
|
{
|
||||||
if (i>5)
|
if (++i<=5) { return false; }
|
||||||
{
|
|
||||||
endPos=subject.GetAimCoord();
|
endPos = subject.GetAimCoord();
|
||||||
if (subject.IsInVehicle() && subject.VehicleWeapon!=VehicleWeaponHash.Invalid)
|
if (subject.IsInVehicle() && subject.VehicleWeapon != VehicleWeaponHash.Invalid)
|
||||||
{
|
|
||||||
if (subject.IsOnTurretSeat())
|
|
||||||
{
|
|
||||||
TriggerBulletShot((uint)subject.VehicleWeapon, c, endPos);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TriggerVehBulletShot((uint)subject.VehicleWeapon, subject.CurrentVehicle, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
TriggerBulletShot((uint)subject.Weapons.Current.Hash, c, endPos);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (subject.IsInVehicle() && subject.VehicleWeapon!=VehicleWeaponHash.Invalid)
|
|
||||||
{
|
{
|
||||||
if (subject.IsOnTurretSeat())
|
if (subject.IsOnTurretSeat())
|
||||||
{
|
{
|
||||||
@ -346,8 +317,25 @@ namespace RageCoop.Client
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (subject.IsInVehicle() && subject.VehicleWeapon != VehicleWeaponHash.Invalid)
|
||||||
|
{
|
||||||
|
if (subject.IsOnTurretSeat())
|
||||||
|
{
|
||||||
|
TriggerBulletShot((uint)subject.VehicleWeapon, c, endPos);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TriggerVehBulletShot((uint)subject.VehicleWeapon, subject.CurrentVehicle, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TriggerBulletShot((uint)subject.Weapons.Current.Hash, c, endPos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!getBulletImpact())
|
if (!getBulletImpact())
|
||||||
{
|
{
|
||||||
Main.QueueAction(getBulletImpact);
|
Main.QueueAction(getBulletImpact);
|
||||||
@ -357,10 +345,8 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
TriggerBulletShot((uint)VehicleWeaponHash.Tank, c, subject.LastWeaponImpactPosition);
|
TriggerBulletShot((uint)VehicleWeaponHash.Tank, c, subject.LastWeaponImpactPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Vehicles
|
// Vehicles
|
||||||
var g = subject.IsGettingIntoVehicle;
|
var g = subject.IsGettingIntoVehicle;
|
||||||
if (g && (!c._lastEnteringVehicle))
|
if (g && (!c._lastEnteringVehicle))
|
||||||
@ -368,6 +354,7 @@ namespace RageCoop.Client
|
|||||||
var v = subject.VehicleTryingToEnter.GetSyncEntity();
|
var v = subject.VehicleTryingToEnter.GetSyncEntity();
|
||||||
TriggerEnteringVehicle(c, v, subject.GetSeatTryingToEnter());
|
TriggerEnteringVehicle(c, v, subject.GetSeatTryingToEnter());
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentSitting = subject.IsSittingInVehicle();
|
var currentSitting = subject.IsSittingInVehicle();
|
||||||
if (c._lastSittingInVehicle)
|
if (c._lastSittingInVehicle)
|
||||||
{
|
{
|
||||||
@ -391,18 +378,20 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
public static void Check(SyncedVehicle v)
|
public static void Check(SyncedVehicle v)
|
||||||
{
|
{
|
||||||
if (v.MainVehicle!=null&&v.MainVehicle.HasNozzle())
|
if (v.MainVehicle==null||!v.MainVehicle.HasNozzle())
|
||||||
{
|
{
|
||||||
if ((v.LastNozzleAngle==1) && (v.MainVehicle.GetNozzleAngel()!=1))
|
return;
|
||||||
{
|
|
||||||
TriggerNozzleTransform(v.ID, false);
|
|
||||||
}
|
|
||||||
else if ((v.LastNozzleAngle==0) && (v.MainVehicle.GetNozzleAngel()!=0))
|
|
||||||
{
|
|
||||||
TriggerNozzleTransform(v.ID, true);
|
|
||||||
}
|
|
||||||
v.LastNozzleAngle=v.MainVehicle.GetNozzleAngel();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((v.LastNozzleAngle == 1) && (v.MainVehicle.GetNozzleAngel() != 1))
|
||||||
|
{
|
||||||
|
TriggerNozzleTransform(v.ID, false);
|
||||||
|
}
|
||||||
|
else if ((v.LastNozzleAngle == 0) && (v.MainVehicle.GetNozzleAngel() != 0))
|
||||||
|
{
|
||||||
|
TriggerNozzleTransform(v.ID, true);
|
||||||
|
}
|
||||||
|
v.LastNozzleAngle = v.MainVehicle.GetNozzleAngel();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using GTA.Math;
|
using GTA.Math;
|
||||||
using GTA;
|
using GTA;
|
||||||
using SHVDN;
|
using SHVDN;
|
||||||
@ -40,8 +37,6 @@ internal static unsafe class Memory
|
|||||||
public static MemPatch TimeScalePatch;
|
public static MemPatch TimeScalePatch;
|
||||||
static Memory()
|
static Memory()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Weapon/radio wheel slow-mo patch
|
// Weapon/radio wheel slow-mo patch
|
||||||
// Thanks @CamxxCore, https://github.com/CamxxCore/GTAVWeaponWheelMod
|
// Thanks @CamxxCore, https://github.com/CamxxCore/GTAVWeaponWheelMod
|
||||||
var result = NativeMemory.FindPattern("\x38\x51\x64\x74\x19", "xxxxx");
|
var result = NativeMemory.FindPattern("\x38\x51\x64\x74\x19", "xxxxx");
|
||||||
@ -73,27 +68,13 @@ internal static unsafe class Memory
|
|||||||
public const int MatrixOffset = 96;
|
public const int MatrixOffset = 96;
|
||||||
#endregion
|
#endregion
|
||||||
#region OPCODE
|
#region OPCODE
|
||||||
|
|
||||||
const byte XOR_32_64 = 0x31;
|
const byte XOR_32_64 = 0x31;
|
||||||
const byte RET = 0xC3;
|
const byte RET = 0xC3;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
public static Vector3 ReadPosition(this Entity e)
|
public static Vector3 ReadPosition(this Entity e) => ReadVector3(e.MemoryAddress + PositionOffset);
|
||||||
{
|
public static Quaternion ReadQuaternion(this Entity e) => Quaternion.RotationMatrix(e.Matrix);
|
||||||
return ReadVector3(e.MemoryAddress+PositionOffset);
|
public static Vector3 ReadRotation(this Entity e) => e.ReadQuaternion().ToEulerDegrees();
|
||||||
}
|
public static Vector3 ReadVelocity(this Ped e) => ReadVector3(e.MemoryAddress+VelocityOffset);
|
||||||
public static Quaternion ReadQuaternion(this Entity e)
|
|
||||||
{
|
|
||||||
return Quaternion.RotationMatrix(e.Matrix);
|
|
||||||
}
|
|
||||||
public static Vector3 ReadRotation(this Entity e)
|
|
||||||
{
|
|
||||||
return e.ReadQuaternion().ToEulerDegrees();
|
|
||||||
}
|
|
||||||
public static Vector3 ReadVelocity(this Ped e)
|
|
||||||
{
|
|
||||||
return ReadVector3(e.MemoryAddress+VelocityOffset);
|
|
||||||
}
|
|
||||||
public static Vector3 ReadVector3(IntPtr address)
|
public static Vector3 ReadVector3(IntPtr address)
|
||||||
{
|
{
|
||||||
float* ptr = (float*)address.ToPointer();
|
float* ptr = (float*)address.ToPointer();
|
||||||
|
@ -28,15 +28,11 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
private void OnTick(object sender, EventArgs e)
|
private void OnTick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (Game.IsLoading)
|
if (Game.IsLoading || !Networking.IsOnServer)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Networking.IsOnServer)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Game.DisableControlThisFrame(Control.FrontendPause);
|
Game.DisableControlThisFrame(Control.FrontendPause);
|
||||||
if (Main.Settings.DisableAlternatePause)
|
if (Main.Settings.DisableAlternatePause)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user