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

DF Chat Enhancements: Merge chat message data flags instead of overwriting #486

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

DrMcCoy
Copy link

@DrMcCoy DrMcCoy commented Aug 1, 2023

When writing the WorldTime into the chat message data flags structure, DF Chat Enhancement would straight out overwrite the whole flags structure, wiping away all previously written flags. Since DF Chat Enhancement is often very late in the Hooks chain, this would mean most flags are destroyed.

This poses a problem when other modules would want to read from the flags, for example data written by the system. One such example is the Pathfinder 1e integration for https://github.com/otigon/automated-jb2a-animations . It would read the flags added by the system to determine when an attack (or spell cast) has taken place and use the attached source item name to match again a list of animations to play, as well as the attacker and attacke. So it can, for example, see that an attack with a crossbow has taken place and animate a crossbow bolt flying towards the target.

If, however, the system flags are wiped away by DF Chat Enhancements, Automated Animations fails to play any animations for any attacks, because it can't determine anything about the attack (or that, in fact, an attack has taken place). See https://github.com/otigon/automated-jb2a-animations/issues/669 .

This PR fixes the situation by using foundry.utils.mergeObject() to merge the DF Chat Enhancements flags into the existing chat message data object instead.

This also fixes #387, if I understand it correctly.

@DrMcCoy
Copy link
Author

DrMcCoy commented Aug 2, 2023

And for completeness's sake, DF Chat Enhancement doesn't build with the code that's in repo right now, because of the @league-of-foundry-developers/foundry-vtt-types dependency. It misses members that DF Chat Enhancement uses.

I'm attaching a ZIP with a modified version, for other people who might stumble over this. After running "npm install", you ZIP. foundry-vtt-types.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant