besteon / Ironmon-Tracker

A Lua script for the Bizhawk/mGBA emulator compatible with Pokemon Fire Red, Leaf Green, Ruby, Sapphire, and Emerald that tracks relevant data for the IronMon challenge.
MIT License
122 stars 44 forks source link

Tracker Data Restructure and Optimization #415

Closed UTDZac closed 10 months ago

UTDZac commented 10 months ago

This PR primarily focuses on changing the structure of the internal Tracker.Data and external .TDAT notes file. The goal being to track less data and optimize for speedy gameplay (large end-game TDAT files). In addition, I've included other useful data from the game for future projects.

Hopefully I did this all correctly such that old TDAT files are compatible with a new Tracker version, assuming it gets upgraded in the middle of a game / between play sessions. I did a good bit of testing with existing log files, but would appreciate additional testing if you can afford it.

As such, I purposefully changed the Tracker version to v8.3.5, not with the intent of doing a release, but as a safeguard for anyone that wants to use/test with it and try to use old TDAT files.

New Structure

In an effort to help better structure what the commonly used data objects for a "Pokémon" look like, I've changed up the simple table structure to what is effectively a "class object" for Lua. This is accomplished through default object tables and metatables.

Tracker Data Removal

A large part of this process was to identify what tracked data could simply just be removed, or moved elsewhere since they don't really need to be "tracked" between play sessions. This mostly applies to data such as a Pokémon object on a player's team. The data file could also be shrunk by unpacking some tables (less pickling to do), shortening variable names that appeared frequently, and leaving out 0 or default values that could otherwise be assumed (empty moves).

For the data that are no longer tracked but simply moved, that includes:

For data that are still tracked but have been changed, refer to Tracker.checkForLegacyTrackedData() to see how it now import an old TDAT file for compatibility

For all other data that are removed, no other changes are needed. The current Tracker simply won't import or use that data. Old TDAT files will have it temporarily until they're updated / overwritten.

Additions

I started this PR with the intent of tracking what trainers the player defeats, for use in a new Tracker project in the near future. However, it turns out this information is just part of game memory itself and can be read in directly. I've included support for this through:

Info on Defeated Trainers

UTDZac commented 10 months ago

Fixed one last outstanding issue with defining default Tracker.Data attributes using nil as the default value (you can't do this btw, given the structure we're using). Thus, those attributes were never read in from a saved .TDAT file.