Skip to content

Instantly share code, notes, and snippets.

@x1nixmzeng
Created September 13, 2012 18:29
Show Gist options
  • Save x1nixmzeng/3716476 to your computer and use it in GitHub Desktop.
Save x1nixmzeng/3716476 to your computer and use it in GitHub Desktop.
My Delphi code to parse all known GunZ replay/recording files
function gzrClass.ReadGzrPlayers( gzrFile: TMemoryStream ): gzreplayState;
const
GZR_OWNER : byte = 1;
var
i : uint32;
tmpName : array[0..31] of char;
charFlag : byte;
begin
Result := GZR_SUCCESS;
gzrFile.Read( PlayerCount, sizeof( uint32 ) );
SetLength( Players, PlayerCount );
for i := 1 to PlayerCount do
begin
gzrFile.Read( charFlag, sizeof( byte ) );// isMyChar flag
if charFlag = GZR_OWNER then Owner := i;
// character detail (just reading name here)
gzrFile.Read( tmpName, 32 );
SetLength( Players[i-1].Name, StrLen( tmpName ) );
Players[i-1].Name := tmpName;
//##############################################################
// read remaining character info
// does not change from 8-9
if version >= 8 then
gzrFile.Position := gzrFile.Position +(382-32) // ??
else
if version >= 6 then
gzrFile.Position := gzrFile.Position +(374-32) // ??
else
if version >= 5 then
gzrFile.Position := gzrFile.Position +(150-32) // added lastGrade
else
if version >= 2 then
gzrFile.Position := gzrFile.Position +(146-32) // added clanid
else
if version >= 1 then
gzrFile.Position := gzrFile.Position +(142-32)
else
// if version = 0 then
gzrFile.Position := gzrFile.Position +(116-32);
//##############################################################
gzrFile.Read( Players[i-1].id, sizeof( gzrUID ) ); // uid
if Version = 0 then
begin
gzrFile.Position := gzrFile.Position +296;
gzrFile.Position := gzrFile.Position +(12*(4+4));
gzrFile.Position := gzrFile.Position +56;
end
else
begin
gzrFile.Position := gzrFile.Position +88;// old properties
if Version = 1 then
begin
gzrFile.Position := gzrFile.Position +56;
end
else
begin
gzrFile.Position := gzrFile.Position +4; // hp
gzrFile.Position := gzrFile.Position +4; // ap
gzrFile.Position := gzrFile.Position +48
end;
if Version >= 9 then
gzrFile.Position := gzrFile.Position +(17*(4+4+4+4)) // increased ids
else
if Version >= 6 then
gzrFile.Position := gzrFile.Position +(17*(4+4)) // increased inv. size
else
gzrFile.Position := gzrFile.Position +(12*(4+4));
end;
gzrFile.Position := gzrFile.Position +12;// pos
gzrFile.Position := gzrFile.Position +12;// dir
gzrFile.Position := gzrFile.Position +4; // teamid
gzrFile.Position := gzrFile.Position +1; // is_dead
// NOT in v1
if Version >= 2 then
gzrFile.Position := gzrFile.Position +1; // is_hidden (for invisible admin)
end;
end;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment