View Full Version : MPR - content of "flags" bytes?
Nitemare
14th November 2005, 12:19
i'm trying to get as much data from mpr file as possibble.. and i found two undocumented integers... rules and flags
...
1 int 12 rules : -
1 int 16 flags : -
...
definition of "rules" can be found here (http://www.lfsforum.net/showthread.php?t=183), but i can't work out what does "flags" mean...
also i would like to know if there is some reliable way to find a list of usernames, other than searching the whole file for a specific pattern...
ikkah
14th November 2005, 13:22
(deleted lots of text here.. should have read the message properly first)
I haven't found a reliable way to find usernames in the replays, but I've had quite good results by playing with offsets. I can find most drivers this way, and it's more reliable than trying to find patterns. Try combining these two methods.
the_angry_angel
14th November 2005, 13:41
Are you trying to get the players with results or all players?
If you want players with results, I suggest re-reading the MPR format, as all the names are in the data block; http://www.liveforspeed.net/?page=MPR
i.e. offset 80 to 104 is player 1's name then + 81 to get the next offset boundary, for each number of players listed in the MPR header.
Edit:
As a suggestion, possibly the flags represent the flags allowed - although we cannot alter this at this stage.
ikkah
14th November 2005, 13:44
Hmm, OK, did a little bit of research, those look like car bits. Allowed cars on that server, that is. S1 cars are listed just above the rules bits, I guess the rest of the cars are in the same order as everywhere else, f.e. LFSWorld.
the_angry_angel, I think he's trying to find LFSWorld usernames.
Nitemare
14th November 2005, 13:59
Are you trying to get the players with results or all players?
If you want players with results, I suggest re-reading the MPR format, as all the names are in the data block; http://www.liveforspeed.net/?page=MPR
i.e. offset 80 to 104 is player 1's name then + 81 to get the next offset boundary, for each number of players listed in the MPR header.
Edit:
As a suggestion, possibly the flags represent the flags allowed - although we cannot alter this at this stage.
yes, but in the header there are just nicknames, not lfs-usernames...
right now, i find the usernames in mpr like this...
somewhere in mpr file is a block of data that consist of:
num unit offset description
--- ---- ------ -----------
CONNECTION INFO : size 61 bytes per connection
2 byte ???? always 0x3C07
1 byte 2 connection id? (host has always 0x01, and is always first in the list)
2 byte 3 ?? (host has always 0x00)
24 char 5 player name
8 char 29 number plate
24 char 37 user name
in s2, this block begins on a different offset in each mpr file, and i didn't found something like a pointer to this block yet...
so i just search the file for a sequence of bytes 0x3C, 0x07, 0x01, 0x00, 0x00 to find the block... it seems to work every time...
btw if someone wants a source for mpr parser in java, i can post it..
Hmm, OK, did a little bit of research, those look like car bits. Allowed cars on that server, that is. S1 cars are listed just above the rules bits, I guess the rest of the cars are in the same order as everywhere else, f.e. LFSWorld.yup, it looks like car bits.. thanks!
ikkah
14th November 2005, 14:13
http://www.lfs-suomi.com/uploads/mpr-parse.cpp
That's my parser, in C++. It's a bit hacky since I didn't think I'd show it to anyone :)
Look for "const int magic_offset", that's where I move to that block of data. The offset to the username block depends on the number of players, unlike in S1 where it was always in the same place.
My parser can find all the players that were ingame when the replay started, this means you can't find people who started from the pits, joined the game after spectating or connected to the server after the replay started. It's good enough for running a league, though.
Nitemare
21st November 2005, 20:55
okay, i modified parser to use your "magical offset", and it works most of the time, but fails in one particular replay..
there are 20 players, so the block of data that follows the offset should have size of 20 * 335 = 6700 bytes, but it has only 6646 bytes
replay is here: http://nitemare.misto.cz/SROctaviaCup_d2_z2_race1.mpr (6.8 MB)
and parser source here: http://nitemare.misto.cz/MPRParser.java
ikkah
22nd November 2005, 12:23
Here's the problem: right when you start the replay, it says "poa.agarash left the pits (FXO)". The race hasn't begun yet, but the countdown has. That's why Agarash's block of data is 282 bytes instead of 335. I don't know of a way to detect this, so I just tell my drivers to not pit when the race starts :)
Nitemare
22nd November 2005, 16:37
thanks, i'll instruct racers to pit-out sooner :)
vBulletin® v3.7.1, Copyright ©2000-2008, Jelsoft Enterprises Ltd.