Quantcast

Jump to content

» «
Photo

San Andreas Save File Companion

91 replies to this topic
OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#61

Posted 17 August 2017 - 01:08 AM Edited by OrionSR, 17 August 2017 - 08:11 AM.

Sweet! I'm already tracking size of main to positively IDs script versions. Version differences within a console system don't effect the base template. It'll make more of a difference once I start working in constants for global names. 010 scripts on the other hand, are highly version dependent. An end thread instruction shouldn't be hard to find for PCv2, but my confidence is much lower for Android. 

 

I was using pointers > 0xA0000000 to test for Android saves. iOS saves are within the range of PC pointers but quite a bit higher. For iOS, maybe the pointers are higher because the offsets are actually higher, but I've only one save strand of known iOS saves so I can't draw any conclusions.

 

I have failed to install my custom main.scm so that it loads as I'd hoped. I'm pretty sure I'm doing it right as .dat files are loading as expect. I can probably use custom maps. at least I could before. But for some reason the new main isn't working. Maybe they patched it out. So... I'll try another shortcut. Fire up a mission and run a cleo script that loads up a task sequence that is never applied, then trigger whatever activates the checkpoint save. And then work up a checkpoint 1 script so I don't need to do anything for the mission. And if that doesn't work, I'll try pasting my modified mission into the retry save created for that mission.

 

And it looks like I'm going to need to go back and work in your updates or I won't know if there's anything new. Yeah, Seemann's right. We need a github page.

 

TaskTest - Task sequence is loaded but not applied by cleo immediately after starting Nines and AKs. Then it waits for a few seconds before triggering this checkpoint 1 save.

0615: define_AS_pack_begin [email protected] 
078F: task_climb -1 flag 1
07CD: task_char_slide_to_coord -1 coord 2440.58 -1979.89 14.2 angle 270.0 radius 4.0
07C9: task_complex_pickup_object -1 object $3140[0]
0850: task_follow_footsteps -1 char $PLAYER_ACTOR
0859: task_walk_alongside_char -1 char $PLAYER_ACTOR
085B: task_set_kinda_stay_in_same_place -1 to 1
0A1D: task_hand_gesture -1 char $PLAYER_ACTOR
0616: define_AS_pack_end [email protected]  

tVehicle instead of PlayerCars 

add local int IsMissionSave = 0;

 

And... broke on too many objects. This was a drive-by save so I was expecting it to parse if I did it right. Wonder what went wrong.

 

Oh wait. It's IsMissionSave for isCheckpointSave. Still broken though.  Fixed! I think.

 

Woah. This save has 418 enex entries so I had to tweak the enex max loops a little. Currently at 500. I wonder what the max entries is for Android. I suppose I should check it out and verify my IPL mods still work on Android.

    for(i, EnexFlag = 0; i < 500; i++)

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#62

Posted 17 August 2017 - 08:43 AM Edited by OrionSR, 17 August 2017 - 10:17 PM.

Tasks by Cleo

 

TaskTest1TaskTest2 - TaskTest3TaskTest4TaskTest5TaskTest6

TaskTest7TaskTest8TaskTest9TaskTest10TaskTest11

 

TaskTest2B - Redo of broken save

 

TaskTest8a - (325,000 bytes) I tried stirring up trouble at the LV military base and a file size shrunk. Will redo.

 

I'm working my way through the task list script spoiling below. // lines are causing issues so I skipped those for now.

 

AllOpcodes - All sets wrapped into their own task sequence.

068B: task_everyone_leave_car $Smoke_Car // is new (Smoke gets out of his car)

//05DC: task_smart_flee_point $Actor_Smoke coord 2508.359 -1676.538 12.579 radius 80.0 time 5000 // can't save checkpoint
 
Spoiler

Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#63

Posted 17 August 2017 - 08:54 AM Edited by Nick007J, 17 August 2017 - 01:32 PM.

Updating tTask from first of the saves. I will do one or two more saves and will continue in a few hours I think.
Spoiler


Save 2 seems broken.

Edit: done for given saves. Tasks with ID 907 have unusual structure, so I had to fix tTaskShell. I don't know if this task can be used in script command event, but if it does there might be problems. On the other hand, game would have had same problems if it was possible so I think there should not be problems with it.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#64

Posted 17 August 2017 - 09:29 AM

Awesome! There are plenty of matches to confirm that the cleo tasks are saving. I couldn't be sure the new stuff was from cleo or from saving earlier in the mission. I figured that even if it didn't work with cleo that I would at least have a working task command list. Tracking down which of 9 opcodes is crashing the game is time consuming. 

 

My strategy for generating the task list was to use Sanny's opcode search for "task" while in SA SCR mode. Much of the time the codes can be intermixed. Opcodes that use a store_to variable are much more problematic. These look safe so far. I'll double check the troubled tasks before I finish.  Can you identify anything that should be tested but isn't on the command list?

 

I'll continue the task test progression tomorrow. I'm worn out for the night, but very pleased with the progress. How tough would it be to include comments about the opcode associated with each task? It's not always clear from the language used. I could always runs specific tests for opcodes and tasks in doubt.

 

And I'm sorry if I have overwhelmed you with too much all at once. Relax, enjoy the challenge, and share in my relief that it's not an impossible task to complete.


Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#65

Posted 17 August 2017 - 12:25 PM Edited by Nick007J, 17 August 2017 - 02:04 PM.

