Skip to content

Commit

Permalink
Merge branch '1.6-pre-alpha' of https://github.com/RAGECOOP/RAGECOOP-V
Browse files Browse the repository at this point in the history
…into 1.6-pre-alpha
  • Loading branch information
Sardelka9515 committed Mar 23, 2023
2 parents 114e59a + db7146e commit 3944d41
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
1 change: 1 addition & 0 deletions Client/Scripts/Networking/Receive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ private static void VehicleSync(Packets.VehicleSync packet)
v.RadioStation = packet.RadioStation;
v.LicensePlate = packet.LicensePlate;
v.Livery = packet.Livery;
v.HeadlightColor = packet.HeadlightColor;
v.ExtrasMask = packet.ExtrasMask;
}
v.SetLastSynced(full);
Expand Down
1 change: 1 addition & 0 deletions Client/Scripts/Networking/Send.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public static void SendVehicle(SyncedVehicle v, bool full)
packet.LockStatus = veh.LockStatus;
packet.LicensePlate = Call<string>(GET_VEHICLE_NUMBER_PLATE_TEXT, veh);
packet.Livery = Call<int>(GET_VEHICLE_LIVERY, veh);
packet.HeadlightColor = (byte)Call<int>(GET_VEHICLE_XENON_LIGHT_COLOR_INDEX, veh);
packet.ExtrasMask = v.GetVehicleExtras();
packet.RadioStation = v.MainVehicle == LastV
? Util.GetPlayerRadioIndex() : byte.MaxValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public partial class SyncedVehicle
internal byte RadioStation = 255;
internal string LicensePlate { get; set; }
internal int Livery { get; set; } = -1;
internal byte HeadlightColor { get; set; } = 255;
internal VehicleDataFlags Flags { get; set; }
internal ushort ExtrasMask;
internal byte ToggleModsMask;
Expand Down Expand Up @@ -75,6 +76,7 @@ public partial class SyncedVehicle
private bool _lastHornActive;
private bool _lastTransformed;
private int _lastLivery = -1;
private byte _lastHeadlightColor = 255;
private Vector3 _predictedPosition;
#endregion

Expand Down
6 changes: 6 additions & 0 deletions Client/Scripts/Sync/Entities/Vehicle/SyncedVehicle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using GTA;
using GTA.Math;
using GTA.Native;
using GTA.UI;
using RageCoop.Core;
using static ICSharpCode.SharpZipLib.Zip.ExtendedUnixData;

Expand Down Expand Up @@ -159,6 +160,11 @@ internal override void Update()
_lastLivery = Livery;
}

if (_lastHeadlightColor != HeadlightColor)
{
Call(SET_VEHICLE_XENON_LIGHT_COLOR_INDEX, MainVehicle.Handle, HeadlightColor);
_lastHeadlightColor = HeadlightColor;
}
MainVehicle.SetDamageModel(DamageModel);

if (MainVehicle.Handle == V?.Handle && Util.GetPlayerRadioIndex() != RadioStation)
Expand Down
6 changes: 5 additions & 1 deletion Core/Packets/VehicleSync.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ protected override void Serialize(NetOutgoingMessage m)

m.Write((byte)(Livery + 1));

m.Write(HeadlightColor);

m.Write(ExtrasMask);
}
}
Expand Down Expand Up @@ -176,6 +178,8 @@ public override void Deserialize(NetIncomingMessage m)

Livery = m.ReadByte() - 1;

HeadlightColor = m.ReadByte();

ExtrasMask = m.ReadUInt16();
}

Expand All @@ -202,7 +206,7 @@ public override void Deserialize(NetIncomingMessage m)
public VehicleLockStatus LockStatus { get; set; }

public int Livery { get; set; } = -1;

public byte HeadlightColor { get; set; } = 255;
public byte RadioStation { get; set; } = 255;
public string LicensePlate { get; set; }

Expand Down

0 comments on commit 3944d41

Please sign in to comment.