[Q4] Checksum calculation?

Locked
User avatar
Foo
Posts: 13840
Joined: Thu Aug 03, 2000 7:00 am
Location: New Zealand

[Q4] Checksum calculation?

Post by Foo »

Trying to calculate the checksum for PK4s manually (in PHP) but can't find any information on the kind of crc check which Q4 performs.

It's not crc32, I get a different checksum than Q4 gets with the 'path' command on the same file.

Any ideas?
"Maybe you have some bird ideas. Maybe that’s the best you can do."
― Terry A. Davis
kaffeedoktor
Posts: 13
Joined: Mon Feb 09, 2004 8:00 am

Post by kaffeedoktor »

Maybe I replay a bit late, but the checksum used to identify PK4s is an MD5, which you can create in PHP using the md5_file( ) method.
User avatar
Foo
Posts: 13840
Joined: Thu Aug 03, 2000 7:00 am
Location: New Zealand

Post by Foo »

The MD5 output I'm familiar with is a 128-bit hash, whereas the checksums listed for quake 4 are in the format 0xAC34CA, and soforth?
"Maybe you have some bird ideas. Maybe that’s the best you can do."
― Terry A. Davis
kaffeedoktor
Posts: 13
Joined: Mon Feb 09, 2004 8:00 am

Post by kaffeedoktor »

Sorry, I got sth wrong.

For ingame usage Q4 uses an 8 byte MD5 blockchecksum, which is build as:

val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3];

(that's code from idlib, val & digest are unsigned long values).

E.g. a 32 byte MD5 0x0123456789ABCDEF0123456789ABCDEF will get split into

0x01234567, 0x89ABCDEF, 0x01234567, 0x89ABCDEF

These 4 parts will are used to calculate the resulting 8-byte blockchecksum using the OR operation.
Locked