From faee2a77e4ef795152e9da37518e390905d8253a Mon Sep 17 00:00:00 2001 From: Kevin nX_ J Date: Sat, 13 Mar 2021 11:35:46 +0100 Subject: [PATCH] Changelog - Added Map Sync configuration - Added Info to the valheim_plus.cfg --- ValheimPlus/GameClasses/Container.cs | 72 ++++++++++++++-------------- ValheimPlus/GameClasses/Minimap.cs | 2 +- ValheimPlus/GameClasses/Player.cs | 2 +- ValheimPlus/GameClasses/ZNet.cs | 6 ++- ValheimPlus/ValheimPlus.cs | 2 +- valheim_plus.cfg | 1 + 6 files changed, 44 insertions(+), 41 deletions(-) diff --git a/ValheimPlus/GameClasses/Container.cs b/ValheimPlus/GameClasses/Container.cs index 4d818bd7..28bf279f 100644 --- a/ValheimPlus/GameClasses/Container.cs +++ b/ValheimPlus/GameClasses/Container.cs @@ -41,55 +41,55 @@ public static class Container_Awake_Patch /// static void Postfix(Container __instance, ref Inventory ___m_inventory) { + if (!Configuration.Current.Inventory.IsEnabled) return; + string containerName = __instance.transform.parent.name; string inventoryName = ___m_inventory.m_name; ref int inventoryColumns = ref ___m_inventory.m_width; ref int inventoryRows = ref ___m_inventory.m_height; - if (Configuration.Current.Inventory.IsEnabled) + // Karve (small boat) + // Use Contains because the actual name is "Karve (Clone)" + if (containerName.Contains("Karve")) { - // Karve (small boat) - // Use Contains because the actual name is "Karve (Clone)" - if (containerName.Contains("Karve")) - { - inventoryRows = Helper.Clamp(Configuration.Current.Inventory.karveInventoryRows, karveChestInventoryMinRows, karveChestInventoryMaxRows); - inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.karveInventoryColumns, karveChestInventoryMinCol, karveChestInventoryMaxCol); - } - // Longboat (Large boat) - else if (containerName.Contains("VikingShip")) + inventoryRows = Helper.Clamp(Configuration.Current.Inventory.karveInventoryRows, karveChestInventoryMinRows, karveChestInventoryMaxRows); + inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.karveInventoryColumns, karveChestInventoryMinCol, karveChestInventoryMaxCol); + } + // Longboat (Large boat) + else if (containerName.Contains("VikingShip")) + { + inventoryRows = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryRows, longboatChestInventoryMinRows, longboatChestInventoryMaxRows); + inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryColumns, longboatChestInventoryMinCol, longboatChestInventoryMaxCol); + } + // Cart (Wagon) + else if (containerName.Contains("Cart")) + { + inventoryRows = Helper.Clamp(Configuration.Current.Inventory.cartInventoryRows, cartChestInventoryMinRows, cartChestInventoryMaxRows); + inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.cartInventoryColumns, cartChestInventoryMinCol, cartChestInventoryMaxCol); + } + // Chests (containerName is _NetSceneRoot) + else + { + // Personal chest + if (inventoryName == "$piece_chestprivate") { - inventoryRows = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryRows, longboatChestInventoryMinRows, longboatChestInventoryMaxRows); - inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.longboatInventoryColumns, longboatChestInventoryMinCol, longboatChestInventoryMaxCol); + inventoryRows = Helper.Clamp(Configuration.Current.Inventory.personalChestRows, personalChestInventoryMinRows, personalChestInventoryMaxRows); + inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.personalChestColumns, personalChestInventoryMinCol, personalChestInventoryMaxCol); } - // Cart (Wagon) - else if (containerName.Contains("Cart")) + // Wood chest + else if (inventoryName == "$piece_chestwood") { - inventoryRows = Helper.Clamp(Configuration.Current.Inventory.cartInventoryRows, cartChestInventoryMinRows, cartChestInventoryMaxRows); - inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.cartInventoryColumns, cartChestInventoryMinCol, cartChestInventoryMaxCol); + inventoryRows = Helper.Clamp(Configuration.Current.Inventory.woodChestRows, woodChestInventoryMinRows, woodChestInventoryMaxRows); + inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.woodChestColumns, woodChestInventoryMinCol, woodChestInventoryMaxCol); } - // Chests (containerName is _NetSceneRoot) - else + // Iron chest + else if (inventoryName == "$piece_chest") { - // Personal chest - if (inventoryName == "$piece_chestprivate") - { - inventoryRows = Helper.Clamp(Configuration.Current.Inventory.personalChestRows, personalChestInventoryMinRows, personalChestInventoryMaxRows); - inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.personalChestColumns, personalChestInventoryMinCol, personalChestInventoryMaxCol); - } - // Wood chest - else if (inventoryName == "$piece_chestwood") - { - inventoryRows = Helper.Clamp(Configuration.Current.Inventory.woodChestRows, woodChestInventoryMinRows, woodChestInventoryMaxRows); - inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.woodChestColumns, woodChestInventoryMinCol, woodChestInventoryMaxCol); - } - // Iron chest - else if (inventoryName == "$piece_chest") - { - inventoryRows = Helper.Clamp(Configuration.Current.Inventory.ironChestRows, ironChestInventoryMinRows, ironChestInventoryMaxRows); - inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.ironChestColumns, ironChestInventoryMinCol, ironChestInventoryMaxCol); - } + inventoryRows = Helper.Clamp(Configuration.Current.Inventory.ironChestRows, ironChestInventoryMinRows, ironChestInventoryMaxRows); + inventoryColumns = Helper.Clamp(Configuration.Current.Inventory.ironChestColumns, ironChestInventoryMinCol, ironChestInventoryMaxCol); } } + } } } diff --git a/ValheimPlus/GameClasses/Minimap.cs b/ValheimPlus/GameClasses/Minimap.cs index 93791f35..cab5ec49 100644 --- a/ValheimPlus/GameClasses/Minimap.cs +++ b/ValheimPlus/GameClasses/Minimap.cs @@ -60,7 +60,7 @@ public static class MinimapAwake { private static void Postfix() { - if (ZNet.m_isServer) + if (ZNet.m_isServer && Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) { //Init map array VPlusMapSync.ServerMapData = new bool[Minimap.instance.m_textureSize * Minimap.instance.m_textureSize]; diff --git a/ValheimPlus/GameClasses/Player.cs b/ValheimPlus/GameClasses/Player.cs index 499abe40..c2ec299f 100644 --- a/ValheimPlus/GameClasses/Player.cs +++ b/ValheimPlus/GameClasses/Player.cs @@ -180,7 +180,7 @@ private static void Prefix() Player.m_localPlayer.ShowTutorial("vplus"); //Only sync on first spawn - if (VPlusMapSync.ShouldSyncOnSpawn) + if (VPlusMapSync.ShouldSyncOnSpawn && Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) { //Send map data to the server VPlusMapSync.SendMapToServer(); diff --git a/ValheimPlus/GameClasses/ZNet.cs b/ValheimPlus/GameClasses/ZNet.cs index b72e79dc..fbe7e614 100644 --- a/ValheimPlus/GameClasses/ZNet.cs +++ b/ValheimPlus/GameClasses/ZNet.cs @@ -89,12 +89,14 @@ private static void Prefix(ref ZNet __instance) ValheimPlusPlugin.harmony.PatchAll(); //We left the server, so reset our map sync check. - VPlusMapSync.ShouldSyncOnSpawn = true; + if (Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) + VPlusMapSync.ShouldSyncOnSpawn = true; } else { //Save map data to disk - VPlusMapSync.SaveMapDataToDisk(); + if (Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) + VPlusMapSync.SaveMapDataToDisk(); } } } diff --git a/ValheimPlus/ValheimPlus.cs b/ValheimPlus/ValheimPlus.cs index c1a11161..f62fd684 100644 --- a/ValheimPlus/ValheimPlus.cs +++ b/ValheimPlus/ValheimPlus.cs @@ -67,7 +67,7 @@ void Awake() VPlusMainMenu.Load(); //Map Sync Save Timer - if (ZNet.m_isServer) + if (ZNet.m_isServer && Configuration.Current.Map.IsEnabled && Configuration.Current.Map.shareMapProgression) { mapSyncSaveTimer.AutoReset = true; mapSyncSaveTimer.Elapsed += (sender, args) => VPlusMapSync.SaveMapDataToDisk(); diff --git a/valheim_plus.cfg b/valheim_plus.cfg index ad75a334..1d5e23a1 100644 --- a/valheim_plus.cfg +++ b/valheim_plus.cfg @@ -362,6 +362,7 @@ autoDepositRange=10 enabled=false ; With this enabled you will receive the same exploration progression as other players on the server +; This will also enable the option for the server to sync everyones exploration progression on connecting to the server. shareMapProgression=false ; The radius of the map that you explore when moving