The online racing simulator
InSim changes in new test patch
(236 posts, closed, started )
Quote from skywatcher122 :is it possible to get the current throttle, current gear and brakes at MCI / NLP ?

That would be also great for a project I'm working on.

(Not really relevant for the test patch, but I thought I'd chime in with this request.)

I modified LRA, my replay analyser, so that it can grab lap data from InSim. The nice thing about this is that you can then also get laps from multiplayer races (live online races as well as MPR replays). And it saves he hassle of generating a RAF file first, so the drive -> analyse -> improve cycle is much shorter.

I've got it working, but for now it can only read the speed and position of each car. That's a bit thin for an analysis. To be really useful, the lap data should also include the pedals, steer position, and current gear.
If anyone is interested here is a diff of InSim.txt showing all the changes.

@@ -13,18 +13,28 @@
// NOTE : This text file was written with a TAB size equal to 4 spaces.


-// INSIM VERSION NUMBER (updated for version 0.5X)
+// INSIM VERSION NUMBER (updated for version 0.5Z30)
// ====================

-const int INSIM_VERSION = 4;
+const int INSIM_VERSION = 5;


-// CHANGES in version 0.5Z (compatible so no change to INSIM_VERSION)
+// CHANGES
// =======

+// Version 0.5Z (compatible so no change to INSIM_VERSION)
+
// NLP / MCI packets are now output at regular intervals
// CCI_LAG bit added to the CompCar structure

+// Version 0.5Z30 (INSIM_VERSION increased to 5)
+
+// IS_CON (CONtact) reports contact between two cars (if ISF_CON is enabled)
+// IS_MTC (Msg To Connection) now has a variable length (up to 128 characters)
+// IS_MTC can be sent to all (UCID = 255) and sound effect can be specified
+// ISS_SHIFTU_HIGH is no longer used (no distinction between high and low view)
+// FIX : Clutch axis / button was not reported after a change in Controls screen
+

// TYPES : (all multi-byte types are PC style - lowest byte first)
// =====
@@ -108,6 +118,7 @@
#define ISF_MSO_COLS 8 // bit 3 : keep colours in MSO text
#define ISF_NLP 16 // bit 4 : receive NLP packets
#define ISF_MCI 32 // bit 5 : receive MCI packets
+#define ISF_CON 64 // bit 6 : receive CON packets

// In most cases you should not set both ISF_NLP and ISF_MCI flags
// because all IS_NLP information is included in the IS_MCI packet.
@@ -179,6 +190,7 @@
ISP_BTT, // 47 - info : sent after typing into a button
ISP_RIP, // 48 - both ways : replay information packet
ISP_SSH, // 49 - both ways : screenshot
+ ISP_CON, // 50 - info : contact (collision report)
};

enum // the fourth byte of an IS_TINY packet is one of these
@@ -188,7 +200,7 @@
TINY_CLOSE, // 2 - instruction : close insim
TINY_PING, // 3 - ping request : external progam requesting a reply
TINY_REPLY, // 4 - ping reply : reply to a ping request
- TINY_VTC, // 5 - info : vote cancelled
+ TINY_VTC, // 5 - both ways : game vote cancel (info or request)
TINY_SCP, // 6 - info request : send camera pos
TINY_SST, // 7 - info request : send state info
TINY_GTH, // 8 - info request : get time in hundredths (i.e. SMALL_RTP)
@@ -363,8 +375,8 @@
#define ISS_REPLAY 2 // in SPR
#define ISS_PAUSED 4 // paused
#define ISS_SHIFTU 8 // SHIFT+U mode
-#define ISS_SHIFTU_HIGH 16 // HIGH view
-#define ISS_SHIFTU_FOLLOW 32 // following car
+#define ISS_16 16 // UNUSED
+#define ISS_SHIFTU_FOLLOW 32 // FOLLOW view
#define ISS_SHIFTU_NO_OPT 64 // SHIFT+U buttons hidden
#define ISS_SHOW_2D 128 // showing 2d display
#define ISS_FRONT_END 256 // entry screen
@@ -384,7 +396,6 @@

// These states can be set by a special packet :

-// ISS_SHIFTU_FOLLOW - following car
// ISS_SHIFTU_NO_OPT - SHIFT+U buttons hidden
// ISS_SHOW_2D - showing 2d display
// ISS_MPSPEEDUP - multiplayer speedup option
@@ -516,19 +527,19 @@
char Msg[128]; // last byte must be zero
};

-struct IS_MTC // Msg To Connection - hosts only - send to a connection or a player
+struct IS_MTC // Msg To Connection - hosts only - send to a connection / a player / all
{
- byte Size; // 72
+ byte Size; // 8 + TEXT_SIZE (TEXT_SIZE = 4, 8, 12... 128)
byte Type; // ISP_MTC
byte ReqI; // 0
- byte Zero;
+ byte Sound; // sound effect (see Message Sounds below)

- byte UCID; // connection's unique id (0 = host)
+ byte UCID; // connection's unique id (0 = host / 255 = all)
byte PLID; // player's unique id (if zero, use UCID)
byte Sp2;
byte Sp3;

- char Msg[64]; // last byte must be zero
+// char Text[TEXT_SIZE]; // up to 128 characters of text - last byte must be zero
};

// Message Sounds (for Sound byte)
@@ -1013,8 +1024,8 @@
// You can send one to LFS before a race start, to specify the starting order.
// It may be a good idea to avoid conflict by using /start=fixed (LFS setting).
// Alternatively, you can leave the LFS setting, but make sure you send your IS_REO
-// AFTER you receive the IS_VTA. LFS does its default grid reordering at the same time
-// as it sends the IS_VTA (VoTe Action) and you can override this by sending an IS_REO.
+// AFTER you receive the SMALL_VTA (VoTe Action). LFS does its default grid reordering at
+// the same time as it sends the SMALL_VTA and you can override this by sending an IS_REO.

struct IS_REO // REOrder (when race restarts after qualifying)
{
@@ -1259,7 +1270,7 @@

// To receive IS_NLP or IS_MCI packets at a specified interval :

-// 1) Set the Interval field in the IS_ISI (InSimInit) packet (50, 60, 70... 8000 ms)
+// 1) Set the Interval field in the IS_ISI (InSimInit) packet (40, 50, 60... 8000 ms)
// 2) Set one of the flags ISF_NLP or ISF_MCI in the IS_ISI packet

// If ISF_NLP flag is set, one IS_NLP packet is sent...
@@ -1296,7 +1307,7 @@
int Y; // Y map (65536 = 1 metre)
int Z; // Z alt (65536 = 1 metre)
word Speed; // speed (32768 = 100 m/s)
- word Direction; // direction of car's motion : 0 = world y direction, 32768 = 180 deg
+ word Direction; // car's motion if Speed > 0 : 0 = world y direction, 32768 = 180 deg
word Heading; // direction of forward axis : 0 = world y direction, 32768 = 180 deg
short AngVel; // signed, rate of change of heading : (16384 = 360 deg/s)
};
@@ -1328,7 +1339,46 @@

// ReqI : 0
// SubT : SMALL_NLI (Node Lap Interval)
-// UVal : interval (0 means stop, otherwise time interval : 50, 60, 70... 8000 ms)
+// UVal : interval (0 means stop, otherwise time interval : 40, 50, 60... 8000 ms)
+
+
+// CONTACT - reports contacts between two cars if the closing speed is above 0.25 m/s
+// =======
+
+struct CarContact // Info about one car in a contact - two of these in the IS_CON (below)
+{
+ byte PLID;
+ byte Info; // like Info byte in CompCar (CCI_BLUE / CCI_YELLOW / CCI_LAG)
+ byte Sp2; // spare
+ char Steer; // front wheel steer in degrees (right positive)
+
+ byte ThrBrk; // high 4 bits : throttle / low 4 bits : brake (0 to 15)
+ byte CluHan; // high 4 bits : clutch / low 4 bits : handbrake (0 to 15)
+ byte GearSp; // high 4 bits : gear (15=R) / low 4 bits : spare
+ byte Speed; // m/s
+
+ byte Direction; // car's motion if Speed > 0 : 0 = world y direction, 128 = 180 deg
+ byte Heading; // direction of forward axis : 0 = world y direction, 128 = 180 deg
+ char AccelF; // m/s^2 longitudinal acceleration (forward positive)
+ char AccelR; // m/s^2 lateral acceleration (right positive)
+
+ short X; // position (1 metre = 16)
+ short Y; // position (1 metre = 16)
+};
+
+struct IS_CON // CONtact - between two cars (A and B are sorted by PLID)
+{
+ byte Size; // 40
+ byte Type; // ISP_CON
+ byte ReqI; // 0
+ byte Zero;
+
+ word SpClose; // high 4 bits : reserved / low 12 bits : closing speed (10 = 1 m/s)
+ word Time; // looping time stamp (hundredths - time since reset - like TINY_GTH)
+
+ CarContact A;
+ CarContact B;
+};


// CAR POSITION PACKETS (Initialising OutSim from InSim - See "OutSim" below)
@@ -1387,7 +1437,7 @@
byte ReqI; // 0
byte Zero;

- byte ViewPLID; // UniqueID of player to view
+ byte ViewPLID; // Unique ID of player to view
byte InGameCam; // InGameCam (as reported in StatePack)
byte Sp2;
byte Sp3;
@@ -1421,22 +1471,19 @@

float FOV; // 4-byte float : FOV in degrees

- word Time; // Time to get there (0 means instant + reset)
+ word Time; // Time in ms to get there (0 means instant)
word Flags; // ISS state flags (see below)
};

// The ISS state flags that can be set are :

// ISS_SHIFTU - in SHIFT+U mode
-// ISS_SHIFTU_HIGH - HIGH view
-// ISS_SHIFTU_FOLLOW - following car
+// ISS_SHIFTU_FOLLOW - FOLLOW view
// ISS_VIEW_OVERRIDE - override user view

// On receiving this packet, LFS will set up the camera to match the values in the packet,
// including switching into or out of SHIFT+U mode depending on the ISS_SHIFTU flag.

-// If ISS_SHIFTU is not set, then ViewPLID and InGameCam will be used.
-
// If ISS_VIEW_OVERRIDE is set, the in-car view Heading Pitch and Roll will be taken
// from the values in this packet. Otherwise normal in game control will be used.

@@ -1695,7 +1742,7 @@
// Text in the IS_BTN packet. If the first character of IS_BTN's Text field is zero, LFS will read
// the caption up to the second zero. The visible button text then follows that second zero.

-// Text : 0-65-66-0 would display button text "AB" and no caption
+// Text : 65-66-67-0 would display button text "ABC" and no caption

// Text : 0-65-66-67-0-68-69-70-71-0-0-0 would display button text "DEFG" and caption "ABC"

Thank you for the feedback so far.

I'll look at the object / segment hit packet and other things in the next few days. I thought it was better to get that patch out and start the testing, even if another incompatible one may need to be released.
Hi Scawen,

I noticed that the IS_CON packet does not appear to be sent when playing back multiplayer replays from previous versions of LFS. I'm wondering if this is a bug or just a limitation. They seem to be sent fine when running a replay from Z30, but not for replays from, say, Z13. I don't have any old singleplayer replays lying around to check those.
That's correct. The MPR is just what a remote player would see. The collisions are detected on the guests - which were not sending any collision packets at the time, so there are none in the MPR to be processed.
Ah OK, that's cool.
Quote from Scawen :That's correct. The MPR is just what a remote player would see. The collisions are detected on the guests - which were not sending any collision packets at the time, so there are none in the MPR to be processed.

So a MPR is basically as the server sees the game? Interesting.
Scawen, can you give us an insim packet that will allow us to color a player's car on the map a certain color.

IS_CMI // Color Map Icon
{
byte Size;
byte Type = IS_CMI;
byte PLID;
byte Color; // RRGGBB, 00 = Off, 01 = Blink, 11 = On;
}
/* Color:
As 00 is off, as 11 is on, and 01 is blink.
[b]000000[/b] = Black
[b]11[/b]0000 = Red
00[b]11[/b]00 = Green
[b]1111[/b]00 = Yellow
0000[b]11[/b] = Blue
[b]11[/b]00[b]11[/b] = Magenta
00[b]1111[/b] = Cyan
[b]111111[/b] = White
If you blink 1 color, then it will cycle between the 2 states.
If you blink 2 colors, then it will cycle between the 4 states.
If you blink 3 colors, then it will cycle between the 8 states.
*/

Hey Scawen, you might like to look at this issue with the BTN packet.

Basically the BTN Text field does not need a trailing zero unless the TEXT_SIZE is exactly 240 characters. To clarify, if the TEXT_SIZE is a multiple of four but less than 240, say eight or 128, then no null terminator is needed. However if the TEXT_SIZE is exactly 240 characters and there is no trailing zero, then LFS fails to display the button and there is no error message or warning.

Just to note that the new MTC packet always needs a trailing zero, no matter what the TEXT_SIZE is (and warns you if you omit it), so it would seem there is a bug/inconsistency here.

I hope I've explained it clearly.
I think I have found a bug in SPX.

By definition, on Lap 1 in practise mode, STime and ETime must have 3600000 (1 hour) value.

When you play in a server for more than an hour ( or the game in that server started 1 hour ago), SPX sends instead of that 3600000, the time of the game started.

Replay #2: http://www.mediafire.com/file/cppk3iauf2zay0z/replay2.mpr
Replay #1: http://www.mediafire.com/file/dndo091rk5at7ni/BugInsim.mpr


I don´t know if I´m explaining myself correctly, that´s the replay, and is very easy to reproduce.

Edit: Add replay 2.. Cleaner than first..
The InSim changes so far are great. Thanks! I do not have enough data to be sure every new thing works perfectly, but I believe it is OK. I wonder if two more InSim updates can make it into the official patch:

1) Would it be possible to have communication from server InSim to client(s) InSim? Currently, client InSim apps can send info to server InSim app using the /i command. Not ideal, but it works. But as far as I know, server InSim cannot communicate with client InSims. The idea would be to create a new packet type, just for inter-InSim communication, best working both ways, from client to server, and also from server to client, either a specific one (via ConnID), or to all clients. Alternatively, maybe the existing IS_MTC packet could be used, but when the text starts with a special char, it is not displayed on client(s), it can only be captured by client InSim tools.

2) I was mentioning this before already, but I'll try once more, sorry. A bit somewhere in OutGauge, indicating pressed Ctrl+Shift (on clients) would be nice to have for the option to create multi-purpose buttons (showing alternately e.g. nickname/username). Is it too hard/impossible to add this info to OutGauge? Inside the OutGauge packet OG_x seems to be very empty and there's a spare bit also in DL_x. Please, Scawen, I would really appreciate just a short comment on this addition, like will do / maybe / too complicated / useless / not a priority. Thanks.
3) Any chance to receive somehow more infos about the currently loaded layout? New race positions while using layouts are great. The open sites with new tracks using layouts are also cool, so layouts are more important now than they used to be, still there is only minimum data reported by LFS about loaded layouts, basically just the number of objects and the layout name. Personally, I'd love to see reported the X/Y positions of the major race elements, specifically split and finish lines. But I realize this cannot be done in a compatible fashion, except by creating a new packet... eh...

Sorry about this additional thing, but it would make checking the correct layout so much easier.
Quote from EQ Worry :1) Would it be possible to have communication from server InSim to client(s) InSim? Currently, client InSim apps can send info to server InSim app using the /i command. Not ideal, but it works. But as far as I know, server InSim cannot communicate with client InSims. The idea would be to create a new packet type, just for inter-InSim communication, best working both ways, from client to server, and also from server to client, either a specific one (via ConnID), or to all clients. Alternatively, maybe the existing IS_MTC packet could be used, but when the text starts with a special char, it is not displayed on client(s), it can only be captured by client InSim tools.

Can you tell me what ideas you have for this? I understand it is quite powerful but I have a couple of concerns.

a) To do anything with this, people must install a client side InSim program. I wouldn't like it if people would need to do that before joining a host, so I'd like to provide enough things on the host side that this is not needed.

b) Security concerns, if LFS's packet system is used for communication between two remote programs, I don't know what implications that might have.

Quote from EQ Worry :2) I was mentioning this before already, but I'll try once more, sorry. A bit somewhere in OutGauge, indicating pressed Ctrl+Shift (on clients) would be nice to have for the option to create multi-purpose buttons (showing alternately e.g. nickname/username). Is it too hard/impossible to add this info to OutGauge? Inside the OutGauge packet OG_x seems to be very empty and there's a spare bit also in DL_x. Please, Scawen, I would really appreciate just a short comment on this addition, like will do / maybe / too complicated / useless / not a priority. Thanks.

I don't know but it is on my list to look at it. There doesn't seem to be any space in the OutSimPack and actually that doesn't seem to be a good place for it. To put it in the Flags (OG_x) of OutGaugePack seems quite sensible, because that is partly about user preferences, whereas DL_x is all about dash lights, and CTRL+SHIFT is not a light! I guess that separate OG_CTRL and OG_SHIFT bits would be better than a combined one.

Quote from EQ Worry :3) Any chance to receive somehow more infos about the currently loaded layout? New race positions while using layouts are great. The open sites with new tracks using layouts are also cool, so layouts are more important now than they used to be, still there is only minimum data reported by LFS about loaded layouts, basically just the number of objects and the layout name. Personally, I'd love to see reported the X/Y positions of the major race elements, specifically split and finish lines. But I realize this cannot be done in a compatible fashion, except by creating a new packet... eh...

(OT) I've just done something today that greatly increases the frame rate when there are a lot of autocross objects. Static vertex buffers are now used for them, like the other world objects, so big layouts just don't slow it down like in the current version.

Back on topic, I intend to add InSim packets that can add and remove autocross objects. Each added object would use the 8 byte OBJECT BLOCK from the LYT file : http://www.lfs.net/?page=LYT and I expect these can be put into a variable sized packet.

This seems easy to do because LFS uses that for internal communication anyway. Also you could enable object reporting so that added and deleted objects (and which connection did that) are sent out to InSim. Loaded layout files also uses the multiplayer system so I guess they would appear naturally.
@Scawen, I remember someone requested a way of tellig the user to change to another server, and a ok/cancel button.

This would be useful not only for multiclass servers, where they could send you to your allowed server, but also to leagues, if you need to go to a specific server to sing up before you can actually race.
I have a suggestion for your Scawen.

Would it be possible to add an IP address variable in the IS_NCN packet?

Another goodie would be to add "/ban IP" and "/unban IP" commands. (which isn't that important IMO)
Quote from Scawen :Can you tell me what ideas you have for this? I understand it is quite powerful but I have a couple of concerns.

a) To do anything with this, people must install a client side InSim program. I wouldn't like it if people would need to do that before joining a host, so I'd like to provide enough things on the host side that this is not needed.

Valid concern, it could end up causing a lot of ... let's call it "perceived incompatibility". On the other hand, if anyone really wanted to exclude people who don't have a specific local InSim application running, they could already do so by (visibly, i.e. MTC) initiating a handshake, expecting a reply via /i.

Quote from Scawen :b) Security concerns, if LFS's packet system is used for communication between two remote programs, I don't know what implications that might have.

Ha! LFS suddenly becomes Live FileSharing Seriously though, I don't think there's much room for abuse if the packet for this carries a max payload of ~128 bytes and the client is asked whether or not to allow communication with the local InSim application(s).

Quote from Scawen :Back on topic, I intend to add InSim packets that can add and remove autocross objects. Each added object would use the 8 byte OBJECT BLOCK from the LYT file : http://www.lfs.net/?page=LYT and I expect these can be put into a variable sized packet.

This seems easy to do because LFS uses that for internal communication anyway. Also you could enable object reporting so that added and deleted objects (and which connection did that) are sent out to InSim. Loaded layout files also uses the multiplayer system so I guess they would appear naturally.

:lovies3d:
Quote from Scawen :Can you tell me what ideas you have for this? I understand it is quite powerful but I have a couple of concerns.

Well, my idea was not to exclude people without a certain client InSim program, rather to supply information to such clients, if they're in use, that extend what LFS itself can provide. Specifically, I'm now working on a support for certain "half-official" layouts on the open tracks, creating PTH files with nodes that allow for path checks and also more precise (continuous) race position reporting. This is all done in an application connected to server (Airio) and I though that the results could be sent to client InSims (Aonio) saying like: It is this special track (A21 instead of AS2X_layout, K32 instead of KY3_layout) and the current positions are these (PID bytes). Finding car nodes and the resulting positions are relatively expensive operations, so sharing the results would be really advantageous. I am not sure if this could be misused, because it is like a message sent to clients (specific or all), just hidden.

Quote from Scawen :I don't know but it is on my list to look at it. ... I guess that separate OG_CTRL and OG_SHIFT bits would be better than a combined one.

That sounds really great! I hope it is not too complicated.

Quote from Scawen :... I intend to add InSim packets that can add and remove autocross objects. ... Loaded layout files also uses the multiplayer system so I guess they would appear naturally.

Does it mean that when a layout is loaded, all its objects will be reported? Uhmm, that could be quite a few packets. Supposing there can be 16 objects per packet it may mean 40 packets for extensive layouts... Of course, it would be great to have all this info!
Quote from PoVo :I have a suggestion for your Scawen.

Would it be possible to add an IP address variable in the IS_NCN packet?

Another goodie would be to add "/ban IP" and "/unban IP" commands. (which isn't that important IMO)

i would have to agree, I personally, have been trying to code something like this for the longest time... but being i had no access i couldn't do anything :/


Quote from Dygear :Scawen, can you give us an insim packet that will allow us to color a player's car on the map a certain color.

IS_CMI // Color Map Icon
{
byte Size;
byte Type = IS_CMI;
byte PLID;
byte Color; // RRGGBB, 00 = Off, 01 = Blink, 11 = On;
}
/* Color:
As 00 is off, as 11 is on, and 01 is blink.
[b]000000[/b] = Black
[b]11[/b]0000 = Red
00[b]11[/b]00 = Green
[b]1111[/b]00 = Yellow
0000[b]11[/b] = Blue
[b]11[/b]00[b]11[/b] = Magenta
00[b]1111[/b] = Cyan
[b]111111[/b] = White
If you blink 1 color, then it will cycle between the 2 states.
If you blink 2 colors, then it will cycle between the 4 states.
If you blink 3 colors, then it will cycle between the 8 states.
*/


That would be cool too, great for cruising

I can see it now, cops blink blue/red, robbers, black, citizens orange i guess?
Quote from PoVo :Would it be possible to add an IP address variable in the IS_NCN packet? Another goodie would be to add "/ban IP" and "/unban IP" commands. (which isn't that important IMO)

In my experience, banning by IP has all the negatives. 1) In many cases it hits completely innocent people that just happen to share a provider. 2) In as many cases it doesn't block the troublemaker, because he's able to use another IP.

So, having IP in NCP packet would be nice (currently I'm grabbing it from the server log file, which is not 100% reliable), but banning by IP is really dangerous.
Quote from EQ Worry :In my experience, banning by IP has all the negatives. 1) In many cases it hits completely innocent people that just happen to share a provider. 2) In as many cases it doesn't block the troublemaker, because he's able to use another IP.

So, having IP in NCP packet would be nice (currently I'm grabbing it from the server log file, which is not 100% reliable), but banning by IP is really dangerous.

How exactly do you get it from the server log? I've tried many times with no success
Well dangerous is not the right word but it's completely unnecessary as far as I see for LFS. It takes way too much time even for a demo'er to keep registering accounts.

But having an IP address available is useful to do connection measurements and be able to determine country location.

Together with server redirection (suggested by someone else) it reaalllllyyyy gets interesting. People from AUS/US tend to connect to the busiest server which is all nice but in my case its based in Paris while I have another one in Los Angeles and Chicago but it's impossible to promote those without good IP address recognition and redirection.

Actually I'm almost sure it would boost global LFS usage a bit more if it's better balanced out because people from AUS and the West Coast of the US are causing for the biggest trouble without knowing it (very high lag) and get banned often without knowing why. Or they even think everyone is crashing them instead of the other way around.

Anyway, long story short... It are powerful tools, which, used in a good way, improve a lot.
Quote from PoVo :How exactly do you get it from the server log? I've tried many times with no success

The condition is the InSim app must be running locally to server, on the same machine. Then you can add a "watch" on the server log changes, being notified about updates of a certain file, the server log. And then you can parse the updates, looking for "Connect" and grabbing the following IP address, assigning it to the new connection. Well, it is complicated, the info is already available, but of course having it as 4 bytes in the new connection packet would be most handy. I use the IP info for DNS lookup of the domain name, often getting the country of origin.
Rhama, the situation you describe still requires the user to install a local InSim application. Now why would anyone with malicious intent bother to transmit the info via LFS when he can spread an application capable of doing virtually anything he desires?

There is no security issue with allowing bi-directional hidden communication, the issue is always the client-side InSim application itself.
This thread is closed

InSim changes in new test patch
(236 posts, closed, started )
FGED GREDG RDFGDR GSFDG