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

Synchronization Events Pre-Sync and on Dedicated Server #414

Merged
merged 14 commits into from
Nov 6, 2023

Conversation

searica
Copy link
Contributor

@searica searica commented Nov 2, 2023

New Synchronization Event

This pull request adds a new event, OnSyncingConfiguration, that triggers just before applying the synchronized values (on both client and server). This event has it's own class for event args which is currently empty but I thought it was best to keep the same design pattern as the OnConfigurationSynchronized event and prevent changes in API if other devs want to add argument to the event.

Modified OnConfigurationSynchronized to Fire on Server

The event OnConfigurationSynchronized has been altered to fire on both the client and the dedicated server after the configuration has been synchronized. I testing the effects of doing this using a mod list that had two different mods that used Jotunn to sync configurations and one that used Blaxxun's ServerSync.

I set up the two Jotunn dependant mods to save their configuration files whenever the OnConfigurationSynchronized event fired and set up the file-watcher in each mod to reload the configuration file when it was saved so the mod could be updated. when Both of the Jotunn dependent mods used a file-watcher that would reload the configuration file when it was changed and an in-game configuration manager watcher that would save the configuration file when the in-game manager was closed.

I tested changing the configuration via the in-game manager, by editing the server configuration file, and editing the local client configuration file. For all test cases the behaviour on the client-side was identical to when OnConfigurationSynchronized only fired on the client. For the server, configuration changes were saved just like they were on client whenever "OnConfigurationSynchronized" fired on the server. As far as I can tell from those tests firing the "OnConfigurationSynchronized" even on the server does not result in any sort of infinite synchronization loop or duplicate synchronizations for existing mods.

Added Synced PluginGUIDs argument to OnConfigurationSynchronized Event

The OnConfigurationSynchronized has a new argument that is a HashSet containing the PluginGUID for each plugin that received configuration data from the SynchronizationManager. This is so that plugins can check if they actually had their configuration updated by checking if the HashSet contains their plugin's GUID. This also required caching the PluginGUID for each custom configuration file that is registered so that changes to custom configuration files are tracked appropriately.

@MSchmoecker MSchmoecker merged commit 687c2ce into Valheim-Modding:dev Nov 6, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants