Quantcast
Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    2. News

    1. Red Dead Redemption 2

      1. News
      2. Red Dead Online
      3. The Armadillo Inn
    1. GTA Online

      1. After Hours
      2. Find Lobbies & Players
      3. Guides & Strategies
      4. Vehicles
      5. Content Creator
      6. Help & Support
    2. Crews

      1. Events
      2. Recruitment
    1. Grand Theft Auto Series

    2. GTA Next

    3. GTA V

      1. PC
      2. Guides & Strategies
      3. Help & Support
    4. GTA IV

      1. Episodes from Liberty City
      2. Multiplayer
      3. Guides & Strategies
      4. Help & Support
      5. GTA Mods
    5. GTA Chinatown Wars

    6. GTA Vice City Stories

    7. GTA Liberty City Stories

    8. GTA San Andreas

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    9. GTA Vice City

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    10. GTA III

      1. Guides & Strategies
      2. Help & Support
      3. GTA Mods
    11. Top Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    12. Wiki

      1. Merchandising
    1. GTA Modding

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    3. Featured Mods

      1. DYOM
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Red Dead Redemption

    2. Rockstar Games

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Programming
      5. Movies & TV
      6. Music
      7. Sports
      8. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Forum Support

    2. Site Suggestions

thehambone

GTA III Save File Documentation

Recommended Posts

OrionSR

I'm hoping that the documentation will reflect the natural structure and terminology of a template as closely as possible. However, data structures, particularly arrays, should always start at 0x00. I think I'm finally going to have to pop for the 010 editor if I'm really going to get a grasp on this. I'm working on a bracket formula that I hope can fully explain the save structure. What I've got so far seems to want to include the initial block size dword as part of the save, and not part of the block. This is consistent with the data size as external to the data, and how BLOCK markers were not included as part of blocks in SA. By extension, the checksum got pushed outside of the save; it's part of the file so it can operate on the entire save.

 

File = [save]+checksum

Save = series of end of block offsets/markers + blocks followed by slack

Blocks include header with optional class structures + data sub-block size + data sub-block

Data sub-blocks include a header with optional class structures + size of data pool + data pool

Data pools can be a free form series of class structures and arrays (and data bubbles?).

 

Data bubbles - I'm looking at those threads with data sizes, but not end of block offsets. I was thinking it would be easier to handle these as part of an array except... What would happen if I saved during a mission, tweaked the wake timer to prevent crashing, and then launched another thread? Bubbles; what else would be contained in a pool?

 

As you can tell I am struggling mightily to find the proper terms and concepts. Please discuss and advise.

 

Data bubble - here, hold this chunk of memory and don't worry about what it is.

Array - a series of identical class records serving the same purpose.

 

Class structure - I don't know. It sounds cool. What I'm getting at is that blocks, headers, and data pools don't (in my mind's eye) contain any fields on their own. For example. I'm looking at System Info and Miscellaneous as two class structures within the block 1 header on PC saves. For PS2 I could disable the system info class since it isn't used.

 

Limits, the hardcoded values that directly effect the structure of the save. It occurs to me that someone may adjust these limits and break our editor. Wouldn't it be cool if the editor could read configuration files from a limits adjuster mod to account for the changes in the save? Limits do change without mods. SA Mobile v1.06 has 75 more radar blips than previous versions. Anyway, I don't think there's anything practical we can do about this now other than keep tabs on the limits and perhaps mark them for easy retrieval later.

Edited by OrionSR

Share this post


Link to post
Share on other sites
OrionSR

Added: The data pool of ped block 2 is 6 bytes less than the block with nothing in the header, which leaves 2 stray bytes in the block at the end of the data pool. So size of data seems to be more accurate than offset to end of block or next block. This block has me baffled. Maybe I'll have more luck with phones.

 

Quick and dirty work up of the object block.

 

How are three magnets getting in the save before the SCM kicks in?

Object Block0x00 dword block size    0x00 dword data size        0x00 dword  object count        0x04 Object Structures[count] 84 bytes            0x00    word        model ID            0x02    byte        unknown (flag? remove from cleanup?)            0x03    word        handle?            0x05    byte        unknown (align?)            0x06    float[3]    x,y,z coordinate            0x12    byte[3]     CXYZ.right.xyz            0x15    byte[3]     CXYZ.top.xyz            0x18    byte[2]     unknown (align?)            0x1A    dword       unknown (0x715CE4)            0x1E    float       unknown (sometimes 125.0, once 120.0)            0x22    float[3]    unknown (xyz coords)            0x2E    byte[3]     unknown (CXYZ.right.xyz)            0x31    byte[3]     unknown (CXYZ.top.xyz)            0x34    byte[2]     unknown (align?)            0x36    dword       unknown (0x715CE4)            0x3A    byte        unknown (flag? always 2?)            0x3B    byte        unknown (flag? sometimes 1)            0x3C    byte[6]     unknown            0x42    float       unknown (always 1.0?)            0x46    byte        unknown            0x47    byte        unknown (flag? 0, or 4 if 0x3B=0)            0x48    byte[4]     unknown            0x4C    byte        unknown (0x24)            0x4D    byte        unknown (4, sometimes 5)            0x4E    byte        unknown (6, twice 0x16)            0x4F    byte        unknown             0x50    byte        unknown (0x80 a couple of times)            0x51    byte        unknown (sometimes 1, special w/0x5C)             0x52    byte        unknown (special w/0x78)            0x53    byte        unknown (special w/0x01)
Phone Block0x00 block size    0x00 data size        0x00    dword   phone count (installed through IPL) [49]        0x04    dword   active phones (024A:) shuffled to top [8]        0x08    phone structures[50]            0x00    float[3]    xyz coords            0x0C    byte[28]    unknown            0x28    byte[2]     unknown (data)            0x2A    byte[2]     unknown            0x2C    dword       phone status (0=inactive,3=idle,9=ringing (all observed) ? from VC docs)            0x30    bytes[4]    unknown(flags, float?) 
Player Info Block0x00 dword block size    0x00 dword data size        0x00 	dword    current money        0x04    byte     unknown (is busted or wasted flag?)        0x05    dword    unknown (data)        0x09    word     unknown (data)        0x09    float    unknown (data)        0x0F 	dword    currently displayed money        0x13 	dword    number of packages picked up        0x17 	dword    total number of packages (02ED)        0x1B 	byte     infinite run (0330) [set]        0x1C 	byte 	 fast reload? (0331 not in III) [not seen]         0x1D 	byte 	 fireproof? (055D not in III) [set]        0x1E    byte[70] unknown        0x64    slack from AUD
Edited by OrionSR

Share this post


Link to post
Share on other sites
thehambone

Do the key press opcodes work in III?

Thanks for the updated script. You have to use opcode 05EE for keypresses in III and VC.

 

 

One clear thing is that before any struct there is a DWORD value of its size. Should this value be a part of the struct itself (as I described in the GTAModding article), or be out of it, directly preceeding, which I stick to in the 010 template?

I think the DWORD size should precede the struct it is describing.

 

 

The data pool of ped block 2 is 6 bytes less than the block with nothing in the header, which leaves 2 stray bytes in the block at the end of the data pool. So size of data seems to be more accurate than offset to end of block or next block. This block has me baffled. Maybe I'll have more luck with phones.

I would just call those last 2 bytes align bytes then.

 

Orion:

I like the way you organized the data in your last post. I think I'm going to use that format for the OP.

Here is a 100% gamesave that I got from gtagaming (there's no "110% completion" in this game like SA).

Here is a brand new gamesave that I created after loading up the 100% gamesave.

Here is a brand new gamesave that I created after exiting and relaunching the game (thus resetting the game's memory).

 

I really like 010 Editor; it makes it much easier to visualize the structure of the gamesave. I made my own template for the save structure and added most of the documented data structures as well as garages, gangs, cargens, and stats structs. You can find my template here (link removed). Seemann, you can copy the new structs from my template and add them to yours if you wish (I'm not trying to replace your template :)).

 

Lastly, the link to my checksum calculator can be found in my previous post.

Edited by thehambone

Share this post


Link to post
Share on other sites
OrionSR

Thanks, I got the saves.

 

I would just call those last 2 bytes align bytes then.

Yes, but at which level should they be called. If it's part of the ped structure then there will be an unaccounted word if, for some odd reason, you had two players in the save. Fortunately Seemann has worked up that baffling structure enough for me to risk tweaking a little. But I gotta tell ya, it still makes me really nervous to modify Seemann's notes. I'm not terribly confident of the accuracy of table below; it is intended to show the concepts but I haven't fully mapped it out.

0x0000 	dword 	block size0x0004    block[]    0x0000 	dword 	data size    0x0004        data []         0x0000 	dword 	players count (n)        0x0004 	PlayerPed[n] 	player peds array            0x0000 	dword 	unknown            0x0004 	word 	unknown            0x0006 	dword 	(unknown) ped reference            0x000A 	CPed 	CPed dump (0x5F0 bytes)            0x05FA 	dword 	max wanted level            0x05FE 	dword 	max chaos level            0x0602 	char[24]    model name//  0x0622        byte[2]  unknown(align) for n=1    [relative size by n] byte[2]  unknown(align)

I continue to be frustrated trying to name the container layers appropriately.

File[save[block[Header[],sub-block[sub-header[],(data) pool[(data) thread or packet instead of bubble?[]]]]]]


So... the stuff in italics is what I'm not clear on. I didn't like sub-block until I typed sub-header, now I'm not so sure. Pool seems to work. Does the term conflict with common "pool" concepts? Data threads meant to describe anything in a data pool that is declared by a data size marker, and so far that seems to just be threads. No hurry on that one but I would like to start using consistent descriptions for the rest. Any thoughts or suggestions?

I'm not sure what I should do next. I'm tempted to splurge for 010. But if I do that I suspect it will take a while before I can get a handle on it. And I get the impression that my rough outlines are helping you guys out a lot with the templates and docs as these blocks seem to be getting first priority for refinement. Or maybe Seemann just doesn't want my errors lingering around - I'm actually quite happy so many of my guesses have been reasonably close. But then again, I'm running out of low hanging fruit; the remaining blocks are either complex or unfamiliar. What do you need from me to make your tasks easier?

Crane Block: I made a little progress on cranes but... I don't remember what they do. There seem to be more cranes in the save than are created by main but I figure they might be getting installed via IPL and the create code makes a script around it, like the phones, maybe. Can you explain the behavior of the cranes and how that might be related to all the X/Y pairs? Relevant opcodes in the table below for reference on what to hunt for.

0368: create_ev_crane 1570.25 -675.375 1565.688 -686.5 1576.75 -706.5625 1639.875 -696.6875 26.0 0.0 02FB: create_crusher_crane 1119.75 51.75 1135.75 56.0625 1149.75 46.25 1143.0 59.875 5.0 180.0 03EC:   ev_crane_collected_all_cars01EF: deactivate_crane 1570.25 -675.37501EE: activate_crane 1570.25 -675.375 1638.688 -687.0625 1647.875 -700.0625 1571.063 -696.5 16.0 0.083A0:   not car $CAR_WITH_CORPSE picked_up_by_crane 1120.0 46.0
Edited by OrionSR

Share this post


Link to post
Share on other sites
Seemann

Those two bytes in block2 is not a part of the PlayerPed struct. I created more players to check it and got the following numbers:

 

For two players:

 

block2 : 3132 bytes  dword size : 4 bytes  inner block : 3128 bytes(no align required)
For three players:

 

block2 : 4696 bytes  dword size : 4 bytes  inner block : 4690 bytes  (align 2 bytes)
Thus align bytes added only when the players number is odd. I've updated the template. Edited by Seemann

Share this post


Link to post
Share on other sites
thehambone

This repeating starts from the offset 5244 of the block1, which is the place for the global variable $1260 (0xCC + 0x1260*4 = 0x147C = 5244).

 

So, 244 bytes in the end of the garages block contains global variables values from $1260 to $1321.

So, based on the math that you did here, is it possible to map out the global variables in block 1?

Share this post


Link to post
Share on other sites
Seemann

Not sure what you mean. Global variables block starts at 0xCC in block 1. Each variable takes 4 bytes, so doing simple math it's possible to find out a variable's offset. (i.e. for $2 : 2 * 4 + 0xCC = 0xD4).

 

On a side note: I reworked the 010 template, each block now has a preceding size and align bytes if necessary.

 

added block14: Car Generators.

Edited by Seemann

Share this post


Link to post
Share on other sites
OrionSR
Thus align bytes added only when the players number is odd.

 

Although I don't believe there remains any confusion about the location of these bytes I feel it is important to search for a description that does not involve an exception. My goal is to form an overall theory of save files that's as simple as possible, so a single statement that explains all blocks is better than a bunch of special cases. My block hypothesis needs to be adjusted in light of this new information. How about?

 

A block always includes a header with optional records, a sub-block size marker, the sub-block, and any alignment bytes required for a doubly even block length.

 

A crude clarification: the block size must be a multiple of 4 so it doesn't end in the middle of a dword. And, this is a testable hypothesis but it remains to be seen if it holds true for all cases. Still, I feel this was an important refinement, much more than I was expecting from an idle observation of an odd a singly even sub-block size.

 

Again, is there something in particular that you guys want me to work on?

Edited by OrionSR

Share this post


Link to post
Share on other sites
Seemann

This is how a save file look like now

Kuk0aoP.png

 

I think it's the optimal solution at the moment. The file consists of 20 data blocks, each of them has a size value and align bytes at the end (not for all, only some of them). It's nicely produced by the following format:

 

struct {   DWORD size;   ...data...   byte[size-sizeof(data)] align; } block [20];
the padding blocks are located after the 20th block, each of them is up to 55,000 bytes of length, there could be up to 4 padding blocks. they make the file size to be exactly 201820 bytes.

 

Orion, I'm not in position to give you any orders or make you do something particular, it's just collaboration. It's not my own project and personally I'm contributing to it with some exe researching, it's kind of thing I'm doing well.

 

But if you want my opinion I would love to see someone to help describe all those structures in the wiki article.

 

 

Edit: I've added Block 7: cranes in the template.

Edit2: Added Block 13: gangs.

Edited by Seemann

Share this post


Link to post
Share on other sites
spaceeinstein

Wow, it's great to see so much activity on this! In the GTAModding doc, should block sizes be still listed within the blocks or outside of it? Or does it need revising?

 

Some more for the player info block:

[table]

0x1B byte infinite run (0330)

 

0x1C byte fast reload (0331)

 

0x1D byte get out of jail free (0413)

 

0x1E byte free health care (0414) [/table]

0331 exists in GTA III but I think guns with animations weren't designed to handle it. Try using a sniper rifle and rocket launcher with it.

Edited by spaceeinstein

Share this post


Link to post
Share on other sites
Seemann

space, check this out: https://github.com/x87/gta/blob/master/formats/gta3save.bt

 

I guess we worked out a consensus to move sizes out of blocks. The wiki's article is still inaccurate on this.

More than it, the whole structure of a save file is not linear, there are much nested blocks which have its own size value preceeding. The article should reflect it too.

Edited by Seemann

Share this post


Link to post
Share on other sites
spaceeinstein

It looks like indenting is the best way to document this. It looks really nice in your template file. I'm trying out an indentation system using divs around tables on the VC doc. Do you think it's a good approach?

Share this post


Link to post
Share on other sites
Seemann

Yeah, I like new indent style. Except the border lines, I think they are unnecessary.

 

Edit: added block 9: phones, guess it's valid for Vice City too.

Edited by Seemann

Share this post


Link to post
Share on other sites
thehambone

Not sure what you mean. Global variables block starts at 0xCC in block 1. Each variable takes 4 bytes, so doing simple math it's possible to find out a variable's offset. (i.e. for $2 : 2 * 4 + 0xCC = 0xD4).

Either way, you answered what I was asking, lol. Thanks!

 

Again, is there something in particular that you guys want me to work on?

I'm more than glad that all of you guys have been helping me out with this -- I would've never figured out some of this stuff by myself. That aside, I'm in no hurry to get this thing fully documented. I would say just pick a block and start digging in! Blocks that I might have trouble understanding right away include Vehicle Pool, Object Pool, Path Find, Particle Objects, and Streaming.

 

It looks like indenting is the best way to document this. It looks really nice in your template file. I'm trying out an indentation system using divs around tables on the VC doc. Do you think it's a good approach?

I think the indentation looks good; it makes it a lot easier to visualize how the file is arranged.

 

I'm contributing to it with some exe researching, it's kind of thing I'm doing well.

Off topic: Frankly, I wish I knew how to do that. Its something I hope to learn eventually.

 

Purple Nines Glitch

I think I've figured out how to fix the Purple Nines glitch on affected saves. Based on Seemann's notes, each gang structure is arranged in the following way in the save file:

 

0x00  dword  vehicle ID0x04  byte   ped model override (opcode 0410)0x05  byte   (?)0x06  word   (?)0x08  dword  primary weapon ID0x0C  dword  secondary weapon ID
According to main.scm, the only gang that utilizes the "ped model override" opcode are the Hoods after the mission "Rumble."

 

0410: override_gang_model 6 0
-1 spawns both Purple Nines and Red Jacks, 0 spawns only Red Jacks, 1 spawns only Purple Nines.

So I loaded up the 100% save that I linked in a previous post and saw that the "ped model override" flag for the hoods was set to 0 as expected. Then I loaded up the new gamesave that was branched off from the 100% game save (which is how the glitch starts) and saw the the "ped model override" flag was still set to 0 when it should be set to -1. So simply changing this byte to -1 (0xFF) fixes the glitch.

 

Updating OP

So I've decided I'm not going to keep the OP updated and instead put focus on putting everything on GTAModding. That way we're 1) not dealing with two concurrent "documents" and 2) anyone can edit the GTAModding page, so it's easy to make corrections. Please continue to post your findings on here though!

 

Block 18: Stats

I've mapped out a good portion of the stats block:

 

 

 

Block 18: Player Stats0x0000  dword      block size                 // constant 0x01A4 (420)0x0004  [105]      stats (defined below)    Stats    0x0000  dword   people youve wasted    0x0004  dword   people wasted by others    0x0008  dword   cars exploded    0x000C  dword   unknown                   // related to bullets fired; not shown in stats menu    0x0010  dword   unknown    0x0014  dword   unknown    0x0018  dword   unknown    0x001C  dword   unknown    0x0020  dword   civmale youve wasted      // not shown in stats menu    0x0024  dword   civfemale youve wasted    // not shown in stats menu    0x0028  dword   cop youve wasted          // not shown in stats menu    0x002C  dword   gang1 youve wasted        // Mafia; not shown in stats menu    0x0030  dword   gang2 youve wasted        // Traids; not shown in stats menu    0x0034  dword   gang3 youve wasted        // Diablos; not shown in stats menu    0x0038  dword   gang4 youve wasted        // Yakuza; not shown in stats menu    0x003C  dword   gang5 youve wasted        // Yardies; not shown in stats menu    0x0040  dword   gang6 youve wasted        // Colombians; not shown in stats menu    0x0044  dword   gang7 youve wasted        // Hoods; not shown in stats menu    0x0048  dword   gang8 youve wasted        // unused; not shown in stats menu    0x004C  dword   gang9 youve wasted        // unused; not shown in stats menu    0x0050  dword   emergency youve wasted    // not shown in stats menu    0x0054  dword   fireman youve wasted      // not shown in stats menu    0x0058  dword   criminals wasted    0x005C  dword   pedtype 19 youve wasted   // not shown in stats menu (which peds are these?)    0x0060  dword   prostitute youve wasted   // not shown in stats menu    0x0064  dword   special youve wasted      // not shown in stats menu    0x0068  dword   unknown    0x006C  dword   helicopters destroyed    0x0070  dword   unknown                   // activities completed?    0x0074  dword   unknown                   // seems to always be 154 (total activities?)    0x0078  dword   kgs of explosives used    0x007C  dword   bullets fired    0x0080  dword   bullets that hit    0x0084  dword   cars crushed    0x0088  dword   unknown    0x008C  dword   unknown    0x0090  dword   unknown    0x0094  dword   unknown    0x0098  dword   mm rain fallen    0x009C  float   unknown    0x00A0  float   unknown    0x00A4  dword   unknown    0x00A8  dword   unknown    0x00AC  dword   unknown    0x00B0  dword   unique jumps completed    0x00B4  dword   total unique jumps        // always 20    0x00B8  dword   mission attempts    0x00BC  dword   missions passed    0x00C0  dword   passengers dropped off    0x00C4  dword   cash made in taxi    0x00C8  dword   unknown    0x00CC  dword   unknown    0x00D0  dword   unknown    0x00D4  dword   best 'Turismo' time in secs    0x00D8  float   unknown    0x00DC  float   unknown    0x00E0  dword   'Patriot Playground' in secs    0x00E4  dword   'A Ride in the Park' in secs    0x00E8  dword   'Gripped!' in secs    0x00EC  dword   'Multistorey Mayhem' in secs    0x00F0  dword   people saved in an Ambulance    0x00F4  dword   criminals killed on 'Vigilante' mission    0x00F8  dword   highest 'Paramedic' mission level    0x00FC  dword   total fires extinguished    0x0100  dword   longest flight in Dodo    0x0104  dword   best time for bomb defusal    0x0108  dword   rampages completed    0x010C  dword   total rampages            // always 20    0x0110  dword   total missions            // always 73    0x0114  dword   unknown    0x0118  dword   unknown    0x011C  dword   unknown    0x0120  dword   unknown    0x0124  dword   unknown    0x0128  dword   unknown    0x012C  dword   unknown    0x0130  dword   unknown    0x0134  dword   unknown    0x0138  dword   unknown    0x013C  dword   unknown    0x0140  dword   unknown    0x0144  dword   unknown    0x0148  dword   unknown    0x014C  dword   unknown    0x0150  dword   unknown    0x0154  dword   'Bling-bling Scramble' most checkpoints    0x0158  dword   'Diablo Destruction' gang cars totalled    0x015C  dword   'Mafia Massacre' gang cars totalled    0x0160  dword   'Casino Calamity' gang cars totalled    0x0164  dword   'Rumpo Wrecker' gang cars totalled    0x0168  dword   unknown    0x016C  dword   unknown    0x0170  dword   unknown    0x0174  dword   unknown    0x0178  dword   unknown    0x017C  dword   unknown    0x0180  dword   unknown    0x0184  dword   unknown    0x0188  dword   unknown    0x018C  dword   unknown    0x0190  dword   unknown    0x0194  dword   unknown    0x0199  dword   unknown                   // related to kills    0x019C  char[4] unknown    0x01A0  dword   unknown    0x01A4  dword   unknown                   // seems to always be 204

 

A lot of the unknowns near the end seem to always be 0, so I'm thinking those are unused.

Edited by thehambone

Share this post


Link to post
Share on other sites
Seemann

 

I'm contributing to it with some exe researching, it's kind of thing I'm doing well.

Off topic: Frankly, I wish I knew how to do that. Its something I hope to learn eventually.

 

Learn IDA, which is the best tool ever, there's a free version available. I'm hosting disassembled exes for all GTA's on my site (mainly done by listener), also you can find a lot of information about reverse engeneering on sannybuilder's forums (requires google translate).

 

 

Purple Nines Glitch

I think I've figured out how to fix the Purple Nines glitch on affected saves.

Nice find. I could explain it even more: the game only does reset gang car models at new game start, all other fields remain the same (including ped override model and weapon ids). Weapon ids are set in the main.scm then, so only ped override model stays untouched (with a value loaded from the latest save file).

Share this post


Link to post
Share on other sites
OrionSR

Wow, these controls are going to take some time to become familiar again. But good news! I found my old disks and III is working, cleo is installed, and the savescreen mod has been adapted so I guess I'm good to go with test scripts. The bad news is that my VC disk is refusing to authenticate. No matter at the moment. The crane puzzle had me frustrated enough that I needed to take a look to figure out what's going on in the game. Hey, ham! What coords hud are you using? So... I'll call that good enough progress for the day.

 

And I've made a decision on what to do next. I want to get started with 010 while there are still some undocumented structures to puzzle over and see how it works. I don't think I'll ever been in sync with Seemann until I get comfortable with the template. And the information I think will help me most is a complete outline of the whole save and this is progress in that direction.

 

Eventually I want to tackle the radar pool since that structure is poorly documented for SA and I'd like to become more familiar with it. Might not be a good place to start though. Zones? Should be simple but huge. Maybe I'll go back to cranes. It shouldn't be too tough if 010 will auto-convert the hex floats for me now that I can run in-game tests with cleo. Anyway, that's the direction I'm headed for anyone that would like to join or diverge efforts.

 

I would very much like to see an indent format used in the wiki. I like the strategy of updating only the wiki and would like to suggest that the OP be used to track our progress. I think the current wiki documentation should be designed toward quick and easy large scale editing with little effort made to make it pretty for the public until we have a better idea of what it's finally going to look like.

 

Should we stick with the traditional byte, word, and dword descriptions or make the switch to the format used in 010 templates?

 

Seemann. My observation is that if I rough out a block you'll follow up with an enhancement and the result is amazing progress. So I'm thinking, that was fun, let's do it again. But I am unsure of my role in the process. (How) do the outlines help you?

 

hambone, good job on the purple nines glitch. How can this glitch be fixed with cleo? Glitch detection and repair was a rewarding side project of the SA save file investigation. Are there common III glitches that haven't been solved?

 

Space, I didn't find 0331 fast reload when I used the opcode search tool before, and a quick check shows it's not in III's opcode.txt either. Can this code be added or must I apply this flag with an editor? Thanks for the follow up on player info. I feel a lot less uncomfortable about my wild speculations and educated guesses knowing that you guy's have got my back.

Edited by OrionSR

Share this post


Link to post
Share on other sites
Silent

True, zeroing CGangs fields properly was the thing I did in the 'patch.

Also, to fix it via cleo just set the override to -1 again.

 

Regarding 0331, need to check it when I'm home.

Share this post


Link to post
Share on other sites
spaceeinstein

There are a ton of opcodes that were not used in III and VC so they will not appear in Sanny Builder's opcodes search list. I have documented every one of them here a while ago. Seemann wanted an updated INI file when he released an update to Sanny Builder but I was missing in action at the time. You have to add unused opcodes into the INI file in order for Sanny Builder to compile.

Edited by spaceeinstein

Share this post


Link to post
Share on other sites
Silent

Many of the opcodes you described as unused in VC don't exist in VC, though.

 

Apparently 0331 exists in III, though.

Share this post


Link to post
Share on other sites
spaceeinstein

Hmm? Which opcodes listed there don't exist in VC? I'm actively documenting opcodes so I can have them updated quickly.

Share this post


Link to post
Share on other sites
thehambone

Learn IDA, which is the best tool ever, there's a free version available. I'm hosting disassembled exes for all GTA's on my site (mainly done by listener), also you can find a lot of information about reverse engeneering on sannybuilder's forums (requires google translate).

Awesome, I'll look into IDA, thanks!

 

Hey, ham! What coords hud are you using?

I'm using the one that's hosted on GTAGarage for GTA III, but I modified it a little so it doesn't have to use the Insane Stunt text. Here's the link to my modified script.

 

I like the strategy of updating only the wiki and would like to suggest that the OP be used to track our progress.

Yes, I was thinking about doing that as well. I can keep the color coded block titles so we know which ones have been well-documented and which ones are untouched.

 

Should we stick with the traditional byte, word, and dword descriptions or make the switch to the format used in 010 templates?

Personally, I like the byte, word, and dword format. Correct me if I'm wrong, but from my understanding, some programming languages have different definitions of primitive data types like int, char, short, etc. Using words, and dwords is more language-agnostic because its generally accepted that a word is 16 bits wide and a dword is 32 bits wide.

 

Are there common III glitches that haven't been solved?

I can't think of any others off of the top of my head right now. I might do some research and see if there are any common glitches that have plagued users over the years.

 

Block 3: Garages

I've got a few questions regarding the StoredCar structs in the Garage block.

Here's what I've mapped out for the StoredCar struct.

 

StoredCar (0x28 bytes each)0x0000    dword          vehicle ID0x0004    float[3]       vehicle coords (x, y, z)0x0010    float[3]       vehicle vector rotation0x001C    dword          vehicle immunities         // bitstring0x0020    byte           primary color ID0x0021    byte           secondary color ID0x0022    byte           radio station ID0x0023    byte           model variation 10x0024    byte           model variation 20x0025    byte           bomb type ID0x0026    byte[2]        align
1) I have no idea how the vector rotation is supposed to work. I've tried doing research on it and it still seems over my head. Do any of you guys know how it works? I'll be taking Calculus III in about a year (which involves vectors), so maybe I'll learn it there.

 

2) Vehicle immunities. I've mapped out the following values for immunities:

 

immunities:0 = no immunities1 = bulletproof2 = fireproof4 = explosion proof8 = collision proof16 = ?out of range value does nothingmax byte value game will write is 0x1F (31)
I've never heard of anything other than BP/DP/EP/FP in GTA III. According to main.scm however, there are 5 immunities. This is a snippet from main.scm that creates Ray's bulletproof Patriot in "Marked Man":

 

00A5: $3310 = create_car #PATRIOT at 241.125 -997.75 20.9375 0175: set_car $3310 z_angle_to 270.0 02AC: set_car $3310 immunities 1 0 0 0 0 03AB:  $3310 1                            // Make car stronger... interesting. Might need to look into this.
Here's another snippet from "Salvatore's Called a Meeting":

 

00A5: $TONI3_LIMO = create_car #STRETCH at 1187.0 -860.375 14.5 0175: set_car $TONI3_LIMO z_angle_to 225.0 0229: set_car $TONI3_LIMO color_to 0 0 03AB:  $TONI3_LIMO 1 02AC: set_car $TONI3_LIMO immunities 1 1 1 1 1 
Does anyone know what this 5th immunity could be?

 

3) Model variations. I derived this from the VC save format page and I believe it is correct. However, I am unable to find where these "model variations" are defined in the game's files. I know that model variations exist because, for example, the Stallion may spawn with the top up or down.

