The online racing simulator
Node count
(7 posts, started )
#1 - juxas
Node count
How to get last node in a track? Without driving through it and watching when node id resets.

Okay... That's IS_RST. Sorry, I haven't checked it
isn't node in the MCI packet?
#3 - juxas
I needed last node in track's path. MCI contains car's current node.
You mean the previous node? why would you even want that? just wondering
#5 - juxas
I mean number of nodes in track. I am splitting track into more splits(like 10) by using path nodes. So knowing node count and split count I can calculate one split size
i use file from the map folder into LFS for that called .pth file.

You have all Node for a Track on a Map.

It contain:
Node Count,
Node Index,
Center Coord,
Parallel distance To track and Limit of Map playable.

Here is a code that is able to retrieve all PTH file and all info from those file! if you need to use it as example.

enum PTH_Format : int
{
FILE_TYPE = 0,
VERSION = 6,
REVISION = 7,
NODE_COUNT = 8,
FINISH_LINE = 12,
NODE_START = 16,
NODE_LENGTH = 40,
CENTER_X = 0,
CENTER_Y = 4,
CENTER_Z = 8,
DIR_X = 12,
DIR_Y = 16,
DIR_Z =20,
LIMIT_LEFT = 24,
LIMIT_RIGHT = 28,
DRIVE_LEFT = 32,
DRIVE_RIGHT = 36,
}
internal static bool Initialize()
{
string[] files = System.IO.Directory.GetFiles(Program.dataPath + Path.DirectorySeparatorChar + "map", "*.pth");
byte[] buffer;
int nodeCount;
int finishNode;
for(int itr = 0; itr < files.Length; itr++)
{
buffer = File.ReadAllBytes(files[itr]);
if(buffer.Length > 12)
{
if (GetString(buffer, (int)PTH_Format.FILE_TYPE, 6) != "LFSPTH")
{
Log.error(" Invalide FileType map -> "+files[itr]+"\r\n");
return false;
}
if (buffer[(int)PTH_Format.VERSION] > 0)
{
Log.error(" Invalide Version map -> " + files[itr] + "\r\n");
return false;
}
if (buffer[(int)PTH_Format.REVISION] > 0)
{
Log.error(" Invalide Revision map -> " + files[itr] + "\r\n");
return false;
}
nodeCount = GetInt(buffer, (int)PTH_Format.NODE_COUNT);
finishNode = GetInt(buffer, (int)PTH_Format.FINISH_LINE);
MapData mapData = new MapData(nodeCount,finishNode);
int firstIndex;
for(int nodeItr = 0; nodeItr < nodeCount; nodeItr++)
{
firstIndex = ((int)PTH_Format.NODE_START + ((int)PTH_Format.NODE_LENGTH * nodeItr));
mapData.SetNode
(
nodeItr,
GetInt(buffer, firstIndex + (int)PTH_Format.CENTER_X),
GetInt(buffer, firstIndex + (int)PTH_Format.CENTER_Y),
GetInt(buffer, firstIndex + (int)PTH_Format.CENTER_Z),
GetFloat(buffer, firstIndex + (int)PTH_Format.DIR_X),
GetFloat(buffer, firstIndex + (int)PTH_Format.DIR_Y),
GetFloat(buffer, firstIndex + (int)PTH_Format.DIR_Z),
GetFloat(buffer, firstIndex + (int)PTH_Format.LIMIT_LEFT),
GetFloat(buffer, firstIndex + (int)PTH_Format.LIMIT_RIGHT),
GetFloat(buffer, firstIndex + (int)PTH_Format.DRIVE_LEFT),
GetFloat(buffer, firstIndex + (int)PTH_Format.DRIVE_RIGHT)
);
}
string trackPrefix = files[itr].Substring(files[itr].LastIndexOf('\\')+1);
trackPrefix = trackPrefix.Replace(".pth","");
maps.Add(trackPrefix,mapData);
}

}
Log.commandHelp(" Loaded "+files.Length+" Maps.\r\n");

return true;
}

I hope this is not for using to calculate SPLIT Time a driver do between Node.
Since you are using a insim application, it is not possible for you to have a real precision time as the LFS server do.
This will deliver not quality content ;(.
As the Maximum Speed Or Acceleration speed Feature, it fun to have but we can't base Valuable thought or data from those system and most of driver don't know that! so this become the duty of people developing insim addons to be vigilant.
There is a easier way...
add a event handler for RST
Quote :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
};

and then sent a TINY_RST wich will request a RST package so you can have total number of nodes on the start of your application

Node count
(7 posts, started )
FGED GREDG RDFGDR GSFDG