Shipwright/soh/include
Malkierian 70a83f647f
Check Tracker Update (#2668)
* Initial commit. What works so far:

Data file loads, saves, deletes, and is created properly.
 - Need to run `HasItemBeenCollected` when creating in case of mid-seed regen.
Organized checks into maps set by area.
Areas show in tracker.

 - Checks pulled from checkObjectsByArea are not currently listed.
 - Areas are being assumed completed and hidden at the start.

* Checks now populate. Still not counting area totals properly.

* Don't track RC_LINKS_POCKET in the data file, and instead manually add it in every time a save is load. rcObjects doesn't contain Link's Pocket location (duh).

* Moved ItemReceive hook to randomizer_check_tracker.cpp.

Skipped items are properly sorted and formatted.

Saved items contribute to an area's gotten/skipped checks on load.

Changed skipped items default main color to gray.

General code cleanup.

* Skipped checks now contribute to area totals for area completion logic.

* Mid-menu rework transfer.

* Started check lookup on item receive.
Tried to enable scum checking on save.

* Fixed scum check on save.

* More code cleanup, which revealed some issues with loading and saving. Loading now works 100%, but entries in checkTrackerData are disappearing in code somewhere, causing issues with later checks.

Scummed color now displays properly.

Collected but unsaved displays properly.

Unchecked, Skipped, Seen and Scummed checks all have arrows for skipping/unskipping.

Counts a little messed up, probably double adding skips.

* Fixed item counts being off across resets. Restarts were fine.

* Beginning of rework for individual check updates. Adds `Actor lastCheck` to PlayState to allow assigning of last actor to give an item. This allows precise tracking of GS, freestanding PoH, etc. Works for chests too. Currently does not work for shops, unknown for normal NPC gives. Doesn't track last gives for non-checks, like drops from grass, pots, crates, etc.

* Actor-based checks fully fleshed out, but can't help with sale-based checks. Implemented `pendingSaleCheck` to back out of an RC check cycle if `gSaveContext->pendingSale` is not NONE when `OnItemReceive` is called, processed through `OnSaleEnd`. This should be the final change necessary to streamline the checks.

* Temporary hook to message box close to tie in trackers for non-gs/chest actors that aren't added to `GetCheckFromActor`. This triggers a 2-frame countdown to check with `HasItemBeenCollected` since half of the methods in there aren't updated until after a text box closes.

Added scene tracking to get last scene so that checks in scenes that span several overworld areas could be tied to their areas properly.

Modified tracker data creation to apply Link's Pocket and Song from Impa conditionally based on randomizer settings instead of just being assumed to be done. May need modification for checking click and drag spoiler loading.

Removed the scene equivalence check from CheckChecks so that an entire area is checked each time to avoid issues with, e.g., leaving a shop before a pending sale finishes.

* Changed check data creation to use RSKs from gRandomizer to account for settings loaded from drag and drop spoilers.

* Beginning of tracker code organization.

Changed check color defaults.

* Reverted moving tracker colors to header.

Some individual check fixes.

* Missed something from previous merge?

* Removed last remnant of removed performance mode.

* Better handle checking when skullsanity is off.

* Song checks sceneIDs don't match the scenes they're actually in for some reason. Removed that check.

* SaleEnd checks don't need the GetItemEntry parameter. Also set a flag that should prevent the check tracker from running during vanilla saves should that not be resolved by the time it's merged.

* Attempting to have only the relevant checks added to the tracker data, as well as showing vanilla checks for non-rando saves. Not working yet (everything is displayed in vanilla).

* Added vanilla check tracker population via `vanillaCheck` bool in `RandomizerCheckObject`. This is also added to `IsVisibleInImGui` to handle file loading and saving to eliminate checks that aren't part of vanilla or the rando seed.

Implemented deleted tracker data file recreation.

Added some extra item name text checks. Songs are still... tricky, so they stay blank.

Utilize local copies of the randomizer check objects that are applicable for performance purposes.

Fixed vanilla item-giving cutscene crashes when triggered mid-transition.

* Apparently not all toolchains can handle macro instantiation without all parameters, like VS can.

* Fixed scummed detail color not showing properly on tracker.

* Fixed dungeon area totals and GS checks not functioning properly.

* Major revamp of checking code. Doesn't rely on `GetCheckFromActor` at all anymore, but instead simply sets a flag to evaluate a number of checks in an area every frame until the check that was gotten is identified. With the new setup, it's much less hardware intensive, and at 60fps 6 checks per frame shows no noticeable effect on framerate. I can envision needing to add a collectedCount in order to account for times when two checks are gotten one right after the other.

Changed area scroll to happen from `OnTransitionEnd`, and allow for scrolling in bazaar (was disabled previously because it would jump back and forth between Kak and Market while you were in one).

Also setup area check order updating by area instead of all at the same time.

* Fixed shooting gallery not reporting proper area.

Prevent checks from actually happening if area is RCAREA_INVALID, now that all areas are reporting something if they have checks.

Fixed `GetCheckArea()` not updating checks for standard scenes.

Lots of vanilla tracking updates, mainly manual checks for gems, medallions and songs, since the often don't have proper scenes in the data.

Prevent vanilla from triggering check loops if junk items are collected.

Fixed sorting based on saved vs collected.

Prevent item name display for vanilla runs.

Change coloring of checks so the check name reflects status in vanilla runs.

* Fixed "Recheck Area" button erroneously adding to an area's check totals?

* Fix DMC vanilla checks.

* Fix check tracker data recreation on data file loss.

Removed redundant file exists check from SaveTrackerDataHook, as it doesn't matter if it exists or not at that point.

Limited check loops to 3 to avoid infinite check loops on non-check/junk item pickup.

Added more checks to disable tracker operations if a save is not running.

Changed check ordering to put boss reward and heart container checks at the end of whatever RCSHOW group they belong to.

* Fixed IsRunning calculation.

Further improving vanilla checking.

Starting framework for checking medallions, stones, and songs on data file recreation.

Fixed medallion check collection.

Added GIFT_FROM_SAGES to check list for vanilla file for tracking light medallion.

Added check loop limitation to prevent infinite checking after picking up junk item from the ground.

* Finished vanilla file recreation and recheck (songs and dungeon rewards all check properly now). This includes deku shield with KF shop item 3.

Finished Gift from Raoru light medallion tracking for vanilla.

Commented all CheckByScene functionality for now.

* Fixed new save data file creation.

Disabled entrance area calculation for now, as it only tracks the previous entrance for some reason.

Fixed area detection for ToT checks.

* GetCheckArea() now utilizes EntranceData almost exclusively, via either `gSaveContext.entranceIndex` or the entrance tracker's `currentGrottoId` in the case of grottos.

This also means that EVERYTHING CAN AUTOSCROLL NOW. Entrance shuffles are now much easier to track.

Autoscroll is now also triggered on save, just in case someone isn't autosaving and has a lot of checks that get converted to saved.

* Fixed missing GS check in LW.

* Added area scroll on toggling Show Hidden Items. May configure differently later.

Fixed area detection for entrances in Gerudo Fortress/Valley and Collossus. Haunted wasteland doesn't autoscroll due to a bug in `OnTransitionEnd` hook, but checks still evaluate properly there.

Rely on scene-based area detection if scene is a main overworld or dungeon scene.

* Fixed grotto detection when shuffle is off.

* Small code cleanup.

Fixed Colossus hand chest checks.

* Missing lus bump from merge conflict resolution

* Fixed Colossus Grotto making `GetCheckArea` return Wasteland.

* Improved OnItemReceive processing for non-token GS checks, since they can sometimes take long enough for the checking process to time out before the item is registered as received.

* First attempt at thread safety for tracker data file writing. Seems to work, but might need more testing.

* Fixed Recheck Area not unskipping items that register as saved.

Improved delayed saving with autosaving, as the autosave triggered quite often before the tracker data save, making things not properly register as saved.

* merge cleanup

* Converted check tracker data to the sectional saves, adding `CheckTrackerData` to `SaveContext`.

Implemented section ID returning and fullSave boolean passing to section functions from my PR temporarily for it to work properly.

Moved `RandomizerCheckTrackerData` enum to `randomizerTypes.h` to accommodate that.

Changed `Randomizer_SaveInit` to a `SaveManager::InitFunc` to allow for other randomizer-dependent sections to be initialized after that. Required a little refactoring to maintain intro cutscene skip when starting a randomizer file.

* Revert section index return and randomizer init changes. Will need to wait on yet more changes to main.

* Fixed check tracker initialization (shouldn't be tied to window initialization), restored saving/loading functionality.

* Removed `CheckTracker::Init` and put SaveManager calls in `CheckTrackerWindow::InitElement`. Also a bit of cleanup from transition back to save file use.

* Fixed tracker displaying check categories while file not loaded.

* Fix Darunia's Joy check not marking in vanilla.

* Fix autosave not triggering change from collected to saved in tracker data.

* Changed default colors for scummed and collected display.

* Merge upgrade code cleanup.

* Add `OnTransitionEnd` calls to sandstorm transitions both to and from Wasteland. Also improved `gSaveContext.lastScene` assignment for both transition types. Allowed a bit of cleanup in `GetCheckArea`.

* Added `StateButton`, a button like `ArrowButton` but that allows text instead of arrow icons. Apparently the changes from ArrowButton to StateButton happened in a previous commit...

* Changed section name to `trackerDataCheck` to force SoH to load it after the randomizer section, as it required some randoSettings to be loaded first, and nothing else I tried to make the randomizer section load before it worked. This hacks a solution to checks not displaying on fast file load to a specific slot.

F*** you, SaveManager, and f*** you too, JSON.

* Forgot to change the section string for loading with the name change.

* Fix check ordering for checks that trigger the autosave.

* Adds option to remove right-side shop items (slots 1-4) from the tracker list. Enabled by default.

* Fix default state of Hide Shop Right Checks checkbox.

* Fixes grotto and great fairy scrolling and checks.

Fixes array overflow from `checkTrackerData` which was creating the issue trying to load the base and randomizer sections first, among other things.

That also fixed the massive file loads that were being exhibited in debug mode.

* Fix shooting galleries being set as collected again when being played a second time after getting the checks.

* Fix Bazaar autoscroll.

* Add Saria's Song to `GetCheckFromActor` and removed some limitations from the messageCloseCheck function to make that check track properly.

* Fix Song from Impa check.

Implemented prevention for multiple "collections" of great fairies, just in case getting the health refill would trigger it with the previous setup.

* Fix ice traps on GS tokens not triggering OnItemReceive.

* Complete fix for ice trap collection from GS.

Add autoscroll when clicking "Expand All".

* Add `OnShopSlotChange` with cursorSlot and basePrice parameters.

* Fixed include in en_ossan for shop slot hook.

Added registration for `OnShopSlotChange` in the tracker, storing the price in a new `price` field in `CheckTrackerData`.

Added "seen" functionality to shop checks. Displays the model item name upon first entering a shop, adding the price and switching to trickName (if it's an ice trap) upon navigating to the slot in buy mode, triggered by an invisible "identified" status that mirrors "seen" in every other way.

Added tooltips to most options for check tracker color picking to describe what each status actually means.

* `std::format` pls

* So apparently std::format just decided to break with the latest merge from develop, but fmt::format exists and works?

* Removed the last vestiges of `locationsSkipped`. Other general code and formatting cleanups.

Moved `IsGameRunning` to `OTRGlobals` so the item tracker could also access it.

Used preceding to "fix" item and bottle display in the item tracker on startup.

* Some more code cleanup.

Removed "Recheck Area" button and relevant code.

Backported changes to Anchor branch applicable for single-player, including making a checkAreas vector and structuring the frame by frame checks around that. Also includes fix for Silver Gauntlets and Mirror Shield check collection crash associated with those changes.

Fixed Kakariko Bazaar "seen" updates.

Fixed tracker window not showing on initial load like it should.

* Forgot 1 formatting fix.

* Removed conditions for showing Song from Impa (isn't junk under certain conditions, so should show all the time).

* Fix vanilla checks, add Zelda's Letter and Malon's Egg to manual check collection.

Fix autoscroll while in child stealth section.

* Fix crash in Happy Mask Shop in OnSlotChange (referenced non-existent shop id in a tracker-specific enum).

* General code cleanup.

* Missed one reversion.

* One more.

* Fix column alignment in `randomizer_check_objects`.

* Fix file encoding on `randomizer_check_tracker`. Again.

* Fix indentation for `actualItemtrackerItemMap`. Also removed unnecessary parts of the map.

* Rename `HasEqItem` to `HasEquipment`.

* Slightly better indentation for `actualItemTrackerItemMap`.

* Add magic bean salesman to vanilla check tracking, and genericized deku shield to trigger KF shop item 3 wherever you get the shield.

Renamed `vanillaCheck` to `vanillaHundoCheck` to (supposedly) clarify the meaning of the usage.

* One more rename to `vanillaCompletion` to avoid possible confusion with 100% speedrun conditions.

* give me a break XD

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>

* Changes suggested by briaguya (rename `RandomizerCheckShow` to `Status`, unused code, newline formatting)

* Remove unused `itemNames` table.

* Remove `IsGameRunning` in favor of `GameInteractor::IsSaveLoaded`.

* Restore anti-spoiler functionality for dungeons with dungeon maps.

* Review cleanup.

* Fix prices not showing for Kak bazaar items.

---------

Co-authored-by: briaguya <70942617+briaguya-ai@users.noreply.github.com>
2023-10-04 10:03:36 -05:00
..
boost_custom/container_hash Add manual seed input for rando generation (#2057) 2023-01-25 18:33:27 -05:00
libc refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
tables Add scene table (#3131) 2023-09-01 11:46:19 -05:00
align_asset_macro.h Simplify Asset Headers (#2474) 2023-03-02 15:37:47 +01:00
alignment.h [docs] Upstream updates 1 (#1955) 2022-11-30 00:28:57 +01:00
alloca.h Linux/GCC Support (#28) 2022-05-11 13:18:24 -04:00
command_macros_base.h Big-endian support (#909) 2022-07-27 23:50:56 +02:00
fp.h Dynamic Actor IDs (#1729) 2023-06-01 21:39:50 -04:00
functions.h Removed hardcoded skeleton types in actor draw code. (#2979) 2023-09-26 08:45:10 -05:00
global.h Dynamic Actor IDs (#1729) 2023-06-01 21:39:50 -04:00
ichain.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
macro.inc git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
macros.h Add scene table (#3131) 2023-09-01 11:46:19 -05:00
message_data_fmt.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
message_data_static.h Randomizer v2 (#1065) 2022-09-21 00:50:22 -04:00
message_data_textbox_types.h Randomizer v2 (#1065) 2022-09-21 00:50:22 -04:00
regs.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
segment_symbols.h Linux crash handler (#1209) 2022-08-31 22:59:38 -04:00
sequence.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
sfx.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
unk.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
variables.h Randomizer feature: Triforce Hunt (#3062) 2023-09-26 08:45:37 -05:00
vt.h Disable BEL char by default when terminal attached (#2306) 2023-01-17 15:18:13 -05:00
z64.h Mirrored world enhancement (#1569) 2023-06-13 08:46:15 -04:00
z64actor.h Enhancement: Enemy Health Bar (#3035) 2023-07-12 21:55:24 -04:00
z64animation.h Removed hardcoded skeleton types in actor draw code. (#2979) 2023-09-26 08:45:10 -05:00
z64audio.h Makes sequenceMap and seqLoadStatus a dynamic size (#2610) 2023-03-12 15:55:25 -04:00
z64bgcheck.h Use PlayState instead of GlobalContext (#1927) 2022-11-06 09:24:34 +01:00
z64camera.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
z64collision_check.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
z64cutscene_commands.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
z64cutscene.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
z64dma.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
z64effect.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
z64elf_message.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
z64environment.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
z64interface.h DPad items 2022-06-22 23:13:32 -04:00
z64item.h Randomizer feature: Triforce Hunt (#3062) 2023-09-26 08:45:37 -05:00
z64light.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
z64map_mark.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00
z64math.h Move Game Saving to Separate Thread (#2820) 2023-05-05 17:20:34 -04:00
z64object.h git subrepo clone https://github.com/HarbourMasters/soh.git 2022-03-22 02:51:23 +01:00
z64player.h Add flag set/unset hooks and GI actions (#3065) 2023-09-26 08:45:51 -05:00
z64save.h Check Tracker Update (#2668) 2023-10-04 10:03:36 -05:00
z64scene.h Add scene table (#3131) 2023-09-01 11:46:19 -05:00
z64skin.h Use PlayState instead of GlobalContext (#1927) 2022-11-06 09:24:34 +01:00
z64transition.h refactor: use LUS 1.0 RC 2023-01-17 00:33:56 -05:00