My strategy for generating the task list was to use Sanny's opcode search for "task" while in SA SCR mode. Much of the time the codes can be intermixed. Opcodes that use a store_to variable are much more problematic. These look safe so far. I'll double check the troubled tasks before I finish.  Can you identify anything that should be tested but isn't on the command list?


There are some tasks that are unlikely to exist in opcodes. Like CTaskComplexMedicTreatInjuredPed is clearly a generic task from ped AI. I'll try to do something about them after we finish everything possible with opcodes.

Opcodes to task association can be calculated more or less easily. I'll try to do it later.

Tasks created by opcodes.
Spoiler
  • OrionSR likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#66

Posted 17 August 2017 - 08:30 PM Edited by OrionSR, 17 August 2017 - 11:36 PM.

Save 2 seems broken.

Do you need a redo on save 2 or did it work out in the end? Making the save is easy enough if the codes don't crash or... freeze the script (the checkpoint save doesn't happen after 4 seconds).  Sometimes I run into trouble with my Windows browser being out of sync with the attached Android device. I must always re-jack if I want things to be accurate. I'll proceed with the new stuff and redo save 2 at the end before taking another shot at the problematic codes.

 

Ambulance and fire response might be tricky on Android. Their disappearance is a common complaint on mobile devices.

 

The Tasks by Cleo post above has been updated with a complete set of test files and a redo save.

 

I've got control of my map mods, script changes still aren't working. For the record, it looks like max enex on mobile is 456 - weird limit. This value simply stops the loop from running forever. One value for all versions will do just as well. I'm tempted to set max enexes at 500 but then it'd be harder to find exceptions.

  for(i, EnexFlag = 0; i < 456; i++)

\Android\data\com.rockstargames.gtasa\  (cleo files)

\Android\data\com.rockstargames.gtasa\files\  (saves)

\Android\data\com.rockstargames.gtasa\files\data (gta.dat)


Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#67

Posted 18 August 2017 - 09:18 AM

Updated tasks for saves above.
Spoiler


It looks like the limit in enex block is 400 on mobile version, unless there is a version with increased limit.
  • OrionSR likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#68

Posted 18 August 2017 - 04:58 PM Edited by OrionSR, 18 August 2017 - 04:58 PM.

I think it was this save that had the extra enexes. Don't have time to double check. I'll make a max enex save after work.


Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#69

Posted 18 August 2017 - 05:38 PM Edited by Nick007J, 18 August 2017 - 05:46 PM.

I see, 1.08 version has a limit of 455 enexes. I previously checked a different version (which produces same "file id" as 1.08, which is hashed "GTASA4" string). I am not sure which exact version it was, but certainly 1.06+ according to file id.

Edit: it was 1.06. Limit was increased from 400 to 455 in 1.07.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#70

Posted 19 August 2017 - 06:25 AM Edited by OrionSR, 19 August 2017 - 05:50 PM.

EnexTest - 455 Enexes
 
Okay, I see what you mean. My enextest save has 456 entries, but index 455 is simply the stopper word, which isn't usable as an enex. This is an unusual structure. It might be worth the trouble to confirm the logic of the routine for multiple versions. How to keep the stopper word out of enex entry structure?
 
I wouldn't mind adding another local for is107 but how would one detect the version difference? I'm having enough trouble distinguishing between Android and iOS.

Well, crap. Does opcode 085A: ever work?
 

085A: create_emergency_services_car #FIRETRUK at 2340.637 -1152.722 25.9686

Not sure why a firetruck is used as an example. The only scripted use is to spawn a couple of SF cop cars on the road next to the Wang's Auto's if CJ has a wanted level during Deconstruction when he runs out of time to destroy the portables or bury the foreman. When tested in game the cop cars don't spawn, and when tested with cleo on Android nothing every happens.

085A=4,spawn_emergency_vehicle_modelID %1d% on_street_nearest_3D_coord %2d% %3d% %4d%
spawns at default radius of spawning, with crew and ready to action vehicle.

I don't know what I'm doing wrong.
 
Any thought on the odd size of this save? TaskTest8a- (325,000 bytes) I tried stirring up trouble at the LV military base and the file size shrunk. I'm curious about why this save is the next size smaller. And, if we added enough jumps, objects, cargens, enexs, and anything else we can think of (threads?) that will increase the amount of data to be saved, can we force a 455000 sized file?

 

Ooooh, 455 max enex entries, and 455,000 max file size... Probably a coincidence. 

 

A hypothesis to test tomorrow. Rural and remote missions, and missions with ghost town effects, might result in the... Check.325 saves.  The main point to the file size investigation is that Samutz must adjust SnP for unknown files. This is not upgrade season for SnP so I'd prefer not to bother him for frequent updates.


Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#71

Posted 19 August 2017 - 06:52 PM

I would expect 085A to work. It does nothing if vehicle model isn't loaded, maybe this is the issue?

I think saves size can exceed 390000, game has no limit, it just writes in blocks of 65000 bytes.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#72

Posted 19 August 2017 - 08:55 PM

My basic hypothesis is holding true. Checkpoints during Badlands mission have the larger file size in town, but if CJ proceeds away from congested areas the smaller file size is written. I need to finish updating my template, and adding a checkpoint condition for this file size before examining my sample. I'm expecting to find far few peds -- not sure what else.

 

