The online racing simulator
IS_OBH - C# App Crashing
(7 posts, started )
IS_OBH - C# App Crashing
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
[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 thinkLooking)

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
..
Is there any reason why you use LFS_External which is known to have multiple serious issues with newer versions of LFS? Use InSim.NET instead...
Quote from cargame.nl :Use code for code to start with here on the forum. Quote makes it quite unreadable. Unless you use no tabs in your original coding also.

I hope is better now.

Quote from MadCatX :Is there any reason why you use LFS_External which is known to have multiple serious issues with newer versions of LFS? Use InSim.NET instead...

Just trying to understand a bit more about the Library. To be honest, I never tried to integrate the Insim.NET library with an application.
Quote from Skinzinho :
Just trying to understand a bit more about the Library. To be honest, I never tried to integrate the Insim.NET library with an application.

Is it worth it? LFS_External is outdated, unmaintained and partially broken. InSim.NET will do a much better job for you and you won't have to hack it by yourself to make it work with recent versions of InSim and LFS.
..
Quote from cargame.nl :Yes it's much better Smile

But I have to agree with MadCatX, it's much better to go with a library and/or language which actually is supported instead of fixing something which is outdated and nobody is using anymore.

I don't have too much knowledge about InSim programming, and T-Ronx base was the most complete source I ever found. Anyway...

I downloaded InSim.NET library, which is more complete than that old one I use. But now I've some difficults to deal with packets. I'll open a new thread to request some help.

Thanks to you and MadCatX for suggesting.

IS_OBH - C# App Crashing
(7 posts, started )
FGED GREDG RDFGDR GSFDG