Removed LVector, LQuaternion.
Server side optimization. Nework optimization (streaming distance).
This commit is contained in:
@ -20,7 +20,7 @@ namespace RageCoop.Client.Menus
|
|||||||
Alignment = Main.Settings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
Alignment = Main.Settings.FlipMenu ? GTA.UI.Alignment.Right : GTA.UI.Alignment.Left
|
||||||
};
|
};
|
||||||
#region SUB
|
#region SUB
|
||||||
public Sub.SettingsMenu SubSettings = new Sub.SettingsMenu();
|
public SettingsMenu SubSettings = new SettingsMenu();
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ITEMS
|
#region ITEMS
|
||||||
@ -51,7 +51,6 @@ namespace RageCoop.Client.Menus
|
|||||||
MainMenu.Add(_usernameItem);
|
MainMenu.Add(_usernameItem);
|
||||||
MainMenu.Add(ServerIpItem);
|
MainMenu.Add(ServerIpItem);
|
||||||
MainMenu.Add(_serverConnectItem);
|
MainMenu.Add(_serverConnectItem);
|
||||||
MainMenu.Add(_aboutItem);
|
|
||||||
|
|
||||||
MainMenu.AddSubMenu(SubSettings.Menu);
|
MainMenu.AddSubMenu(SubSettings.Menu);
|
||||||
MainMenu.AddSubMenu(DevToolMenu.Menu);
|
MainMenu.AddSubMenu(DevToolMenu.Menu);
|
||||||
@ -63,6 +62,8 @@ namespace RageCoop.Client.Menus
|
|||||||
MenuPool.Add(DevToolMenu.Menu);
|
MenuPool.Add(DevToolMenu.Menu);
|
||||||
MenuPool.Add(DebugMenu.Menu);
|
MenuPool.Add(DebugMenu.Menu);
|
||||||
MenuPool.Add(DebugMenu.DiagnosticMenu);
|
MenuPool.Add(DebugMenu.DiagnosticMenu);
|
||||||
|
|
||||||
|
MainMenu.Add(_aboutItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UsernameActivated(object a, System.EventArgs b)
|
public void UsernameActivated(object a, System.EventArgs b)
|
||||||
@ -91,25 +92,24 @@ namespace RageCoop.Client.Menus
|
|||||||
|
|
||||||
public void InitiateConnectionMenuSetting()
|
public void InitiateConnectionMenuSetting()
|
||||||
{
|
{
|
||||||
MainMenu.Items[0].Enabled = false;
|
_usernameItem.Enabled = false;
|
||||||
MainMenu.Items[1].Enabled = false;
|
ServerIpItem.Enabled = false;
|
||||||
MainMenu.Items[2].Enabled = false;
|
_serverConnectItem.Enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ConnectedMenuSetting()
|
public void ConnectedMenuSetting()
|
||||||
{
|
{
|
||||||
MainMenu.Items[2].Enabled = true;
|
_serverConnectItem.Enabled = true;
|
||||||
MainMenu.Items[2].Title = "Disconnect";
|
_serverConnectItem.Title = "Disconnect";
|
||||||
MainMenu.Visible = false;
|
MainMenu.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisconnectedMenuSetting()
|
public void DisconnectedMenuSetting()
|
||||||
{
|
{
|
||||||
MainMenu.Items[0].Enabled = true;
|
_usernameItem.Enabled = true;
|
||||||
MainMenu.Items[1].Enabled = true;
|
ServerIpItem.Enabled = true;
|
||||||
MainMenu.Items[2].Enabled = true;
|
_serverConnectItem.Enabled = true;
|
||||||
MainMenu.Items[2].Title = "Connect";
|
_serverConnectItem.Title = "Connect";
|
||||||
SubSettings.Menu.Items[1].Enabled = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ using System.Windows.Forms;
|
|||||||
using GTA;
|
using GTA;
|
||||||
using LemonUI.Menus;
|
using LemonUI.Menus;
|
||||||
|
|
||||||
namespace RageCoop.Client.Menus.Sub
|
namespace RageCoop.Client.Menus
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Don't use it!
|
/// Don't use it!
|
||||||
|
@ -275,7 +275,10 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
flags |=PedDataFlags.IsInCover;
|
flags |=PedDataFlags.IsInCover;
|
||||||
}
|
}
|
||||||
|
if (ped.IsPlayer)
|
||||||
|
{
|
||||||
|
flags|=PedDataFlags.IsPlayer;
|
||||||
|
}
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -911,35 +914,6 @@ namespace RageCoop.Client
|
|||||||
};
|
};
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public static LVector3 ToLVector(this Vector3 vec)
|
|
||||||
{
|
|
||||||
return new LVector3()
|
|
||||||
{
|
|
||||||
X = vec.X,
|
|
||||||
Y = vec.Y,
|
|
||||||
Z = vec.Z
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public static LQuaternion ToLQuaternion(this Quaternion vec)
|
|
||||||
{
|
|
||||||
return new LQuaternion()
|
|
||||||
{
|
|
||||||
X = vec.X,
|
|
||||||
Y = vec.Y,
|
|
||||||
Z = vec.Z,
|
|
||||||
W = vec.W
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static double DegToRad(double deg)
|
public static double DegToRad(double deg)
|
||||||
{
|
{
|
||||||
return deg * Math.PI / 180.0;
|
return deg * Math.PI / 180.0;
|
||||||
|
@ -6,7 +6,7 @@ using Lidgren.Network;
|
|||||||
using RageCoop.Core;
|
using RageCoop.Core;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using GTA;
|
using GTA.Math;
|
||||||
using GTA.Native;
|
using GTA.Native;
|
||||||
|
|
||||||
namespace RageCoop.Client
|
namespace RageCoop.Client
|
||||||
@ -144,8 +144,8 @@ namespace RageCoop.Client
|
|||||||
case string _:
|
case string _:
|
||||||
arguments.Add((string)x);
|
arguments.Add((string)x);
|
||||||
break;
|
break;
|
||||||
case LVector3 _:
|
case Vector3 _:
|
||||||
LVector3 vector = (LVector3)x;
|
Vector3 vector = (Vector3)x;
|
||||||
arguments.Add((float)vector.X);
|
arguments.Add((float)vector.X);
|
||||||
arguments.Add((float)vector.Y);
|
arguments.Add((float)vector.Y);
|
||||||
arguments.Add((float)vector.Z);
|
arguments.Add((float)vector.Z);
|
||||||
@ -173,7 +173,7 @@ namespace RageCoop.Client
|
|||||||
case 0x03: // string
|
case 0x03: // string
|
||||||
return Function.Call<string>((Hash)hash, arguments.ToArray());
|
return Function.Call<string>((Hash)hash, arguments.ToArray());
|
||||||
case 0x04: // vector3
|
case 0x04: // vector3
|
||||||
return Function.Call<GTA.Math.Vector3>((Hash)hash, arguments.ToArray()).ToLVector();
|
return Function.Call<Vector3>((Hash)hash, arguments.ToArray());
|
||||||
default:
|
default:
|
||||||
GTA.UI.Notification.Show("[DecodeNativeCall][" + hash + "]: Type of return not found!");
|
GTA.UI.Notification.Show("[DecodeNativeCall][" + hash + "]: Type of return not found!");
|
||||||
return null;
|
return null;
|
||||||
|
@ -307,20 +307,19 @@ namespace RageCoop.Client
|
|||||||
|
|
||||||
private static void PedSync(Packets.PedSync packet)
|
private static void PedSync(Packets.PedSync packet)
|
||||||
{
|
{
|
||||||
if (!EntityPool.PedExists(packet.ID))
|
SyncedPed c = EntityPool.GetPedByID(packet.ID);
|
||||||
|
if (c==null)
|
||||||
{
|
{
|
||||||
Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}");
|
Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}");
|
||||||
|
EntityPool.ThreadSafe.Add(c=new SyncedPed(packet.ID));
|
||||||
EntityPool.ThreadSafe.Add(new SyncedPed(packet.ID));
|
|
||||||
}
|
}
|
||||||
PedDataFlags flags = packet.Flag;
|
PedDataFlags flags = packet.Flag;
|
||||||
SyncedPed c = EntityPool.GetPedByID(packet.ID);
|
|
||||||
c.ID=packet.ID;
|
c.ID=packet.ID;
|
||||||
//c.OwnerID=packet.OwnerID;
|
//c.OwnerID=packet.OwnerID;
|
||||||
c.Health = packet.Health;
|
c.Health = packet.Health;
|
||||||
c.Position = packet.Position.ToVector();
|
c.Position = packet.Position;
|
||||||
c.Rotation = packet.Rotation.ToVector();
|
c.Rotation = packet.Rotation;
|
||||||
c.Velocity = packet.Velocity.ToVector();
|
c.Velocity = packet.Velocity;
|
||||||
c.Speed = packet.Speed;
|
c.Speed = packet.Speed;
|
||||||
c.CurrentWeaponHash = packet.CurrentWeaponHash;
|
c.CurrentWeaponHash = packet.CurrentWeaponHash;
|
||||||
c.IsAiming = flags.HasFlag(PedDataFlags.IsAiming);
|
c.IsAiming = flags.HasFlag(PedDataFlags.IsAiming);
|
||||||
@ -337,22 +336,17 @@ namespace RageCoop.Client
|
|||||||
c.LastSynced = Main.Ticked;
|
c.LastSynced = Main.Ticked;
|
||||||
if (c.IsAiming)
|
if (c.IsAiming)
|
||||||
{
|
{
|
||||||
c.AimCoords = packet.AimCoords.ToVector();
|
c.AimCoords = packet.AimCoords;
|
||||||
}
|
}
|
||||||
if (c.IsRagdoll)
|
if (c.IsRagdoll)
|
||||||
{
|
{
|
||||||
c.RotationVelocity=packet.RotationVelocity.ToVector();
|
c.RotationVelocity=packet.RotationVelocity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private static void PedStateSync(Packets.PedStateSync packet)
|
private static void PedStateSync(Packets.PedStateSync packet)
|
||||||
{
|
{
|
||||||
if (!EntityPool.PedExists(packet.ID))
|
|
||||||
{
|
|
||||||
Main.Logger.Debug($"Creating character for incoming sync:{packet.ID}");
|
|
||||||
|
|
||||||
EntityPool.ThreadSafe.Add(new SyncedPed(packet.ID));
|
|
||||||
}
|
|
||||||
SyncedPed c = EntityPool.GetPedByID(packet.ID);
|
SyncedPed c = EntityPool.GetPedByID(packet.ID);
|
||||||
|
if (c==null) { return; }
|
||||||
c.ID=packet.ID;
|
c.ID=packet.ID;
|
||||||
c.OwnerID=packet.OwnerID;
|
c.OwnerID=packet.OwnerID;
|
||||||
c.Clothes=packet.Clothes;
|
c.Clothes=packet.Clothes;
|
||||||
@ -362,30 +356,26 @@ namespace RageCoop.Client
|
|||||||
}
|
}
|
||||||
private static void VehicleSync(Packets.VehicleSync packet)
|
private static void VehicleSync(Packets.VehicleSync packet)
|
||||||
{
|
{
|
||||||
if (!EntityPool.VehicleExists(packet.ID))
|
SyncedVehicle v = EntityPool.GetVehicleByID(packet.ID);
|
||||||
|
if (v==null)
|
||||||
{
|
{
|
||||||
EntityPool.ThreadSafe.Add(new SyncedVehicle(packet.ID));
|
EntityPool.ThreadSafe.Add(v=new SyncedVehicle(packet.ID));
|
||||||
}
|
}
|
||||||
SyncedVehicle v = EntityPool.GetVehicleByID(packet.ID);
|
|
||||||
if (v.IsMine) { return; }
|
if (v.IsMine) { return; }
|
||||||
v.ID= packet.ID;
|
v.ID= packet.ID;
|
||||||
v.Position=packet.Position.ToVector();
|
v.Position=packet.Position;
|
||||||
v.Rotation=packet.Rotation.ToVector();
|
v.Rotation=packet.Rotation;
|
||||||
v.SteeringAngle=packet.SteeringAngle;
|
v.SteeringAngle=packet.SteeringAngle;
|
||||||
v.ThrottlePower=packet.ThrottlePower;
|
v.ThrottlePower=packet.ThrottlePower;
|
||||||
v.BrakePower=packet.BrakePower;
|
v.BrakePower=packet.BrakePower;
|
||||||
v.Velocity=packet.Velocity.ToVector();
|
v.Velocity=packet.Velocity;
|
||||||
v.RotationVelocity=packet.RotationVelocity.ToVector();
|
v.RotationVelocity=packet.RotationVelocity;
|
||||||
v.LastSynced=Main.Ticked;
|
v.LastSynced=Main.Ticked;
|
||||||
}
|
}
|
||||||
private static void VehicleStateSync(Packets.VehicleStateSync packet)
|
private static void VehicleStateSync(Packets.VehicleStateSync packet)
|
||||||
{
|
{
|
||||||
if (!EntityPool.VehicleExists(packet.ID))
|
|
||||||
{
|
|
||||||
EntityPool.ThreadSafe.Add(new SyncedVehicle(packet.ID));
|
|
||||||
}
|
|
||||||
SyncedVehicle v = EntityPool.GetVehicleByID(packet.ID);
|
SyncedVehicle v = EntityPool.GetVehicleByID(packet.ID);
|
||||||
if (v.IsMine) { return; }
|
if (v==null||v.IsMine) { return; }
|
||||||
v.ID= packet.ID;
|
v.ID= packet.ID;
|
||||||
v.OwnerID= packet.OwnerID;
|
v.OwnerID= packet.OwnerID;
|
||||||
v.DamageModel=packet.DamageModel;
|
v.DamageModel=packet.DamageModel;
|
||||||
@ -425,9 +415,9 @@ namespace RageCoop.Client
|
|||||||
Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
|
Main.Logger.Debug($"Creating new projectile: {(WeaponHash)packet.WeaponHash}");
|
||||||
EntityPool.ThreadSafe.Add(p=new SyncedProjectile(packet.ID));
|
EntityPool.ThreadSafe.Add(p=new SyncedProjectile(packet.ID));
|
||||||
}
|
}
|
||||||
p.Position=packet.Position.ToVector();
|
p.Position=packet.Position;
|
||||||
p.Rotation=packet.Rotation.ToVector();
|
p.Rotation=packet.Rotation;
|
||||||
p.Velocity=packet.Velocity.ToVector();
|
p.Velocity=packet.Velocity;
|
||||||
p.Hash=(WeaponHash)packet.WeaponHash;
|
p.Hash=(WeaponHash)packet.WeaponHash;
|
||||||
p.ShooterID=packet.ShooterID;
|
p.ShooterID=packet.ShooterID;
|
||||||
p.Exploded=packet.Exploded;
|
p.Exploded=packet.Exploded;
|
||||||
|
@ -36,9 +36,9 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
ID =c.ID,
|
ID =c.ID,
|
||||||
Health = p.Health,
|
Health = p.Health,
|
||||||
Position = p.Position.ToLVector(),
|
Position = p.Position,
|
||||||
Rotation = p.Rotation.ToLVector(),
|
Rotation = p.Rotation,
|
||||||
Velocity = p.Velocity.ToLVector(),
|
Velocity = p.Velocity,
|
||||||
Speed = p.GetPedSpeed(),
|
Speed = p.GetPedSpeed(),
|
||||||
CurrentWeaponHash = (uint)p.Weapons.Current.Hash,
|
CurrentWeaponHash = (uint)p.Weapons.Current.Hash,
|
||||||
Flag = p.GetPedFlags(),
|
Flag = p.GetPedFlags(),
|
||||||
@ -46,11 +46,11 @@ namespace RageCoop.Client
|
|||||||
};
|
};
|
||||||
if (packet.Flag.HasFlag(PedDataFlags.IsAiming))
|
if (packet.Flag.HasFlag(PedDataFlags.IsAiming))
|
||||||
{
|
{
|
||||||
packet.AimCoords = p.GetAimCoord().ToLVector();
|
packet.AimCoords = p.GetAimCoord();
|
||||||
}
|
}
|
||||||
if (packet.Flag.HasFlag(PedDataFlags.IsRagdoll))
|
if (packet.Flag.HasFlag(PedDataFlags.IsRagdoll))
|
||||||
{
|
{
|
||||||
packet.RotationVelocity=p.RotationVelocity.ToLVector();
|
packet.RotationVelocity=p.RotationVelocity;
|
||||||
}
|
}
|
||||||
Send(packet, ConnectionChannel.PedSync);
|
Send(packet, ConnectionChannel.PedSync);
|
||||||
}
|
}
|
||||||
@ -76,10 +76,10 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
ID =v.ID,
|
ID =v.ID,
|
||||||
SteeringAngle = veh.SteeringAngle,
|
SteeringAngle = veh.SteeringAngle,
|
||||||
Position = veh.PredictPosition().ToLVector(),
|
Position = veh.PredictPosition(),
|
||||||
Rotation = veh.Rotation.ToLVector(),
|
Rotation = veh.Rotation,
|
||||||
Velocity = veh.Velocity.ToLVector(),
|
Velocity = veh.Velocity,
|
||||||
RotationVelocity=veh.RotationVelocity.ToLVector(),
|
RotationVelocity=veh.RotationVelocity,
|
||||||
ThrottlePower = veh.ThrottlePower,
|
ThrottlePower = veh.ThrottlePower,
|
||||||
BrakePower = veh.BrakePower,
|
BrakePower = veh.BrakePower,
|
||||||
};
|
};
|
||||||
@ -117,9 +117,9 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
ID =sp.ID,
|
ID =sp.ID,
|
||||||
ShooterID=sp.ShooterID,
|
ShooterID=sp.ShooterID,
|
||||||
Position=p.Position.ToLVector(),
|
Position=p.Position,
|
||||||
Rotation=p.Rotation.ToLVector(),
|
Rotation=p.Rotation,
|
||||||
Velocity=p.Velocity.ToLVector(),
|
Velocity=p.Velocity,
|
||||||
WeaponHash=(uint)p.WeaponHash,
|
WeaponHash=(uint)p.WeaponHash,
|
||||||
Exploded=p.IsDead
|
Exploded=p.IsDead
|
||||||
};
|
};
|
||||||
@ -133,8 +133,8 @@ namespace RageCoop.Client
|
|||||||
{
|
{
|
||||||
Send(new Packets.BulletShot()
|
Send(new Packets.BulletShot()
|
||||||
{
|
{
|
||||||
StartPosition = start.ToLVector(),
|
StartPosition = start,
|
||||||
EndPosition = end.ToLVector(),
|
EndPosition = end,
|
||||||
OwnerID = ownerID,
|
OwnerID = ownerID,
|
||||||
WeaponHash=weapon,
|
WeaponHash=weapon,
|
||||||
}, ConnectionChannel.SyncEvents);
|
}, ConnectionChannel.SyncEvents);
|
||||||
|
@ -288,7 +288,7 @@ namespace RageCoop.Client
|
|||||||
var allProjectiles=World.GetAllProjectiles();
|
var allProjectiles=World.GetAllProjectiles();
|
||||||
if (Main.Settings.WorldVehicleSoftLimit>-1)
|
if (Main.Settings.WorldVehicleSoftLimit>-1)
|
||||||
{
|
{
|
||||||
if (Main.Ticked%100==0) { if (allVehicles.Length>Main.Settings.WorldVehicleSoftLimit) { SetBudget(0); } else { SetBudget(1); } }
|
if (Main.Ticked%100==0) { if (allVehicles.Length>Main.Settings.WorldVehicleSoftLimit) { SetBudget(0); } else { SetBudget(3); } }
|
||||||
}
|
}
|
||||||
|
|
||||||
#if BENCHMARK
|
#if BENCHMARK
|
||||||
|
@ -211,7 +211,7 @@ namespace RageCoop.Client {
|
|||||||
{
|
{
|
||||||
Packets.BulletShot p = new Packets.BulletShot();
|
Packets.BulletShot p = new Packets.BulletShot();
|
||||||
p.Unpack(data);
|
p.Unpack(data);
|
||||||
HandleBulletShot(p.StartPosition.ToVector(), p.EndPosition.ToVector(), p.WeaponHash, p.OwnerID);
|
HandleBulletShot(p.StartPosition, p.EndPosition, p.WeaponHash, p.OwnerID);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PacketTypes.EnteringVehicle:
|
case PacketTypes.EnteringVehicle:
|
||||||
|
@ -49,7 +49,7 @@ namespace RageCoop.Client
|
|||||||
// Values of 2.0 or more make for very aggressive waves like you see during a thunderstorm.
|
// Values of 2.0 or more make for very aggressive waves like you see during a thunderstorm.
|
||||||
Function.Call(Hash.SET_DEEP_OCEAN_SCALER, 0.0f); // Works only ~200 meters around the player
|
Function.Call(Hash.SET_DEEP_OCEAN_SCALER, 0.0f); // Works only ~200 meters around the player
|
||||||
|
|
||||||
Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, Game.Player.Character.Handle, true, false);
|
// Function.Call(Hash.SET_CAN_ATTACK_FRIENDLY, Game.Player.Character.Handle, true, false);
|
||||||
if (Main.Settings==null) { return; }
|
if (Main.Settings==null) { return; }
|
||||||
if (Main.Settings.DisableTraffic)
|
if (Main.Settings.DisableTraffic)
|
||||||
{
|
{
|
||||||
@ -83,8 +83,8 @@ namespace RageCoop.Client
|
|||||||
Function.Call(Hash.SET_RANDOM_TRAINS, true);
|
Function.Call(Hash.SET_RANDOM_TRAINS, true);
|
||||||
Function.Call(Hash.SET_RANDOM_BOATS, true);
|
Function.Call(Hash.SET_RANDOM_BOATS, true);
|
||||||
Function.Call(Hash.SET_GARBAGE_TRUCKS, true);
|
Function.Call(Hash.SET_GARBAGE_TRUCKS, true);
|
||||||
Function.Call(Hash.SET_PED_POPULATION_BUDGET, 1); // 0 - 3
|
Function.Call(Hash.SET_PED_POPULATION_BUDGET, 3); // 0 - 3
|
||||||
Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 1); // 0 - 3
|
Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 3); // 0 - 3
|
||||||
Function.Call(Hash.SET_ALL_VEHICLE_GENERATORS_ACTIVE);
|
Function.Call(Hash.SET_ALL_VEHICLE_GENERATORS_ACTIVE);
|
||||||
Function.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, true);
|
Function.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, true);
|
||||||
Function.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, -1);
|
Function.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, -1);
|
||||||
@ -99,8 +99,8 @@ namespace RageCoop.Client
|
|||||||
Function.Call(Hash.SET_RANDOM_BOATS, false);
|
Function.Call(Hash.SET_RANDOM_BOATS, false);
|
||||||
Function.Call(Hash.SET_GARBAGE_TRUCKS, false);
|
Function.Call(Hash.SET_GARBAGE_TRUCKS, false);
|
||||||
Function.Call(Hash.DELETE_ALL_TRAINS);
|
Function.Call(Hash.DELETE_ALL_TRAINS);
|
||||||
Function.Call(Hash.SET_PED_POPULATION_BUDGET, 0);
|
Function.Call(Hash.SET_PED_POPULATION_BUDGET, 3);
|
||||||
Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 0);
|
Function.Call(Hash.SET_VEHICLE_POPULATION_BUDGET, 3);
|
||||||
Function.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, false);
|
Function.Call(Hash.SET_ALL_LOW_PRIORITY_VEHICLE_GENERATORS_ACTIVE, false);
|
||||||
Function.Call(Hash.SET_FAR_DRAW_VEHICLES, false);
|
Function.Call(Hash.SET_FAR_DRAW_VEHICLES, false);
|
||||||
Function.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, 0);
|
Function.Call(Hash.SET_NUMBER_OF_PARKED_VEHICLES, 0);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using GTA.Math;
|
||||||
|
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
{
|
{
|
||||||
@ -103,18 +104,18 @@ namespace RageCoop.Core
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LVector3 ReadLVector3()
|
public Vector3 ReadVector3()
|
||||||
{
|
{
|
||||||
return new LVector3()
|
return new Vector3()
|
||||||
{
|
{
|
||||||
X = ReadFloat(),
|
X = ReadFloat(),
|
||||||
Y = ReadFloat(),
|
Y = ReadFloat(),
|
||||||
Z = ReadFloat()
|
Z = ReadFloat()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
public LQuaternion ReadLQuaternion()
|
public Quaternion ReadLQuaternion()
|
||||||
{
|
{
|
||||||
return new LQuaternion()
|
return new Quaternion()
|
||||||
{
|
{
|
||||||
X = ReadFloat(),
|
X = ReadFloat(),
|
||||||
Y = ReadFloat(),
|
Y = ReadFloat(),
|
||||||
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using GTA.Math;
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
{
|
{
|
||||||
public class CoreUtils
|
public class CoreUtils
|
||||||
@ -37,13 +38,13 @@ namespace RageCoop.Core
|
|||||||
}
|
}
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
public static void AddLVector3(this List<byte> bytes, LVector3 vec3)
|
public static void AddVector3(this List<byte> bytes, Vector3 vec3)
|
||||||
{
|
{
|
||||||
bytes.AddRange(BitConverter.GetBytes(vec3.X));
|
bytes.AddRange(BitConverter.GetBytes(vec3.X));
|
||||||
bytes.AddRange(BitConverter.GetBytes(vec3.Y));
|
bytes.AddRange(BitConverter.GetBytes(vec3.Y));
|
||||||
bytes.AddRange(BitConverter.GetBytes(vec3.Z));
|
bytes.AddRange(BitConverter.GetBytes(vec3.Z));
|
||||||
}
|
}
|
||||||
public static void AddLQuaternion(this List<byte> bytes, LQuaternion quat)
|
public static void AddQuaternion(this List<byte> bytes, Quaternion quat)
|
||||||
{
|
{
|
||||||
bytes.AddRange(BitConverter.GetBytes(quat.X));
|
bytes.AddRange(BitConverter.GetBytes(quat.X));
|
||||||
bytes.AddRange(BitConverter.GetBytes(quat.Y));
|
bytes.AddRange(BitConverter.GetBytes(quat.Y));
|
||||||
|
@ -7,6 +7,7 @@ using GTA.Math;
|
|||||||
|
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -111,7 +112,7 @@ namespace RageCoop.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public float W { get; set; }
|
public float W { get; set; }
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public enum PacketTypes:byte
|
public enum PacketTypes:byte
|
||||||
{
|
{
|
||||||
Handshake=0,
|
Handshake=0,
|
||||||
@ -190,6 +191,7 @@ namespace RageCoop.Core
|
|||||||
IsOnLadder = 1 << 8,
|
IsOnLadder = 1 << 8,
|
||||||
IsVaulting = 1 << 9,
|
IsVaulting = 1 << 9,
|
||||||
IsInCover=1<< 10,
|
IsInCover=1<< 10,
|
||||||
|
IsPlayer=1<<11,
|
||||||
}
|
}
|
||||||
|
|
||||||
#region ===== VEHICLE DATA =====
|
#region ===== VEHICLE DATA =====
|
||||||
@ -493,10 +495,10 @@ namespace RageCoop.Core
|
|||||||
byteArray.AddRange(BitConverter.GetBytes(stringBytes.Length));
|
byteArray.AddRange(BitConverter.GetBytes(stringBytes.Length));
|
||||||
byteArray.AddRange(stringBytes);
|
byteArray.AddRange(stringBytes);
|
||||||
}
|
}
|
||||||
else if (type == typeof(LVector3))
|
else if (type == typeof(Vector3))
|
||||||
{
|
{
|
||||||
byteArray.Add(0x04);
|
byteArray.Add(0x04);
|
||||||
LVector3 vector = (LVector3)x;
|
Vector3 vector = (Vector3)x;
|
||||||
byteArray.AddRange(BitConverter.GetBytes(vector.X));
|
byteArray.AddRange(BitConverter.GetBytes(vector.X));
|
||||||
byteArray.AddRange(BitConverter.GetBytes(vector.Y));
|
byteArray.AddRange(BitConverter.GetBytes(vector.Y));
|
||||||
byteArray.AddRange(BitConverter.GetBytes(vector.Z));
|
byteArray.AddRange(BitConverter.GetBytes(vector.Z));
|
||||||
@ -540,7 +542,7 @@ namespace RageCoop.Core
|
|||||||
Args.Add(reader.ReadString(stringLength));
|
Args.Add(reader.ReadString(stringLength));
|
||||||
break;
|
break;
|
||||||
case 0x04:
|
case 0x04:
|
||||||
Args.Add(new LVector3()
|
Args.Add(new Vector3()
|
||||||
{
|
{
|
||||||
X = reader.ReadFloat(),
|
X = reader.ReadFloat(),
|
||||||
Y = reader.ReadFloat(),
|
Y = reader.ReadFloat(),
|
||||||
@ -603,10 +605,10 @@ namespace RageCoop.Core
|
|||||||
byteArray.AddRange(BitConverter.GetBytes(stringBytes.Length));
|
byteArray.AddRange(BitConverter.GetBytes(stringBytes.Length));
|
||||||
byteArray.AddRange(stringBytes);
|
byteArray.AddRange(stringBytes);
|
||||||
}
|
}
|
||||||
else if (type == typeof(LVector3))
|
else if (type == typeof(Vector3))
|
||||||
{
|
{
|
||||||
byteArray.Add(0x04);
|
byteArray.Add(0x04);
|
||||||
LVector3 vector = (LVector3)x;
|
Vector3 vector = (Vector3)x;
|
||||||
byteArray.AddRange(BitConverter.GetBytes(vector.X));
|
byteArray.AddRange(BitConverter.GetBytes(vector.X));
|
||||||
byteArray.AddRange(BitConverter.GetBytes(vector.Y));
|
byteArray.AddRange(BitConverter.GetBytes(vector.Y));
|
||||||
byteArray.AddRange(BitConverter.GetBytes(vector.Z));
|
byteArray.AddRange(BitConverter.GetBytes(vector.Z));
|
||||||
@ -658,7 +660,7 @@ namespace RageCoop.Core
|
|||||||
Args.Add(reader.ReadString(stringLength));
|
Args.Add(reader.ReadString(stringLength));
|
||||||
break;
|
break;
|
||||||
case 0x04:
|
case 0x04:
|
||||||
Args.Add(new LVector3()
|
Args.Add(new Vector3()
|
||||||
{
|
{
|
||||||
X = reader.ReadFloat(),
|
X = reader.ReadFloat(),
|
||||||
Y = reader.ReadFloat(),
|
Y = reader.ReadFloat(),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using GTA.Math;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
|
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
@ -126,17 +126,17 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
public int Health { get; set; }
|
public int Health { get; set; }
|
||||||
|
|
||||||
public LVector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
|
|
||||||
public LVector3 Rotation { get; set; }
|
public Vector3 Rotation { get; set; }
|
||||||
|
|
||||||
public LVector3 Velocity { get; set; }
|
public Vector3 Velocity { get; set; }
|
||||||
|
|
||||||
public LVector3 RotationVelocity { get; set; }
|
public Vector3 RotationVelocity { get; set; }
|
||||||
|
|
||||||
public byte Speed { get; set; }
|
public byte Speed { get; set; }
|
||||||
|
|
||||||
public LVector3 AimCoords { get; set; }
|
public Vector3 AimCoords { get; set; }
|
||||||
|
|
||||||
public uint CurrentWeaponHash { get; set; }
|
public uint CurrentWeaponHash { get; set; }
|
||||||
|
|
||||||
@ -160,17 +160,17 @@ namespace RageCoop.Core
|
|||||||
byteArray.AddRange(BitConverter.GetBytes(Health));
|
byteArray.AddRange(BitConverter.GetBytes(Health));
|
||||||
|
|
||||||
// Write ped position
|
// Write ped position
|
||||||
byteArray.AddLVector3(Position);
|
byteArray.AddVector3(Position);
|
||||||
|
|
||||||
// Write ped rotation
|
// Write ped rotation
|
||||||
byteArray.AddLVector3(Rotation);
|
byteArray.AddVector3(Rotation);
|
||||||
|
|
||||||
// Write ped velocity
|
// Write ped velocity
|
||||||
byteArray.AddLVector3(Velocity);
|
byteArray.AddVector3(Velocity);
|
||||||
|
|
||||||
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
||||||
{
|
{
|
||||||
byteArray.AddLVector3(RotationVelocity);
|
byteArray.AddVector3(RotationVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write ped speed
|
// Write ped speed
|
||||||
@ -182,7 +182,7 @@ namespace RageCoop.Core
|
|||||||
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
||||||
{
|
{
|
||||||
// Write ped aim coords
|
// Write ped aim coords
|
||||||
byteArray.AddLVector3(AimCoords);
|
byteArray.AddVector3(AimCoords);
|
||||||
}
|
}
|
||||||
|
|
||||||
byteArray.AddFloat(Heading);
|
byteArray.AddFloat(Heading);
|
||||||
@ -209,18 +209,18 @@ namespace RageCoop.Core
|
|||||||
Health = reader.ReadInt();
|
Health = reader.ReadInt();
|
||||||
|
|
||||||
// Read player position
|
// Read player position
|
||||||
Position = reader.ReadLVector3();
|
Position = reader.ReadVector3();
|
||||||
|
|
||||||
// Read player rotation
|
// Read player rotation
|
||||||
Rotation = reader.ReadLVector3();
|
Rotation = reader.ReadVector3();
|
||||||
|
|
||||||
// Read player velocity
|
// Read player velocity
|
||||||
Velocity = reader.ReadLVector3();
|
Velocity = reader.ReadVector3();
|
||||||
|
|
||||||
// Read rotation velocity if in ragdoll
|
// Read rotation velocity if in ragdoll
|
||||||
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
if (Flag.HasFlag(PedDataFlags.IsRagdoll))
|
||||||
{
|
{
|
||||||
RotationVelocity=reader.ReadLVector3();
|
RotationVelocity=reader.ReadVector3();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read player speed
|
// Read player speed
|
||||||
@ -233,7 +233,7 @@ namespace RageCoop.Core
|
|||||||
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
if (Flag.HasFlag(PedDataFlags.IsAiming))
|
||||||
{
|
{
|
||||||
// Read player aim coords
|
// Read player aim coords
|
||||||
AimCoords = reader.ReadLVector3();
|
AimCoords = reader.ReadVector3();
|
||||||
}
|
}
|
||||||
|
|
||||||
Heading=reader.ReadFloat();
|
Heading=reader.ReadFloat();
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using GTA.Math;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
|
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
@ -15,11 +16,11 @@ namespace RageCoop.Core
|
|||||||
public int ShooterID { get; set; }
|
public int ShooterID { get; set; }
|
||||||
public uint WeaponHash { get; set; }
|
public uint WeaponHash { get; set; }
|
||||||
|
|
||||||
public LVector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
|
|
||||||
public LVector3 Rotation { get; set; }
|
public Vector3 Rotation { get; set; }
|
||||||
|
|
||||||
public LVector3 Velocity { get; set; }
|
public Vector3 Velocity { get; set; }
|
||||||
|
|
||||||
public bool Exploded { get; set; }
|
public bool Exploded { get; set; }
|
||||||
|
|
||||||
@ -41,14 +42,14 @@ namespace RageCoop.Core
|
|||||||
byteArray.AddUint(WeaponHash);
|
byteArray.AddUint(WeaponHash);
|
||||||
|
|
||||||
// Write position
|
// Write position
|
||||||
byteArray.AddLVector3(Position);
|
byteArray.AddVector3(Position);
|
||||||
|
|
||||||
|
|
||||||
// Write rotation
|
// Write rotation
|
||||||
byteArray.AddLVector3(Rotation);
|
byteArray.AddVector3(Rotation);
|
||||||
|
|
||||||
// Write velocity
|
// Write velocity
|
||||||
byteArray.AddLVector3(Velocity);
|
byteArray.AddVector3(Velocity);
|
||||||
|
|
||||||
if (Exploded) { byteArray.Add(1); }
|
if (Exploded) { byteArray.Add(1); }
|
||||||
|
|
||||||
@ -73,13 +74,13 @@ namespace RageCoop.Core
|
|||||||
WeaponHash= reader.ReadUInt();
|
WeaponHash= reader.ReadUInt();
|
||||||
|
|
||||||
// Read position
|
// Read position
|
||||||
Position = reader.ReadLVector3();
|
Position = reader.ReadVector3();
|
||||||
|
|
||||||
// Read rotation
|
// Read rotation
|
||||||
Rotation = reader.ReadLVector3();
|
Rotation = reader.ReadVector3();
|
||||||
|
|
||||||
// Read velocity
|
// Read velocity
|
||||||
Velocity =reader.ReadLVector3();
|
Velocity =reader.ReadVector3();
|
||||||
|
|
||||||
if (reader.CanRead(1))
|
if (reader.CanRead(1))
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using GTA.Math;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
|
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
@ -15,8 +15,8 @@ namespace RageCoop.Core
|
|||||||
|
|
||||||
public uint WeaponHash { get; set; }
|
public uint WeaponHash { get; set; }
|
||||||
|
|
||||||
public LVector3 StartPosition { get; set; }
|
public Vector3 StartPosition { get; set; }
|
||||||
public LVector3 EndPosition { get; set; }
|
public Vector3 EndPosition { get; set; }
|
||||||
|
|
||||||
public override void Pack(NetOutgoingMessage message)
|
public override void Pack(NetOutgoingMessage message)
|
||||||
{
|
{
|
||||||
@ -32,10 +32,10 @@ namespace RageCoop.Core
|
|||||||
byteArray.AddRange(BitConverter.GetBytes(WeaponHash));
|
byteArray.AddRange(BitConverter.GetBytes(WeaponHash));
|
||||||
|
|
||||||
// Write StartPosition
|
// Write StartPosition
|
||||||
byteArray.AddLVector3(StartPosition);
|
byteArray.AddVector3(StartPosition);
|
||||||
|
|
||||||
// Write EndPosition
|
// Write EndPosition
|
||||||
byteArray.AddLVector3(EndPosition);
|
byteArray.AddVector3(EndPosition);
|
||||||
|
|
||||||
|
|
||||||
byte[] result = byteArray.ToArray();
|
byte[] result = byteArray.ToArray();
|
||||||
@ -57,10 +57,10 @@ namespace RageCoop.Core
|
|||||||
WeaponHash=reader.ReadUInt();
|
WeaponHash=reader.ReadUInt();
|
||||||
|
|
||||||
// Read StartPosition
|
// Read StartPosition
|
||||||
StartPosition=reader.ReadLVector3();
|
StartPosition=reader.ReadVector3();
|
||||||
|
|
||||||
// Read EndPosition
|
// Read EndPosition
|
||||||
EndPosition=reader.ReadLVector3();
|
EndPosition=reader.ReadVector3();
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using GTA;
|
using GTA;
|
||||||
|
using GTA.Math;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
|
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
@ -207,13 +208,13 @@ namespace RageCoop.Core
|
|||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
public LVector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
|
|
||||||
public LVector3 Rotation { get; set; }
|
public Vector3 Rotation { get; set; }
|
||||||
|
|
||||||
public LVector3 Velocity { get; set; }
|
public Vector3 Velocity { get; set; }
|
||||||
|
|
||||||
public LVector3 RotationVelocity { get; set; }
|
public Vector3 RotationVelocity { get; set; }
|
||||||
|
|
||||||
public float ThrottlePower { get; set; }
|
public float ThrottlePower { get; set; }
|
||||||
public float BrakePower { get; set; }
|
public float BrakePower { get; set; }
|
||||||
@ -231,17 +232,17 @@ namespace RageCoop.Core
|
|||||||
byteArray.AddInt(ID);
|
byteArray.AddInt(ID);
|
||||||
|
|
||||||
// Write position
|
// Write position
|
||||||
byteArray.AddLVector3(Position);
|
byteArray.AddVector3(Position);
|
||||||
|
|
||||||
|
|
||||||
// Write rotation
|
// Write rotation
|
||||||
byteArray.AddLVector3(Rotation);
|
byteArray.AddVector3(Rotation);
|
||||||
|
|
||||||
// Write velocity
|
// Write velocity
|
||||||
byteArray.AddLVector3(Velocity);
|
byteArray.AddVector3(Velocity);
|
||||||
|
|
||||||
// Write rotation velocity
|
// Write rotation velocity
|
||||||
byteArray.AddLVector3(RotationVelocity);
|
byteArray.AddVector3(RotationVelocity);
|
||||||
|
|
||||||
|
|
||||||
byteArray.AddFloat(ThrottlePower);
|
byteArray.AddFloat(ThrottlePower);
|
||||||
@ -268,16 +269,16 @@ namespace RageCoop.Core
|
|||||||
ID = reader.ReadInt();
|
ID = reader.ReadInt();
|
||||||
|
|
||||||
// Read position
|
// Read position
|
||||||
Position = reader.ReadLVector3();
|
Position = reader.ReadVector3();
|
||||||
|
|
||||||
// Read rotation
|
// Read rotation
|
||||||
Rotation = reader.ReadLVector3();
|
Rotation = reader.ReadVector3();
|
||||||
|
|
||||||
// Read velocity
|
// Read velocity
|
||||||
Velocity =reader.ReadLVector3();
|
Velocity =reader.ReadVector3();
|
||||||
|
|
||||||
// Read rotation velocity
|
// Read rotation velocity
|
||||||
RotationVelocity=reader.ReadLVector3();
|
RotationVelocity=reader.ReadVector3();
|
||||||
|
|
||||||
// Read throttle power
|
// Read throttle power
|
||||||
ThrottlePower=reader.ReadFloat();
|
ThrottlePower=reader.ReadFloat();
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using GTA.Math;
|
||||||
namespace RageCoop.Core
|
namespace RageCoop.Core
|
||||||
{
|
{
|
||||||
public class PlayerData
|
public class PlayerData
|
||||||
@ -18,17 +19,12 @@ namespace RageCoop.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int VehicleID { get; set; }
|
public int VehicleID { get; set; }
|
||||||
public bool IsInVehicle { get; internal set; }
|
public bool IsInVehicle { get; internal set; }
|
||||||
public LVector3 Position { get; set; }
|
public Vector3 Position { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Player Latency in second.
|
/// Player Latency in second.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float Latency { get; set; }
|
public float Latency { get; set; }
|
||||||
public int Health { get; set; }
|
public int Health { get; set; }
|
||||||
|
|
||||||
public bool IsInRangeOf(LVector3 position, float distance)
|
|
||||||
{
|
|
||||||
return LVector3.Subtract(Position, position).Length() < distance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using RageCoop.Core;
|
using RageCoop.Core;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
|
using GTA.Math;
|
||||||
|
|
||||||
namespace RageCoop.Server
|
namespace RageCoop.Server
|
||||||
{
|
{
|
||||||
@ -160,7 +161,7 @@ namespace RageCoop.Server
|
|||||||
{
|
{
|
||||||
returnTypeValue = 0x03;
|
returnTypeValue = 0x03;
|
||||||
}
|
}
|
||||||
else if (returnType == typeof(LVector3))
|
else if (returnType == typeof(Vector3))
|
||||||
{
|
{
|
||||||
returnTypeValue = 0x04;
|
returnTypeValue = 0x04;
|
||||||
}
|
}
|
||||||
|
@ -912,12 +912,26 @@ namespace RageCoop.Server
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool isPlayer = packet.Flag.HasFlag(PedDataFlags.IsPlayer);
|
||||||
|
if (isPlayer) { client.Player.Position=packet.Position; }
|
||||||
foreach(var c in Clients.Values)
|
foreach (var c in Clients.Values)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Don't send data back
|
// Don't send data back
|
||||||
if (c.ClientID==client.ClientID) { continue; }
|
if (c.ClientID==client.ClientID) { continue; }
|
||||||
|
|
||||||
|
// Check streaming distance
|
||||||
|
if (isPlayer)
|
||||||
|
{
|
||||||
|
if ((MainSettings.PlayerStreamingDistance!=-1)&&(packet.Position.DistanceTo(c.Player.Position)>MainSettings.PlayerStreamingDistance))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((MainSettings.NpcStreamingDistance!=-1)&&(packet.Position.DistanceTo(c.Player.Position)>MainSettings.NpcStreamingDistance))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
NetOutgoingMessage outgoingMessage = MainNetServer.CreateMessage();
|
NetOutgoingMessage outgoingMessage = MainNetServer.CreateMessage();
|
||||||
packet.Pack(outgoingMessage);
|
packet.Pack(outgoingMessage);
|
||||||
MainNetServer.SendMessage(outgoingMessage,c.Connection, NetDeliveryMethod.UnreliableSequenced, (byte)ConnectionChannel.PedSync);
|
MainNetServer.SendMessage(outgoingMessage,c.Connection, NetDeliveryMethod.UnreliableSequenced, (byte)ConnectionChannel.PedSync);
|
||||||
@ -935,43 +949,27 @@ namespace RageCoop.Server
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
bool isPlayer = packet.ID==client.Player.VehicleID;
|
||||||
foreach (var c in Clients.Values)
|
foreach (var c in Clients.Values)
|
||||||
{
|
{
|
||||||
if (c.ClientID==client.ClientID) { continue; }
|
if (c.ClientID==client.ClientID) { continue; }
|
||||||
|
if (isPlayer)
|
||||||
|
{
|
||||||
|
// Player's vehicle
|
||||||
|
if ((MainSettings.PlayerStreamingDistance!=-1)&&(packet.Position.DistanceTo(c.Player.Position)>MainSettings.PlayerStreamingDistance))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else if((MainSettings.NpcStreamingDistance!=-1)&&(packet.Position.DistanceTo(c.Player.Position)>MainSettings.NpcStreamingDistance))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
NetOutgoingMessage outgoingMessage = MainNetServer.CreateMessage();
|
NetOutgoingMessage outgoingMessage = MainNetServer.CreateMessage();
|
||||||
packet.Pack(outgoingMessage);
|
packet.Pack(outgoingMessage);
|
||||||
MainNetServer.SendMessage(outgoingMessage, c.Connection, NetDeliveryMethod.UnreliableSequenced, (byte)ConnectionChannel.PedSync);
|
MainNetServer.SendMessage(outgoingMessage, c.Connection, NetDeliveryMethod.UnreliableSequenced, (byte)ConnectionChannel.PedSync);
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
Client client = Util.GetClientByID(ClientID);
|
|
||||||
if (client == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// Save the new data
|
|
||||||
client.Player.PedHandle = packet.PedHandle;
|
|
||||||
client.Player.VehicleHandle = packet.VehicleHandle;
|
|
||||||
client.Player.IsInVehicle = true;
|
|
||||||
client.Player.Position = packet.Position;
|
|
||||||
client.Player.Health = packet.Health;
|
|
||||||
|
|
||||||
// Override the latency
|
|
||||||
packet.Latency = client.Latency;
|
|
||||||
|
|
||||||
MainNetServer.Connections.FindAll(x => x.RemoteUniqueIdentifier != ClientID).ForEach(x =>
|
|
||||||
{
|
|
||||||
NetOutgoingMessage outgoingMessage = MainNetServer.CreateMessage();
|
|
||||||
packet.PacketToNetOutGoingMessage(outgoingMessage);
|
|
||||||
MainNetServer.SendMessage(outgoingMessage, x, NetDeliveryMethod.UnreliableSequenced, (byte)ConnectionChannel.PlayerFull);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if (RunningResource != null)
|
|
||||||
{
|
|
||||||
RunningResource.InvokePlayerUpdate(client);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
private static void ProjectileSync(Packets.ProjectileSync packet, long ClientID)
|
private static void ProjectileSync(Packets.ProjectileSync packet, long ClientID)
|
||||||
{
|
{
|
||||||
|
@ -15,9 +15,9 @@
|
|||||||
public string MasterServer { get; set; } = "https://ragecoop.online/gtav/servers";
|
public string MasterServer { get; set; } = "https://ragecoop.online/gtav/servers";
|
||||||
public bool DebugMode { get; set; } = false;
|
public bool DebugMode { get; set; } = false;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// NPC data won't be sent to a player if distance is greater than this value. -1 for unlimited.
|
/// NPC data won't be sent to a player if their distance is greater than this value. -1 for unlimited.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public float NpcStreamingDistance { get; set; } = 200;
|
public float NpcStreamingDistance { get; set; } = 1000;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Player's data won't be sent to another player if their distance is greater than this value. -1 for unlimited.
|
/// Player's data won't be sent to another player if their distance is greater than this value. -1 for unlimited.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -66,25 +66,6 @@ namespace RageCoop.Server
|
|||||||
return new(Server.MainNetServer.Connections.Where(e => e.RemoteUniqueIdentifier != local));
|
return new(Server.MainNetServer.Connections.Where(e => e.RemoteUniqueIdentifier != local));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return a list of players within range of ...
|
|
||||||
public static List<NetConnection> GetAllInRange(LVector3 position, float range)
|
|
||||||
{
|
|
||||||
return new(Server.MainNetServer.Connections.FindAll(e =>
|
|
||||||
{
|
|
||||||
Client client = Server.Clients.Values.First(x => x.ClientID == e.RemoteUniqueIdentifier);
|
|
||||||
return client != null && client.Player.IsInRangeOf(position, range);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
// Return a list of players within range of ... but not the local one
|
|
||||||
public static List<NetConnection> GetAllInRange(LVector3 position, float range, NetConnection local)
|
|
||||||
{
|
|
||||||
return new(Server.MainNetServer.Connections.Where(e =>
|
|
||||||
{
|
|
||||||
Client client = Server.Clients.Values.First(x => x.ClientID == e.RemoteUniqueIdentifier);
|
|
||||||
return e != local && client != null && client.Player.IsInRangeOf(position, range);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static T Read<T>(string file) where T : new()
|
public static T Read<T>(string file) where T : new()
|
||||||
{
|
{
|
||||||
XmlSerializer ser = new(typeof(T));
|
XmlSerializer ser = new(typeof(T));
|
||||||
|
Reference in New Issue
Block a user