Cleaned up (Client)
This commit is contained in:
@ -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;
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user