The online racing simulator
where to put this packet ?
struct CarHCP // Car handicaps in 2 bytes - there is an array of these in the HCP (below)
{
byteH_Mass;// 0 to 200 - added mass (kg)
byteH_TRes;// 0 to 50 - intake restriction
};

struct IS_HCP // HandiCaPs
{
byteSize;// 68
byteType;// ISP_HCP
byteReqI;// 0
byteZero;

CarHCPInfo[32];// H_Mass and H_TRes for each car : XF GTI = 0 / XR GT = 1 etc
};
Hello,

I'm now porting from FullMotion.LiveForSpeed.dll (yeah, maybe ten years old with our own fixes inside it) to InSimDotNet.

I've hit some problem with encoding (?). Let's say we create a test button:


<?php 
            IS_BTN _testButton 
= new IS_BTN
            
{
                
804512020,
                
BStyle ButtonStyles.ISB_CLICK ButtonStyles.ISB_LIGHT,
                
Text "^2Spauskite čia",
                
Caption "^3Įrašykite čia",
                
TypeIn 30,
                
ClickID 1,
                
ReqI 1,
                
UCID ConnectionID
            
};
            
Handler.Send(_testButton);
?>

Button is shown with invalid (wrong encoding, letter č becomes some gibberish) text, but caption is OK. If I remove caption, button text is shown with right encoding and caption is the same as text (which I believe is right). It's probably something wrong with captioning. I'd try to fix it by myself, but can't really understand encoding stuff... Smile

I'm using InSimDotNet v2.1.3 built from GitHub repo, on Windows 8.1 (if it's info of any use).
Switch to Baltic encoding:
"^B^2Spauskite čia"
"^B^3Įrašykite čia"

Your modified library probably inserts this before sending IS_MSO/MTC/MSX/BTN packets Smile
It's strange that I need to do this... Well, at least it works. But would be nice if someone said (or gave me a link) that this is mandatory to do. MSO/MTC/MSX packets are all ok, only BTN packet when Caption is present does this random behaviour.

Thank you for info!
It's required at standard and should be documented in the InSim.txt. By default it's Latin characters (^L) so you need to switch to a different encoding manually.
I'll look into this, it might be a bug, not sure yet.
I just tested this on my machine and as far as I can tell it seems to work OK as it is. I have attached two images to show how it looks on my computer. I changed the font color to make it more readable.

Can I ask, what language is your version of Windows and your version of LFS set to?
Attached images
LfsButton.jpg
LfsCaption.jpg
First one shows exactly the problem I'm facing - first letter of second word is transformed to another encoding than it should be (you get another character and not č).

I've tried PoVo's advice, but then even button without caption sometimes gets invalid encoding as ž becomes ,

It's kinda strange as it should work or not at all times, but not rather randomly.

I'm developing on Win which is only English (US).
DCon is in english, LFS client (game itself) is in lithuanian.
OK - I think I've fixed it, but it will still need some testing. In the mean time you should be able to work around it by just ignoring the Caption property and setting the zero bytes yourself.

IS_BTN button = new IS_BTN {
T = 80,
L = 45,
W = 120,
H = 20,
BStyle = ButtonStyles.ISB_CLICK | ButtonStyles.ISB_LIGHT,
Text = Char.MinValue + "^4Spauskite čia" + Char.MinValue + "^4Įrašykite čia",
TypeIn = 30,
ClickID = 1,
ReqI = 1,
UCID = 0
};

I'll try and get a proper fix out soon.
A few notes.

Text = \0<Caption>\0<Text>

You gave us the format as caption should be first, then the text (I agree though that it's a bit strange), spent some amount until I understood (or, more of a truth, read some of IS_BTN code of yours Smile ).

Another thing - it doesn't work anyway, I get the same issue - wrong encoding on a button front, right encoding on the caption.

However, if I add ^B and make it like "\0^BĮrašykite čia:\0^BSpauskite čia", it works as expected.

Do I really need to add ^B or is it regarding the bug you think you've fixed earlier?

Could you make some branch with this fix? I'm working on it, so I could test it myself since I'm writing everything from scratch. And if not a branch, actual fix location maybe?

Thanks, anyway, at least it's an easier approach when I inherited IS_BTN in my own written class.
Quote from gibasa :Do I really need to add ^B or is it regarding the bug you think you've fixed earlier?

You almost certainly do need ^B on both parts - LFS probably treats it as two separate strings (that happen to be encoded in the same char array), so the encoding would need to be set on both.
-
(MariusMM) DELETED by MariusMM
I'm positive that you still have invalid enum - you've skipped value 256 and from that point every flag would be invalid (at least in your app, e.g. where real PSE_BODY_MAJOR would be sent, you'd read it as PSE_BODY_MINOR or PSE_SETUP).

When dealing with big flags, it's easier to do shifting (the end of post).
Sorry I've been very busy this last week. I'm sure you're right about missing a value in that enum - I'll look into it when I have time. Feel free to create a pull request on GitHub and fix it yourself.
Does the IS_SCH packet also receive key presses?
http://www.nudoq.org/#!/Packages/InSimDotNet/InSimDotNet/IS_SCH

Tried it earlier and it wouldn't work.

static void Main()
{
// Create new InSim object
InSim insim = new InSim();

insim.Bind<IS_SCH>(key);

// Initailize InSim
insim.Initialize(new InSimSettings
{
Host = "localhost",
Port = 29999,
Admin = String.Empty,
});

Console.ReadLine();
}

static void key(InSim insim, IS_SCH sch)
{
Console.WriteLine("Key pressed");
Console.WriteLine(sch.CharB);
}

Quote from pipa :Does the IS_SCH packet also receive key presses?

No, it's a one-way instruction to LFS.

AFAIK, the only thing that tells you if a key is being pressed is OutGauge and that only tells you about Shift & Ctrl
Ah right thanks Elmo. Plan b then.
Hello, is this supposed to be so inaccurate or i'm missing something?
if (args.Equals("!speed", StringComparison.InvariantCultureIgnoreCase))
{
Connection conn = connections[mso.UCID];
if (conn.Car != null)
{
insim.Send("/msg ^7Current speed: ^8" + MathHelper.SpeedToKph(conn.Car.Speed), mso.UCID);
}
}

Output: Current speed: 0.03295978905735
Without speedtokph: Current speed: 3
The car was obviously standing still. I'm using the last release of InSim.NET.

... figured it out, seems like mathhelper it's wrong. Anyway, the raw speed it's still 3.
Hi

I have forked this project to keep it updated to last InSim Version, version 6.

I haven´t test it yet, but I´m confident about it.

I have changed version to from 2.1.3 to 2.1.3.6, but I think when LFS get to official realease, should become 2.1.4

Here you can download everything ( source code and bins ): https://github.com/neonsp/insimdotnet/releases/tag/2.1.3.6

If you find any problem with this, let me know it, so I can try solve it..

@DarkTimes: Feel free to check my code, make any changes, and push it to your official repo if you think convenient .

Regards

PS. Updated to 2.1.3.6, very small changes but, to make clear there is other version.
OK thanks, I'll take a look at it. Thumbs up
I've updated the main repository with changes for LFS 0.6H and a few other bug fixes. I'll release a new binary and NuGet package in the near future, the version will be InSim.NET 2.2.0. If any one has a bug or a feature request now is the time to suggest it!
I put out a new release on both GitHub and NuGet.

InSim.NET 2.2.0
  • Updated library for LFS 0.6H (added IS_NCI packet, added TINY_NCI, updated IS_REO/IS_NLP, added IS_NCI to PacketFactory).
  • Fixed bug in PitWorkFlags (thanks to MariusMM for fix)
  • Added new Westhill configurations to TrackHelper (thanks to NeOn_sp)
  • Added new objects to ObjectHelper (thanks to NeOn_sp)
I managed to break the NuGet package. I uploaded a new one that fixes things but it won't let you reuse a version number, so I made it 2.2.0.1 instead. It's the same bits as the one on GitHub just with a slightly different version.
Thanks for new update will test for some bugs
Hi DarkTimes, I installed your NuGet package, but I cannot seem to find the Object/Car/Track-Helpers anymore. I used to have those a year or two ago when I worked on another project of mine. Is there something that I have to include first in the 'using' list or something, because when I copied the code from my previous project there was no option for 'resolve' (which you usually get when you're missing a using line.
-
(MariusMM) DELETED by MariusMM : History
Oh duh, that must be it. I feel like a rookie here. Big grin

FGED GREDG RDFGDR GSFDG