Renamed Props to Clothes. Reduced bytes for data

This commit is contained in:
EntenKoeniq
2021-12-16 22:05:40 +01:00
parent c4fe931ced
commit 6c09c10bd9
7 changed files with 68 additions and 70 deletions

View File

@ -55,8 +55,8 @@ namespace CoopClient.Entities
CurrentModelHash = value;
}
}
private Dictionary<int, int> LastProps = null;
internal Dictionary<int, int> Props { get; set; }
private Dictionary<byte, short> LastClothes = null;
internal Dictionary<byte, short> Clothes { get; set; }
/// <summary>
/// The latest character position (may not have been applied yet)
/// </summary>
@ -177,14 +177,14 @@ namespace CoopClient.Entities
return;
}
}
else if (Props != LastProps)
else if (Clothes != LastClothes)
{
foreach (KeyValuePair<int, int> prop in Props)
foreach (KeyValuePair<byte, short> cloth in Clothes)
{
Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, prop.Key, prop.Value, 0, 0);
Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, cloth.Key, cloth.Value, 0, 0);
}
LastProps = Props;
LastClothes = Clothes;
}
}
@ -297,9 +297,9 @@ namespace CoopClient.Entities
Function.Call(Hash.SET_PED_GET_OUT_UPSIDE_DOWN_VEHICLE, Character.Handle, false);
}
foreach (KeyValuePair<int, int> prop in Props)
foreach (KeyValuePair<byte, short> cloth in Clothes)
{
Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, prop.Key, prop.Value, 0, 0);
Function.Call(Hash.SET_PED_COMPONENT_VARIATION, Character.Handle, cloth.Key, cloth.Value, 0, 0);
}
return true;

View File

@ -28,13 +28,13 @@ namespace CoopClient.Entities
CurrentVehicleModelHash = value;
}
}
private int[] LastVehicleColors = new int[] { 0, 0 };
internal int[] VehicleColors { get; set; }
private byte[] LastVehicleColors = new byte[] { 0, 0 };
internal byte[] VehicleColors { get; set; }
private Dictionary<int, int> LastVehicleMods = new Dictionary<int, int>();
internal Dictionary<int, int> VehicleMods { get; set; }
internal bool VehicleDead { get; set; }
internal float VehicleEngineHealth { get; set; }
internal int VehicleSeatIndex { get; set; }
internal short VehicleSeatIndex { get; set; }
/// <summary>
/// ?
/// </summary>

View File

@ -272,7 +272,7 @@ namespace CoopClient
if (fullSync)
{
DebugSyncPed.ModelHash = player.Model.Hash;
DebugSyncPed.Props = player.GetPedProps();
DebugSyncPed.Clothes = player.GetPedClothes();
}
DebugSyncPed.Health = player.Health;
DebugSyncPed.Position = player.Position;
@ -286,15 +286,15 @@ namespace CoopClient
flags = veh.GetVehicleFlags();
int secondaryColor;
int primaryColor;
byte secondaryColor;
byte primaryColor;
unsafe
{
Function.Call<int>(Hash.GET_VEHICLE_COLOURS, veh, &primaryColor, &secondaryColor);
Function.Call<byte>(Hash.GET_VEHICLE_COLOURS, veh, &primaryColor, &secondaryColor);
}
DebugSyncPed.VehicleModelHash = veh.Model.Hash;
DebugSyncPed.VehicleSeatIndex = (int)player.SeatIndex;
DebugSyncPed.VehicleSeatIndex = (short)player.SeatIndex;
DebugSyncPed.VehiclePosition = veh.Position;
DebugSyncPed.VehicleRotation = veh.Quaternion;
DebugSyncPed.VehicleEngineHealth = veh.EngineHealth;
@ -303,7 +303,7 @@ namespace CoopClient
DebugSyncPed.VehicleSpeed = veh.Speed;
DebugSyncPed.VehicleSteeringAngle = veh.SteeringAngle;
DebugSyncPed.AimCoords = veh.IsTurretSeat((int)player.SeatIndex) ? Util.GetVehicleAimCoords() : new GTA.Math.Vector3();
DebugSyncPed.VehicleColors = new int[] { primaryColor, secondaryColor };
DebugSyncPed.VehicleColors = new byte[] { primaryColor, secondaryColor };
DebugSyncPed.VehicleMods = veh.Mods.GetVehicleMods();
DebugSyncPed.VehDoors = veh.Doors.GetVehicleDoors();
DebugSyncPed.VehTires = veh.Wheels.GetBrokenTires();

View File

