Some interesting 'structure' functions...
Posted: Sat Oct 02, 2021 8:20 am
I'm currently trying out this tool on Kena; and in the process came up with this stuff to make life somewhat easier.
I'm in particular interested in any suggestions/improvements/etc related to the ''Add address by reference'' and 'Clean up structures' routines !
***
HowTo: Adding a [Design] menu to 'Dissect Data/Structure'
Note: will only work via this script !
How to make use of this:
1. copy/paste 'Open Dissect Structure...' script to your table
(all code now sits in the script itself)
2. save (/quit) table...
3. (load table)
4. run 'Open Dissect Structure...', which opens a DissectStructure form with added [Design] menu
4.a 'Delete all Unnamed structures'
(there is also an option to delete ALL of them...)
4.b 'Delete structures selectively': this opens a listCheckbox, allowing you to select particular structures to be deleted
Note: with a really large structure list (~ beyond screen size) or screen resolution, it is possible that not all structures
are shown in the list?! Either remove some manually; or edit 'local nRange =' in the script appropriately....
- EDIT -: this problem seems to be solved by NOT using '.VertScrollBar.Range' property (just comment the 2 related lines for now)
4.c 'Add address by reference': this will add the currently selected Element in a (sub)structure as 'pointer' memoryrecord to the addresslist.
Important: the base address of your (main) structure must be a pointer address (eg: [pHealth])
(as a memRecord will read the pointer of that address to create/build the "offset_chain")
Note1: Structures/Elements which do not (yet) exist in their respective 'structure.element'-offsets will be created accordingly.
(see also: [ ])
Note2: now also takes care of names with '[]', empty descriptives and spaces in descriptives (if desired ~ see script)
4.d 'Clean up structures': specifically written for this tool. while i was not aware one could do that, it is possible to use structure references as offsets in your 'Address' definition (see for example the 'Player' entry). If you want to continue using this feature, you'll have to keep the appropriate structures, and its related offsets.
The previous version would/will lock up CE in case of many/large structures (either CE not coping well with all them deletions and/or bad coding from my part) ?! Eventually, I've chosen to - basically - delete all structures and add 'structure.element' objects currently present in the table.
Note though that it still relies on existing structures to collect the proper offsets (~ if the table is not attached to the game, the memrecords will not show these offsets)
Practically: when finished, your structures are reduced to bare ("flat") structures, holding only them element references...
(Obsolete; only for pre-v4: This routine parcours your addresslist, picks up any such references and then loops through all structures remomving any "obsolete" elements.)
Important:
i) unnamed structures are not treated (pre-v4 only)
ii) 'structure.element' references in (lua) scripts are not treated either ! (see for example 'Fly' routine)
Workaround: add these base references manually to your table (see f.e. 'CharacterMovement')
eg: create a ptr_entry with base address '+PlayerController.bActorEnableCollision'
(you can also add these manually to the structure itself ~ not advisable though)
iii) only run this prior to releasing your table (and keep your "original" structures for ease of future updates)
Iow: [Save As] under a new name !
4.e Switch Lua Engine Lua (just in case something goes wrong...)
PS: see #aSwedishMagyar's routine on page 3 on how to add this script as menu_option in the main CE window.
- UPDATE - v1.2
* moved all code to script
* added ''Add address by reference'' function
* minor updates/corrections
- UPDATE - v1.4 ~ v4
* Delete all Unnamed structures: added 'All' option
* Delete structures selectively: should now/always show complete list of structures (see Note though)
* Add address by reference: further finetuning
* Clean up structures: different approach on how to "keep" flat structures (and must faster now)
(note: v3 script contains the "old" 'Clean up structures')
I'm in particular interested in any suggestions/improvements/etc related to the ''Add address by reference'' and 'Clean up structures' routines !
***
HowTo: Adding a [Design] menu to 'Dissect Data/Structure'
Note: will only work via this script !
How to make use of this:
1. copy/paste 'Open Dissect Structure...' script to your table
(all code now sits in the script itself)
2. save (/quit) table...
3. (load table)
4. run 'Open Dissect Structure...', which opens a DissectStructure form with added [Design] menu
4.a 'Delete all Unnamed structures'
(there is also an option to delete ALL of them...)
4.b 'Delete structures selectively': this opens a listCheckbox, allowing you to select particular structures to be deleted
Note: with a really large structure list (~ beyond screen size) or screen resolution, it is possible that not all structures
are shown in the list?! Either remove some manually; or edit 'local nRange =' in the script appropriately....
- EDIT -: this problem seems to be solved by NOT using '.VertScrollBar.Range' property (just comment the 2 related lines for now)
4.c 'Add address by reference': this will add the currently selected Element in a (sub)structure as 'pointer' memoryrecord to the addresslist.
Important: the base address of your (main) structure must be a pointer address (eg: [pHealth])
(as a memRecord will read the pointer of that address to create/build the "offset_chain")
Note1: Structures/Elements which do not (yet) exist in their respective 'structure.element'-offsets will be created accordingly.
(see also: [ ])
Note2: now also takes care of names with '[]', empty descriptives and spaces in descriptives (if desired ~ see script)
4.d 'Clean up structures': specifically written for this tool. while i was not aware one could do that, it is possible to use structure references as offsets in your 'Address' definition (see for example the 'Player' entry). If you want to continue using this feature, you'll have to keep the appropriate structures, and its related offsets.
The previous version would/will lock up CE in case of many/large structures (either CE not coping well with all them deletions and/or bad coding from my part) ?! Eventually, I've chosen to - basically - delete all structures and add 'structure.element' objects currently present in the table.
Note though that it still relies on existing structures to collect the proper offsets (~ if the table is not attached to the game, the memrecords will not show these offsets)
Practically: when finished, your structures are reduced to bare ("flat") structures, holding only them element references...
(Obsolete; only for pre-v4: This routine parcours your addresslist, picks up any such references and then loops through all structures remomving any "obsolete" elements.)
Important:
i) unnamed structures are not treated (pre-v4 only)
ii) 'structure.element' references in (lua) scripts are not treated either ! (see for example 'Fly' routine)
Workaround: add these base references manually to your table (see f.e. 'CharacterMovement')
eg: create a ptr_entry with base address '+PlayerController.bActorEnableCollision'
(you can also add these manually to the structure itself ~ not advisable though)
iii) only run this prior to releasing your table (and keep your "original" structures for ease of future updates)
Iow: [Save As] under a new name !
4.e Switch Lua Engine Lua (just in case something goes wrong...)
PS: see #aSwedishMagyar's routine on page 3 on how to add this script as menu_option in the main CE window.
- UPDATE - v1.2
* moved all code to script
* added ''Add address by reference'' function
* minor updates/corrections
- UPDATE - v1.4 ~ v4
* Delete all Unnamed structures: added 'All' option
* Delete structures selectively: should now/always show complete list of structures (see Note though)
* Add address by reference: further finetuning
* Clean up structures: different approach on how to "keep" flat structures (and must faster now)
(note: v3 script contains the "old" 'Clean up structures')