Repository navigation
Fix SynchronizationManger Not Updating Local Config Changes when AdminOnlyStrictness.IfOnServer and Jotunn not on Server - #505
Open
searica wants to merge 13 commits into
Conversation
Fixes issue with AdminOnly config entries for mods with AdminOnlyStrictness.IfOnServer where changing the settings for AdminOnly entries via the local file would not update in-game and changing settings in-game would not save to disk.
Save time parsing long config files that Jotunn should not manage and helps fix the issue of not updating AdminOnly config entries for mods with AdminOnlyStrictness.IfOnServer when Jotunn is not on the server.
Resets the cache upon a new connection, disconnection, and upon receiving server version data
Added a late check to see if mod version info was received from the server or not. If no version info is received then set the flag AllowShouldManageCheckWithoutVersionData and update the admin configs to return control to those we shouldn't manage. Added convenience method `IsShouldManageValid` for checking if ShouldManage result is valid for use throughout.
These changes can be reverted or excluded from a PR. This is just to make deployment easier in my dev env.
Contributor
Author
|
Sorry for the extra commits at the end, I hadn't realized that the buildtask dll got included and it was preventing things from building. |
This got removed when I was cleaning up all the places I had added a check doing troubleshooting. So I'm restoring the original check now and updating the method description.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
So I ran into a really non-intuitive issue with
MoreVanillaBuildPrefabs(which hasAdminOnlyStrictness.IfOnServer) when it was used as a client side only mod where the dedicated server is entirely unmodded and the client is not an admin. Here is a description of the issue and what occurs when connected to a dedicated server withoutJotunninstalled versus when not connected to a dedicated server at all.When connected to the dedicated server:
For any config entries that were
AdminOnly, changing the value via the local config file had no effect in game while connected to the dedicated server, despiteMoreVanillaBuildPrefabsusing theConfigFileWatcherprovided byJotunn.Changing the value for
AdminOnlyconfigs using an in-game config manager while connected to the dedicated server did update the value in-game and immediately took effect, but the changes were not saved to the local config file.For non-
AdminOnlyconfigs, changing them in the local file immediately updated the value in-game and changing them via an in-game config manager immediately saved those changes to the local config file.When not connected to a dedicated server:
For all config entries, whether they were
AdminOnlyor not, changing them in the local file immediately updated the value in-game and changing them via an in-game config manager immediately save those changes to the local config file.Troubleshooting
So I did some digging into both the
ConfigFileWatcherandSynchronizationManagerclasses. First, I started logging of which config filesSynchronizationManagerwas trying to manage settings for and found that everything was working as intended based on whether mods depend onJotunnand theAdminOnlyStrictness.IfOnServerattribute setting. So, I dug intoConfigFileWatcherto see if it was redirecting changes to a server that wasn't actually there to receive them, but it also appeared to be working as intended.I did some more testing and confirmed that the values for
AdminOnlyconfig entries were straight up not changing even when a reload of the local config file was triggered so I suspected that something was interfering with the actual reloading of just theAdminOnlyconfig entries, since non-AdminOnlyconfig entries were reloading as intended. Then I caught that the methodsSubscribeToConfigReload,UnsubscribeToConfigReload, andSynchronizeChangedConfigdid not include a check to see whetherSynchronizationManagershould be managing those configs or not.This meant that when the config was reloaded, the
SynchronizeChangedConfigmethod would run and trigger an update of all theAdminOnlyvalues when the eventConfigFile.ConfigReloadedis invoked which occurs before the eventConfigFileWatcher.OnConfigFileReloadedis invoked. From there I can't quite tell exactly what was happening as the events were invoked but I know values accessed viaConfigEntry<T>.Valuefor allAdminOnlyconfig entries were not changing as a result.I added
ShouldManage(config)checks to the methodsSubscribeToConfigReload,UnsubscribeToConfigReload, andSynchronizeChangedConfigand it restored the intended behavior of changing anAdminOnlyconfig entry value in the local config file updating the value in-game when connected to a dedicated server withoutJotunnfor a mod withAdminOnlyStrictness.IfOnServer. It also restored saving changes made via an in-game config manager to the local config file.This has the added benefit of not requiring
Jotunnto scan for changes in large config files that it should not even be managing when it synchronizes config changes.Upon further testing though, if
Jotunnis present on the dedicated server then mods withAdminOnlyStrictness.IfOnServerstill had the same issue as before whenJotunnwas not present on the dedicated server. Any changes made to the local config file would be reset when saving changes made to non-AdminOnlyconfig entries via an in-game config manager. I thought this could be due the process of caching values for comparison to check what changed so I added a check inGetSyncConfigValuesto only cacheAdminOnlyconfig values from configs that should be managed. While that still seems like a worthwhile change to include, it did not solve the issue.Solution
After lots of debugging and testing it turned out the issue was that control is never returned back to the local config entries if they should not be managed. So I've added events to check when mod version info is received from the server and a very late check on Game.SpawnPlayer to handle cases where Jotunn is not on the server at all. When either the event fires or the late check finds that no version info was received, SynchronizationManager now returns control of all config entries that it should not manage to the local config.
I have tested connecting to a unmodded dedicated server with MoreVanillaBuildPrefabs and changes from the local config are shown in game and changes in game are shown in the local config file. This is true even when I'm not an admin since MoreVanillaBuildPrfabs only enforces AdminOnly when it is on the server.
The same is behavior occurs when Jotunn is present on the server.
Once MoreVanillaBuildPrefabs is present on the server, all AdminOnly configs are locked unless I am an admin, as intended. Furthermore, if I am an admin and I make changes to the config in-game then those changes are correctly redirected to the server config file. Similarly, if I change the server config file on disk, those changes take effect in-game without altering my local config file.
I have not tested connecting with two different versions of Jotunn as of yet though.
Final Notes
I hope I covered everything. I wanted to be more thorough on this PR since changes to config syncing can have significant impacts for users. This took a long time to trace and solve though so I need to stop here for now.