Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Game Interactor] Add LoadGame and ExitGame hooks #2542

Merged
merged 4 commits into from
Feb 27, 2023

Conversation

Archez
Copy link
Contributor

@Archez Archez commented Feb 26, 2023

This adds LoadGame and ExitGame hooks which can be used to run actions when entering/exiting the game. The hooks will have the file number passed in if needed by the consumer.

As an example, I have moved the entrance tracker data setup/teardown methods to use these hooks.

The hooks run in the following scenarios:

LoadGame

  • When loading a file from the file select menu
  • When using fast file select to automatically load into a save

ExitGame

  • Choosing not to continue the game from the game over screen
  • Using the reset command (Ctrl+R/selecting reset from the menu bar/using reset in the console)
  • An invalid entrance was provided, causing the game to reset to the title opening

Build Artifacts

@Malkierian
Copy link
Contributor

Is ExitGame called on reset (Ctrl + R), too, if in-game?

@Archez
Copy link
Contributor Author

Archez commented Feb 26, 2023

Is ExitGame called on reset (Ctrl + R), too, if in-game?

Yes all reset options use the reset command (Ctrl+R/selecting reset from the menu bar/using reset in the console).
Updated main description.

Copy link
Contributor

@dcvz dcvz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beginning to move some rando stuff over! Nice :)
Nice changes also to the file slots stuff

LGTM 👍

@jbodner09
Copy link
Contributor

Hell yes, this is exactly what I need in order to fix #1187

@Archez
Copy link
Contributor Author

Archez commented Feb 26, 2023

Hell yes, this is exactly what I need in order to fix #1187

Keep in mind as it is right now, LoadGame will execute prior to the first game frame. So that may or may not be useful for your case.
Would need to think through something else if we want a hook that executes exactly on the first game frame and no other frames later. Or maybe can think of a way to have a "QueueForNextGameFrame" pattern.

@jbodner09
Copy link
Contributor

Ah. It is if play is valid at that point, which I unfortunately don't think it is since that pointer is to a fileChooseContext at that point instead of a playContext if memory serves.

My fix in the non-fast-file-select case was indeed to run something that executes exactly once per file before the first frame of gameplay, and that something was to initialize play->frameCounter that had previously been uninitialized and using garbage data. The only place I found to do that was when exiting the title screen (since it had an exit routine and a valid play pointer whose frame counter was preserved when a save file was loaded), which was why the fix didn't work for fast file select.

@dcvz if we could find a different place to place the call to GameInteractor_ExecuteOnLoadGame so that play is valid at that point (assuming it's not where it currently is, which you should definitely fact-check me on), then the Load Game hook would be a lot more useful anyway since it would have access to more than just the save data.

@briaguya-ai briaguya-ai merged commit f7bb807 into HarbourMasters:develop Feb 27, 2023
@Archez Archez deleted the load-exit-game-hooks branch February 27, 2023 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants