Replays (GTA SA)

From GTAMods Wiki
Jump to navigation Jump to search

Replays are the sequence of the scenes and actions recorded and stored in the replay.rep file. This file is located in the GTA San Andreas User Files directory.

Format Details

Each .rep file consists of a header string and variable amount of 'scenes' (or 'frames'). A scene is a copy of important game information at given moment of time (actors, vehicles positions, weather, clothes, etc). Following one after another, the scenes create an illusion of a movie when played. The most of scenes contains a same set of blocks and ends with Block 8.

The .rep file itself consist of a header string which is simply the text GtaSA29 and up to 8 parts, size of each one is 100,000 bytes, depending on the replay length. So, the maximum size of a replay file is 800,008 bytes (including 8 bytes of the header string). If the replay length is that it does not match 100,000 bytes boundary being less, the rest of the file is filled with useless data (commonly the previous replay data).

Data Blocks

Each block consists of a byte denoting its type and some data as described below. A number in a block name is the data type stored in the first byte of the block. Reading this byte, the game detects what block follows.

Block 0: End of file

This block denotes the end of replay data. It consists only of a data type. After this block the game stops reading the replay file.

OFFSET  TYPE      DESCRIPTION
0x00    byte      data type (0x00)
0x01    (end)

Block 1: Vehicle

size 52 bytes

Block 2: Bike

Special bike information, first 52 bytes are from vehicle block.

OFFSET  TYPE      DESCRIPTION
0x00    BLOCK     vehicle (type= 0x2)
0x34    byte      animLean
0x35    byte      steerAngle
0x36    byte[2]   (align)
0x38    (end)

Block 3: Ped Header

Common information about a ped to be created. If the said ped is the player, a clothes block will follow after.

OFFSET  TYPE      DESCRIPTION
0x00    byte      data type (0x03)
0x01    byte      index (handle?)
0x02    WORD      modelID
0x04    byte      ped type
0x05    byte[3]   (align)
0x08    (end)

Block 4: Ped Update

Update information of a ped already existed. size 52 bytes

Block 5: Camera

This block contains information about game camera. Also called 'general'

OFFSET  TYPE      DESCRIPTION
0x00    byte      data type (0x05)
0x01    byte      isUsingRemoteVehicle
0x02    byte[2]   (align)
0x04    CMatrix   matrix
0x4C    CVector   firstFocus
0x58    (end)

Block 6: Day time

This block contains information about current day time during a scene.

OFFSET  TYPE      DESCRIPTION
0x00    byte      data type (0x06)
0x01    byte      currentHour
0x02    byte      currentMinute
0x03    byte      (align)
0x04    (end)

Block 7: Weather

OFFSET  TYPE      DESCRIPTION
0x00    byte      data type (0x07)
0x01    byte      oldWeather
0x02    byte      newWeather
0x03    byte      (align)
0x04    float     interpValue
0x08    (end)

Block 8: End of scene

This block denotes the end of the current scene (frame). It consists only of a data type.

OFFSET  TYPE      DESCRIPTION
0x00    byte      data type (0x08)
0x01    (end)

Block 9: Scene timing

This block contains value of the global game timer. The replay play length could be found by using this block.

OFFSET  TYPE      DESCRIPTION
0x00    byte      data type (0x09)
0x01    byte[3]   (align)
0x04    DWORD     timer
0x08              (end)

Block 10: Bullet Traces

OFFSET  TYPE      DESCRIPTION
0x00    byte      type (0xA)
0x01    byte[2]   (align)
0x03    byte      index
0x04    CVector   start
0x10    CVector   end
0x1C    (end)

Block 11: Particles

Unused, size 20 bytes.

Block 12: Misc

OFFSET  TYPE      DESCRIPTION
0x00    byte      type (0xC)
0x01    byte[3]   (align)
0x04    DWORD     camShakeStart
0x08    float     camShakeForce
0x0C    byte      currArea
0x0D    byte      cameraFX (bit 1: video, bit 2: lift)
0x0E    byte[2]   (align)
0x10    (end)

Block 13: Deleted Vehicle

Used for reporting a vehicle needs to be removed from the world.

OFFSET  TYPE      DESCRIPTION
0x00    byte      type (0xD)
0x01    byte      (align)
0x02    WORD      handle
0x04    (end)

Block 14: Deleted Ped

Used for reporting a ped needs to be removed from the ped.

OFFSET  TYPE      DESCRIPTION
0x00    byte      type (0xE)
0x01    byte      (align)
0x02    WORD      handle
0x04    (end)

Block 15: BMX

Special BMX information, first 52 bytes are from vehicle block. Exactly the same with the bike block.

OFFSET  TYPE      DESCRIPTION
0x00    BLOCK     vehicle (type= 0xF)
0x34    byte      animLean
0x35    byte      steerAngle
0x36    byte[2]   (align)
0x38    (end)

Block 16: Heli

Special helicopter information, first 52 bytes are from vehicle block

OFFSET  TYPE      DESCRIPTION
0x00    BLOCK     vehicle (type= 0x10)
0x34    float     rotorSpeed
0x38    (end)


Block 17: Plane

Special plane information, first 52 bytes are from vehicle block

OFFSET  TYPE      DESCRIPTION
0x00    BLOCK     vehicle (type= 0x11)
0x34    float     propSpeed
0x38    float     field_0x9c8
0x3C    (end)

Block 18: Train

Special train information, first 52 bytes are from vehicle block

OFFSET  TYPE      DESCRIPTION
0x00    BLOCK     vehicle (type= 0x12)
0x34    float     speed
0x38    float     currentRailDistance
0x3C    float     length
0x40    DWORD     prevCarriageHandle
0x44    DWORD     nextCarriageHandle
0x48    byte      trackId
0x49    byte[3]   (align)
0x4C    (end)

Block 19: Clothes

This block contains information on the current clothes of the player. The block structure is identical to the one in the Player structure in a save file.

OFFSET  TYPE      DESCRIPTION
0x00    byte      type (0x13)
0x01    byte[3]   (align)
0x04    DWORD[10] modelCRCs
0x2C    DWORD[18] textureCRCs
0x74    WORD      Fat
0x76    WORD      Muscle;
0x78    (end)

Tools