View Full Version : Separating values in sSector and sGearNumGears

25-01-2019, 12:37
Hi all,

I'm in C++ here, can someone tell me how can I read the following values:

1. sSector: I need the sector value only, without the extra precision bits for x/z position.
2. sGearNumGears: I need the current gear.

How can I seperating the values?


25-01-2019, 16:44
I'm using C# so this might not work, but this is the code I use for sector: (UDP v1)
byte Sector_ALL = binaryReader.ReadByte();
var Sector_Extracted = Sector_ALL & 7;
ParticipantInfo[i, 7] = Convert.ToDouble(Sector_Extracted); //sSector

This gives you sector number as a double. Hope that helps.

EDIT: afaik, the '& 7' means that you read the first 7 bits of the byte, but not the last.
In c#, use '>>' to shift the position you read from. I might be wrong :)

25-01-2019, 17:51
unsigned char curr_gear = ...sGearNumGears & 0xf;

unsigned char curr_sector = ...sSector & 0x3;

Those should work for PCars2 UDP.

26-01-2019, 15:48
Thank you guys! The solution of Sampo works! THX! :)