I did some testing with the Taxi and this is what I found:

 

taxi model variations:-1 = lightless                               // Awesome, now I know how to spawn a lightless Taxi!0 = light bumper, front-facing "Taxi" light1 = dark bumper, size-facing "Taki" light
So my question is: does anyone know where the model variations for vehicles are defined?

 

 

Great work guys, keep it up! :^:

Edited by thehambone

Share this post


Link to post
Share on other sites
Seemann

I use the following script for III to display coords in-game:

 

 

// FXT: COORD X ~1~.~1~ Y ~1~.~1~ Z ~1~.~1~{$CLEO}0000:float [email protected] [email protected] [email protected] [email protected] true    wait 250    if        0256:   player $PLAYER_CHAR defined     then        00A0: store_actor $PLAYER_ACTOR position_to [email protected] [email protected] [email protected]          05F5: call_scm_func @RealCoordSet params_count 1 [email protected] store_to [email protected] [email protected]        05F5: call_scm_func @RealCoordSet params_count 1 [email protected] store_to [email protected] [email protected]        05F5: call_scm_func @RealCoordSet params_count 1 [email protected] store_to [email protected] [email protected]                 0309: text 6numbers 'COORD' [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]  300 ms  5    endend :RealCoordSet                              if    [email protected] 

Share this post


Link to post
Share on other sites
OrionSR

The 5th immunities is probably against melee damage (weapons or fists) like it is in SA. If not, try gas caps, windshield, tires, or... You might find clues in the Bulletproof/special vehicle guides, but don't count on finding answers. Collectors tend to describe savable vehicle attributes more accurately than others but may not understand them. If you are stumped I'll bet we can recruit some enthusiastic collectors to figure it out. But then they'll get the scoop.

 

Oh, wait. I'll bet the collectors at gta.ru have already figured this out. Accurate info may have trickled back to GTAF, we have several ,ru members with local accounts. My experience is that Bing does a better job of translating the monstrous SA guide than google, but... they both kind of suck.

 

At some point we need to draw a line between what needs to be included in the save wiki and what should be referenced in another document. An example would be stats. We didn't document these for SA since there were so many other references it didn't seem necessary. I always look them up in the Sanny help files. It just seems like there should be a single reference for the stats and the save docs should defer to the definitive reference.

 

I was never able to do the math for things like vector rotation for garaged cars and quaternion rotation for garage zones. If I need to edit in these values I usually just put a car in a garage or create a modified garage zone and then copy the values from the save.

 

Off-topic, but inspired by the possibility of updating common files like the opcode list: Has there been any effort to expand on CustomVariables.ini? The specific application is porting hundreds of globals from SA PC to SA Mobile. I get the impression that the current status of the custom variables is Do Not Touch for fear of confusing the hell out of everyone, but I was hoping that whatever was being used as a source of proper names for opcodes might also provide a complete and definitive variable table.

Share this post


Link to post
Share on other sites
Seemann

Should we stick with the traditional byte, word, and dword descriptions or make the switch to the format used in 010 templates?

The problem is, those are unsigned, so negative values are displayed not as we expecting them to be. So, personally, I apply a signed type (int8, int16, int32 or simply int) for those fields where negative values are allowable (most commonly -1).

 

 

Seemann. My observation is that if I rough out a block you'll follow up with an enhancement and the result is amazing progress. So I'm thinking, that was fun, let's do it again. But I am unsure of my role in the process. (How) do the outlines help you?

I'm very unfamiliar with III internals (my modding career began with Vice City), so mostly I'm referring to SA's structures which are described very well. Your notes help me to understand what's going on in a particalur save block, then I look into the exe to extract the block structure (sizes of fields, align gaps, arrays, etc), then I name the fields as best as it's possible using all available notes and decompiled scripts. Any reference does help. I guess my work also help you to not waste your time on experimenting with unused/align bytes.

Edited by Seemann

Share this post


Link to post
Share on other sites
OrionSR

Update on Cranes

 

I won't be able to convert all the floats tonight to identify any fields but I wanted to write up a progress report before someone else gets the scoop on me.

 

Block Size Search: 0C 04 00 00 08 04 00 00

0x00    dword    block size    0x00    dword    sub-block size        0x00    dword    active cranes[6]        0x04    dword    ev crane flags        0x08    crane records[8] 128 bytes            0x00  dword    m_dwStaticIndex            0x04  dword    unknown            0x08  dword    unknown            0x0C  float    To Drop X            0x10  float    To Start X            0x14  float    To Start Y            0x18  float    To Drop Y            0x1C  float    Drop X            0x20  float    Drop Y            0x24  float    Drop Z            0x28  float    Drop Rot?            0x2C  float    float8            0x30  float    float9            0x34  float    float10            0x38  float    float11            0x3C  float    float12            0x40  float    copy drop Z?            0x44  float    float14            0x48  float    float15            0x4C  float    float16            0x50  float    near Start X            0x54  float    near Start Y            0x58  float    near Start Z            0x5C  float    current X            0x60  float    current Y            0x64  float    current Z            0x68  float    current Rot1?            0x6C  float    current Rot2?            0x70  dword    unknown            0x74  dword    time stamp            0x78  byte[7]  unknown            0x7F  byte     align
EV Crane Flags:    0x01 Fire    0x02 Ambulance    0x04 Enforcer    0x08 FBICar    0x10 Rhino    0x20 Barracks    0x40 Police
// SCM Reference:0368: create_ev_crane 1570.25 -675.375 1565.688 -686.5 1576.75 -706.5625 1639.875 -696.6875 26.0 0.0 // 10 params02FB: create_crusher_crane 1119.75 51.75 1135.75 56.0625 1149.75 46.25 1143.0 59.875 5.0 180.0 03EC:   ev_crane_collected_all_cars01EF: deactivate_crane 1570.25 -675.37501EE: activate_crane 1570.25 -675.375 1638.688 -687.0625 1647.875 -700.0625 1571.063 -696.5 16.0 0.083A0:   not car $CAR_WITH_CORPSE picked_up_by_crane 1120.0 46.0

