The online racing simulator
Quote from DarkKostas :The code is ultra NOT optimised. The "MCI_Update(MCI.Info[i].PLID);" should be into the first loop, and actually the whole function would be better to be moved at your MCI packet cause now most of your code is dublicated.

But what i need to remove to not be duplicated ?
Hi,

I have found a critical bug with encoding.

If a InSim APP try to send "{" or "}" in a message , InSim.Net won´t send it, and if you dont have that line surrounded by try/catch, it will crash your insim.

How to replicate, try any of those.. I don´t know if any other char will fail too:

insim.Send(con.UCID, "{", 0); // crash
insim.Send(con.UCID, "}", 0); // crash

//both with catch Exceptionm.Msg= Input string was not in a correct format.

By the way, if you try to send:
insim.Send(con.UCID, "{{", 0); // will work, and send a single {
That's not really a bug, the Send method formats your message with any arguments you pass in, internally it just calls String.Format(). I think the issue here isn't that there is a bug in those methods but that the documentation for them doesn't mention the formatting. If you want to you can avoid using the convenience method altogether and just send the packet directly:

insim.Send(new IS_MTC { UCID=con.UCID, Msg="{" });

That does the same thing while avoiding the string formatting stuff.
I imagined that Send method job was to take care about formating it.. So that´s why I thought some char scape was missing on that method or something like that.

Ok, I will use the send packet directly but I´m still thinking Send method should do that without error.

Thanks for your fast reply..
-
(kristofferandersen) DELETED by kristofferandersen : Minor mistake, I had the InSim object in the RunInSim func instead of on top of the whole proj.
Enable the timers after insim.init. Because it tries to send the buttons while its disconnected.
The timers are enabled, because this code works:
http://prntscr.com/9lvdl5

(enables in the Form1_Load event)
I've also tried to send the button without the variable and with UCID on 255.
Quote from kristofferandersen :The timers are enabled, because this code works:
http://prntscr.com/9lvdl5

(enables in the Form1_Load event)
I've also tried to send the button without the variable and with UCID on 255.

my car payout system


if (user.CurrentCar == "UF1")
{
if (user.Speed > 29)
{
Random uf1 = new Random();
int uf1count = uf1.Next(5, 15);
user.Cash += uf1count;
}
}

#583 - tpx
Quote from YounGPimP :my car payout system


if (user.CurrentCar == "UF1")
{
if (user.Speed > 29)
{
Random uf1 = new Random();
int uf1count = uf1.Next(5, 15);
user.Cash += uf1count;
}
}


Give more code
Hello wanted to ask if someone would have a traffic light, for use to drag, if anyone would have any left and I would be very grateful!
Added the new IS_JRR packet to the repository on GitHub.

I won't create a release for it at the moment as Scawen is still testing the packet.

Edit: I also added Rockingham to the TrackHelper.
How to update player name in IS_CON packet if he change his name ?
In my insim if he change the name and hit/crash someone the name is same.
Quote from LFS Marius LFS :How to update player name in IS_CON packet if he change his name ?
In my insim if he change the name and hit/crash someone the name is same.

The IS_CON packet doesn't contain the player name, you need to watch for the IS_CPR (Connection / Player Rename) packet and then update the player's name in your list of active players.
I have updated the GitHub repo for LFS 6K11.
  • IS_MSO, IS_III, and IS_ACR are now variable sized packets.
  • IS_BFN can be used to delete a range of buttons.
Very glad to see you're keeping this up-to-date! I'll make sure to update the version I'm using as soon I get back to programming. The JRR packet seems interesting to use.

Keep up the great work.
Quote from DarkTimes : you need to watch for the IS_CPR (Connection / Player Rename) packet and then update the player's name in your list of active players.

but don't work

foreach(clsConnection Conn in Connections)
{
Conn.NoColPlyName = CPR.PName;
}

insim don't show me the message

EDIT: and I have this problem too
Quote from ab12 :but don't work

foreach(clsConnection Conn in Connections)
{
Conn.NoColPlyName = CPR.PName;
}

insim don't show me the message

EDIT: and I have this problem too

It looks like you are updating the connection list, you want to change the name in your player list instead. Also you want to only change name of that one player, so you would need to check that the player has the correct PLID before updating them.
I have updated InSim.NET for LFS 6K12. It now requests InSim version 7 when connecting. I also added TINY_ALC and SMALL_ALC to their respective enums.

In addition I fixed a bug where if you called InSim.IsConnected from inside the InSim.Disconnected event it would return true, which didn't make much sense.

Lastly I have changed it so that you no longer need to create a new instance of the InSim object each time you want to connect to LFS. Instead you can just create one object and reuse that. I was working on a small app and it was so annoying to have to undo all your bindings and redo them again each time you wanted to connect. Now you don't need to do that.
Thanks, nothing to report on version 2.3.0.0 so far Thumbs up
I have done a few small things today, most notably I have changed the InSim.Send(IEnumerable<ISendable>) method to be InSim.Send(params ISendable[]) instead.

This makes sending packets in batches simpler. Now you can just do this:

<?php 
insim
.Send(
    new 
IS_TINY ReqI=1SubT=TinyType.TINY_NCN }, 
    new 
IS_TINY ReqI=1SubT=TinyType.TINY_NPL }, 
    new 
IS_MST Msg="Hello, world!" }
);
?>

Sending multiple packets in a single Send call uses less bandwidth than sending them individually. You should always look for ways to batch send your packets.

This is a slight breaking change as that method used to accept IEnumerable<ISendable>, which meant you could pass pretty much any .NET collection into it, however I think this new syntax is much neater. If you want to pass in an List<ISendable> or whatever you can just call its List<ISendable>.ToArray() LINQ method.

<?php 
var packets = new List<ISendable>();
packets.Add(new IS_TINY ReqI=1SubT=TinyType.TINY_NCN }); 
packets.Add(new IS_MST Msg="Hello, world!" });
insim.Send(packets.ToArray());
?>

Aside from that just some minor updates. I rewrote the TrackHelper class, as I was adding Rockingham it was very confusing as I had to add the new configs in four different places. Now I've simplified it so there is only one track list and the reversed/open stuff is worked out programmatically.

As I am in the mood to update the library let me know of any features you want added or bugs you want fixed.
Quote from DarkTimes :Aside from that just some minor updates. I rewrote the TrackHelper class, as I was adding Rockingham it was very confusing as I had to add the new configs in four different places. Now I've simplified it so there is only one track list and the reversed/open stuff is worked out programmatically.

Autocross and Rockingham don't have reverse configs (and Y configs). I think that should be taken care of in the helper class too, because now e.g. TrackExists('RO1R') will return true.
Bah.

I'll need to go back to the drawing board.
Quote :
I have done a few small things today, most notably I have changed the InSim.Send(IEnumerable<ISendable>) method to be InSim.Send(params ISendable[]) instead.

This makes sending packets in batches simpler. Now you can just do this:

Cool improvement Thumbs up

Quote :As I am in the mood to update the library let me know of any features you want added or bugs you want fixed.

• A very old bug you are probably aware of is IS_BTN special characters problem. Some special characters result in a bugged output. I forgot how to reproduce it easily (I think it was a combination of special characters).
Either way, it's not a big nuisance.

There are a few suggestions I have for InSim.NET:

• A fool proof packet buffer (mainly concerning IS_BTN's): insim.NET would deal appropriately with the many buttons sent so you wouldn't have to worry about overflows etc. For IS_AXM I use the safe LFS system for example (wait for packet arrival, then send new packet).

• A button manager: I made a far from ideal button manager where I group buttons (parent -> child). Maybe you know the perfect way to deal cleanly with buttons (clickID & text updates)?

• Improving the socket loss detection (the error I mailed you) to improve our chances to catch the reason of the disconnection.

• An event manager: it seems to be a pain to maintain 8 InSim connections with all packet events bound. Maybe you have some clearer thought about this?
-
(DarkTimes) DELETED by DarkTimes : too long and rambling, i'll rewrite more concise
Quote from DarkTimes :sending packets in batches simpler. Now you can just do this:

<?php 
insim
.Send(
    new 
IS_TINY ReqI=1SubT=TinyType.TINY_NCN }, 
    new 
IS_TINY ReqI=1SubT=TinyType.TINY_NPL }, 
    new 
IS_MST Msg="Hello, world!" }
);
?>

Sending multiple packets in a single Send call uses less bandwidth than sending them individually. You should always look for ways to batch send your packets.

That's **** awesome!
Quote from sicotange :Cool improvement Thumbs up

• A very old bug you are probably aware of is IS_BTN special characters problem. Some special characters result in a bugged output. I forgot how to reproduce it easily (I think it was a combination of special characters).
Either way, it's not a big nuisance.


If you could try and give me an example of the kinds of characters that cause the problem that would be helpful.

Quote :• A fool proof packet buffer (mainly concerning IS_BTN's): insim.NET would deal appropriately with the many buttons sent so you wouldn't have to worry about overflows etc. For IS_AXM I use the safe LFS system for example (wait for packet arrival, then send new packet).

Again, not sure what you mean. Could you explain what you mean by overflow and can you give me an example of how you currently need to deal with them?

Quote :• A button manager: I made a far from ideal button manager where I group buttons (parent -> child). Maybe you know the perfect way to deal cleanly with buttons (clickID & text updates)?

I've thought about doing something like this before, basically I would add a new ButtonHelper to the helpers namespace. I'll see what I can do.

Quote :• Improving the socket loss detection (the error I mailed you) to improve our chances to catch the reason of the disconnection.

I don't really know what I can do about this. "An existing connection was forcibly closed by the remote host" basically means that LFS closed the connection. As I said before it would be nice to know if LFS says anything when this is happening. Alternatively maybe Scawen might be able to answer in what scenarios LFS would just close the connection.

Quote :• An event manager: it seems to be a pain to maintain 8 InSim connections with all packet events bound. Maybe you have some clearer thought about this?

This falls into the same category as ButtonHelper. It's not something I would add to the main library but could be added to the helpers section.
Quote :If you could try and give me an example of the kinds of characters that cause the problem that would be helpful.

I have a note somewhere about this. I will get back to you once I can give you info on how to reproduce it easily.

Quote :Again, not sure what you mean. Could you explain what you mean by overflow and can you give me an example of how you currently need to deal with them?

For example, you have a panel of 200 buttons. All 47 players of a full server should be shown this panel at the same time. I'm looking for the best & fastest way to do this. Same for buttons who get updated often (text updates every 100ms of several buttons for example). Basically a way to queue packets, making batches and send them at appropriate intervals. You master this stuff. I don't have enough knowledge about sockets & netcode to implement this well.

Quote :This falls into the same category as ButtonHelper. It's not something I would add to the main library but could be added to the helpers section.

Thanks for the library updates (EventHelper & 0.6K13). I will test EventHelper once I'm done updating my program with IS_UCO & IS_JRR.

FGED GREDG RDFGDR GSFDG