Replays

Replays

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Replays

Post by Maelstrom »

A few questions about replays:

1) Opening the replay file in a text editor shows that, as far as I can see, there is a whole bunch of lines starting in two [NUL] chars, and ending in [ENQ][NUL][NUL][NUL][ETX]. My guess (I have not read the source, im probably wrong) is that each of these is a command recieved by Spring. Therefore, by counting how many times this pattern of control characters is repeated, the number of commands recieved can be counted, and then therefore the length of the game can be calculated. Would this be possible, or am I missing something?

2) Could the date/time saved in the [VERSION] section be converted to a unix time stamp, still using GMT time? They are much easier to work with

3) What mime type is the correct type for the replays?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

1)

It's probably harder then that. I don't know the ascii values of the characters you mention (except NUL ofcourse) but the replay is really just a stream of binary data and to count one message type you need to know atleast the length of all message types so you can skip over them.

For the same reason you can't talk about "lines" in the file.

3)

application/octet-stream ?
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

After some checking I found that the message length is saved too, so basically the format is:

BYTE gameSetupAvaiable (always 1 with proper demos)
INT scriptLength;
BYTE[scriptLength] the game startup script

while(not EOF) {
FLOAT gametime (this is 4 bytes),
INT packetLength;
BYTE[packetLength]
}


I hope my newly invented syntax for file formats is a bit understandable ;)
Point is, with packetLength known, it is possible to iterate through everything and maybe check for certain messages.

It is likely that packets/messages start with a constant NETMSG_* from Net.h
Last edited by jcnossen on 16 Sep 2006, 13:11, edited 1 time in total.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

And..... That went STRAIGHT over my head.

Please, forgive my ignorance and explain to this lowly PHP coder what the fuck all that ment? Cause to me that ment not a lot at all.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

It is the fileformat for replays... maybe you can ask a more specific question?
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Ok, ive managed to work out the first bit, but i still working out what the second bit means. Im not used to working with binary files, this is new stuff to me.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Still lost, turns out i havnt worked out the first bit even. Psuedo code to get info would be handy, cause I have NO idea what im doing here...
Torrasque
Posts: 1022
Joined: 05 Oct 2004, 23:55

Post by Torrasque »

If you open a script with a text editor, you will have :

first caractere = BYTE gameSetupAvaiable ( it's 8 bits )
4 next = INT scriptLength; ( an int = 4 byte, 32 bits )
Then, the startscript. it's an array of byte/ascii char with the size of scriptlength.

And then, until the end of the file, you have this, wich are the commande send over the network during the game :

First 32 bits are the gametime
next 32 bits are the lenght of the information.
and then, an array with the information.

next 32 bits are the gametime
next 32 bits are the lenght of the information.
and then, an array with the information

next 32 bits are the gametime
next 32 bits are the lenght of the information.
and then, an array with the information

etc..
End of file


I'm not sure it's more clear, but I hope you will better understand.
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Ah that helps, now I just have to work out how to do this. Thanks
User avatar
Maelstrom
Posts: 1950
Joined: 23 Jul 2005, 14:52

Post by Maelstrom »

Ok, I can succesfully extract the straight text from the top, but I cant figure out how the rest of it works, as it does not seem to follow what has been suggested. Either that or im doing it wrong again, which is more likely.
Post Reply

Return to “Engine”