I think the .NET cross-platform stuff will be released with Visual Studio 2015, although that's a guess, I don't really know. Visual Studio Community is out now.
Yeah, I read about this. From a InSim.NET point of view it means you won't need to use Mono to run it on Linux and Mac anymore, there will be an official .NET runtime you can use. Also Visual Studio Community is very interesting as well, as it has all the same features and functionality as Visual Studio Professional, which is normally very expensive. It's basically like they are going to give away Professional for free now.
Yeah I improved the Mono support a lot in a recent release. It should work identically except that on Mono the string encoding is a bit slower. Glad it works anyway.
Added ContinueOnCapturedContext property to InSim, OutSim, OutGauge, TcpSocket and UdpSocket. Setting this to false prevents InSim.NET from marshalling packet callbacks back onto the calling thread e.g. in UI apps.
Fixed bug that allowed players to crash InSim.NET by typing characters in LFS that were not translatable into unicode.
TcpSocket and UdpSocket now expose their underlying .NET Socket objects for convenience.
I added the new IS_HCP packet, here's how to use it:
var hcp = new IS_HCP();
// Set handicap for XF GTI hcp.Info[0].H_Mass = 50; hcp.Info[0].H_TRes = 20;
// Set handicap for XR GT hcp.Info[1].H_Mass = 20; hcp.Info[1].H_TRes = 30;
// etc.
// Send packet. insim.Send(hcp);
Alternatively I added a new HandicapHelper class to the Helpers namespace which makes it easier to use:
// Create packet. var hcp = new IS_HCP();
// Set handicaps for specified cars. HandicapHelper.SetHandicap(hpc, CarFlags.XFG | CarFlags.XRG, H_Mass: 50, H_TRes: 20);
// Send packet to LFS. insim.Send(hcp);
You can also set CarFlags.All to set the handicap for all cars:
I added the new packet and pushed it to GitHub, not massively tested it yet so might still have some problems, seems to work OK though. I will add it to the beta tomorrow as it's a bit late tonight.
Here is how you use it:
var hcp = new IS_HCP();
// Set handicap for XF GTI hcp.Info[0].H_Mass = 50; hcp.Info[0].H_TRes = 20;
// Set handicap for XR GT hcp.Info[1].H_Mass = 20; hcp.Info[1].H_TRes = 30;
// etc.
// Send packet. insim.Send(hcp);
There might be a better way to specify which car you want to modify as remembering the index for each one will be very difficult.
That version of InSimDotNet.dll is from back in August, did you try it with the updated DLL in my last post?
The DLL in my last post is an updated one with a fix for this exploit, if you could try that one in your project and report if the issue is fixed or not. It seems to be fixed in my tests but I need someone to confirm it.
Is this with the latest code from the GitHub repository? I have been able to recreate this bug (finally) but only in the current stable release, it doesn't seem to happen for me in the updated code I pushed to GitHub.
onecheque say "☆SORRY☆☆NO PROBLEM☆". He bind that.
In LFSLazy log its look like this (in LFS Japanese code page 81/82):
^J™‚r‚n‚q‚q‚x™^™‚m‚n ‚o‚q‚n‚a‚k‚d‚l™
this part
™^™
is the problem
and sorry sicotange i kill your insim when i try to reproduce this bug
OK thanks, that's really helpful actually, hopefully that will let me reproduce the bug as well.
I've got a report of an interesting exploit where people are able to make InSim.NET's string handling code crash by typing certain characters (and are then able to use that to grief servers). I'm struggling to reproduce it here but I have a few ideas for what's causing it.
Can I ask, has anyone had any of these sorts of problems running InSim.NET on Windows?
On Windows server 2012 I encountered the following causing InSim.NET to crash:
Could this be related to that infamous exploit?
Yes I think that's the same bug as it's also a DecoderFallbackException that's being thrown. I presume you're using the last proper release of InSim.NET, have you tried using the latest changeset in the repository? I recently made some improvements to the LfsEncoding class to try and prevent that exception being thrown. If not I'll test it later today myself.
There is still another bug that PeterN posted a fix to but I don't think it's related to this. I still don't know what bug his fixes are designed to correct.
If you ever used my patch, that has some bugs... I'm using this code to do character set conversion now, but it's not for InSim.NET so you'll probably need to adjust bits.
http://fuzzle.org/~petern/CodePage.cs
(There's also an issue with different symbols in different codepages resolving to the same unicode codepoint. I decided to ignore that.)
Thanks for this. I'm looking through the code and I see the changes you've made but it would be useful if you could tell me what these changes are supposed to do. I can see what the code does but I don't understand its intent.
With the changes to the async code it now makes it a very good idea for newbie coders to write InSim.NET stuff inside of a WinForms app (or WPF), because the marshalling is now handled automatically and you won't have to deal with any threading issues. In the past you needed to deal with lots of things like Invokes and delegates, but now it should all just work without any of that. I will create a small demo of InSim.NET running in a Windows Forms app soon.
OK - I'll look into it later this week in more detail. I've made a small change to the repo which might help with the exploit I'm working on. I changed the DecoderExceptionFallback to ReplacementFallback, which should stop the GetString method from throwing an exception if it finds a character it cannot decode. That was the original intention of that code that somehow got lost along the way.
On another matter...
In 2.1.0 I rewrote the socket code to use async/await, a side-effect of this is that the sockets now reuse any existing SynchronizationContext when returning from an async call. Basically what this means is that if you use InSim.NET in a WinForms or WPF app then you no longer have to worry about threading problems as .NET automatically marshals the packet callbacks back onto the main UI thread. That being said I realised that you may actually not want this behaviour, so I added a new property called ContinueOnCapturedContext to the InSim class that allows you to set false to return to the previous functionality.
var insim = new InSim(); insim.ContinueOnCapturedContext = false;
I picked the name ContinueOnCapturedContext because that's how .NET describes it, however I may change it to something more friendly such as SyncToUIThread.
These changes are both in the repo, but as usual they might be buggy.
I've got a report of an interesting exploit where people are able to make InSim.NET's string handling code crash by typing certain characters (and are then able to use that to grief servers). I'm struggling to reproduce it here but I have a few ideas for what's causing it.
Can I ask, has anyone had any of these sorts of problems running InSim.NET on Windows? I have a feeling that the issue lies in the new Mono code (and by extension the old Mono hack people had been using). I would like to confirm no Windows users have had these sorts of issues though.