Difference between revisions of "Saves (GTA 4)"

From GTAMods Wiki
Jump to navigation Jump to search
(Add Garage Block documentation)
m (Add flags description. Also made the description lowercase for consistency. Hexadecimal numbers are now uppercase)
Line 108: Line 108:
 
==== Block 3: Scripts ====
 
==== Block 3: Scripts ====
 
==== Block 4: Garages ====
 
==== Block 4: Garages ====
 +
 +
Stores garages defined in the game along with their stored vehicles.
 +
 +
The block starts with a 4 byte integer containing the size of it. The below data follows.
  
 
{|class="wikitable"
 
{|class="wikitable"
Line 114: Line 118:
 
!DESCRIPTION
 
!DESCRIPTION
 
|-
 
|-
| 0x0000 || uint32 || Garage Count
+
| 0x0000 || uint32 || garage count
 
|-
 
|-
 
| 0x0004 || uint8 || (unknown)
 
| 0x0004 || uint8 || (unknown)
 
|-
 
|-
| 0x0005 || uint8 || Resprays are free
+
| 0x0005 || uint8 || resprays are free
 
|-
 
|-
| 0x0006 || uint8 || Resprays are disabled
+
| 0x0006 || uint8 || resprays are disabled
 
|-
 
|-
 
| 0x0007 || uint32 || (unknown)
 
| 0x0007 || uint32 || (unknown)
 
|-
 
|-
| 0x000b || uint32 || Safehouse Garage Count
+
| 0x000B || uint32 || safehouse garage count
 
|-
 
|-
| 0x000f || StoredCar[20] || Stored Cars array
+
| 0x000F || StoredCar[20] || stored cars array
 
|-
 
|-
| 0x05a0 || Garage[40] || Garages array
+
| 0x05A0 || Garage[40] || garages array
 
|-
 
|-
 
|}
 
|}
Line 139: Line 143:
 
!DESCRIPTION
 
!DESCRIPTION
 
|-
 
|-
| 0x0000 || float[3] || Position (x, y, z)
+
| 0x0000 || float[3] || position (x, y, z)
 
|-
 
|-
| 0x000c || uint32 || Handling Flags
+
| 0x000C || uint32 || handling flags
 
|-
 
|-
| 0x0010 || uint16 || Model Index
+
| 0x0010 || uint16 || model index
 
|-
 
|-
| 0x0032 || uint8[4] || Colors
+
| 0x0032 || uint8[4] || colors
 
|-
 
|-
| 0x0038 || uint32 || Extra?
+
| 0x0038 || uint32 || extras
 
|-
 
|-
| 0x003c || uint32 || Livery
+
| 0x003C || uint32 || livery
 
|-
 
|-
| 0x0043 || uint8[3] || Rotation (x, y, z)
+
| 0x0043 || uint8[3] || rotation (x, y, z)
 +
|-
 +
| 0x0048 || uint16 || flags (see below)
 
|-
 
|-
 
|}
 
|}
 +
 +
''' flags - Bitfield '''
 +
* 0b00000'''1'''000 = Bullet proof
 +
* 0b0000'''1'''0000 = Fire proof
 +
* 0b000'''1'''00000 = Explosion proof
 +
* 0b00'''1'''000000 = Collision proof
 +
* 0b0'''1'''0000000 = Melee proof
 +
 
</div>
 
</div>
  
Line 163: Line 177:
 
!DESCRIPTION
 
!DESCRIPTION
 
|-
 
|-
| 0x0000 || uint8 || Type
+
| 0x0000 || uint8 || type
 
|-
 
|-
| 0x0001 || uint8 || Open State
+
| 0x0001 || uint8 || open state
 
|-
 
|-
| 0x0002 || uint8 || Door Flags
+
| 0x0002 || uint8 || door flags
 
|-
 
|-
| 0x0004 || float[3] || Position (x, y, z)
+
| 0x0004 || float[3] || position (x, y, z)
 
|-
 
|-
| 0x0016 || float[2] || Direction A (x, y)
+
| 0x0016 || float[2] || direction a (x, y)
 
|-
 
|-
| 0x0024 || float[2] || Direction B (x, y)
+
| 0x0024 || float[2] || direction b (x, y)
 
|-
 
|-
| 0x0032 || float || Top Z
+
| 0x0032 || float || top z
 
|-
 
|-
 
| 0x0036 || float || (unknown)
 
| 0x0036 || float || (unknown)
Line 181: Line 195:
 
| 0x0040 || float || (unknown)
 
| 0x0040 || float || (unknown)
 
|-
 
|-
| 0x0044 || float || Left coordinate
+
| 0x0044 || float || left coordinate
 
|-
 
|-
| 0x0048 || float || Right coordinate
+
| 0x0048 || float || right coordinate
 
|-
 
|-
| 0x0052 || float || Front coordinate
+
| 0x0052 || float || front coordinate
 
|-
 
|-
| 0x0056 || float || Back coordinate
+
| 0x0056 || float || back coordinate
 
|-
 
|-
 
| 0x0060 || uint32 || (unknown)
 
| 0x0060 || uint32 || (unknown)
 
|-
 
|-
| 0x0064 || uint32 || Garage name hash
+
| 0x0064 || uint32 || garage name hash
 
|-
 
|-
| 0x0068 || uint8 || Original type
+
| 0x0068 || uint8 || original type
 
|-
 
|-
| 0x0069 || uint8 || Safehouse garage index (if safehouse)
+
| 0x0069 || uint8 || safehouse garage index (if safehouse)
 
|-
 
|-
 
|}
 
|}

Revision as of 15:45, 10 February 2019

This article deals with the format of a save game file for the PC version of GTA 4.

Location

By default, the game places its save game files into the "%LocalAppData%\Rockstar Games\GTA IV\savegames\user_XXXXXXXXXXXXXXXX\" folder where XXXXXXXXXXXXXXXX is a 16-character string tied to the user's Games for Windows Live account.

The save files themselves are named in the format SGTA4XX where XX represents the in-game slot number. There are 12 slots available in the game (1-12) plus an additional auto-save slot (SGTA400).

Format Details

  • Save file size varies but is typically just under 2 megabytes.
  • Byte order is little endian. For example, the number 3452 (0x0D7C) is represented as as 0x7C 0x0D.
  • A savegame consists of 32 data blocks, two blocks with metadata and a checksum number.

Savegame Metadata

A savegame file starts with this block, which has a constant length of 0x110 bytes.

OFFSET TYPE DESCRIPTION
0x00 dword savegame version number
0x04 dword savegame size in bytes
0x08 dword global variables size (?)
0x0C char[4] "SAVE" string
0x10 wchar_t[128] Name of last mission passed
0x110 end

Notes:

  • Savegame version number value is set under the [SAVEGAME_VERSION_NUMBER] section in the GTA IV/common/data/version.txt file
  • Last mission name is prefixed with either "TLAD - " or "TBoGT - " for Episodes From Liberty City saves

Data Blocks

Each data block consists of the 5 characters BLOCK followed by a variable amount of data; in general, each block has its own unique internal format. Following the BLOCK character is always a dword specifying the size of the block, starting at the beginning of BLOCK characters.

Block 0: SimpleVars

OFFSET TYPE DESCRIPTION
0x00 char[5] a "BLOCK" string
0x04 dword size of block in bytes (always 0xB9)
0x09 dword start of data; see below
SimpleVars
OFFSET TYPE DESCRIPTION
0x00 byte[32] unknown data
0x20 dword length (ms) of in-game minute
0x24 dword weather timer (?)
0x28 dword in-game month
0x2C dword in-game day
0x30 dword in-game hours
0x34 dword in-game minutes
0x38 dword in-game day of week
0x3C byte[116] unknown data
0xB0 end

Block 1: PlayerInfo

This block has a constant length of 0xD4 bytes.

OFFSET TYPE DESCRIPTION
0x00 dword Size of block
0x04 byte[18] unknown
0x1C dword Player money
0x20 byte[4] unknown
0x24 dword Player money (Again. Perhaps one is amount shown on screen.)
0x28 byte[172] unknown
0xD4 end

Block 2: ExtraContent

Block 3: Scripts

Block 4: Garages

Stores garages defined in the game along with their stored vehicles.

The block starts with a 4 byte integer containing the size of it. The below data follows.

OFFSET TYPE DESCRIPTION
0x0000 uint32 garage count
0x0004 uint8 (unknown)
0x0005 uint8 resprays are free
0x0006 uint8 resprays are disabled
0x0007 uint32 (unknown)
0x000B uint32 safehouse garage count
0x000F StoredCar[20] stored cars array
0x05A0 Garage[40] garages array
StoredCar (72 bytes)
OFFSET TYPE DESCRIPTION
0x0000 float[3] position (x, y, z)
0x000C uint32 handling flags
0x0010 uint16 model index
0x0032 uint8[4] colors
0x0038 uint32 extras
0x003C uint32 livery
0x0043 uint8[3] rotation (x, y, z)
0x0048 uint16 flags (see below)

flags - Bitfield

  • 0b000001000 = Bullet proof
  • 0b000010000 = Fire proof
  • 0b000100000 = Explosion proof
  • 0b001000000 = Collision proof
  • 0b010000000 = Melee proof
Garage (72 bytes)
OFFSET TYPE DESCRIPTION
0x0000 uint8 type
0x0001 uint8 open state
0x0002 uint8 door flags
0x0004 float[3] position (x, y, z)
0x0016 float[2] direction a (x, y)
0x0024 float[2] direction b (x, y)
0x0032 float top z
0x0036 float (unknown)
0x0040 float (unknown)
0x0044 float left coordinate
0x0048 float right coordinate
0x0052 float front coordinate
0x0056 float back coordinate
0x0060 uint32 (unknown)
0x0064 uint32 garage name hash
0x0068 uint8 original type
0x0069 uint8 safehouse garage index (if safehouse)

Block 5: GameLogic

Block 6: PathFind

Block 7: Pickups

This block contains an array of 650 Pickup structures plus 9 bytes of padding. Each Pickup structure is a constant 0x54 bytes.

OFFSET TYPE DESCRIPTION
0x00 char[5] a "BLOCK" string
0x04 dword size of block in bytes (always 0xD55A)
0x09 Pickup[650] Pickups array
0xD551 byte[9] padding
Pickup
OFFSET TYPE DESCRIPTION
0x00 dword unknown
0x04 int32_t index (-1 indicates unused pickup)
0x08 dword unknown
0x0C dword unknown
0x10 dword amount (ammo, etc.)
0x14 dword unknown
0x18 dword unknown
0x1C dword unknown
0x20 dword unknown
0x24 float[3] location (x,y,z)
0x30 dword unknown
0x34 dword unknown
0x34 dword unknown
0x38 float unknown
0x3C dword unknown
0x40 float unknown
0x44 dword unknown
0x48 uint16_t object ID
0x4A uint16_t reference number
0x4C uint8_t pickup type
0x4D uint8_t flags
0x4E word unknown
0x50 dword unknown
0x54 (end)

Block 8: Restart

Block 9: Radar

Block 10: Zones

Block 11: Gangs

Block 12: CarGenerators

This block stores Car Generators managed by scripts in GTA 4. This includes mission rewards and boats or helicopters disabled before Algonquin and Alderney are unlocked.

OFFSET TYPE DESCRIPTION
0x0000 CarGenerator[25] Car Generators array (see below)
0x044C Unknown[15] Unknown is 16 bytes each
CarGenerator
OFFSET TYPE DESCRIPTION
0x0000 float[3] Position of the Parked Vehicle
0x000C float[2] Rotation (X,Y)
0x0014 float[2] Unknown (has something to do with Z rotation)
0x001C uint16_t Model ID
0x001E uint16_t Pool index (normally always 0)
0x0022 uint8_t Color 1
0x0023 uint8_t Color 2
0x0024 uint8_t Color 3
0x0025 uint8_t Color 4
0x0026 uint8_t[5] Unknown (flags)
0x002B uint8_t Enabled (0 = disabled, 101 = enabled)

Block 13: Stats

This block has a constant length of 0x1724 bytes and stores various statistics; most of which can be viewed the game's Stats menu.

OFFSET TYPE DESCRIPTION
0x00 dword Size of block
0x04 byte[80] unknown stats
0x54 float game_progress (GTA IV main story only. TLAD and TBoGT variables are below.)
0x58 float roman_like
0x5C float roman_respect
0x60 float roman_mission_progress
0x64 float vlad_mission_progress
0x65 float jacob_like
0x6C float jacob_respect
0x70 float jacob_mission_progress
0x74 float faustin_mission_progress
0x78 float manny_mission_progress
0x7C float elizabeta_mission_progress
0x80 float dwayne_like
0x84 float dwayne_respect
0x88 float dwayne_mission_progress
0x8C float brucie_like
0x90 float brucie_respect
0x94 float brucie_mission_progress
0x98 float playboy_mission_progress
0x9C float francis_mission_progress
0xA0 float ulpc_mission_progress
0xA4 float packie_like
0xA8 float packie_respect
0xAC float packie_mission_progress
0xB0 float ray_mission_progress
0xB4 float gerry_mission_progress
0xB8 float derrick_mission_progress
0xBC float bernie_mission_progress
0xC0 float bell_mission_progress
0xC4 float gambetti_mission_progress
0xC8 float jimmy_mission_progress
0xCC float carmen_ortiz_fondness
0xD0 float carmen_trust
0xD4 float alex_chilton_fondness
0xD8 float alex_trust
0xDC float kiki_jenkins_fondness
0xE0 float kiki_trust
0xE4 float michelle_fondness
0xE8 float michelle_trust
0xEC float kate_fondness
0xF0 float kate_trust
0xF4 byte[93] unknown stats
0x268 float tlad_game_progress
0x26C byte[53] unknown stats
0x340 float tbogt_game_progress
0x344 byte[65] unknown stats
0x448 dword missions_passed
0x44C dword missions_failed
0x450 dword missions_attempted
0x454 dword replays_used
0x458 dword people_killed
0x45C dword taxi_fares_completed
0x460 dword times_cheated
0x464 dword days_passed
0x468 dword times_died
0x46C dword people_run_down
0x470 dword vehicles_exploded
0x474 dword flips_done_in_vehicle
0x478 dword most_vehicle_air_spins
0x47C dword air_launches
0x480 dword helicopter_tours_taken
0x484 dword taxis_hailed
0x488 dword stunt_jumps_found
0x48C dword stunt_jumps_completed
0x490 dword kills_since_last_save
0x494 dword fires_started
0x498 dword criminals_killed
0x49C dword cars_stolen
0x4A0 dword bikes_stolen
0x4A4 dword boats_stolen
0x4A8 dword helicopters_stolen
0x4AC dword stars_attained
0x4B0 dword stars_evaded
0x4B4 dword vehicles_exported
0x4B8 dword bridges_flown_under
0x4BC dword paynspray_visits
0x4C0 dword times_got_drunk
0x4C4 dword drug_packages_delivered
0x4C8 dword cars_sold_to_stevie
0x4CC dword random_characters_met
0x4D0 dword bullets_fired
0x4D4 dword bullets_hit
0x4D8 dword kills_by_headshot
0x4DC dword melee_kills
0x4E0 dword armed_kills
0x4E4 dword __stat
0x4E8 dword __stat
0x4EC dword cars_exploded
0x4F0 dword bikes_exploded
0x4F4 dword boats_exploded
0x4F8 dword helicopters_exploded
0x4FC dword tires_popped_by_gunshot
0x500 dword weapons_pickedup
0x504 dword texts_received
0x508 dword calls_made_on_phone
0x50C dword calls_received_on_phone
0x510 dword prostitute_visits
0x514 dword tramps_given_money_to
0x518 dword emails_sent
0x51C dword meals_eaten
0x520 dword hotdogs_eaten
0x524 dword burgers_eaten
0x528 dword nuts_eaten
0x52C dword binoculars_used
0x530 dword player_died_by_melee
0x534 dword player_shot_to_death
0x538 dword player_was_blown_up
0x53C dword player_was_roadkill
0x540 dword scored_with_girl
0x544 dword pool_wins
0x548 dword pool_defeats
0x54C dword pool_clearances_from_break
0x550 dword darts_wins
0x554 dword darts_defeats
0x558 dword darts_180s_hit
0x55C dword darts_bullseyes
0x560 dword darts_shortest_checkout
0x564 dword bowling_high_score
0x568 dword bowling_wins
0x56C dword bowling_draws
0x570 dword bowling_defeats
0x574 dword bowling_spares
0x578 dword bowling_perfects
0x57C dword bowling_strikes
0x580 dword total_races_lost
0x584 dword total_races_won
0x588 dword south_broken_wins
0x58C dword south_broker_races
0x590 dword airport_run_wins
0x594 dword airport_run_races
0x598 dword dukes_blvd_wins
0x59C dword dukes_blvd_races
0x5A0 dword south_algonquin_wins
0x5A4 dword south_algonquin_races
0x5A8 dword star_junction_wins
0x5AC dword star_junction_races
0x5B0 dword road_to_bohan_wins
0x5B4 dword road_to_bohan_races
0x5B8 dword north_alderny_wins
0x5BC dword north_alderny_races
0x5C0 dword elevated_wins
0x5C4 dword elevated_races
0x5C8 dword south_alderny_wins
0x5CC dword south_alderny_races
0x5D0 dword qub3d_high_score
0x5D4 dword boating_destinations
0x5D8 dword heli_ride_destinations
0x5DC dword activities_with_roman
0x5E0 dword activities_with_jacob
0x5E4 dword activities_with_brucie
0x5E8 dword activities_with_dwayne
0x5EC dword activities_with_packie
0x5F0 dword vigilante_levels_done
0x5F4 dword most_wanted_completed
0x5F8 dword pigeons_exterminated
0x5FC dword first_aid_collected
0x600 dword islands_unlocked
0x604 dword total_dates
0x608 dword successful_dates
0x60C dword bad_dates
0x610 dword girls_dumped
0x614 dword emails_received
0x618 dword photos_taken
0x61C dword mocap_cutscenes_skipped
0x620 dword mocap_cutscenes_watched
0x624 dword cutscenes_skipped
0x628 dword cutscenes_watched
0x62C dword sodas_drunk
0x630 dword kills_with_unarmed
0x634 dword kills_with_baseball_bat
0x638 dword kills_with_poolcue
0x63C dword kills_with_knife
0x640 dword kills_with_grenade
0x644 dword kills_with_molotov
0x648 dword kills_with_rocket
0x64C dword kills_with_pistol
0x650 dword kills_with_combat_pistol
0x654 dword kills_with_pump_shotgun
0x658 dword kills_with_combat_shotgun
0x65C dword kills_with_micro_smg
0x660 dword kills_with_smg
0x664 dword kills_with_assault_rifle
0x668 dword kills_with_carbine_rifle
0x66C dword kills_with_combat_sniper
0x670 dword kills_with_sniper_rifle
0x674 dword kills_with_rpg
0x678 dword kills_with_flame_thrower
0x67C dword kills_with_minigun
0x680 dword kills_with_episodic_1
0x684 dword kills_with_episodic_2
0x688 dword kills_with_episodic_3
0x68C dword kills_with_episodic_4
0x690 dword kills_with_episodic_5
0x694 dword kills_with_episodic_6
0x698 dword kills_with_episodic_7
0x69C dword kills_with_episodic_8
0x6A0 dword kills_with_episodic_9
0x6A4 dword kills_with_episodic_10
0x6A8 dword kills_with_episodic_11
0x6AC dword kills_with_episodic_12
0x6B0 dword kills_with_episodic_13
0x6B4 dword kills_with_episodic_14
0x6B8 dword kills_with_episodic_15
0x6BC dword kills_with_episodic_16
0x6C0 dword kills_with_episodic_17
0x6C4 dword kills_with_episodic_18
0x6C8 dword kills_with_episodic_19
0x6CC dword kills_with_episodic_20
0x6D0 dword kills_with_episodic_21
0x6D4 dword kills_with_episodic_22
0x6D8 dword kills_with_episodic_23
0x6DC dword kills_with_episodic_24
0x6E0 dword times_busted
0x6E4 dword saves_made
0x6E8 byte[4156] unknown stats
0x1724 end

Block 14: IplStore

Block 15: StuntJumps

OFFSET TYPE DESCRIPTION
0x00 dword Size of block
0x04 byte[5] unknown
0x09 dword number of stunt jumps
0x0E byte[4] unknown
0x11 start of stunt jump structs (0x64 bytes each; see below)
StuntJump
OFFSET TYPE DESCRIPTION
0x00 byte unknown
0x01 byte id
0x02 byte[2] unknown, maybe padding/align
0x04 float[3] Start zone point 1 (x,y,z)
0x10 byte[4] unknown
0x14 float[3] Start zone point 2 (x,y,z)
0x20 byte[4] unknown
0x24 float[3] Land zone point 1 (x,y,z)
0x30 byte[4] unknown
0x34 float[3] Land zone point 2 (x,y,z)
0x40 byte[4] unknown
0x44 float[3] Camera coordinates (x,y,z)
0x50 byte[4] unknown
0x54 dword Reward ammount
0x58 byte is completed
0x59 byte is found
0x5A byte[10] unknown, maybe align/padding

Block 16: Radio

Block 17: Objects

Block 18: Relationships

Block 19: Inventory

Block 20: Pools

Block 21: PhoneInfo

Block 22: AudioScriptObject

Block 23: SetPieces

Block 24: Streaming

Block 25: PedType

Block 26: Tags

Block 27: Shopping

Block 28: GangWars

Block 29: EntryExits

Block 30: 3dMarkers

Block 31: Vehicles

Checksum

After the last data block the checksum value goes. The checksum appears to be the sum of most of the bytes preceding it, however, which bytes exactly is unknown (See discussion).

End Block

This block has a constant length of 0x16C bytes. Data in this block appears to relate to Games For Windows Live data.

OFFSET TYPE DESCRIPTION
0x00 char[4] END\0
0x04 dword Unknown, appears to always be 0x128
0x08 byte[292] Unknown, appears to always be a mix of 0x0, 0x1, 0x2 and 0x3 bytes
0x12C byte[64] Unknown
0x16C end