I'm thinking, if we are on the cusp between two file sizes depending on congestion, then it's pretty unlikely that we could push things far enough to push things to the next level. Maybe as a test save that doesn't function properly, but unlikely in normal play. Still, might be worth a test.

 

Main questions:

  • Can the two larger file sizes (>300KB) always be associated with checkpoint saves? Probably yes.
  • Is a file size of 260,000 bytes unique to mission saves? Can this size be forced by a bloated standard save?
  • How low can we go? (cue limbo music) Can a file size of 130,000 bytes be forced by a stripped main and IPL files modified to remove garages, enexes, or other structures that effect the size of the structure?

I think the question of extremes can wait, for now. But it looks like the 325,000 isn't a fluke, and will need to be accounted for.

 

Yeah, I thought of loading models and went looking for scripted examples and forgot about it when it didn't work in the mission either. Thanks. Will I need to load the crew models as well? (I'll try without first.)


Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#73

Posted 19 August 2017 - 09:15 PM Edited by Nick007J, 19 August 2017 - 09:22 PM.

Formally speaking, 'checkpoint save' (a type of save that contains ped, vehicles and other data) is determined by IsMissionSave variable which is set if following conditions are true:
1) save has a mission thread (one with a negative index of a script)
2) variable preceeding threads array equals to 0 OR a variable that follows script resource array equals to 1.

If condition 2 is false but condition 1 is true, then it's 'mission save'. If condition 1 is false, it's a normal save. I think you can make a save of ususual size if you try or mod the game, so size is not always a guaranteed sign of save type.

As far as I understand, you don't need to load peds models for 085A opcode.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#74

Posted 19 August 2017 - 10:03 PM Edited by OrionSR, 20 August 2017 - 03:59 AM.

Okay... I think I follow the logic for checkpoint, but I need to step through some examples to solidify the matter in my thoughts. My primary concern is that I want to positively identify the save type without processing any template variables. I try to rely on variables found a fixed offsets. Anything after the main thread gets progressively more difficult to target.

 

I suppose I can safely flag mobile saves as any file size that's a multiple of 65000, and work to get more specific from there.

 

Okay, gotta work in my model loads for 058A:. I'm determined to save those exclusive emergency tasks.

 

Ambulance Checkpoint

 

I'll need to update my template to see if this worked for the unique tasks. EMT models needed to be loaded too or it would crash. On PC, ambulances spawn quite a distance away, approach the coordinates, and medics will revive any dead bodies in the area. On Android, ambulances spawn at a distance and appear to either fall through the ground or simply disappear after a few seconds. 

 

If I need to get the medic to engage a dead body before the specialty tasks are loaded I may need to learn to scan for ambulances and mark them so they don't disappear. I read about this, but haven't tried it myself. And, the examples are for PC, and I'm not sure if I've got a good handle on Android memory pools. The offsets I was using before probably don't apply to v1.07+, or whatever I'm using with the increased enexes. Hopefully CleoA will offer a solution.

 

I'm having the same problem with an emergency firetruck response. The truck spawns, and is removed after a couple of seconds. I'm not having any luck keeping it alive by approaching.

 

Well... This is disappointing. I lost all of my template update for the tasks. I need to go back and rebuild everything, one update at a time plus revisions, and my notes on omissions, and hopefully I'll have a working template and can run more tests. 


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#75

Posted 20 August 2017 - 04:42 AM Edited by OrionSR, 20 August 2017 - 07:06 PM.

Now that my template seems to be working again, I added a line to treat the 325000 sized files just like checkpoint saves. I should probably work in some or statements but this is working for now.

if (FileSize() == 325000) IsMissionSave = 1, isMobile = 1;

The primary difference between two checkpoint saves of different sizes (the Ryder and TaskTest8a checkpoint saves linked above) is that the TaskTest save only has 6 peds (436 bytes), 6 vehicles (200 bytes) and 30 threads (298 bytes), where as the Ryder save has 6 peds, 8 vehicles and 29 threads (mob_la1 shut down when I unlocked the cities). It seems like the checkpoint saves will always be teetering on the edge of this limit.

 

Other structures that can influence file size are objects, but this only varies a by 1 or two (unless glitched, then figure an extra 120 or more) and are fairly small (64 bytes). Enex records (6 bytes) can increase naturally from the 376 IPL enexes if CJ saves outside near burglary houses. 

 

Other structures tend to remain static without mods. Variable structures include garages (50 max, 80 bytes) and Unique Stunt Jumps (255 max, 68 bytes). It looks like the busted/wasted restart structures (20 bytes) might be variable. I've got no guess of the limits. I suspect zones can be adjusted, I don't know the limits. Each of the 378 standard zones (32 bytes) has an associated zonepop record (17 bytes).

 

Most of the structures appear to have fixed parameters that would be unlikely to vary without a tool like a limits adjuster. I'm undecided about adding support for saves with adjusted limits or extended IPL. 

 

Estimating Max File Size:

 

Rounding a bit, and dropping max enexes as trivial, this is still within a few hundred of my best estimate for maxing out the file size with easy mods.

  • 185 jumps, 12500 bytes
  • 292 cargens, 10000
  • 150 objects, 9500
  • 20 pool peds, 9000
  • 20 pool cars, 4000
  • Total, 45000 - 20000 short of 65000

The max added jumps and cargens numbers are fixed limits on PC, but should probably be tested considering all the other limit adjustments. But if we double the peds and cars in the pool, and glitch in another 100 objects, we're within a few hundred bytes of pushing things to the next level. 1 more ped and car ought to do it. I'm not sure how many peds and cars I can actually save in a pool. I've seen 28 peds so far, but I'm counting added peds to the cusp of 6. Lots of peds seems easier than lots of cars. Maybe. It'll be close. Object are key as there's no hard limit, but add too many (hardly any on PC) and the game starts to crash. Mobile hasn't shown any signs of trouble though.

 

Kill addresses for saved mission threads:

  • PCv1 {61825} 004E: terminate_this_script (confirmed)
  • PCv2 {61804} 004E: terminate_this_script (confirmed)
  • Mobile {69015} 004E: end_thread

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#76

Posted 03 September 2017 - 03:57 AM Edited by OrionSR, 03 September 2017 - 03:58 AM.

Updated tasks for saves above.

 
AllOpcodes - unknown type: 420
 
I just noticed this while verifying I didn't break anything while shuffling around pieces of my template.

Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#77

Posted 03 September 2017 - 09:47 AM

This task doesn't have any fields saved so
      case 420: //CTaskSimpleUseAtm
        break;
  • OrionSR likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#78

Posted 05 September 2017 - 01:52 AM Edited by OrionSR, 05 September 2017 - 09:55 PM.

Bells and Whistles and Enums

 

I'm trying to upgrade my template so that dozens reference files aren't required to make sense of the data or to make the appropriate changes. I'm making a little progress on my enumeration of different field and wanted to document my progress, get a little feedback, and pose a few questions. I'm working on the low hanging fruit and will list some of the shorter examples.

 

Some enums are a bit too large, and repetitive, to list here. I've got two slightly different copies of the vehicle lists. eCarID, which defaults to an integer, but eVehID <word> is needed for other structures.

enum <ubyte> eBlipIcons {
    SmallSquare, LargeSquare, PlayerPosition, Arrow, North, Airport, AmmuNation, Barber, BigSmoke, Docks, BurgerShot, Bulldozer,
    Catalina, CesarViapando, Chicken, CarlJohnson, Crash, Dinner, Emmet, EnemyAttack, Fire, Girlfriend, Hospital, LocoSyndicate, 
    MaddDogg, Mafia, MCStrap, TuningShop, OGLoc, Pizza, Police, PropForSale, PropLocked, Race, Ryder, SaveDisk, School, Unknown, 
    Sweet, Tattoo, TheTruth, PlayerTarget, Toreno, Triads, TriadsCasino, Clothes, Woozie, Zero, Disco, Bar, Restaurant, Truck, 
    Robbery, StreetRace, Gym, Car, Light, Runway, AztecasGang, BallasGang, VagosGang, RifaGang, GroveGang, PayNSpray
};
enum <DWORD> ePedType {Player1, Player2, PlayerNetwork, PlayerUnused, Civmale, Civfemale, Cop,
    Gang_1, Gang_2, Gang_3, Gang_4, Gang_5, Gang_6, Gang_7, Gang_8, Gang_9, Gang_10, Dealer,
    Medic, Fireman, Criminal, Bum, Prostitute, Special,
    Mission1, Mission2, Mission3, Mission4, Mission5, Mission6, Mission7, Mission8
};

enum <ubyte> eBlipColor {Red, Green, Cyan, White, Yellow};
enum <byte> eMonths {Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec };
enum <byte> eWeekdays {Mon, Tue, Wed, Thur, Fri, Sat, Sun};

enum <byte> eRadio {Emergency_Band, Playback_FM, KROSE, KDST, Bounce, SFUR, Radio_Los_Santos,
                    Radio_X, CSR, KJAH_West, Master_Sounds, WCTR, User_Track_Player, Radio_Off};

enum <byte> eBombType {NoBombs, FiveSecondDetonator, IgnitionUnarmed, RemoteDetonator, IgnitionArmed = 5};
enum <byte> eWeaponGroup {Disarmed, Melee, Handguns, Shotguns, Uzis, Assault, Rifles, Heavy, Thrown, Equipment, Gift, Other, Detonation};
enum <byte> eObjectType {Unbreakable = 1, Breakable, ComplexBreakable, NonBreakable};

Puzzlers:

 

external script trigger type: Nothing is coming up in searches.

 

enum <byte> ePickupType

 

This was fun. The pickup Type descriptions that I could find for SA weren't terribly helpful so I went back to basics with a few old-fashioned experiments. Pickups were one of the first structures I ever hex edited, and these were pretty much the same sorts of tests. I think I made a bit more progress this time. The VC documentation was fairly helpful. A lot of my enums are based on those descriptions.

 

A lower case first letter indicates some doubt.

  • 1, probably a defunct shop pickup leftover from VC
  • 6, I'm guessing a hidden package pickup
  • B versions of the mines since I can't tell them apart
  • 23, won't pickup, no idea what it's for

This appears to be the most comprehensive Pickup Type list available. 

Spoiler
  • Wesser likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#79

Posted 05 September 2017 - 11:11 PM Edited by OrionSR, 06 September 2017 - 08:21 PM.

Latest Puzzle: How to Enumerate the CRC Textures for Clothing

 

The formula is well documented. I think this is probably Paul's note in the SA save wiki.

 

The CRC32 is calculated of the uppercase filename without extension. After calculation the bits are inverted. The files/filenames can be found in data/shopping.dat and by extracting models/player.img. For example, for White Tank the value is 0xffffffff-crc32("VEST") = 0xbb1ca4cc for both model and texture.

 

As far as I can tell, Paul and Ryosuke, the authors of the two most versatile save editors for SA, are the only people that have spent much time on the CRCs for textures. I can't tell what strategy Ryosuke was using but Paul has published his source code. He's got a great database for clothing but it looks like he crunches the hashes on the database so the CRCs aren't recorded.

 

It doesn't look like 010 has any CRC functions that can work on strings, unless, maybe, I can manage them in their own file. But I suspect it'd be quicker to change settings one at a time in the Savegame Editor and pull the hashes out of the save than figure out that process. I'm not terribly optimistic that I can convince my spreadsheet to perform these functions. 

 

So... I'm stumped on this one for now. I think I'll let the problem incubate and return to other mysteries. It looks like I should be able to enumerate bit flags but I'm been putting that off in favor of easier fields. I'm appreciating the enumeration process as a strategy for documenting proper settings. Much of the time this information was difficult to include in the save documentation. External references were always required.

 

Another puzzle, possible without easy solutions, is how to... "enumerate my indexes." The ZonePop structure has a couple of good examples. For starter, there's no easy way to tell which zone the record is associated with without looking up the name on an indexed list. How to display ZonePop[SUNMA] instead of ZonePop[0], for example. I suspect 010 doesn't want to do this but it might have options to vary a comment based on the index, maybe.

 

Again in ZonePop are the gang density records; the gang densities are indexed from 0 to 9. I don't want to lose the indexing by breaking them out of the structure but it'd be better if I had a comment or something. Ballas through Vagos is easy enough but I lose track of the rest. Anyway, I'm not really expecting too many people to be familiar with the quirks for the 010 Editor but I wanted to pose the question anyway.


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#80

Posted 06 September 2017 - 09:26 PM Edited by OrionSR, 07 September 2017 - 11:59 AM.

SAS.multi.bt now hosted on GitHub
 
I've managed to clean up my template enough to get a copy online at GitHub. The template is still in the process of rapid transition but it's starting to take a reasonably good shape. The opening post has been updated with the new link. I'm not at all sure of what to do with the file now that's it's there.
 
Bitfield Enums are going very well. With only 3 enums for bytes, words and integers I can easily parse individual flags one bit at a time, or in sets. This provided a strategy for managing the annoying blip flags with an integer type mixed in with the flags.

enum <WORD> eBlipType {None_, VehicleBlip, ActorBlip, ObjectBlip, DestinationBlip, ContactBlip, SpotlightBlip, PickupBlip, AirstripBlip};

enum <byte>   eByteFlags {Off, On};
enum <WORD>   eWordFlags {False, True};
enum <int>    eIntFlags  {Disabled, Enabled};

struct tBlipFlags {
    eWordFlags BrightColors : 1;
    eWordFlags Allocated : 1;
    eWordFlags LongDistance : 1;
    eWordFlags IsFriendly : 1;

    eWordFlags WithoutEntity : 1;
    WORD       UnusedBlipFlag : 1;
    eWordFlags IsThreat : 1;
    eWordFlags IsFriend : 1;

    eWordFlags MarkEntity : 1;
    eWordFlags OnRadar : 1;
};

That accounts for the first 10 bits of the word. The other 6 bits are managed in the tRadar struct. The first 4 bits are used to record the blip type, the two remaining bits are usused.

    tBlipFlags  Flags;
    eBlipType   Type : 4;
    WORD        UnusedBits : 2; 

There, all 16 bits accounted for. Note: It's important to maintain the same variable size during this process. UnusedBits, UnusedBlipFlag  and eWordFlags must all be defined as WORDs.
 
It didn't take long to work out a strategy for structuring large sets of flags. Check out the table for integer flags (handling) and byte flags (CarFlags) in the spoiler below.

Spoiler
  • Wesser likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#81

Posted 12 September 2017 - 12:45 PM Edited by OrionSR, 12 September 2017 - 06:05 PM.

Progress on the enums for the SA save template has been good. I still have a few giant lists to compile but I've run across a few mysteries. I'm showing my work in an effort to solicit a little information. I haven't updated my template on GitHub recently as it's going through a major transition. As the enums stacked up the template became difficult to manage so I broke most of the enums out into a separate include file. I'm still not sure if I want to mix them back into the main template or keep the enums external.
 
Done List:
ePathType, eCameraView, eTowns, eSaveGameStateType, eWeatherID, eSkyID, eObjectType,
ePedType, eWeaponGroup, eWeaponNum, ePedID, eRadio, eBombType, eGarageType, 
eVehID <WORD>, eVehicleMods, eCarCols, ePickupID, ePickupType, eBlipColor, 
eBlipType, eBlipIcons, ePopCycle, eCarID <DWORD>
 
eTorsoModels, eHeadModels, eHandsModels, eLegsModels, eFeetModels, 
eChainsModels, eWatchModels, eShadesModels, eHatModels, eSpecialModels, 
eTorsoTextures, eHeadTextures, eLegsTextures, eFeetTextures, 
eChainsTextures, eWatchTextures, eShadesTextures, eHatTextures, eSpecialTextures, 
eTattooTextures, eULArmTattoos, eLLArmTattoos, eURArmTattoos, eLRArmTattoos, 
eBackTattoos, eLChestTattoos, eRChestTattoos, eStomachTattoos, eLowBackTattoos
 
tHandlingFlags, tCarFlags, tGarageFlags, tPickupFlags, tBlipFlags, tEthnicFlags
 
The enums for clothing include quite a few unused models and textures. I thought I had a complete list and then found some more, but just a list, no suggestion for proper implementation.The clothing CRC list took forever to generate. I'm a bit burned out on them. The blip color enum has a few RBGA colors included.
 
Todo:
EnexFlags
external script trigger type
ObjectIDs (defined)
ModelIDs (all)
object flags galore
radio stations vehicle pool
player enex
shopping.dat
ipl streams
 
Stalled:
garage names LifesABeach = mul_lan (not numerical, maybe QWORD?)
garage names with stored cars (can't enum index)
interior (heaven) IDs (no standard)
zoneInfo IDs (redundant link to zonepop)
enum for zonepop (can't enum index)
 
I'm really hoping someone can help me with the mysteries. I've got notes on some of the object flags earlier in this topic but have little confidence in my experimental results.
 
Mysteries:
Block 1: Script, tExternalScriptTrigger byte Type
Block 2: Pools, Ped tPed byte unknown_melee1, unknown_melee2;
Block 2: Pools, Objects tObject  int  ObjectFlags, EntityFlags 
Block 2: Pools int CameraTargetEntityType
Block 4: GameLogic byte GameState
 
I'm not really sure what to do with CameraTargetEntityType. Is a camera target entity type like other entity types? Has there been any progress on entity types? I'm not even sure how to manipulate this in my saves yet. In the second set of values Wesser seemed to be working mostly with vehicles, but Wesser generally knows what he's talking about so... Yeah, not sure how to proceed.
 
EntityType, CameraTargetEntityType
0x00 = NOTHING,
0x01 = BUILDING,
0x02 = VEHICLE,
0x03 = PED,
0x04 = OBJECT,
0x05 = DUMMY,
0x06 = NOTINPOOLS
 
0x02 = Player as driver
0x12 = Quiet driver
0x1A = Suspicious driver (when slightly or heavily collided, unlike cops who are never quiet)
0x22 = No driver
0x2A = Destroyed
0x4A = Player as driver is exiting or being wasted, busted or hijacked

Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#82

Posted 12 September 2017 - 04:23 PM Edited by Nick007J, 12 September 2017 - 06:08 PM.

CameraTargetEntityType is the one that I can help with. It is clearly a bitfield, and a 010 Editor understands the format as from the topic you linked.
    //********* BEGIN CEntityInfo **********//
    BYTE nType : 3; // what type is the entity              // 54 (2 == Vehicle)
    BYTE nStatus : 5;               // control status       // 54
    //********* END CEntityInfo **********//
As for status, original R* constants are actually known for VC:
http://www.gtamoddin...initions#STATUS
 
STATUS
ID 	CONSTANT 	
0 	STATUS_PLAYER
1 	STATUS_PLAYER_PLAYBACKFROMBUFFER
2 	STATUS_SIMPLE
3 	STATUS_PHYSICS
4 	STATUS_ABANDONED
5 	STATUS_WRECKED
6 	STATUS_TRAIN_MOVING
7 	STATUS_TRAIN_NOT_MOVING
8 	STATUS_HELI
9 	STATUS_PLANE
10 	STATUS_PLAYER_REMOTE
11 	STATUS_PLAYER_DISABLED
It has, however, been expanded in SA with new types, names of which are unknown, as far as I know.

Edit: oops :) I didn't check what I said properly. This particular field can only be a value between 0 and 6, which is covered already in your post. I don't know if the type I defined earlier (which is used in memory) is present anywhere in save file.
  • OrionSR likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#83

Posted 12 September 2017 - 08:41 PM Edited by OrionSR, 12 September 2017 - 08:44 PM.

Lets see if I've got this right.
        struct  tCameraTarget { 
                eEntityType      Type : 3;
                eEntityStatus    Status : 5;
                char            padding[3];
        }Entity;

enum <byte> eEntityType {
    NOTHING = 0x00,
    BUILDING = 0x01,
    VEHICLE = 0x02,
    PED = 0x03,
    OBJECT = 0x04,
    DUMMY = 0x05,
    NOTINPOOLS = 0x06
};

enum <byte> eEntityStatus {
    STATUS_PLAYER = 0, 
    STATUS_PLAYER_PLAYBACKFROMBUFFER = 1, 
    STATUS_SIMPLE = 2, 
    STATUS_PHYSICS = 3, 
    STATUS_ABANDONED = 4, 
    STATUS_WRECKED = 5, 
    STATUS_TRAIN_MOVING = 6,
    STATUS_TRAIN_NOT_MOVING = 7, 
    STATUS_HELI = 8, 
    STATUS_PLANE = 9, 
    STATUS_PLAYER_REMOTE = 10, 
    STATUS_PLAYER_DISABLED = 11,
};

Wesser's Nitro Notes: 

  • 0x02 = VEHICLE (2), STATUS_PLAYER (0) - Player as driver
  • 0x12 = VEHICLE (2), STATUS_SIMPLE (2) - Quiet driver
  • 0x1A = VEHICLE (2), STATUS_PHYSICS (3) - Suspicious driver (when slightly or heavily collided, unlike cops who are never quiet)
  • 0x22 = VEHICLE (2), STATUS_ABANDONED (4) - No driver
  • 0x2A = VEHICLE (2), STATUS_WRECKED (5) - Destroyed
  • 0x4A = VEHICLE (2), STATUS_PLANE (9) - Player as driver is exiting or being wasted, busted or hijacked
     
  • 0x03 = PED (3), STATUS_PLAYER (0) - how it started in the save I manipulated with these variables.

So far so good, but progress will be slow as I can only view this variable in mobile saves. The suggested strategies for determining entity type are out of context and too complex for the purpose of testing enumeration. Is the memory offset of CameraTargetEntityType known for PC? A basic cleo script that displays the value on screen could provide fairly quick data that I can punch into that field on a dummy save.


Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#84

Posted 12 September 2017 - 08:55 PM

Sorry for confusing you, I edited my message apearlier. This particular field can only contain values between 0 and 6, so status part is not very important in given context.

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#85

Posted 12 September 2017 - 09:31 PM Edited by OrionSR, 13 September 2017 - 10:21 AM.

Okay, now I'm confused. Your status ID list includes a range beyond 6.

 

8 bits

  eEntityType Type : 3; value range 0 thru 7
  eEntityStatus Status : 5; value range 0 thru 31

 

Wesser's observation of 0x4A (2, 9) suggests that something is going on with the 4th bit of Status, but that observation seems out of context. 

 

If this is wrong I want to fix it but otherwise I think I'll bail on looking for more Status enums and move on. I mostly wanted to understand what I was looking at and I think I've got a handle on it, hopefully. Those bitfields always throw me for a loop; I don't "see" them as clearly as other hex data. But at least I've got a strategy for managing them with 010 now. 

 

Added: The thread index was discussed before as the uppermost bit of the Index is used to flag a mission thread in a different struct. At the time I was using a simple is_negative evaluation to flag a mission thread in a local. When I learned how to manage my bits I broke out the short into 15 bit and and 1 bit shorts.

 

Now that's I've figured out how to handle a proper bitwise conditional operation I'm wonder which is the most proper form of the variable. Is it somehow more proper to manage as a full 16 bit short? There isn't much of an advantage in breaking out the last bit other than the index is not obscured. I'm also a bit worried about using the variable in a script.

struct tThread {
    short   index;
//    short   Index : 15;
//    short   IsMissionThread : 1;
    /* Script Thread */
    if (isMobile==1) int streamedScriptIndex <format=hex>;
//    if (index < 0) {
//    if (IsMissionThread == 1) {
    if (index & 0x8000) {
        isMissionThread = 1;
        byte   MissionCode[69000];
        DWORD  LocalVar[1024];
    }

Nick007J
  • Nick007J

    Mark Chump

  • Members
  • Joined: 17 Jan 2010
  • Russia

#86

Posted 13 September 2017 - 04:48 PM

What I tried to explain was that mobile SA during the save process gets the value, which is a combined byte of type and status (the one that is duscussed in the topic), only keeps lowest 3 bits (thus only leaving type) and stores it. Therefore in a save only values between 0 and 6 are achievable.

I haven't checked status constants in SA, so I might have been wrong that first 11 values are the same. I can definitely say that when player is busted in III and VC, his vehicle's status is changed into STATUS_PLAYER_DISABLED, so 2 of the values might have been removed.
  • OrionSR likes this

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#87

Posted 13 September 2017 - 08:07 PM

Okay. I think I understand. For the purpose of the save variables:

  • Revert CameraTargetEntityType to an int. I'm assuming that all bits are significant for this save variable.
  • Change the eEntityType enum to an int for use with CameraTargetEntityType.
  • Keep eEntityStatus on file in case I ever need to apply these enums to actual entity bytes.

This certainly makes things easier to manage but I'm a little disappointed. I was quite pleased with how the structure enumerated Wesser's notes. But if I'm going to play with that I'll need something with a better choice of targets than a vehicle's camera can allow. And the investigation is yet another tangent that doesn't have any particular application at the time. I'll come back to this if I run into any other save fields describing entity types or status.

 

BTW, I've been trying to distinguish all the different variable names. Global variables are well understood in GTAIII terms - don't mess with that. Local variables is a term usually applied to the 32 or 40 local variables available to threads. Missions have their own set of 1024 local variables. The 010 editor parses the save into template variables, but I'd prefer a term not specific to 010. Save variable seems like it would apply well in other contexts, like the save wiki. It makes sense so far but my templates have their own set of local template variables used to set flags like isMobile or to track progress in a loop. 


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#88

Posted 4 weeks ago Edited by OrionSR, 4 weeks ago.

List of all Zones in San Andreas

 

Enumeration includes the zone name,  zone index, gxt key, gxt string, ethnic flags, popcycle and dominant gang in the sequence of info.zon.

 

I wasn't planning on posting my longer enums but I need this list for reference in another topic. Besides, other zone lists are often incomplete, sorted by area, and don't include information on the popcycle, so I'm glad to have everything listed in one spot. 

 

Spoiler

 

Ethnicity Flags for reference:

struct tEthnicFlags {
    eByteFlags  BlackPeds : 1;      // 0x1
    eByteFlags  WhitePeds : 1;      // 0x2
    eByteFlags  AsianPeds : 1;      // 0x4
    eByteFlags  HispanicPeds : 1;   // 0x8
    byte        unusedFlags : 4;    
};

OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#89

Posted 4 weeks ago Edited by OrionSR, 4 weeks ago.

The lastest puzzler - How to display the coordinates of the pickups and cargens in a useful format using a custom function?

 

The problem is that SA encodes float coordinates for pickups and cargens as a 16 bit integer after multiplying the coordinate by 8, so I need to make a few calculations before I can use or manipulated the data. I didn't know to look for a strategy to change how the coordinates are displayed, but I was having other problems getting started with custom functions so I was practicing with examples I could find of custom auto-inspector functions for dates. The auto-inspector is a side-bar tool that displays the bytes after the cursor as signed or unsigned byte, word, dword, qword, float, etc. - a very handy tool if your not sure what your looking at.

 

The function below is from InspectorDate.bt on the template repository at SweetScape. 

//----------------------------------------------------------------
// BlackberryDate
//      32-bit integer, number of minutes since 01/01/1900 00:00:00
typedef uint BlackberryDate <read=BlackberryDateRead, write=BlackberryDateWrite>;
FSeek( pos ); BlackberryDate _gt <name="BlackberryDate">;
string BlackberryDateRead( BlackberryDate t )
{   
    // Convert to FILETIME
    return FileTimeToString( t*600000000L + 94354848000000000L );
}
int BlackberryDateWrite( BlackberryDate &t, string value )
{
    // Convert from FILETIME
    FILETIME ft;
    int result = StringToFileTime( value, ft );
    t = (int)(((uint64)ft - 94354848000000000L)/600000000L);
    return result;
}

The result of the date investigation, btw, it that I'm pretty sure system time is only recorded in PC saves so I've blocked out PS2 and mobile data as unknown bytes.

 

But the point of this post is: typedef uint BlackberryDate <read=BlackberryDateRead, write=BlackberryDateWrite>;

 

It sure looks like I can use one function to read data to something that's easy to work with and write it back to the proper format if I change it. At this point I feel I'm doing well if I can take a working function and implement it properly within the template. I've had no luck adapting functions to a new purpose. So... I think I'll let this problem sit, practice some more, and come back to it with a better skill set - unless someone is kind enough to help me out. This seems like a good example to build from. I just can't manage my data types well enough to get started.

 

Added: Milliseconds to Hours for the timers. Damn. Now that I know it's possible I'm in for a lot of frustration if I can't figure these things out.

 

So instead, I'll finish on a positive note. The investigation with a custom date inspector lead to experiments with a custom GTASA inspector, and I've been quite happy with the results. Usually I've got a half dozen or more saves of different types open at one time as I test my template modifications. Except for PS2, which has a unique naming convention, it can be difficult to tell them apart. 

 

qMiPKSG.png

 

The GTASA Inspector struct only appears for larger files. I need to change that to .b extension or something. 

  • Current Version - the first field in the save, File ID, EXE Version
  • string | wstring - character type, and the Last Mission Passed string
  • Block 1 Offset - the name field is different depending on the offset found for the 2nd "BLOCK" (+9 for varspace)
  • Script version - size of main, a very positive identifier of script versions 
  • PC/PS2 Standard (file size) - labeling the current "Heaven" - and heavens enummed with a common safehouse interior
  • Save Pickup Index - many safehouses share the same pickup, kind of confusing. These need better enums.
  • Glitches popup only if detected. These are all at static offsets - SimpleVars and global variables.
    • Two-Timing - not really a glitch. -1 means the script is disabled but that's pretty normal
    • Girlfriend Censor - HC 2.0 unlocked the cities early and glitched the phone calls, so I track this setting
    • Gym glitch appears if not -1. This guy's subscription will run out for two weeks at the first of year
    • Basketball glitch from saving at Madd Dogg's crib
    • Pool Player glitch from saving near an active pool player
    • Looks like I forgot to enable the Pimping glitch in this save. An old glitch from a bad mission passer script.
    • Riot Glitch - this has been popping up a lot recently. Something popular is corrupting $58.

When I get back to an investigative mode I'm planning to implement some of the SA enums on the current cursor location. I'm hoping it'll help tease out unknown field types, especially when I'm poking around in memory and not really sure what I'm looking at.

 

Added: Glitch detection is currently only working for PC. I need to work out a strategy for defining constants for the global variables associated with common glitches.


OrionSR
  • OrionSR

    Chain Game Development Team

  • Feroci
  • Joined: 23 May 2007
  • None
  • Helpfulness Award [GTA & Modding]

#90

Posted 3 weeks ago Edited by OrionSR, 2 weeks ago.

Object Flags

 

I've had very little luck finding complete information or any kind of naming convention for the object flags in SA, so I had to mix data from VC with a few in-game observations to round out this list as best I can. Comments and suggestions would be appreciated.

 

The completely inaccurate information included in the spoiler below has provoked a much more accurate list in the next post. Apparently I was mixing observations about object flags with documentation on the model flags which are not included in the save.

 

Check the next post for information on object flags and ignore the old garbage in the spoiler.

Spoiler

  • The Hero and Tomasak like this




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users