Emergency Vehicle Crane - a description of movement:

 

(These initial observations are based solely on the EV Crane on a standard game starter save. Car Generators were created for vehicles not handy on the island. This information is preliminary. Confirmation would be very wise at this point.)

 

When an emergency vehicle is parked in the correct location one of 3 magnet objects (entered into the object pool before any SCM objects, so presumably IPL?) will lift the vehicle from the Start point and move at a regular speed to a To Drop way point, move slowly to the Drop point, drop (remove?) the vehicle, and then move quickly to a To Start way point and then quickly to the Start point. The current position of the magnet appears to be saved and to resume it's path to the Start point when loading. I assume the magnet is rotating the vehicle but haven't made detailed observations. So, maybe something like:

0368: create_ev_crane Start_XY 1570.25 -675.375 To_Drop_XY 1565.688 -686.5 To_Start_XY 1576.75 -706.5625 Drop_XYZ 1639.875 -696.6875 26.0 rotation? 0.0

Added: My current hypothesis is that the Near Start coordinates are the IPL coordinates of the object and the Start XY coords are used to find it, so the coords are slightly off. It would seem that "near" might be better applied in the opcode text.

Edited by OrionSR

Share this post


Link to post
Share on other sites
Seemann

For those who want to know how things done, example of opcode 0331 in III (which is actually works):

 

set the flag to 0/1

 

 

...CRunningScript::ProcessCommands800To899() method// read opcode 0331 parameters.text:00448CA0                 call    CollectParameters__14CRunningScriptFPUis ; CRunningScript::CollectParameters((uint *,short)).text:00448CA5                 mov     eax, ds:_opcodeParameters// get a player struct using the first parameter.text:00448CAA                 imul    eax, 316                            ; Signed Multiply.text:00448CB0                 add     eax, offset _playerInfo             ; Add// check the second parameter of the opcode (param2 == 0 ?).text:00448CB5                 cmp     ds:_opcodeParameters+4, 0           ; Compare Two Operands.text:00448CBC                 jz      short loc_448CC7                    ; Jump if Zero (ZF=1)// set the player's flag to 1 if the condition is true.text:00448CBE                 mov     [eax+CPlayerInfo.m_bFastReload], 1.text:00448CC5                 jmp     short loc_448CCE                    ; Jump.text:00448CC7 ; ---------------------------------------------------------------------------.text:00448CC7.text:00448CC7 loc_448CC7:                                                 ; CODE XREF: CRunningScript::ProcessCommands800To899((int))+A7Cj// set the player's flag to 0 otherwise.text:00448CC7                 mov     [eax+CPlayerInfo.m_bFastReload], 0...rest of code
skip the reload time set if the flag is non-zero

 

... CWeapon::Fire() method// check the player's Fast Reload flag (flag == 0?).text:0055C855                 movzx   eax, ds:_playerId                   ; Move with Zero-Extend.text:0055C85C                 imul    eax, 79                             ; Signed Multiply.text:0055C85F                 cmp     ds:_playerInfo.m_bFastReload[eax*4], 0 ; Compare Two Operands// skip the code if not (flag != 0).text:0055C867                 jz      short _fastReloadEnabled            ; Jump if Zero (ZF=1)// get current weapon info.text:0055C869                 mov     eax, [edi+CWeapon.m_eWeaponType].text:0055C86B                 push    eax.text:0055C86C                 call    GetWeaponInfo__11CWeaponInfoF11eWeaponType ; CWeaponInfo::GetWeaponInfo((eWeaponType))// read reload time of it (as set in weapon.dat).text:0055C871                 mov     eax, [eax+CWeaponInfo.m_dwReloadDelay].text:0055C874                 pop     ecx.text:0055C875                 cdq                                         ; EAX -> EDX:EAX (with sign).text:0055C876                 and     edx, 3                              ; Logical AND.text:0055C879                 add     eax, edx                            ; Add.text:0055C87B                 sar     eax, 2                              ; Shift Arithmetic Right.text:0055C87E                 add     eax, ds:dwCurrentTime               ; Add// increase the weapon reload time (current time + 1/4 * reload_delay).text:0055C884                 mov     [edi+CWeapon.m_dwReloadFinishTime], eax.text:0055C887.text:0055C887 _fastReloadEnabled:                                         ; CODE XREF: CWeapon::Fire((CEntity *,CVector *))+4D3j...rest of code
edit: added block7: player data in the template. Edited by Seemann

Share this post


Link to post
Share on other sites
spaceeinstein

Does anyone know what exactly streaming do? It looks like it is related to requesting and loading models. Some data for the block:

 

0x00 - dword - size of subblock, constant 0xC8    0x00 - 20 bytes[10] - streaming structures, 20 bytes each, 10 total
Edited by spaceeinstein

Share this post


Link to post
Share on other sites
OrionSR

In San Andreas the Steaming block was called IPL. The bytes flags (1=enabled) are associated with the sequence of streaming IPL files in gta3.img. All flags are 0 except the few used to enable groups of objects for Barriers to SF and LV, Truth's Crops, much of the pre-YKBB crack factory in SF, and the floor behind the smashwall at Smoke's crack palace in east LS. The relevant flags were initially mapped by examining saves at different stages of the save. Later the streaming files were sequenced so we could control v2 flags using v1 data files by referencing the appropriate stream.

 

The crane post above as been updated with more info on the float fields. Here's just the structure in 010 template format. I need to get a grip on the labeling but... first try and all.

                    DWORD   m_dwStaticIndex <comment="index in static objects pool?">;                    DWORD   _unknown;                    DWORD   _unknown;                    FLOAT   _To_Drop_X;                    FLOAT   _To_Start_X;                    FLOAT   _To_Start_Y;                    FLOAT   _To_Drop_Y;                    FLOAT   _Drop_X;                    FLOAT   _Drop_Y;                    FLOAT   _Drop_Z;                    FLOAT   _Drop_Rot;                    FLOAT   _float8;                    FLOAT   _float9;                    FLOAT   _float10;                    FLOAT   _float11;                    FLOAT   _float12;                    FLOAT   _copy_drop_Z;                    FLOAT   _float14;                    FLOAT   _float15;                    FLOAT   _float16;                    FLOAT   _near_Start_X;                    FLOAT   _near_Start_Y;                    FLOAT   _near_Start_Z;                    FLOAT   _current_X;                    FLOAT   _current_Y;                    FLOAT   _current_Z;                    FLOAT   _current_Rot1;                    FLOAT   _current_Rot2;                    DWORD   _unknown;                    DWORD   time_stamp;                    BYTE    _BYTE[7];                    BYTE    align;
Edited by OrionSR

Share this post


Link to post
Share on other sites
Seemann

 

FLOAT _To_Drop_X;FLOAT _To_Start_X;FLOAT _To_Start_Y;FLOAT _To_Drop_Y;

Orion, are you sure the values arranged in this way? never seen it before, it used to be start_x, start_y, drop_x, drop_y; or start_x, drop_x, start_y, drop_y.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 1 User Currently Viewing
    0 Members, 0 Anonymous, 1 Guest

×

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.