From 72ede82acd1c9cbb6ce33328208941c804f59335 Mon Sep 17 00:00:00 2001 From: O3H Date: Mon, 4 Mar 2024 12:09:47 +0000 Subject: [PATCH 1/7] bump version --- CSync.csproj | 5 ++++- Core/Metadata.cs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CSync.csproj b/CSync.csproj index 2e849a4..b65f6f1 100644 --- a/CSync.csproj +++ b/CSync.csproj @@ -3,7 +3,7 @@ netstandard2.1;net472;net48 CSync Configuration file syncing library for BepInEx. - 2.1.0 + 2.2.0 true latest @@ -62,6 +62,9 @@ E:\SteamLibrary\steamapps\common\Lethal Company\Lethal Company_Data\Managed\Assembly-CSharp.dll + + E:\SteamLibrary\steamapps\common\Lethal Company\BepInEx\plugins\LethalConfig\LethalConfig.dll + E:\SteamLibrary\steamapps\common\Lethal Company\Lethal Company_Data\Managed\Unity.Collections.dll diff --git a/Core/Metadata.cs b/Core/Metadata.cs index 0421ca0..f8a5918 100644 --- a/Core/Metadata.cs +++ b/Core/Metadata.cs @@ -3,5 +3,5 @@ namespace CSync.Core; static class Metadata { public const string GUID = "io.github.CSync"; public const string NAME = "CSync"; - public const string VERSION = "2.1.0"; + public const string VERSION = "2.2.0"; } \ No newline at end of file From df97299aa962b58a0a53ddd001dc88e9e1811a8a Mon Sep 17 00:00:00 2001 From: O3H Date: Mon, 4 Mar 2024 12:15:00 +0000 Subject: [PATCH 2/7] sync request/receive events --- Lib/SyncedConfig.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Lib/SyncedConfig.cs b/Lib/SyncedConfig.cs index 76c8cea..d9e4fce 100644 --- a/Lib/SyncedConfig.cs +++ b/Lib/SyncedConfig.cs @@ -15,6 +15,18 @@ public class SyncedConfig(string guid) : SyncedInstance, ISynchronizable w static void LogErr(string str) => Plugin.Logger.LogError(str); static void LogDebug(string str) => Plugin.Logger.LogDebug(str); + /// + /// Invoked on the host when a client requests to sync. + /// + [field:NonSerialized] public event EventHandler SyncRequested; + internal void OnSyncRequested() => SyncRequested?.Invoke(this, EventArgs.Empty); + + /// + /// Invoked on the client when they receive the host config. + /// + [field:NonSerialized] public event EventHandler SyncReceived; + internal void OnSyncReceived() => SyncReceived?.Invoke(this, EventArgs.Empty); + /// /// The mod name or abbreviation. After being given to the constructor, it cannot be changed. /// @@ -51,8 +63,8 @@ void RequestSync() { } internal void OnRequestSync(ulong clientId, FastBufferReader _) { - // Only run if we are host/server. if (!IsHost) return; + OnSyncRequested(); if (SYNC_TO_CLIENTS != null && SYNC_TO_CLIENTS == false) { using FastBufferWriter s = new(IntSize, Allocator.Temp); @@ -80,6 +92,8 @@ internal void OnRequestSync(ulong clientId, FastBufferReader _) { } internal void OnReceiveSync(ulong _, FastBufferReader reader) { + OnSyncReceived(); + if (!reader.TryBeginRead(IntSize)) { LogErr($"{GUID} - Config sync error: Could not begin reading buffer."); return; From b8c1980354b7c82c70e5545045caa228f47d2841 Mon Sep 17 00:00:00 2001 From: Owen <48495634+Owen3H@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:33:58 +0000 Subject: [PATCH 3/7] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 70f112e..e85edff 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -## I WILL NO LONGER AFFILIATE WITH THUNDERSTORE OR THE LETHAL MODDING DISCORD.
-## PLEASE SEE [RELEASES](https://github.com/Owen3H/CSync/releases) +> [!WARNING] +> **I WILL NO LONGER AFFILIATE WITH THUNDERSTORE OR THE LETHAL MODDING DISCORD.
+> PLEASE SEE [RELEASES](https://github.com/Owen3H/CSync/releases)** # CSync A BepInEx configuration file syncing library.
From 6c7f1f93b98c797701aad2fec9cb865ba65a58fc Mon Sep 17 00:00:00 2001 From: Owen <48495634+Owen3H@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:38:19 +0000 Subject: [PATCH 4/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e85edff..4fe99ee 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ > [!WARNING] > **I WILL NO LONGER AFFILIATE WITH THUNDERSTORE OR THE LETHAL MODDING DISCORD.
-> PLEASE SEE [RELEASES](https://github.com/Owen3H/CSync/releases)** +> FURTHER UPDATES WILL ONLY BE HERE -> [RELEASES](https://github.com/Owen3H/CSync/releases)** # CSync A BepInEx configuration file syncing library.
From c36374d5ecda6e353351237a63703acd17e054a9 Mon Sep 17 00:00:00 2001 From: Owen <48495634+Owen3H@users.noreply.github.com> Date: Mon, 4 Mar 2024 14:08:14 +0000 Subject: [PATCH 5/7] Update README.md --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index 4fe99ee..4b494f5 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,6 @@ # CSync A BepInEx configuration file syncing library.
-This library will help you force clients to have the same settings as the host! > [!IMPORTANT] > - This is **NOT** a standalone mod, it is intended for mod developers and does nothing on its own!
@@ -19,7 +18,7 @@ This library will help you force clients to have the same settings as the host! - Provides helpful extension methods. ## Setup & Usage -A guide to both setting up and using CSync is available on [Lethal Wiki](https://lethal.wiki/dev/apis/csync). +A guide to both setting up and using CSync is available on the [Wiki](https://github.com/Owen3H/CSync/wiki). ## License This project has the `CC BY-NC-SA 4.0` license.
From f1500596feebfd83f9d71e083e798a6d91451560 Mon Sep 17 00:00:00 2001 From: O3H Date: Mon, 4 Mar 2024 14:12:40 +0000 Subject: [PATCH 6/7] Update SyncedConfig.cs --- Lib/SyncedConfig.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/SyncedConfig.cs b/Lib/SyncedConfig.cs index d9e4fce..b8eac1c 100644 --- a/Lib/SyncedConfig.cs +++ b/Lib/SyncedConfig.cs @@ -34,6 +34,11 @@ public class SyncedConfig(string guid) : SyncedInstance, ISynchronizable w internal SyncedEntry SYNC_TO_CLIENTS { get; private set; } = null; + /// + /// Allow the host to control whether clients can use their own config. + /// This MUST be called after binding the entry parameter. + /// + /// The entry for the host to use in your config file. protected void EnableHostSyncControl(SyncedEntry hostSyncControlOption) { SYNC_TO_CLIENTS = hostSyncControlOption; From ec4b324587f29cb2ac45ab231c302592d2932d56 Mon Sep 17 00:00:00 2001 From: O3H Date: Mon, 4 Mar 2024 14:14:16 +0000 Subject: [PATCH 7/7] oops --- CSync.csproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/CSync.csproj b/CSync.csproj index b65f6f1..c28aa49 100644 --- a/CSync.csproj +++ b/CSync.csproj @@ -62,9 +62,6 @@ E:\SteamLibrary\steamapps\common\Lethal Company\Lethal Company_Data\Managed\Assembly-CSharp.dll - - E:\SteamLibrary\steamapps\common\Lethal Company\BepInEx\plugins\LethalConfig\LethalConfig.dll - E:\SteamLibrary\steamapps\common\Lethal Company\Lethal Company_Data\Managed\Unity.Collections.dll