The online racing simulator
Problem with Time in IS_CON
(4 posts, started , go to first unread)
Problem with Time in IS_CON
Hi. I'm trying to store car contacts made in a race but I'm not getting the right values for variable "Time" if the race is long. Here is the packet specification from InSim.txt:

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;
};

The packet size is 40 bytes. The first 4 bytes are for Size, Type,Reql and Zero. CarContact A and B are 16 bytes each one and SpClose and Time are 2 bytes integers each. According to Wikipedia for a 2 bytes unsigned integer the range is 0 to 65535. So, for Time, it can't have values larger than 65535 and in real time measure (100 = 1 second) that is like 655 seconds or so. If the race length is longer than that the Time value will not be correct.
For tests I've used Pyinsim library.

I wonder if this is a Insim or Pyinsim bug, or perhaps I'm doing something wrong. Thanks.
Hello,
Sorry to resume this very old post but i have the exact same problem and don't see a reply in the forum.
I am getting the ISP_CON packets but cannot determine when the contact happened. I don't see a packet indicating a time reset and can't stop the game (replay I guess ...) as indicated in the insim.txt doc to perform a reset.
Is there a trick or is there a type issue (word) for this info (Time)?
There is a method to work this out.

I don't know the details of how to do it in Python, but I can describe it in C-style. The principle is that you assume the packet that arrives is sent recently, so it is comparable with a "word" version of the current time.

The types I will use here are:

'unsigned' = 4 byte unsigned integer
'word' = 2 byte unsigned integer
'short' = 2 byte signed integer

word looping_time = CurrentTime; // convert current time in hundredths (e.g. from a SMALL_RTP packet) to a word

short lag = looping_time - ISP_CON.Time; // get a signed difference from when the collision happened to current time (both have been converted to 'word')

// Now you have a number 'lag' that should be positive, if the packet was sent any time recently.

if (lag >= 0) // valid lag - can now reconstruct sent time
{
unsigned packet_sent_time = CurrentTime - lag;
}

Thank you for the answer Scawen !
It's too long time since I did C or assembler so it took me a long time to understand...
Then I saw the subtlety of converting a 4-byte unsigned integer to 2-byte unsigned integer (which crashes in a lot of languages but keeps the low weight bytes in C).
Thanks, I just have to code now ...

Problem with Time in IS_CON
(4 posts, started )
FGED GREDG RDFGDR GSFDG