Hello everybody...
I started a personal project, based on T-Ronx LFS_External (https://www.lfs.net/forum/thread/30012). Actualy, I'm trying to add some new packets, as this application library is a bit old. So, basically I added IS_OBH on its library, as follow:
On Packets.cs
Then I made some changes on InSimInterface.cs
And included these codes (of course on correct part, I think)
And finally updated Flags.cs
After compiling, I've loaded this new library on LFS_External and called it on InSim sets:
Everything works fine. All packets I added before are working. But when I hit an object (when supposed to have this packet), my app crashes:
I already tried a lot of things, from debug to compile a new library, but unsuccessful. Anyone has a clue about what I'm doing wrong with this packet?
Thanks in advance =D
I started a personal project, based on T-Ronx LFS_External (https://www.lfs.net/forum/thread/30012). Actualy, I'm trying to add some new packets, as this application library is a bit old. So, basically I added IS_OBH on its library, as follow:
On Packets.cs
[StructLayout(LayoutKind.Sequential)]
public struct CarContOBJ // 8 bytes : car in a contact with an object
{
public byte Direction; // car's motion if Speed > 0 : 0 = world y direction, 128 = 180 deg
public byte Heading; // direction of forward axis : 0 = world y direction, 128 = 180 deg
public byte Speed; // m/s
public byte Sp3;
short X; // position (1 metre = 16)
short Y; // position (1 metre = 16)
};
[StructLayout(LayoutKind.Sequential)]
public struct IS_OBH // OBject Hit - car hit an autocross object or an unknown object
{
internal byte Size; // 24
internal byte Type; // ISP_OBH
public byte ReqI; // 0
public byte PLID; // player's unique id
public string SpClose; // high 4 bits : reserved / low 12 bits : closing speed (10 = 1 m/s)
public string Time; // looping time stamp (hundredths - time since reset - like TINY_GTH)
CarContOBJ C;
public short X; // as in ObjectInfo
public short Y; // as in ObjectInfo
public byte Sp0;
public byte Sp1;
public byte Index; // AXO_x as in ObjectInfo or zero if it is an unknown object
public byte OBHFlags; // see below
}
Then I made some changes on InSimInterface.cs
case Enums.Packets.ISP_OBH:
{
LFS_External.Packets.IS_OBH is_obh = new LFS_External.Packets.IS_OBH();
is_obh = (LFS_External.Packets.IS_OBH)Util.DataToPacket(destinationArray, is_obh);
if (this.OBH_Received != null)
{
this.OBH_Received(is_obh);
}
goto Label_0AB9;
}
And included these codes (of course on correct part, I think)
public event OBH_EventHandler OBH_Received;
public delegate void OBH_EventHandler(LFS_External.Packets.IS_OBH OBH);
And finally updated Flags.cs
[Flags]
public enum InSimFlags : byte
{
ISF_LOCAL = 4,
ISF_MCI = 0x20,
ISF_CON = 64,
ISF_OBH = 128,
ISF_MSO_COLS = 8,
ISF_NLP = 0x10,
ISF_RES_0 = 1,
ISF_RES_1 = 2
}
After compiling, I've loaded this new library on LFS_External and called it on InSim sets:
InSimSettings Settings = new InSimSettings("127.0.0.1", 29999, 0, Flags.InSimFlags.ISF_MSO_COLS | Flags.InSimFlags.ISF_MCI | Flags.InSimFlags.ISF_OBH, '!', 500, AdminPW, "TestProject", 5);
Everything works fine. All packets I added before are working. But when I hit an object (when supposed to have this packet), my app crashes:
I already tried a lot of things, from debug to compile a new library, but unsuccessful. Anyone has a clue about what I'm doing wrong with this packet?
Thanks in advance =D