feat(Core/Hook): New hook OnBeforePlayerLogout #18163
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes Proposed:
Adding a new hook "OnBeforePlayerLogout" which fires before the logout logic is executed for a player inside WorldSession::LogoutPlayer. This is to support a mod I made which allows a character to change their class, which you can find here.
There is logic to perform before the logout save event, which made utilizing the existing OnPlayerLogout non-viable (visual item changes on class switch were not being pushed and registered on the client). Since the save hook does not have the "logout" bool available, I was left with a choice to add this new hook or update/overload that hook. It seems that a OnBeforeLogout could be useful for more hypothetical use cases, so I elected with this approach. Also, this allows it to work in the situation that save on logout isn't enabled for some reason.
Issues Addressed:
none
SOURCE:
n/a
Tests Performed:
How to Test the Changes:
The mod here uses this hook. Install that mod, and switch your class while wearing gear.
Known Issues and TODO List:
none