The online racing simulator
Tracking meters driven
(7 posts, started )
#1 - jur
Tracking meters driven
I have a question. I'm using LFSLib to develop my first insim application and I'm stuck on figuring out how i can track a car's driven meters. Also, i wish to have some track length, so i can know how much progress a driver has made through the track. Or maybe there's some other way to have this info. Thanks for feedback, LFS programmers!
Quote from jur :I have a question. I'm using LFSLib to develop my first insim application and I'm stuck on figuring out how i can track a car's driven meters. Also, i wish to have some track length, so i can know how much progress a driver has made through the track. Or maybe there's some other way to have this info. Thanks for feedback, LFS programmers!

Driven meters:
I have made this. I did it by summing distances between successive points where the car has been (IS_MCI). The greater the frequency of the mci packets, the more accurate the distance is. But it is never 100% accurate.

Track lenght:
You cannot really compare the driven meters to the track length. This is because the driver might have been making just donuts and not even trying to drive a lap. Besides the track lenght the game informs is not that accurate and depending on your driving line might be tens of meters off the driven lap distance. If you want to follow the progress around a lap, you should use the nodes.
#3 - jur
Quote from Aquilifer :Driven meters:
I have made this. I did it by summing distances between successive points where the car has been (IS_MCI). The greater the frequency of the mci packets, the more accurate the distance is. But it is never 100% accurate.

Track lenght:
You cannot really compare the driven meters to the track length. This is because the driver might have been making just donuts and not even trying to drive a lap. Besides the track lenght the game informs is not that accurate and depending on your driving line might be tens of meters off the driven lap distance. If you want to follow the progress around a lap, you should use the nodes.

Thanks for the quick feedback! Now it's getting clearer. Just another question about those nodes. So as I understand InSim informs about driver passing some track node? Where can I get more info on these nodes? Like what are their positions on a specific track? How many of them are there and so on...
Quote from jur :Thanks for the quick feedback! Now it's getting clearer. Just another question about those nodes. So as I understand InSim informs about driver passing some track node? Where can I get more info on these nodes? Like what are their positions on a specific track? How many of them are there and so on...

IS_RST:

...
word NumNodes; // total number of nodes in the path
word Finish; // node index - finish line
word Split1; // node index - split 1
word Split2; // node index - split 2
word Split3; // node index - split 3


struct IS_RST // Race STart
{
byte Size; // 28
byte Type; // ISP_RST
byte ReqI; // 0 unless this is a reply to an TINY_RST request
byte Zero;
byte RaceLaps; // 0 if qualifying
byte QualMins; // 0 if race
byte NumP; // number of players in race
byte Spare;
char Track[6]; // short track name
byte Weather;
byte Wind;
word Flags; // race flags (must pit, can reset, etc - see below)
word NumNodes; // total number of nodes in the path
word Finish; // node index - finish line
word Split1; // node index - split 1
word Split2; // node index - split 2
word Split3; // node index - split 3
};

EDIT: plus these....


struct NodeLap // Car info in 6 bytes - there is an array of these in the NLP (below)
{
word Node; // current path node
word Lap; // current lap
byte PLID; // player's unique id
byte Position; // current race position : 0 = unknown, 1 = leader, etc...
};

struct IS_NLP // Node and Lap Packet - variable size
{
byte Size; // 4 + NumP * 6 (PLUS 2 if needed to make it a multiple of 4)
byte Type; // ISP_NLP
byte ReqI; // 0 unless this is a reply to an TINY_NLP request
byte NumP; // number of players in race

NodeLap Info[32]; // node and lap of each player, 1 to 32 of these (NumP)
};

#5 - jur
thanks a lot!
Average speed divided by laptime?

Tracking meters driven
(7 posts, started )
FGED GREDG RDFGDR GSFDG