Extract car location from replay

Moderators: Xymph, NADEO

User avatar
Electron
Posts: 797
Joined: 15 Jun 2010, 18:02
Contact:

Re: Extract car location from replay

Post by Electron »

Phenom wrote:Since this part is documented in WIKI, I think it wouldn't be an issues.
This Wiki was created by the community. It's not an official Nadeo page.
However, I can't put an hand on the 03 03F 005 (CGameGhostInfo) on a Replay.Gbx file and I'm sure it contain position. May the chunk have a different ID ?
See my posting above. I've updated the Wiki accordingly.
User avatar
Phenom
Posts: 63
Joined: 28 Feb 2014, 23:54

Re: Extract car location from replay

Post by Phenom »

Thanks for your answer. I've read your post above, but you described the "uint32 IsReplaying" chunk. Maybe I didn't understand and you might already answer this question, but I'm looking precisely the beginning to the CGameGhost (03 03F 005) where I can retrieve size of data and the data itself. But I can't find the 03 03F 005 (means 05 F0 03 03) hex values on the file which match the very beginning of the chunk.

Without the very beginning of the CGameGhost, I can't get the proper size and be able to parse correctly child data. Since sample data (which contains position, speed, angle etc.) are not inside a precise chuck (preceded by the identifier lile 03 03 XX etc.), I must get the start offset of the ID of the CGameGhost for the maniaplanet2 replay.

I'm not sure I'm perfectly clear. It's hard to explain a technical issue in a foreign language :mrgreen:

Thanks for taking time for my question ! :thumbsup:
Creator of Lerya
Race graphic viewer for TrackMania²
More information on http://www.lerya.org
User avatar
Phenom
Posts: 63
Joined: 28 Feb 2014, 23:54

Re: Extract car location from replay

Post by Phenom »

I think I've final founded what I'm looking for. I keep you aware about it !
Creator of Lerya
Race graphic viewer for TrackMania²
More information on http://www.lerya.org
User avatar
Electron
Posts: 797
Joined: 15 Jun 2010, 18:02
Contact:

Re: Extract car location from replay

Post by Electron »

Here is a possible implementation of the ReadChunk() function inside ReadNode(). If you come across class ID 0x0303F006, read the IsReplaying Nat32 and fall-through chunk 0x0303F005 to be compatible with older Replays:

Code: Select all

ReadChunk(chunkID, chunkDataSize)
{
    switch (chunkID)
    {
        case 0x03093002:
            CGameCtnChallenge::Archive();
            break;
        case 0x03093007:
            CClassicArchive::DoNat32();
            break;
        case 0x03093014:
            CFastBuffer::ArchiveFastBufferNod();
            CFastBuffer::AddRefAll();
            CClassicArchive::DoNat32();
            CFastBuffer::ArchiveCountAndElems();
            break;
        case 0x03093015:
            CClassicArchive::MwDoNodRef();
            break;
        case 0x0303F006:
            IsReplaying = CClassicArchive::DoNat32();
        case 0x0303F005:
            uncompressedSize = CClassicArchive::ReadNat32();
            compressedSize = CClassicArchive::ReadNat32();
            CClassicArchive::ReadData();
            CClassicBufferZlib::OpenForReading();
            ...
            ...
            ...
            break;
        // read all other non-skipable chunks
        case 0x...
            ...
            ...
            break;
        ...
        ...
        default:
            // skip all not needed skipable chunks
            FileSeekCurrent(chunkDataSize);
    }
}
Last edited by Electron on 11 Jun 2017, 14:05, edited 2 times in total.
User avatar
phil13hebert
Posts: 564
Joined: 29 Oct 2011, 14:11
Location: Québec

Re: Extract car location from replay

Post by phil13hebert »

I love this kind of thing, but unfortunately, I can't understand for now ^^
OS: Windows 7 64 bit
CPU: Intel Core i7 3770 @ 3.40Ghz
RAM: 8GB DDR3 798MHz
GPU: Nvidia GeForce GTX 660 1536MB
Motherboard: Intel 0KM92T
Sound: 7.1
Peripherals: Logitech G510, SteelSeries sensei raw, Corsair vengeance 1500
User avatar
Phenom
Posts: 63
Joined: 28 Feb 2014, 23:54

Re: Extract car location from replay

Post by Phenom »

Thanks for you tips Electron !

I've finally located, isolated and decompress the CGameGhost datas. I'm able to :
- Retrieve class ID (seems to always be C2 B0 02 0A)
- Retrieve the bSkipList2 (seems to always be true => 01 00 00 00)
- Retrieve the samplePeriod (seems to always be 100 => 64 00 00 00)

But when I'm trying to get the size of the bytes array "sampleData", I've weird value : the size is bigger than the entire block !

This is the first bytes of the decompress CGameGhost data :

Code: Select all

C2 B0 02 0A 01 00 00 00 00 00 00 00 64 00 00 00 0C 00 00 00 C2 A0 1B 00 00 00 00 C2 B8 43 25 06 20 41 C5 A1 E2 84 A2 C3 A5 43 00 00 00 00 00 00
The size here is normally C2 A0 1B 00 (l.e) => 1 810 626 which is bigger than the entire block length ! I think it's another field, but I'm not sure where is located the proper size
Creator of Lerya
Race graphic viewer for TrackMania²
More information on http://www.lerya.org
User avatar
Electron
Posts: 797
Joined: 15 Jun 2010, 18:02
Contact:

Re: Extract car location from replay

Post by Electron »

It looks like your Zlib decompressor doesn't work properly.

I manually uncompressed a current Replay and extracted chunk 0303F006. Then I uncompressed it using IP Tools by Erwan L. (I doesn't quickly found a utility that is able to decompress raw zlib deflate data). The result corresponds exactly to the wiki documentation. Note: The class ID at the beginning should be 0A02B000 (CSceneVehicleCar), not 0A02B0C2.
User avatar
TMarc
Posts: 15255
Joined: 05 Apr 2011, 19:10
Location: Europe
Contact:

Re: Extract car location from replay

Post by TMarc »

could the sampleperiod be the user's configured steps prediction value? it is also 100 as default (launcher -> configure -> advanced -> game) :?
Of course it is not relevant for TrackMania ;)
User avatar
Phenom
Posts: 63
Joined: 28 Feb 2014, 23:54

Re: Extract car location from replay

Post by Phenom »

TMarc wrote:could the sampleperiod be the user's configured steps prediction value? it is also 100 as default (launcher -> configure -> advanced -> game) :?
Of course it is not relevant for TrackMania ;)
Good point TMarc, but I think it's only use for multi-player in case of hight latency
Electron wrote:It looks like your Zlib decompressor doesn't work properly.
I've used a ZLib decompressor, but since I'm working on .NET technology, I might have some issues (some users have already warn Microsoft for an issue with de decompressor). I'm going to look further to see if I could decompress it without any errors
Creator of Lerya
Race graphic viewer for TrackMania²
More information on http://www.lerya.org
User avatar
Phenom
Posts: 63
Joined: 28 Feb 2014, 23:54

Re: Extract car location from replay

Post by Phenom »

Hi Electron

Thanks for all information you gave me ! I've finally achieved to retrieve valid data. You can't imagine how I'm grateful ! Everything works perfectly !
:D :thumbsup: :1010




:thx:
Creator of Lerya
Race graphic viewer for TrackMania²
More information on http://www.lerya.org
Post Reply

Return to “General Tools”

Who is online

Users browsing this forum: No registered users and 1 guest