The online racing simulator
Help with the MCI packet
(13 posts, started )
Help with the MCI packet
I don't quite understand how to unpack the MCI packet.

the CompCar Info [8]; is the bit that I don't understand.

Any hinters please?
What exactly is the problem? It is 8 times the CompCar structure. Loop it through (8 loops). In C/C++ e.g with 'for'-loop.

After the NumC, there is Node for the first car (#0) and all the other data for car #0. After that there is car #1 CompCar and so on.
when I use unpack, its like c for this, S for that - what do I use for compcar?
Ahem.... what?

EDIT: You are using PHP? Well I do not use that... but you do understand the structure do you?
Think of "CompCar" as "a packet within a packet", and you should figure it out.

You should see the definition around the same sort of location.
Compcar is a struct, which means its composed of several other types. To retrieve it from the byte array, you would need to read the proper amount of bytes and then access each element.

A way of doing it using C# would be:


_info = new CompCar[_numC];
Array.Copy(_buffer, 4, _info, 0, _numC * 28);

_numC is the number of valid CompCar structs. Array.Copy just copies the origin array starting in the specified index (4 in this case) to the start of the destination array (_info), the number of bytes _numC * 28, being 28 the size of a CompCar struct.

After doing this you have a nice array of CompCars that can be accessed individually.

Dont know if I helped or I confused you even more
okay, I managed to get the following data, let me know if it looks right

Quote :
[nodelap] => 49
[lap] => 1
[uid] => 11
[x] => -27
[y] => 81
[z] => -58
[speed] => 14846
[direction] => 14303
[heading] => 53251

I think there is something funny.
The speed is c. 163km/h(101mi/h), your direction is 78deg, but heading is 292deg. Doesn't sound like from this world. Or is your car flying?

EDIT: Actually the heading was anticlockwise so it is 360-ang. e.g 78->360-78=282 for heading. Now if the direction is clockwise this could even make sense (282<->292 -> 10deg slide)
High-speed spin?

But the X,Y,Z values are very low. Is that diviede through 65563 or are you really at the center. I usually get much higher values for normal packets.
the car is just sitting there on the start line, I guess I am not getting it out of the packet correctly.

Anybody got a PHP script that decodes that data, that I can look at please?
How'd this look?

Quote :
Car #9 position
X: 4603019
Y: 44664308
Z: 1076387

Yes, usually you get large values like those. Of course they could be low too if you are near the origo or axis. I don't know what point of the car it is. It could the center of gravity, mesh or something else.
okay, I've sorted the MCI packet out!
Thanks for all ya help lads!

Help with the MCI packet
(13 posts, started )
FGED GREDG RDFGDR GSFDG