@ -302,7 +302,7 @@ namespace CoopClient
EntitiesPlayer player = Main.Players[packet.Extra.NetHandle];
player.ModelHash = packet.ModelHash;
player.Props = packet.Props;
player.Clothes = packet.Clothes;
player.Health = packet.Extra.Health;
player.Position = packet.Extra.Position.ToVector();
player.Rotation = packet.Rotation.ToVector();
@ -332,7 +332,7 @@ namespace CoopClient
EntitiesPlayer player = Main.Players[packet.Extra.NetHandle];
player.ModelHash = packet.ModelHash;
player.Props = packet.Props;
player.Clothes = packet.Clothes;
player.Health = packet.Extra.Health;
player.Position = packet.Extra.Position.ToVector();
player.VehicleModelHash = packet.VehModelHash;
@ -575,7 +575,7 @@ namespace CoopClient
npc.NPCVehHandle = 0;
npc.ModelHash = packet.ModelHash;
npc.Props = packet.Props;
npc.Clothes = packet.Clothes;
npc.Health = packet.Health;
npc.Position = packet.Position.ToVector();
npc.Rotation = packet.Rotation.ToVector();
@ -599,7 +599,7 @@ namespace CoopClient
Main.NPCs.Add(packet.NetHandle, new EntitiesNpc()
{
ModelHash = packet.ModelHash,
Props = packet.Props,
Clothes = packet.Clothes,
Health = packet.Health,
Position = packet.Position.ToVector(),
Rotation = packet.Rotation.ToVector(),
@ -633,7 +633,7 @@ namespace CoopClient
npc.NPCVehHandle = packet.VehHandle;
npc.ModelHash = packet.ModelHash;
npc.Props = packet.Props;
npc.Clothes = packet.Clothes;
npc.Health = packet.Health;
npc.Position = packet.Position.ToVector();
npc.VehicleModelHash = packet.VehModelHash;
@ -668,7 +668,7 @@ namespace CoopClient
NPCVehHandle = packet.VehHandle,
ModelHash = packet.ModelHash,
Props = packet.Props,
Clothes = packet.Clothes,
Health = packet.Health,
Position = packet.Position.ToVector(),
VehicleModelHash = packet.VehModelHash,
@ -719,12 +719,11 @@ namespace CoopClient
{
Vehicle veh = player.CurrentVehicle;
int primaryColor = 0;
int secondaryColor = 0;
byte primaryColor = 0;
byte secondaryColor = 0;
unsafe
{
Function.Call<int>(Hash.GET_VEHICLE_COLOURS, veh, &primaryColor, &secondaryColor);
Function.Call<byte>(Hash.GET_VEHICLE_COLOURS, veh, &primaryColor, &secondaryColor);
}
new FullSyncPlayerVehPacket()
@ -736,9 +735,9 @@ namespace CoopClient
Position = player.Position.ToLVector()
},
ModelHash = player.Model.Hash,
Props = player.GetPedProps(),
Clothes = player.GetPedClothes(),
VehModelHash = veh.Model.Hash,
VehSeatIndex = (int)player.SeatIndex,
VehSeatIndex = (short)player.SeatIndex,
VehPosition = veh.Position.ToLVector(),
VehRotation = veh.Quaternion.ToLQuaternion(),
VehEngineHealth = veh.EngineHealth,
@ -747,7 +746,7 @@ namespace CoopClient
VehSpeed = veh.Speed,
VehSteeringAngle = veh.SteeringAngle,
VehAimCoords = veh.IsTurretSeat((int)player.SeatIndex) ? Util.GetVehicleAimCoords().ToLVector() : new LVector3(),
VehColors = new int[] { primaryColor, secondaryColor },
VehColors = new byte[] { primaryColor, secondaryColor },
VehMods = veh.Mods.GetVehicleMods(),
VehDoors = veh.Doors.GetVehicleDoors(),
VehTires = veh.Wheels.GetBrokenTires(),
@ -766,7 +765,7 @@ namespace CoopClient
Position = player.Position.ToLVector()
},
ModelHash = player.Model.Hash,
Props = player.GetPedProps(),
Clothes = player.GetPedClothes(),
Rotation = player.Rotation.ToLVector(),
Velocity = player.Velocity.ToLVector(),
Speed = player.GetPedSpeed(),
@ -796,7 +795,7 @@ namespace CoopClient
Position = player.Position.ToLVector()
},
VehModelHash = veh.Model.Hash,
VehSeatIndex = (int)player.SeatIndex,
VehSeatIndex = (short)player.SeatIndex,
VehPosition = veh.Position.ToLVector(),
VehRotation = veh.Quaternion.ToLQuaternion(),
VehVelocity = veh.Velocity.ToLVector(),
@ -844,12 +843,11 @@ namespace CoopClient
{
Vehicle veh = npc.CurrentVehicle;
int primaryColor = 0;
int secondaryColor = 0;
byte primaryColor = 0;
byte secondaryColor = 0;
unsafe
{
Function.Call<int>(Hash.GET_VEHICLE_COLOURS, npc.CurrentVehicle, &primaryColor, &secondaryColor);
Function.Call<byte>(Hash.GET_VEHICLE_COLOURS, npc.CurrentVehicle, &primaryColor, &secondaryColor);
}
new FullSyncNpcVehPacket()
@ -857,11 +855,11 @@ namespace CoopClient
NetHandle = Main.LocalNetHandle + npc.Handle,
VehHandle = Main.LocalNetHandle + veh.Handle,
ModelHash = npc.Model.Hash,
Props = npc.GetPedProps(),
Clothes = npc.GetPedClothes(),
Health = npc.Health,
Position = npc.Position.ToLVector(),
VehModelHash = veh.Model.Hash,
VehSeatIndex = (int)npc.SeatIndex,
VehSeatIndex = (short)npc.SeatIndex,
VehPosition = veh.Position.ToLVector(),
VehRotation = veh.Quaternion.ToLQuaternion(),
VehEngineHealth = veh.EngineHealth,
@ -869,7 +867,7 @@ namespace CoopClient
VehVelocity = veh.Velocity.ToLVector(),
VehSpeed = veh.Speed,
VehSteeringAngle = veh.SteeringAngle,
VehColors = new int[] { primaryColor, secondaryColor },
VehColors = new byte[] { primaryColor, secondaryColor },
VehMods = veh.Mods.GetVehicleMods(),
VehDoors = veh.Doors.GetVehicleDoors(),
VehTires = veh.Wheels.GetBrokenTires(),
@ -883,7 +881,7 @@ namespace CoopClient
{
NetHandle = Main.LocalNetHandle + npc.Handle,
ModelHash = npc.Model.Hash,
Props = npc.GetPedProps(),
Clothes = npc.GetPedClothes(),
Health = npc.Health,
Position = npc.Position.ToLVector(),
Rotation = npc.Rotation.ToLVector(),

View File

@ -395,7 +395,7 @@ namespace CoopClient
public int ModelHash { get; set; }
[ProtoMember(3)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(4)]
public LVector3 Rotation { get; set; }
@ -436,7 +436,7 @@ namespace CoopClient
Extra = data.Extra;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
Rotation = data.Rotation;
Velocity = data.Velocity;
Speed = data.Speed;
@ -457,13 +457,13 @@ namespace CoopClient
public int ModelHash { get; set; }
[ProtoMember(3)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(4)]
public int VehModelHash { get; set; }
[ProtoMember(5)]
public int VehSeatIndex { get; set; }
public short VehSeatIndex { get; set; }
[ProtoMember(6)]
public LVector3 VehPosition { get; set; }
@ -490,7 +490,7 @@ namespace CoopClient
public LVector3 VehAimCoords { get; set; }
[ProtoMember(14)]
public int[] VehColors { get; set; }
public byte[] VehColors { get; set; }
[ProtoMember(15)]
public Dictionary<int, int> VehMods { get; set; }
@ -525,7 +525,7 @@ namespace CoopClient
Extra = data.Extra;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
VehModelHash = data.VehModelHash;
VehSeatIndex = data.VehSeatIndex;
VehPosition = data.VehPosition;
@ -605,7 +605,7 @@ namespace CoopClient
public int VehModelHash { get; set; }
[ProtoMember(5)]
public int VehSeatIndex { get; set; }
public short VehSeatIndex { get; set; }
[ProtoMember(6)]
public LVector3 VehPosition { get; set; }
@ -834,7 +834,7 @@ namespace CoopClient
public int ModelHash { get; set; }
[ProtoMember(3)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(4)]
public int Health { get; set; }
@ -878,7 +878,7 @@ namespace CoopClient
NetHandle = data.NetHandle;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
Health = data.Health;
Position = data.Position;
Rotation = data.Rotation;
@ -903,7 +903,7 @@ namespace CoopClient
public int ModelHash { get; set; }
[ProtoMember(4)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(5)]
public int Health { get; set; }
@ -915,7 +915,7 @@ namespace CoopClient
public int VehModelHash { get; set; }
[ProtoMember(8)]
public int VehSeatIndex { get; set; }
public short VehSeatIndex { get; set; }
[ProtoMember(9)]
public LVector3 VehPosition { get; set; }
@ -939,7 +939,7 @@ namespace CoopClient
public float VehSteeringAngle { get; set; }
[ProtoMember(16)]
public int[] VehColors { get; set; }
public byte[] VehColors { get; set; }
[ProtoMember(17)]
public Dictionary<int, int> VehMods { get; set; }
@ -975,7 +975,7 @@ namespace CoopClient
NetHandle = data.NetHandle;
VehHandle = data.VehHandle;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
Health = data.Health;
Position = data.Position;
VehModelHash = data.VehModelHash;

View File

@ -225,12 +225,12 @@ namespace CoopClient
return flags;
}
public static Dictionary<int, int> GetPedProps(this Ped ped)
public static Dictionary<byte, short> GetPedClothes(this Ped ped)
{
Dictionary<int, int> result = new Dictionary<int, int>();
for (int i = 0; i < 11; i++)
Dictionary<byte, short> result = new Dictionary<byte, short>();
for (byte i = 0; i < 11; i++)
{
int mod = Function.Call<int>(Hash.GET_PED_DRAWABLE_VARIATION, ped.Handle, i);
short mod = Function.Call<short>(Hash.GET_PED_DRAWABLE_VARIATION, ped.Handle, i);
result.Add(i, mod);
}
return result;

View File

@ -310,7 +310,7 @@ namespace CoopServer
public int ModelHash { get; set; }
[ProtoMember(3)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(4)]
public LVector3 Rotation { get; set; }
@ -351,7 +351,7 @@ namespace CoopServer
Extra = data.Extra;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
Rotation = data.Rotation;
Velocity = data.Velocity;
Speed = data.Speed;
@ -372,13 +372,13 @@ namespace CoopServer
public int ModelHash { get; set; }
[ProtoMember(3)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(4)]
public int VehModelHash { get; set; }
[ProtoMember(5)]
public int VehSeatIndex { get; set; }
public short VehSeatIndex { get; set; }
[ProtoMember(6)]
public LVector3 VehPosition { get; set; }
@ -405,7 +405,7 @@ namespace CoopServer
public LVector3 VehAimCoords { get; set; }
[ProtoMember(14)]
public int[] VehColors { get; set; }
public byte[] VehColors { get; set; }
[ProtoMember(15)]
public Dictionary<int, int> VehMods { get; set; }
@ -440,7 +440,7 @@ namespace CoopServer
Extra = data.Extra;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
VehModelHash = data.VehModelHash;
VehSeatIndex = data.VehSeatIndex;
VehPosition = data.VehPosition;
@ -520,7 +520,7 @@ namespace CoopServer
public int VehModelHash { get; set; }
[ProtoMember(5)]
public int VehSeatIndex { get; set; }
public short VehSeatIndex { get; set; }
[ProtoMember(6)]
public LVector3 VehPosition { get; set; }
@ -749,7 +749,7 @@ namespace CoopServer
public int ModelHash { get; set; }
[ProtoMember(3)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(4)]
public int Health { get; set; }
@ -793,7 +793,7 @@ namespace CoopServer
NetHandle = data.NetHandle;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
Health = data.Health;
Position = data.Position;
Rotation = data.Rotation;
@ -818,7 +818,7 @@ namespace CoopServer
public int ModelHash { get; set; }
[ProtoMember(4)]
public Dictionary<int, int> Props { get; set; }
public Dictionary<byte, short> Clothes { get; set; }
[ProtoMember(5)]
public int Health { get; set; }
@ -830,7 +830,7 @@ namespace CoopServer
public int VehModelHash { get; set; }
[ProtoMember(8)]
public int VehSeatIndex { get; set; }
public short VehSeatIndex { get; set; }
[ProtoMember(9)]
public LVector3 VehPosition { get; set; }
@ -854,7 +854,7 @@ namespace CoopServer
public float VehSteeringAngle { get; set; }
[ProtoMember(16)]
public int[] VehColors { get; set; }
public byte[] VehColors { get; set; }
[ProtoMember(17)]
public Dictionary<int, int> VehMods { get; set; }
@ -890,7 +890,7 @@ namespace CoopServer
NetHandle = data.NetHandle;
VehHandle = data.VehHandle;
ModelHash = data.ModelHash;
Props = data.Props;
Clothes = data.Clothes;
Health = data.Health;
Position = data.Position;
VehModelHash = data.VehModelHash;