Skip to content

Commit

Permalink
Added IS_HPC packet for LFS 0.6F12
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmcbride committed Sep 26, 2014
1 parent ebd0084 commit b41ba4c
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 0 deletions.
2 changes: 2 additions & 0 deletions InSimDotNet/InSimDotNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<Compile Include="Packets\CarContact.cs" />
<Compile Include="Packets\CarContOBJ.cs" />
<Compile Include="Packets\CarFlags.cs" />
<Compile Include="Packets\CarHCP.cs" />
<Compile Include="Packets\CharacterModifiers.cs" />
<Compile Include="Packets\ContactFlags.cs" />
<Compile Include="Packets\FlagType.cs" />
Expand All @@ -91,6 +92,7 @@
<Compile Include="Packets\IS_ACR.cs" />
<Compile Include="Packets\IS_AXM.cs" />
<Compile Include="Packets\IS_CON.cs" />
<Compile Include="Packets\IS_HCP.cs" />
<Compile Include="Packets\IS_HLV.cs" />
<Compile Include="Packets\IS_OBH.cs" />
<Compile Include="Packets\IS_PLC.cs" />
Expand Down
26 changes: 26 additions & 0 deletions InSimDotNet/Packets/CarHCP.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

namespace InSimDotNet.Packets {
/// <summary>
/// Car handicaps - there is an array of these in IS_HCP.
/// </summary>
public struct CarHCP {
/// <summary>
/// Added mass (0kg to 200kg)
/// </summary>
public byte H_Mass { get; set; }

/// <summary>
/// Intake restriction (0 to 50)
/// </summary>
public byte H_TRes { get; set; }

/// <summary>
/// Gets the packet data.
/// </summary>
/// <returns>An array containing the packet data.</returns>
public void GetBuffer(PacketWriter writer) {
writer.Write(H_Mass);
writer.Write(H_TRes);
}
}
}
56 changes: 56 additions & 0 deletions InSimDotNet/Packets/IS_HCP.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

namespace InSimDotNet.Packets {
/// <summary>
/// HandiCaPs
/// </summary>
public class IS_HCP : IPacket, ISendable {
private const int NumCars = 32;

/// <summary>
/// Gets the packet size.
/// </summary>
public byte Size { get; private set; }

/// <summary>
/// Gets the packet type.
/// </summary>
public PacketType Type { get; private set; }

/// <summary>
/// Gets or sets the request ID.
/// </summary>
public byte ReqI { get; set; }

/// <summary>
/// Gets the handicap info for each car in order (XF GTI first, XR GT second etc..).
/// </summary>
public CarHCP[] Info { get; private set; }

/// <summary>
/// Creates a new IS_HCP packet.
/// </summary>
public IS_HCP() {
Size = 68;
Type = PacketType.ISP_HCP;
Info = new CarHCP[NumCars];
}

/// <summary>
/// Gets the packet buffer.
/// </summary>
/// <returns>An array containing the packet data.</returns>
public byte[] GetBuffer() {
PacketWriter writer = new PacketWriter(Size);
writer.Write(Size);
writer.Write((byte)Type);
writer.Write(ReqI);
writer.Skip(1);

foreach (CarHCP info in Info) {
info.GetBuffer(writer);
}

return writer.GetBuffer();
}
}
}
5 changes: 5 additions & 0 deletions InSimDotNet/Packets/PacketType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,11 @@ public enum PacketType {
/// </summary>
ISP_ACR,

/// <summary>
/// car handicaps
/// </summary>
ISP_HCP,

/// <summary>
/// Admin request
/// </summary>
Expand Down

0 comments on commit b41ba4c

Please sign in to comment.