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?
Replays
Moderator: Moderators
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 ?
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 ?
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
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.
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.
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.